|
1 | 1 | body common control |
2 | 2 | { |
3 | | - bundlesequence => { "test" }; |
| 3 | + inputs => { "../../default.cf.sub" }; |
| 4 | + bundlesequence => { default("$(this.promise_filename)") }; |
| 5 | + version => "1.0"; |
4 | 6 | } |
5 | 7 |
|
| 8 | +bundle agent init |
| 9 | +{ |
| 10 | + files: |
| 11 | + "$(G.testfile)" delete => tidy; |
| 12 | +} |
| 13 | + |
| 14 | +bundle agent test_variable(name, regex) |
| 15 | +{ |
| 16 | + classes: |
| 17 | + "defined" expression => isvariable("$(name)"); |
| 18 | + "match" expression => regcmp("$(regex)", "$($(name))"); |
| 19 | + |
| 20 | + reports: |
| 21 | + "FAIL: '$(name)' is not defined" unless => "defined"; |
| 22 | + "FAIL: '$(name) => $($(name))' did not match '$(regex)'" unless => "match"; |
| 23 | + |
| 24 | + files: |
| 25 | + "$(G.testfile)" |
| 26 | + create => "true", |
| 27 | + unless => "defined&match"; |
| 28 | +} |
6 | 29 |
|
7 | 30 | bundle agent test |
8 | 31 | { |
| 32 | + meta: |
| 33 | + "description" -> { "ENT-13540" } |
| 34 | + string => "Test time based variables"; |
| 35 | + |
9 | 36 | vars: |
10 | | - "time_based_var_names" slist => variablesmatching(".*sys.time_based.*"); |
11 | | - "time_based_vars" slist => maplist("$($(this))", "@(time_based_var_names)"); |
| 37 | + "variables" data => '{ |
| 38 | + "dom": "^Day([1-9]|[1-2][0-9]|3[0-1])$", |
| 39 | + "dow": "^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)$", |
| 40 | + "hr": "^Hr(0[0-9]|1[0-9]|2[0-4])$", |
| 41 | + "hr_2": "^Hr([0-9]|1[0-9]|2[0-4])$", |
| 42 | + "hr_qoh": "^Hr(0[0-9]|1[0-9]|2[0-4])_Q[1-4]$", |
| 43 | + "lcycle": "^Lcycle_[0-3]$", |
| 44 | + "min": "^Min([0-5][0-9]|60)$", |
| 45 | + "min_span_5": "^Min(00_05|05_10|10_15|15_20|20_25|25_30|30_35|35_40|40_45|45_50|50_55|55_00)$", |
| 46 | + "month": "^(January|February|March|April|May|June|July|August|September|October|November|December)$", |
| 47 | + "pod": "^(Night|Morning|Afternoon|Evening)$", |
| 48 | + "qoh": "^Q[1-4]$", |
| 49 | + "yr": "^Yr\d{4}$", |
12 | 50 |
|
13 | | - classes: |
14 | | - "year_ok" expression => reglist("@(time_based_vars)", "^Yr\d{4}$"); |
15 | | - "month_ok" expression => reglist("@(time_based_vars)", "^(January|February|March|April|May|June|July|August|September|October|November|December)$"); |
16 | | - "day_ok" expression => reglist("@(time_based_vars)", "^Day([1-9]|[1-2][0-9]|3[0-1])$"); |
17 | | - "weekday_ok" expression => reglist("@(time_based_vars)", "^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)$"); |
18 | | - "shift_ok" expression => reglist("@(time_based_vars)", "^(Night|Morning|Afternoon|Evening)$"); |
19 | | - "hour_2_ok" expression => reglist("@(time_based_vars)", "^Hr(0[1-9]|1[0-9]|2[0-4])$"); |
20 | | - "hour_ok" expression => reglist("@(time_based_vars)", "^Hr([1-9]|1[0-9]|2[0-4])$"); |
21 | | - "quarter_ok" expression => reglist("@(time_based_vars)", "^Q[1-4]$"); |
22 | | - "minute_ok" expression => reglist("@(time_based_vars)", "^Min([0-5][0-9]|60)$"); |
23 | | - "minute_span_5_ok" expression => reglist("@(time_based_vars)", "^Min([0-5][0-9]|60)_(05|[0-5][05]|60)$"); |
24 | | - "hour_2_quarter_ok" expression => reglist("@(time_based_vars)", "^Hr(0[1-9]|1[0-9]|2[0-4])_Q[1-4]$"); |
25 | | - |
26 | | - # Testing for one GMT |
27 | | - "hour_2_gmt_ok" expression => reglist("@(time_based_vars)", "^GMT_Hr(0[1-9]|1[0-9]|2[0-4])$"); |
28 | | - |
29 | | - "ok" expression => and("year_ok", "month_ok", "day_ok", "weekday_ok", "shift_ok", "hour_2_ok", "hour_ok", |
30 | | - "quarter_ok", "minute_ok", "minute_span_5_ok", "hour_2_quarter_ok", "hour_2_gmt_ok"); |
| 51 | + "gmt_dom": "^GMT_Day([1-9]|[1-2][0-9]|3[0-1])$", |
| 52 | + "gmt_dow": "^GMT_(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)$", |
| 53 | + "gmt_hr": "^GMT_Hr(0[0-9]|1[0-9]|2[0-4])$", |
| 54 | + "gmt_hr_2": "^GMT_Hr([0-9]|1[0-9]|2[0-4])$", |
| 55 | + "gmt_hr_qoh": "^GMT_Hr(0[0-9]|1[0-9]|2[0-4])_Q[1-4]$", |
| 56 | + "gmt_lcycle": "^GMT_Lcycle_[0-3]$", |
| 57 | + "gmt_min": "^GMT_Min([0-5][0-9]|60)$", |
| 58 | + "gmt_min_span_5": "^GMT_Min(00_05|05_10|10_15|15_20|20_25|25_30|30_35|35_40|40_45|45_50|50_55|55_00)$", |
| 59 | + "gmt_month": "^GMT_(January|February|March|April|May|June|July|August|September|October|November|December)$", |
| 60 | + "gmt_pod": "^GMT_(Night|Morning|Afternoon|Evening)$", |
| 61 | + "gmt_qoh": "^GMT_Q[1-4]$", |
| 62 | + "gmt_yr": "^GMT_Yr\d{4}$" |
| 63 | + }'; |
| 64 | + |
| 65 | + "names" |
| 66 | + slist => getindices("variables"); |
| 67 | + |
| 68 | + methods: |
| 69 | + "any" usebundle => test_variable("default:sys.time_based_$(names)", |
| 70 | + "$(variables[$(names)])"); |
| 71 | +} |
31 | 72 |
|
| 73 | +bundle agent check |
| 74 | +{ |
32 | 75 | reports: |
33 | | - ok:: |
34 | | - "$(this.promise_filename) Pass"; |
35 | | - !ok:: |
36 | | - "$(this.promise_filename) FAIL"; |
| 76 | + "$(this.promise_filename) Pass" unless => fileexists("$(G.testfile)"); |
| 77 | + "$(this.promise_filename) FAIL" if => fileexists("$(G.testfile)"); |
| 78 | +} |
| 79 | + |
| 80 | +bundle agent destroy |
| 81 | +{ |
| 82 | + methods: |
| 83 | + "init"; |
37 | 84 | } |
0 commit comments