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 bundle set_config_values
#
#######################################################
body common control
{
inputs => { '../../default.cf.sub' };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}
#######################################################
bundle agent init
{
files:
# We want to test editing multiple similar files so that we know we do not
# have a problem with namespace scoped classes colliding unintentionally.
"$(G.testfile)-1.expected"
copy_from => local_cp("$(this.promise_filename).finish");
"$(G.testfile)-1.actual"
copy_from => local_cp("$(this.promise_filename).start");
"$(G.testfile)-2.expected"
copy_from => local_cp("$(this.promise_filename).finish");
"$(G.testfile)-2.actual"
copy_from => local_cp("$(this.promise_filename).start");
}
#######################################################
bundle agent test
{
meta:
"description" string => "Test that set_config_values works as expected";
vars:
# should create a new line right after existing commented-out Protocol lines
"config[Protocol]" string => "2";
# should uncomment the existing line
"config[Port]" string => "22";
# should insert a new line at the end, this is missing
"config[AddressFamily]" string => "any";
# should uncomment the line and edit the value
"config[AuthorizedKeysFile]" string => ".*ssh/authorized_keys";
# blanks should be OK
"config[BlankOption]" string => "";
files:
"$(G.testfile)-1.actual"
edit_line => set_config_values("test.config");
"$(G.testfile)-2.actual"
edit_line => set_config_values("test.config");
}
#######################################################
bundle agent check
{
vars:
"files" slist => { "1", "2" };
classes:
"pass" and => { "1_pass", "2_pass" };
methods:
"check"
usebundle => dcs_if_diff( "$(G.testfile)-$(files).actual", "$(G.testfile)-$(files).expected",
"$(files)_pass", "$(files)_fail");
# Fail the test if any of the files fail.
"fail"
usebundle => dcs_fail( $(this.promise_filename) ),
if => "$(files)_fail";
pass::
"pass"
usebundle => dcs_pass( $(this.promise_filename) );
reports:
DEBUG::
"$(files)_fail"
if => "$(files)_fail";
}
|