Skip to content

Commit

Permalink
Merge branch 'branches/rudder/4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Normation GIT merger committed Dec 27, 2017
2 parents a3abf85 + d17043e commit cdeaa36
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/acceptance/30_generic_methods/classes_cancel.cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#######################################################
#
# This will check that result classes are canceled
#
#######################################################

bundle common acc_path
{
vars:
"root" string => getenv("NCF_TESTS_ACCEPTANCE", 1024);
}

body common control
{
inputs => { "${acc_path.root}/default.cf.sub", "${acc_path.root}/default_ncf.cf.sub", "@{ncf_inputs.default_files}" };
bundlesequence => { configuration, default("$(this.promise_filename)") };
version => "1.0";
}

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

bundle agent init
{
vars:
"tmp" string => getenv("TEMP", 1024);
"file" string => "${tmp}/test";
"file_canon" string => canonify("${file}");
}

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

bundle agent test
{

methods:
"ph1" usebundle => file_ensure_lines_present("${init.file}", "sample two"); # should get repaired
"ph2" usebundle => _classes_cancel("file_ensure_lines_present_${init.file_canon}");

}

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

bundle agent check
{
classes:
"ok" expression => "!file_ensure_lines_present_${init.file_canon}_reached";

reports:
ok::
"$(this.promise_filename) Pass";
!ok::
"$(this.promise_filename) FAIL";
}
44 changes: 44 additions & 0 deletions tree/30_generic_methods/_classes_cancel.cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#####################################################################################
# Copyright 2017 Normation SAS
#####################################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#####################################################################################

# @name Classes cancel
# @description Cleans a class prefix by undefining all classes for it
# @documentation This bundle will undefine ${prefix}_{kept, not_kept, repaired, not_repaired, ok, not_ok, error, failed, denied, timeout, reached}
#
# @parameter prefix The prefix of the classes to cancel
#
# @class_prefix
# @class_parameter

bundle agent _classes_cancel(prefix)
{
vars:
# this is a way to remove the class withouto side effect
"ignored_kept" string => "", classes => if_ok_cancel("${prefix}_kept");
"ignored_not_kept" string => "", classes => if_ok_cancel("${prefix}_not_kept");
"ignored_repaired" string => "", classes => if_ok_cancel("${prefix}_repaired");
"ignored_not_repaired" string => "", classes => if_ok_cancel("${prefix}_not_repaired");
"ignored_ok" string => "", classes => if_ok_cancel("${prefix}_ok");
"ignored_not_ok" string => "", classes => if_ok_cancel("${prefix}_not_ok");
"ignored_error" string => "", classes => if_ok_cancel("${prefix}_error");
"ignored_failed" string => "", classes => if_ok_cancel("${prefix}_failed");
"ignored_denied" string => "", classes => if_ok_cancel("${prefix}_denied");
"ignored_timeout" string => "", classes => if_ok_cancel("${prefix}_timeout");
"ignored_reached" string => "", classes => if_ok_cancel("${prefix}_reached");
}

0 comments on commit cdeaa36

Please sign in to comment.