Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion services/autorun/hello.cf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bundle agent hello_world_autorun
{
meta:
"tags" slist => { "autorun" };
"tags" slist => { "autorun" };

reports:
verbose_mode::
Expand Down
1 change: 0 additions & 1 deletion services/init.cf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# This is loaded very early, only use hard classes or classes from def.json here.
#
###############################################################################

# For example:
# promise agent git
# {
Expand Down
4 changes: 1 addition & 3 deletions services/main.cf
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
# - User/Site policy entry
#
###############################################################################

bundle agent mpf_main
# User Defined Service Catalogue
{
methods:
# Activate your custom policies here

# Activate your custom policies here
}
36 changes: 18 additions & 18 deletions tests/acceptance/promises/autorun-D.cf
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@
# Test autorun
#
#######################################################

body common control
{
inputs => { '../default.cf.sub' };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
inputs => { '../default.cf.sub' };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}

bundle agent init
{
commands:
"$(G.make) install DESTDIR=$(G.testdir)"
contain => in_dir_shell("$(this.promise_dirname)/../../..");
"$(G.make) install DESTDIR=$(G.testdir)"
contain => in_dir_shell("$(this.promise_dirname)/../../..");

vars:
# If masterfiles are installed with --prefix=/other/prefix then we
# need to figure out where did "make install DESTDIR=..." has put
# the files.
"promises_cf_slist" slist =>
findfiles("$(G.testdir)/**/promises.cf");
"promises_cf_path" string => nth(promises_cf_slist, 0);
# If masterfiles are installed with --prefix=/other/prefix then we
# need to figure out where did "make install DESTDIR=..." has put
# the files.
"promises_cf_slist" slist => findfiles("$(G.testdir)/**/promises.cf");
"promises_cf_path" string => nth(promises_cf_slist, 0);
}

#######################################################

bundle agent check
{
methods:
"" usebundle => dcs_passif_output(".*R: hello_world_autorun: Hello, this is an automatically loaded bundle.*",
"",
"$(sys.cf_agent) -Dservices_autorun -v -f $(init.promises_cf_path) | $(G.grep) Hello",
$(this.promise_filename));
""
usebundle => dcs_passif_output(
".*R: hello_world_autorun: Hello, this is an automatically loaded bundle.*",
"",
"$(sys.cf_agent) -Dservices_autorun -v -f $(init.promises_cf_path) | $(G.grep) Hello",
$(this.promise_filename)
);
}
53 changes: 26 additions & 27 deletions tests/acceptance/promises/autorun-def_json.cf
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,55 @@
# Test autorun
#
#######################################################

body common control
{
inputs => { '../default.cf.sub' };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
inputs => { '../default.cf.sub' };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}

bundle agent init
{
commands:
"$(G.make) install DESTDIR=$(G.testdir)"
contain => in_dir_shell("$(this.promise_dirname)/../../..");
vars:
# If masterfiles are installed with --prefix=/other/prefix then we
# need to figure out where did "make install DESTDIR=..." has put
# the files.
"promises_cf_slist" slist =>
findfiles("$(G.testdir)/**/promises.cf");
"promises_cf_path" string => nth(promises_cf_slist, 0);
"$(G.make) install DESTDIR=$(G.testdir)"
contain => in_dir_shell("$(this.promise_dirname)/../../..");

"masterfiles_path" string => dirname("$(promises_cf_path)");
"def_json_path" string => concat("$(masterfiles_path)", "/def.json");
vars:
# If masterfiles are installed with --prefix=/other/prefix then we
# need to figure out where did "make install DESTDIR=..." has put
# the files.
"promises_cf_slist" slist => findfiles("$(G.testdir)/**/promises.cf");
"promises_cf_path" string => nth(promises_cf_slist, 0);
"masterfiles_path" string => dirname("$(promises_cf_path)");
"def_json_path" string => concat("$(masterfiles_path)", "/def.json");
}

bundle agent test
{
meta:
"description" string => "Test that def.json can enable autorun as expected.";

"description"
string => "Test that def.json can enable autorun as expected.";
# We need to lay down the def.json that will enable autorun.
files:
"$(init.def_json_path)"
create => "true",
edit_line => enable_autorun;
"$(init.def_json_path)"
create => "true",
edit_line => enable_autorun;
}

bundle edit_line enable_autorun
{
insert_lines:
'{ "classes": { "services_autorun": ["any"] } }';
'{ "classes": { "services_autorun": ["any"] } }';
}

#######################################################

bundle agent check
{
methods:
"" usebundle => dcs_passif_output(".*R: hello_world_autorun: Hello, this is an automatically loaded bundle.*",
"",
"$(sys.cf_agent) -v -f $(init.promises_cf_path) | $(G.grep) Hello",
$(this.promise_filename));
""
usebundle => dcs_passif_output(
".*R: hello_world_autorun: Hello, this is an automatically loaded bundle.*",
"",
"$(sys.cf_agent) -v -f $(init.promises_cf_path) | $(G.grep) Hello",
$(this.promise_filename)
);
}
57 changes: 27 additions & 30 deletions tests/acceptance/promises/autorun.cf
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,34 @@
# Test autorun
#
#######################################################

body common control
{
inputs => { '../default.cf.sub' };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
inputs => { '../default.cf.sub' };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}

bundle agent init
{
commands:
"$(G.make) install DESTDIR=$(G.testdir)"
contain => in_dir_shell("$(this.promise_dirname)/../../..");
vars:
# If masterfiles are installed with --prefix=/other/prefix then we
# need to figure out where did "make install DESTDIR=..." has put
# the files.
"promises_cf_slist" slist =>
findfiles("$(G.testdir)/**/promises.cf");
"promises_cf_path" string => nth(promises_cf_slist, 0);
"$(G.make) install DESTDIR=$(G.testdir)"
contain => in_dir_shell("$(this.promise_dirname)/../../..");

"masterfiles_path" string => dirname("$(promises_cf_path)");
"def_cf_path" string => concat("$(masterfiles_path)", "/controls/def.cf");
vars:
# If masterfiles are installed with --prefix=/other/prefix then we
# need to figure out where did "make install DESTDIR=..." has put
# the files.
"promises_cf_slist" slist => findfiles("$(G.testdir)/**/promises.cf");
"promises_cf_path" string => nth(promises_cf_slist, 0);
"masterfiles_path" string => dirname("$(promises_cf_path)");
"def_cf_path" string => concat("$(masterfiles_path)", "/controls/def.cf");
}

bundle agent test
{
meta:


"description"
string => "Test that enabling autorun from policy is not sufficient for activation.
"description"
string => "Test that enabling autorun from policy is not sufficient for activation.

In order to prevent the parsing of files unnecessarily we guard that with the
definition of the services_autorun class. If that class is defined from
Expand All @@ -44,27 +40,28 @@ behavior to change so that defining from policy worked as desired. This
test is intended to track that specific case and if ever fixed, simply
update this test to allow it to pass.";

"test_soft_fail"
string => "any",
meta => { "redmine7572", "jiraCFE2135"};
"test_soft_fail"
string => "any",
meta => { "redmine7572", "jiraCFE2135" };

files:
"$(init.def_cf_path)" edit_line => enable_autorun;
"$(init.def_cf_path)" edit_line => enable_autorun;
}

bundle edit_line enable_autorun
{
insert_lines:
'bundle common __autorun_enable { classes: "services_autorun" expression => "any"; }';
'bundle common __autorun_enable { classes: "services_autorun" expression => "any"; }';
}

#######################################################

bundle agent check
{
methods:
"" usebundle => dcs_passif_output(".*R: hello_world_autorun: Hello, this is an automatically loaded bundle.*",
"",
"$(sys.cf_agent) -v -f $(init.promises_cf_path) | $(G.grep) Hello",
$(this.promise_filename));
""
usebundle => dcs_passif_output(
".*R: hello_world_autorun: Hello, this is an automatically loaded bundle.*",
"",
"$(sys.cf_agent) -v -f $(init.promises_cf_path) | $(G.grep) Hello",
$(this.promise_filename)
);
}
22 changes: 8 additions & 14 deletions tests/acceptance/promises/promises.cf
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,38 @@
# Test promises.cf
#
#######################################################

body common control
{
inputs => { '../default.cf.sub' };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
inputs => { '../default.cf.sub' };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}

#######################################################

bundle agent init
{
}

#######################################################

bundle agent test
{
vars:
"rundir" string => dirname($(this.promise_filename));
"rundir" string => dirname($(this.promise_filename));

commands:
"$(sys.cf_promises) -c --eval-functions -f $(this.promise_dirname)/../../../promises.cf"
classes => if_ok("agent_worked_all_right");
"$(sys.cf_promises) -c --eval-functions -f $(this.promise_dirname)/../../../promises.cf"
classes => if_ok("agent_worked_all_right");
}

#######################################################

bundle agent check
{
classes:
"ok" and => { "agent_worked_all_right" };
"ok" and => { "agent_worked_all_right" };

reports:
DEBUG::

ok::
"$(this.promise_filename) Pass";

!ok::
"$(this.promise_filename) FAIL";
}
Loading