t/Setup: move subs calling hydra-* programs to a CliPrograms module

[?]
Dec 15, 2021, 1:25 AM
LEW5O57PMQ4SMFWYFWJ22R3IFJ63RPV5FMPEAGW3JRZCDJCR5WNAC

Dependencies

  • [2] MIQH5W3F Test: Show error output from hydra-queue-runner on timeout
  • [3] YIZWKGFI tests: add jobsdir and testdir to ctx hash
  • [4] HXEZUCTD Add test to verify includes work
  • [5] EAFAL4V3 Test Setup: fix evalSucceeds to actually output evaluation errors
  • [6] FAIJDQKZ
  • [7] UGA45FNC Add a plugin for backing up builds in s3
  • [8] OWRS526H Create an ephemeral PostgreSQL database per test
  • [9] 3AKZKWCR RunCommand: Test
  • [10] 4QI6G7YB tests: replace the flat list of contexts with a hash
  • [11] UIA3ULNU Give each test its own Nix directories
  • [12] VI32YSGA I should test first
  • [13] HX4QYOYA add first evaluations tests
  • [14] SBKX3YH2 cleanup
  • [15] OSIBECOE Attempt to fix errors during test teardown
  • [16] QIW2WZKW Fix indentation
  • [17] V2ALOFRR Fix the test
  • [18] 7VQ4ALFY Update "make check" for the new queue runner
  • [19] OB7GB5DL Test environment cleanups
  • [20] HE3GX5IP Optimize fetch-git.
  • [21] 4YCF3KBG Concurrent hydra-evaluator
  • [22] A43SLRSH Fix handling of IPC::Run::run exit status
  • [*] 2JJP7673 tests: move to t, allow `yath test` from root

Change contents

  • file addition: CliRunners.pm (----------)
    [24.2459]
    use warnings;
    use strict;
    package CliRunners;
    our @ISA = qw(Exporter);
    our @EXPORT = qw(
    evalSucceeds runBuild sendNotifications
    captureStdoutStderr);
    sub captureStdoutStderr {
    # "Lazy"-load Hydra::Helper::Nix to avoid the compile-time
    # import of Hydra::Model::DB. Early loading of the DB class
    # causes fixation of the DSN, and we need to fixate it after
    # the temporary DB is setup.
    require Hydra::Helper::Nix;
    return Hydra::Helper::Nix::captureStdoutStderr(@_)
    }
    sub evalSucceeds {
    my ($jobset) = @_;
    my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-eval-jobset", $jobset->project->name, $jobset->name));
    $jobset->discard_changes; # refresh from DB
    chomp $stdout; chomp $stderr;
    print STDERR "Evaluation errors for jobset ".$jobset->project->name.":".$jobset->name.": \n".$jobset->errormsg."\n" if $jobset->errormsg;
    print STDERR "STDOUT: $stdout\n" if $stdout ne "";
    print STDERR "STDERR: $stderr\n" if $stderr ne "";
    return !$res;
    }
    sub runBuild {
    my ($build) = @_;
    my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-queue-runner", "-vvvv", "--build-one", $build->id));
    if ($res) {
    print STDERR "Queue runner stdout: $stdout\n" if $stdout ne "";
    print STDERR "Queue runner stderr: $stderr\n" if $stderr ne "";
    }
    return !$res;
    }
    sub sendNotifications() {
    my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-notify", "--queued-only"));
    if ($res) {
    print STDERR "hydra notify stdout: $stdout\n" if $stdout ne "";
    print STDERR "hydra notify stderr: $stderr\n" if $stderr ne "";
    }
    return !$res;
    }
    1;
  • edit in t/lib/Setup.pm at line 11
    [3.1330]
    [6.561]
    use CliRunners;
  • edit in t/lib/Setup.pm at line 47
    [6.137][6.915:1256](),[4.1031][6.915:1256](),[6.2224][6.915:1256](),[6.915][6.915:1256]()
    }
    sub captureStdoutStderr {
    # "Lazy"-load Hydra::Helper::Nix to avoid the compile-time
    # import of Hydra::Model::DB. Early loading of the DB class
    # causes fixation of the DSN, and we need to fixate it after
    # the temporary DB is setup.
    require Hydra::Helper::Nix;
    return Hydra::Helper::Nix::captureStdoutStderr(@_)
  • edit in t/lib/Setup.pm at line 96
    [6.1172][6.763:766](),[6.1312][6.763:766](),[6.763][6.763:766](),[6.766][6.1173:1192](),[6.1192][6.1313:1336](),[6.1336][6.11450:11571](),[6.11571][5.0:49](),[5.49][6.1469:1755](),[6.9463][6.1469:1755](),[6.11571][6.1469:1755](),[6.1469][6.1469:1755](),[6.1755][6.3646:3664](),[6.1772][6.1482:1485](),[6.3664][6.1482:1485](),[6.1482][6.1482:1485](),[6.1485][6.707:722](),[6.722][6.1773:1795](),[6.1795][6.1696:1815](),[6.1815][2.62:228](),[2.228][6.3711:3729](),[6.1815][6.3711:3729](),[6.3711][6.3711:3729](),[6.271][6.4328:4331](),[6.1971][6.4328:4331](),[6.3729][6.4328:4331](),[6.440][6.4328:4331](),[6.4331][6.900:1204]()
    }
    sub evalSucceeds {
    my ($jobset) = @_;
    my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-eval-jobset", $jobset->project->name, $jobset->name));
    $jobset->discard_changes; # refresh from DB
    chomp $stdout; chomp $stderr;
    print STDERR "Evaluation errors for jobset ".$jobset->project->name.":".$jobset->name.": \n".$jobset->errormsg."\n" if $jobset->errormsg;
    print STDERR "STDOUT: $stdout\n" if $stdout ne "";
    print STDERR "STDERR: $stderr\n" if $stderr ne "";
    return !$res;
    }
    sub runBuild {
    my ($build) = @_;
    my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-queue-runner", "-vvvv", "--build-one", $build->id));
    if ($res) {
    print STDERR "Queue runner stdout: $stdout\n" if $stdout ne "";
    print STDERR "Queue runner stderr: $stderr\n" if $stderr ne "";
    }
    return !$res;
    }
    sub sendNotifications() {
    my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-notify", "--queued-only"));
    if ($res) {
    print STDERR "hydra notify stdout: $stdout\n" if $stdout ne "";
    print STDERR "hydra notify stderr: $stderr\n" if $stderr ne "";
    }
    return !$res;