Only run dynamic runcommand hooks if the jobset enables them

This commit is contained in:
Graham Christensen 2021-12-14 22:15:50 -05:00
parent 97a1d2d1d4
commit 3cce0c5ef6
2 changed files with 16 additions and 4 deletions

View file

@ -71,7 +71,9 @@ sub isBuildEligibleForDynamicRunCommand {
return 0; return 0;
} }
return 1; if ($build->jobset->enable_dynamic_run_command) {
return 1;
}
} }
return 0; return 0;
@ -136,9 +138,6 @@ sub fanoutToCommands {
# Calculate all dynamically defined commands to execute # Calculate all dynamically defined commands to execute
if (areDynamicCommandsEnabled($config)) { if (areDynamicCommandsEnabled($config)) {
# missing test cases:
#
# 1. is it enabled on the jobset?
if (isBuildEligibleForDynamicRunCommand($build)) { if (isBuildEligibleForDynamicRunCommand($build)) {
my $job = $build->get_column('job'); my $job = $build->get_column('job');
my $out = $build->buildoutputs->find({name => "out"}); my $out = $build->buildoutputs->find({name => "out"});

View file

@ -13,6 +13,9 @@ my $builds = $ctx->makeAndEvaluateJobset(
my $build = $builds->{"runCommandHook.example"}; my $build = $builds->{"runCommandHook.example"};
# Enable dynamic runcommand on the jobset
$build->jobset->update({enable_dynamic_run_command => 1});
is($build->job, "runCommandHook.example", "The only job should be runCommandHook.example"); is($build->job, "runCommandHook.example", "The only job should be runCommandHook.example");
is($build->finished, 1, "Build should be finished."); is($build->finished, 1, "Build should be finished.");
is($build->buildstatus, 0, "Build should have buildstatus 0."); is($build->buildstatus, 0, "Build should have buildstatus 0.");
@ -167,6 +170,16 @@ subtest "isBuildEligibleForDynamicRunCommand" => sub {
"Failed builds don't get run" "Failed builds don't get run"
); );
}; };
subtest "With dynamic runcommand disabled ..." => sub {
$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"
);
};
}; };