RunCommand: only run dynamic runcommand hooks if the project AND jobset agree they should be enabled

This commit is contained in:
Graham Christensen 2021-12-15 12:33:16 -05:00
parent 85a53694c8
commit 0c96172c28

View file

@ -13,7 +13,8 @@ my $builds = $ctx->makeAndEvaluateJobset(
my $build = $builds->{"runCommandHook.example"};
# Enable dynamic runcommand on the jobset
# Enable dynamic runcommand on the project and jobset
$build->project->update({enable_dynamic_run_command => 1});
$build->jobset->update({enable_dynamic_run_command => 1});
is($build->job, "runCommandHook.example", "The only job should be runCommandHook.example");
@ -172,6 +173,30 @@ subtest "isBuildEligibleForDynamicRunCommand" => sub {
};
subtest "With dynamic runcommand disabled ..." => sub {
subtest "disabled on the project, enabled on the jobset" => {
$build->project->update({enable_dynamic_run_command => 0});
$build->jobset->update({enable_dynamic_run_command => 1});
is(
Hydra::Plugin::RunCommand::isBuildEligibleForDynamicRunCommand($builds->{"runCommandHook.example"}),
0,
"Builds don't run from a jobset with disabled dynamic runcommand"
);
};
subtest "enabled on the project, disabled on the jobset" => {
$build->project->update({enable_dynamic_run_command => 1});
$build->jobset->update({enable_dynamic_run_command => 0});
is(
Hydra::Plugin::RunCommand::isBuildEligibleForDynamicRunCommand($builds->{"runCommandHook.example"}),
0,
"Builds don't run from a jobset with disabled dynamic runcommand"
);
};
subtest "disabled on the project, disabled on the jobset" => {
$build->project->update({enable_dynamic_run_command => 0});
$build->jobset->update({enable_dynamic_run_command => 0});
is(
@ -181,6 +206,7 @@ subtest "isBuildEligibleForDynamicRunCommand" => sub {
);
};
};
};
done_testing;