1# Test that merged data does not inherit variables from calling bundle
2
3body common control
4{
5      inputs => { "../../default.cf.sub" };
6      bundlesequence => { default("$(this.promise_filename)") };
7}
8
9bundle agent test
10{
11  meta:
12      "description" -> { "CFE-2551" }
13        string => "Test that merged data does not include variables from calling bundle. Variant specifying bundle qualified variable";
14
15  vars:
16
17      "a" string => "string a";
18      "b" string => "string b";
19
20      "vars1[a]" string => "$(a)";
21      "vars1[b]" string => "$(b)";
22
23  methods:
24
25      # Call bundle that will define and merge it's own vars1 data structure.
26
27      "Call another bundle"
28        usebundle => called_by_bundle_test;
29
30}
31
32bundle agent called_by_bundle_test
33{
34  vars:
35      "c" string => "string c";
36      "vars1[c]" string => "$(c)";
37
38      # Create a new data structure NOT including data from calling bundle
39
40      # NOTE: This is what differs from the base test
41      "merged_data_vars"
42        data => mergedata('{ "vars1": $(this.bundle).vars1 }');
43
44    DEBUG|EXTRA::
45      # We only care to stringify this if we need the debug reports
46      "merged_data_vars_string"
47        string => storejson( merged_data_vars );
48
49  reports:
50    DEBUG|EXTRA::
51      "Got:$(const.n)$(merged_data_vars_string)";
52      'Expect:
53{
54  "vars1": {
55    "c": "string c"
56  }
57}';
58}
59
60
61bundle agent check
62{
63  classes:
64
65      # We pass if the variable indicies found in bundle test are NOT found in
66      # the bundle it called, and we find the index defined in the bundle it
67      # called that we expect.
68
69      "pass"
70        expression => and(
71                           and(
72                               not( isvariable("called_by_bundle_test.merged_data_vars[vars1][a]")),
73                               not( isvariable("called_by_bundle_test.merged_data_vars[vars1][b]"))
74                           ),
75                           isvariable("called_by_bundle_test.merged_data_vars[vars1][c]")
76        );
77
78      # We fail if the variable indicies found in bundle test are also found in
79      # the bundle it called.
80
81      "fail"
82        or => {
83                isvariable( "called_by_bundle_test.merged_data_vars[vars1][a]" ),
84                isvariable( "called_by_bundle_test.merged_data_vars[vars1][b]" ),
85        };
86
87
88  reports:
89
90    fail::
91      "$(this.promise_filename) FAIL";
92
93    pass::
94      "$(this.promise_filename) Pass";
95  }
96