Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #7461: classes_* methods should refuse to copy classes to a prefix which is an empty string #272

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
4 changes: 3 additions & 1 deletion tests/acceptance/30_generic_methods/class_failure.cf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ bundle agent test
{
methods:
"ph1" usebundle => _classes_failure("my_class");
"ph2" usebundle => _classes_failure("");

}

Expand All @@ -42,7 +43,8 @@ bundle agent check
"ok_success" expression => "!(promise_kept_my_class|my_class_kept|my_class_ok)";
"ok_repaired" expression => "!(promise_repaired_my_class|my_class_repaired)";
"ok_error" expression => "(repair_failed_my_class.my_class_failed.my_class_not_ok.my_class_not_kept.my_class_not_repaired.my_class_reached).!(repair_denied_class_my_class|repair_timeout_my_class|my_class_timeout|my_class_denied)";
"ok" and => { "ok_success", "ok_repaired", "ok_error" };
"ok_no_empty" expression => "!_not_kept.!_not_ok.!_not_repaired.!_failed.!_reached.!_error.!repair_failed_";
"ok" and => { "ok_success", "ok_repaired", "ok_error", "ok_no_empty" };

reports:
ok::
Expand Down
4 changes: 3 additions & 1 deletion tests/acceptance/30_generic_methods/class_noop.cf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ bundle agent test
{
methods:
"ph1" usebundle => _classes_noop("my_class");
"ph1" usebundle => _classes_noop("");

}

Expand All @@ -43,7 +44,8 @@ bundle agent check
"ok_success" expression => "!(promise_kept_my_class|my_class_kept|my_class_not_repaired|my_class_ok|my_class_reached)";
"ok_repaired" expression => "!(promise_repaired_my_class|my_class_repaired)";
"ok_error" expression => "!(repair_failed_my_class|repair_denied_class_my_class|repair_timeout_my_class|my_class_failed|my_class_not_ok|my_class_not_kept|my_class_denied|my_class_timeout)";
"ok" and => { "ok_noop", "ok_success", "ok_repaired", "ok_error" };
"ok_no_empty" expression => "!_noop";
"ok" and => { "ok_noop", "ok_success", "ok_repaired", "ok_error", "ok_no_empty" };

reports:
ok::
Expand Down
4 changes: 3 additions & 1 deletion tests/acceptance/30_generic_methods/class_success.cf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ bundle agent test
{
methods:
"ph1" usebundle => _classes_success("my_class");
"ph2" usebundle => _classes_success("");

}

Expand All @@ -42,7 +43,8 @@ bundle agent check
"ok_success" and => { "promise_kept_my_class", "my_class_kept", "my_class_not_repaired", "my_class_ok", "my_class_reached" };
"ok_repaired" expression => "!(promise_repaired_my_class|my_class_repaired)";
"ok_error" expression => "!(repair_failed_my_class|repair_denied_class_my_class|repair_timeout_my_class|my_class_failed|my_class_not_ok|my_class_not_kept|my_class_denied|my_class_timeout)";
"ok" and => { "ok_success", "ok_repaired", "ok_error" };
"ok_no_empty" expression => "!_ok.!_reached.!_kept.!_not_repaired.!promise_kept_";
"ok" and => { "ok_success", "ok_repaired", "ok_error", "ok_no_empty" };

reports:
ok::
Expand Down
6 changes: 4 additions & 2 deletions tests/acceptance/30_generic_methods/classes_copy.cf
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ bundle agent test
"ph2" usebundle => file_ensure_lines_absent("${init.file}", "sample one"); # should get success
"ph3" usebundle => file_ensure_lines_absent("/dev/zero", "sample three"); # should get failed

"ph1" usebundle => _classes_copy("file_ensure_lines_absent_${init.file_canon}","global_classA");
"ph2" usebundle => _classes_copy("file_ensure_lines_present_${init.file_canon}","global_classB");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you change the ordering ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the original ordering made no sense. Now, the order matches the order of the calls above.

"ph1" usebundle => _classes_copy("file_ensure_lines_absent_${init.file_canon}","global_classA");
"ph3" usebundle => _classes_copy("file_ensure_lines_absent__dev_zero","global_classC");
"ph4" usebundle => _classes_copy("file_ensure_lines_absent_${init.file_canon}","");

}

Expand All @@ -51,7 +52,8 @@ bundle agent check
"ok_repaired" expression => "(global_classA_ok.global_classA_reached.global_classA_kept.global_classA_not_repaired.promise_kept_global_classA).!(global_classA_repaired|promise_repaired_global_classA)";
"ok_success" expression => "(global_classB_ok.global_classB_reached.global_classB_repaired.promise_repaired_global_classB).!(global_classB_kept|global_classB_not_repaired|promise_kept_global_classB)";
"ok_error" expression => "(global_classC_failed.repair_failed_global_classC.global_classC_not_ok.global_classC_not_kept.global_classC_not_repaired.global_classC_reached).!(global_classC_kept|promise_kept_global_classC|global_classC_repaired|promise_repaired_global_classC)";
"ok" expression => "ok_success.ok_repaired.ok_error";
"ok_no_empty" expression => "(!_ok.!_reached.!_kept.!_not_repaired.!promise_kept_)";
"ok" expression => "ok_success.ok_repaired.ok_error.ok_no_empty";

