|
| 1 | +body common control |
| 2 | +{ |
| 3 | + bundlesequence => { "test", "check" }; |
| 4 | +} |
| 5 | + |
| 6 | +bundle agent test |
| 7 | +{ |
| 8 | + |
| 9 | + vars: |
| 10 | + # Platforms to test |
| 11 | + any:: |
| 12 | + "platforms" |
| 13 | + slist => { "debian", "ubuntu", "redhat", "rhel", "centos", "fedora", |
| 14 | + "aix", "hpux", "suse", "opensuse", "opensuse_leap", "sles", |
| 15 | + "solaris", "sunos", "windows", "freebsd", "macos" }; |
| 16 | + |
| 17 | + |
| 18 | + # Regex matching current platforms OS-class with version numbers |
| 19 | + !solaris&!sunos:: |
| 20 | + "class_regex" |
| 21 | + string => format("^(%s)_[0-9]+_[0-9]+$", join("|", "platforms")); |
| 22 | + solaris|sunos:: |
| 23 | + "class_regex" |
| 24 | + string => format("^(%s)_[0-9]+$", join("|", "platforms")); |
| 25 | + |
| 26 | + # Regex to extract minor version number from OS-class |
| 27 | + # Edge cases: |
| 28 | + # - On Solaris/SunOS minor version comes second |
| 29 | + # E.g. Solaris 11 has class "solaris_5_11" |
| 30 | + any:: |
| 31 | + "extract_regex" |
| 32 | + string => ifelse("solaris|sunos", "^[a-z]+_([0-9]+)$", |
| 33 | + "opensuse_leap", "^[a-z_]+_[0-9]+_([0-9]+$)", |
| 34 | + "^[a-z]+_[0-9]+_([0-9]+$)"); |
| 35 | + |
| 36 | + # Find OS-class with version numbers using regex |
| 37 | + any:: |
| 38 | + "os_class" |
| 39 | + string => nth(classesmatching("$(class_regex)"), "0"); |
| 40 | + |
| 41 | + # Get extracted minor version number |
| 42 | + any:: |
| 43 | + "expected" |
| 44 | + string => nth("version_number", "1"); |
| 45 | + |
| 46 | + classes: |
| 47 | + any:: |
| 48 | + "regextract_success" |
| 49 | + expression => regextract("$(extract_regex)", "$(os_class)", "version_number"); |
| 50 | +} |
| 51 | + |
| 52 | +bundle agent check |
| 53 | +{ |
| 54 | + vars: |
| 55 | + any:: |
| 56 | + "defined_classes" |
| 57 | + slist => classesmatching(".*"); |
| 58 | + |
| 59 | + classes: |
| 60 | + any:: |
| 61 | + "passed" |
| 62 | + expression => strcmp("$(test.expected)", "$(sys.os_version_minor)"); |
| 63 | + |
| 64 | + reports: |
| 65 | + DEBUG:: |
| 66 | + "Version number extracted from class: $(test.os_class)"; |
| 67 | + "Defined classes: $(defined_classes)"; |
| 68 | + "$(this.promise_filename) Expected: $(test.expected)"; |
| 69 | + "$(this.promise_filename) Found: $(sys.os_version_minor)"; |
| 70 | + passed:: |
| 71 | + "$(this.promise_filename) Pass"; |
| 72 | + !passed:: |
| 73 | + "$(this.promise_filename) FAIL"; |
| 74 | +} |
0 commit comments