1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
#######################################################
#
# Test datacontainers can be passed with a variable name.
#
#######################################################
body common control
{
inputs => { "../../default.cf.sub" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}
#######################################################
bundle agent init
{
meta:
"tags" slist => { "find" };
commands:
windows::
"$(G.dos2unix) $(this.promise_filename).expected" -> { "ENT-10433" };
vars:
# We want to be sure we can reference this data subsequently
"d" data => parsejson( '{
"hosts": {
"path": "/etc/hosts"
},
"auto_master" {
"path": "/etc/auto.master"
}
}');
}
bundle agent test
{
meta:
"description" -> { "CFE-2434" }
string => "Test that variable data containers can be passed.";
vars:
"found" slist => bundlesmatching(".*", "find");
# "ns_bundle" string => "default:init"; # This is the same content as the
# "found" variable, so we just use that instead.
"bundle_name" string => "init";
"bundle_name_suffix" string => "it";
methods:
"" usebundle => report_data("Pass by name:", @(init.d));
"" usebundle => report_data("Pass by namespace:name:", @(default:init.d));
"" usebundle => report_data("Pass by variable name:", "@($(bundle_name).d)");
"" usebundle => report_data("Pass by variable name including namespace:", "@($(found).d)");
"" usebundle => report_data("Pass by variable name with prefix:", "@(in$(bundle_name_suffix).d)");
"" usebundle => report_data("Pass by variable name with namespace:", "@(default:$(bundle_name).d)");
}
bundle agent check
{
methods:
"" usebundle => dcs_check_diff( $(G.testfile),
"$(this.promise_filename).expected",
$(this.promise_filename));
}
bundle agent report_data(id, datacontainer)
{
vars:
"keys" slist => getindices("datacontainer");
classes:
"some_keys" expression => some(".*", keys);
reports:
DEBUG::
"$(id) found keys in data container"
if => "some_keys";
"$(id) did *not* find keys in data container"
unless => "some_keys";
any::
"$(id) $(keys)=$(datacontainer[$(keys)][path])"
report_to_file => "$(G.testfile)";
}
|