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
|
#######################################################
#
# Test bundle set_config_values
#
#######################################################
body common control
{
inputs => { '../../default.cf.sub' };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}
#######################################################
bundle agent init
{
files:
"$(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
{
vars:
"config[use chroot]" string => "maybe";
# should uncomment the existing line
"config[pid file]" string => "/tmp/rsyncd.pid";
# should insert a new line at the end, this is missing
"config[fake setting]" string => "anything";
# should uncomment the line and edit the value
"config[read only]" string => ".* maybe";
# blanks should be OK
"config[blank option]" string => "";
files:
"$(G.testfile)-1.actual"
edit_line => set_variable_values("test.config");
"$(G.testfile)-2.actual"
edit_line => set_variable_values("test.config");
}
#######################################################
bundle agent check
{
vars:
"files" slist => { "1", "2" };
classes:
"pass" and => { "1_pass", "2_pass" };
methods:
"sort actual"
usebundle => dcs_sort("$(G.testfile)-$(files).actual", "$(G.testfile)-$(files).actual.sort");
"sort expected"
usebundle => dcs_sort("$(G.testfile)-$(files).expected", "$(G.testfile)-$(files).expected.sort");
"check"
usebundle => dcs_if_diff( "$(G.testfile)-$(files).actual.sort", "$(G.testfile)-$(files).expected.sort",
"$(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";
}
|