reports:
ok::
Expand Down
4 changes: 4 additions & 0 deletions tree/30_generic_methods/_classes_copy.cf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ bundle agent _classes_copy(source_prefix, destination_prefix)
"prefix" slist => { "promise_kept", "promise_repaired", "repair_failed", "repair_denied", "repair_timeout" };
"suffix" slist => { "repaired", "ok", "reached", "failed", "not_ok", "not_kept", "not_repaired", "denied", "timeout", "kept", "error" };

destination_exists::
# Copy result classes prefixes
"${prefix}_local_destination_prefix"
string => "${prefix}_${destination_prefix}",
Expand All @@ -44,6 +45,9 @@ bundle agent _classes_copy(source_prefix, destination_prefix)
string => "${destination_prefix}_${suffix}",
ifvarclass => "${source_prefix}_${suffix}",
classes => always("${destination_prefix}_${suffix}");

classes:
"destination_exists" not => strcmp("${destination_prefix}", "");
}


5 changes: 5 additions & 0 deletions tree/30_generic_methods/_classes_copy_invert_kept_repaired.cf
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ bundle agent _classes_copy_invert_kept_repaired(source_prefix, destination_prefi
"error_prefix" slist => { "repair_failed", "repair_denied", "repair_timeout" };
"error_suffix" slist => { "failed", "not_ok", "not_kept", "denied", "timeout", "error" };

destination_exists::

# Copy not_repaired class, as it is a special case (only exists for error or kept, so kept classes are not exactly inverted repaired classes)
"local_destination_prefix_not_repaired"
string => "${destination_prefix}_not_repaired",
Expand Down Expand Up @@ -107,4 +109,7 @@ bundle agent _classes_copy_invert_kept_repaired(source_prefix, destination_prefi
ifvarclass => "${source_prefix}_${error_suffix}",
classes => always("${destination_prefix}_${error_suffix}");

classes:
"destination_exists" not => strcmp("${destination_prefix}", "");

}
5 changes: 5 additions & 0 deletions tree/30_generic_methods/_classes_failure.cf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ bundle agent _classes_failure(class_prefix)
"prefix" slist => { "repair_failed" };
"suffix" slist => { "not_kept", "not_ok", "not_repaired", "failed", "reached", "error" };

destination_exists::
"${prefix}_local"
string => "${prefix}_${class_prefix}",
classes => always("${prefix}_${class_prefix}");
Expand All @@ -39,4 +40,8 @@ bundle agent _classes_failure(class_prefix)
string => "${class_prefix}_${suffix}",
classes => always("${class_prefix}_${suffix}");

classes:
"destination_exists" not => strcmp("${class_prefix}", "");


}
5 changes: 5 additions & 0 deletions tree/30_generic_methods/_classes_noop.cf
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ bundle agent _classes_noop(class_prefix)
vars:
"suffix" slist => { "noop" };

destination_exists::
"local_${suffix}"
string => "${class_prefix}_${suffix}",
classes => always("${class_prefix}_${suffix}");

classes:
"destination_exists" not => strcmp("${class_prefix}", "");

}


5 changes: 5 additions & 0 deletions tree/30_generic_methods/_classes_repaired.cf
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,18 @@ bundle agent _classes_repaired(class_prefix)
"prefix" slist => { "promise_repaired" };
"suffix" slist => { "ok", "reached", "repaired" };

destination_exists::
"${prefix}_local"
string => "${prefix}_${class_prefix}",
classes => always("${prefix}_${class_prefix}");

"local_${suffix}"
string => "${class_prefix}_${suffix}",
classes => always("${class_prefix}_${suffix}");

classes:
"destination_exists" not => strcmp("${class_prefix}", "");

}


5 changes: 5 additions & 0 deletions tree/30_generic_methods/_classes_success.cf
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,18 @@ bundle agent _classes_success(class_prefix)
"prefix" slist => { "promise_kept" };
"suffix" slist => { "ok", "reached", "kept", "not_repaired" };

destination_exists::
"${prefix}_local"
string => "${prefix}_${class_prefix}",
classes => always("${prefix}_${class_prefix}");

"local_${suffix}"
string => "${class_prefix}_${suffix}",
classes => always("${class_prefix}_${suffix}");

classes:
"destination_exists" not => strcmp("${class_prefix}", "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it report a warning if an empty string is passed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In master we use this property in every generic method so that calls don't fail when this.caller_promisers doesn't exist. So it could be a warning, but not in the general case.


}