Details
-
Type:
Bug
-
Status: Open
-
Priority:
Medium
-
Resolution: Unresolved
-
Affects Version/s: 3.15.3, 3.17.0
-
Fix Version/s: None
-
Component/s: Built-in functions
-
Labels:None
Description
this.promiser and this.handle are not expanded when used in classes bodies specific to files promise while Iican define classes containing this.promiser and this.handle using commands promises .
Test Policy
Test
bundle agent test { vars: "something" string => "test string"; files: "/tmp/testfile1" create => "true", handle => "file1_static_promiser_static_handle", classes => results( "namespace", "_mymarker_file_1_static_promiser_static_handle" ); "/tmp/testfile2" create => "true", handle => "file2_static_promiser_static_handle_dynamic_class", classes => results( "namespace", "_mymarker_file_2_$(this.promiser)_$(this._handle)" ); "/tmp/testfile3" create => "true", handle => "file3_dynamic_promiser_dynamic_handle_dynamic_class_$(something)", classes => results( "namespace", "_mymarker_file_3_$(this.promiser)_$(this._handle)" ); commands: "/bin/echo Test Commands 0" handle => "command_0_static_promiser_static_handle", classes => results( "namespace", "_mymarker_command_0_/bin/echo Test Commands 0_command_0_static_promiser_static_handle" ); "/bin/echo Test Commands 1" handle => "command_1_static_promiser_static_handle", classes => results( "namespace", "_mymarker_command_1_$(this.promiser)_$(this.handle)" ); "/bin/echo Test Commands 2 $(something)" handle => "command_2_dynamic_promiser_dynamic_handle_$(something)", classes => results( "namespace", "_mymarker_command_2_$(this.promiser)_$(this.handle)" ); } bundle agent check { vars: "_found_classes" slist => { sort( classesmatching( "_mymarker_.*" ), lex) }; "_expected_classes" slist => { "_mymarker_file_1_static_promiser_static_handle_reached", "_mymarker_file_1_static_promiser_static_handle_repaired", "_mymarker_file_2__tmp_testfile2_file2_static_promiser_static_handle_dynamic_class_reached", #__this__handle__reached", "_mymarker_file_2__tmp_testfile2_file2_static_promiser_static_handle_dynamic_class_repaired", #__this__handle__repaired", "_mymarker_file_3__tmp_testfile3_file3_dynamic_promiser_dynamic_handle_dynamic_class_test_string", #__this__handle__repaired", "_mymarker_file_3__tmp_testfile3_file3_dynamic_promiser_dynamic_handle_dynamic_class_test_string", #__this__handle__reached", "_mymarker_command_0__bin_echo_Test_Commands_0_command_0_static_promiser_static_handle_repaired", "_mymarker_command_1__bin_echo_Test_Commands_1_command_1_static_promiser_static_handle_reached", "_mymarker_command_1__bin_echo_Test_Commands_1_command_1_static_promiser_static_handle_repaired", "_mymarker_command_2__bin_echo_Test_Commands_2_test_string_command_2_dynamic_promiser_dynamic_handle_test_string_repaired", "_mymarker_command_2__bin_echo_Test_Commands_2_test_string_command_2_dynamic_promiser_dynamic_handle_test_string_reached", "_mymarker_command_0__bin_echo_Test_Commands_0_command_0_static_promiser_static_handle_reached", }; "_diff_found_vs_expected" slist => difference( @(_found_classes), @(_expected_classes) ); "_diff_expected_vs_found" slist => difference( @(_expected_classes), @(_found_classes) ); reports: "$(this.promise_filename) FAIL" if => reglist( @(_found_classes), ".*__this__handle__.*" ); DEBUG:: "Found '$(_diff_found_vs_expected)' but did not expect to" if => reglist( @(_found_classes), ".*__this__handle__.*" ); "Did not find '$(_diff_expected_vs_found)' but expected to" if => reglist( @(_found_classes), ".*__this__handle__.*" ); } bundle agent cleanup { files: "/tmp/testfile1" delete => tidy; "/tmp/testfile2" delete => tidy; "/tmp/testfile3" delete => tidy; } bundle agent __main__ { methods: "test"; "check"; "cleanup"; }
R: /home/nickanderson/org/roam/daily/work/cfengine3-fMwDwt FAIL R: Found '_mymarker_file_2__tmp_testfile2___this__handle__reached' but did not expect to R: Found '_mymarker_file_2__tmp_testfile2___this__handle__repaired' but did not expect to R: Found '_mymarker_file_3__tmp_testfile3___this__handle__reached' but did not expect to R: Found '_mymarker_file_3__tmp_testfile3___this__handle__repaired' but did not expect to R: Did not find '_mymarker_file_2__tmp_testfile2_file2_static_promiser_static_handle_dynamic_class_reached' but expected to R: Did not find '_mymarker_file_2__tmp_testfile2_file2_static_promiser_static_handle_dynamic_class_repaired' but expected to R: Did not find '_mymarker_file_3__tmp_testfile3_file3_dynamic_promiser_dynamic_handle_dynamic_class_test_string' but expected to
see discussion -> https://groups.google.com/g/help-cfengine/c/gHxQIICMOeE