cleanup

[?]
Mar 17, 2011, 11:55 AM
SBKX3YH2EOCYY2IDACGOTXHJZSYSRHD5EC7FB6WGPKHLFYOF6SAAC

Dependencies

  • [2] ZHBEOOUQ show evaluation errors in log of tests
  • [3] WFJ3ZPRM add tests for scm inputs
  • [4] HX4QYOYA add first evaluations tests
  • [5] W6J4PVRP remove debug statement

Change contents

  • edit in tests/Setup.pm at line 12
    [3.763]
    [3.763]
    }
    sub nrBuildsForJobset {
    my ($jobset) = @_;
    return $jobset->builds->search({},{})->count ;
    }
    sub nrQueuedBuildsForJobset {
    my ($jobset) = @_;
    return $jobset->builds->search({},{ join => 'schedulingInfo' })->count ;
    }
    sub createBaseJobset {
    my ($jobsetName, $nixexprpath) = @_;
    my $project = $db->resultset('Projects')->update_or_create({name => "tests", displayname => "", owner => "root"});
    my $jobset = $project->jobsets->create({name => $jobsetName, nixexprinput => "jobs", nixexprpath => $nixexprpath, emailoverride => ""});
    my $jobsetinput;
    my $jobsetinputals;
    $jobsetinput = $jobset->jobsetinputs->create({name => "jobs", type => "path"});
    $jobsetinputals = $jobsetinput->jobsetinputalts->create({altnr => 0, value => getcwd."/jobs"});
    return $jobset;
    }
    sub createJobsetWithOneInput {
    my ($jobsetName, $nixexprpath, $name, $type, $uri) = @_;
    my $jobset = createBaseJobset($jobsetName, $nixexprpath);
    my $jobsetinput;
    my $jobsetinputals;
    $jobsetinput = $jobset->jobsetinputs->create({name => $name, type => $type});
    $jobsetinputals = $jobsetinput->jobsetinputalts->create({altnr => 1, value => $uri});
    return $jobset;
  • edit in tests/Setup.pm at line 51
    [3.766]
    [3.766]
    sub evalSucceeds {
    my ($jobset) = @_;
    my $res = captureStdoutStderr(60, ("../src/script/hydra_evaluator.pl", $jobset->project->name, $jobset->name));
    print STDERR "Evaluation errors for jobset ".$jobset->project->name.":".$jobset->name.": \n".$jobset->errormsg."\n" if $jobset->errormsg;
    return $res;
    }
  • replacement in tests/evaluation-tests.pl.in at line 13
    [3.969][3.347:377]()
    use Test::Simple tests => 14;
    [3.969]
    [3.998]
    use Test::Simple tests => 16;
  • edit in tests/evaluation-tests.pl.in at line 23
    [3.1157]
    [3.415]
    my $jobset;
  • replacement in tests/evaluation-tests.pl.in at line 25
    [3.416][3.416:570]()
    sub nrBuildsForJobset {
    my ($project, $jobset) = @_;
    return $db->resultset('Builds')->search({ project => $project, jobset => $jobset},{})->count ;
    }
    [3.416]
    [3.570]
    # Most basic test case, no parameters
    $jobset = createBaseJobset("basic", "basic.nix");
  • replacement in tests/evaluation-tests.pl.in at line 28
    [3.571][3.571:796]()
    sub createJobsetWithOneSCMInput {
    my ($jobsetName, $nixexprpath, $type, $uri) = @_;
    my $jobset = $project->jobsets->create({name => $jobsetName, nixexprinput => "jobs", nixexprpath => $nixexprpath, emailoverride => ""});
    [3.571]
    [3.796]
    ok(evalSucceeds($jobset), "Evaluating jobs/basic.nix should exit with return code 0");
    ok(nrQueuedBuildsForJobset($jobset) == 3 , "Evaluating jobs/basic.nix should result in 3 builds");
  • edit in tests/evaluation-tests.pl.in at line 31
    [3.797][3.797:838]()
    my $jobsetinput;
    my $jobsetinputals;
  • replacement in tests/evaluation-tests.pl.in at line 32
    [3.839][3.839:1019]()
    $jobsetinput = $jobset->jobsetinputs->create({name => "jobs", type => "path"});
    $jobsetinputals = $jobsetinput->jobsetinputalts->create({altnr => 0, value => getcwd."/jobs"});
    [3.839]
    [3.1019]
    # Test jobset with 2 jobs, one has parameter of succeeded build of the other
    $jobset = createJobsetWithOneInput("build-output-as-input", "build-output-as-input.nix", "build1", "build", "build1");
  • replacement in tests/evaluation-tests.pl.in at line 35
    [3.1020][3.1020:1188]()
    $jobsetinput = $jobset->jobsetinputs->create({name => "src", type => $type});
    $jobsetinputals = $jobsetinput->jobsetinputalts->create({altnr => 0, value => $uri});
    [3.1020]
    [2.28]
    ok(evalSucceeds($jobset), "Evaluating jobs/build-output-as-input.nix should exit with return code 0");
    ok(nrQueuedBuildsForJobset($jobset) == 1 , "Evaluating jobs/build-output-as-input.nix for first time should result in 1 build in queue");
  • edit in tests/evaluation-tests.pl.in at line 38
    [2.29][2.29:47](),[2.47][3.1188:1550](),[3.1188][3.1188:1550](),[3.1550][3.1374:1653](),[3.1374][3.1374:1653](),[3.1653][3.1551:1654](),[3.1654][3.1653:1654](),[3.1653][3.1653:1654]()
    return $jobset;
    }
    sub evalSucceeds {
    my ($project, $jobset) = @_;
    return captureStdoutStderr(60, ("../src/script/hydra_evaluator.pl", $project, $jobset));
    }
    my $jobset = $project->jobsets->create({name => "basic", nixexprinput => "jobs", nixexprpath => "basic.nix", emailoverride => ""});
    my $jobsetinput = $jobset->jobsetinputs->create({name => "jobs", type => "path"});
    my $jobsetinputals = $jobsetinput->jobsetinputalts->create({altnr => 0, value => getcwd."/jobs"});
    ($res, $stdout, $stderr) = captureStdoutStderr(60, ("../src/script/hydra_evaluator.pl", "tests", "basic"));
    ok($res, "Evaluating jobs/basic.nix should exit with return code 0");
    ok( nrBuildsForJobset("tests", "basic") == 3 , "Evaluating jobs/basic.nix should result in 3 builds");
  • edit in tests/evaluation-tests.pl.in at line 39
    [3.1680]
    [3.1655]
    # Test scm inputs
  • replacement in tests/evaluation-tests.pl.in at line 42
    [3.1763][2.48:145](),[2.145][3.1850:1951](),[3.1850][3.1850:1951](),[3.1951][2.146:252]()
    $jobset = createJobsetWithOneSCMInput($scm, "$scm-input.nix", $scm, "$jobsBaseUri/$scm-repo");
    ok(evalSucceeds("tests", $scm), "Evaluating jobs/$scm-input.nix should exit with return code 0.");
    print STDERR "Evaluation errors for jobset tests:$scm: \n".$jobset->errormsg."\n" if $jobset->errormsg;
    [3.1763]
    [2.252]
    $jobset = createJobsetWithOneInput($scm, "$scm-input.nix", "src", $scm, "$jobsBaseUri/$scm-repo");
  • replacement in tests/evaluation-tests.pl.in at line 44
    [2.253][2.253:357]()
    ok(nrBuildsForJobset("tests", $scm) == 1, "Evaluating jobs/$scm-input.nix should result in 1 build");
    [2.253]
    [3.2054]
    ok(evalSucceeds($jobset), "Evaluating jobs/$scm-input.nix should exit with return code 0.");
    ok(nrQueuedBuildsForJobset($jobset) == 1, "Evaluating jobs/$scm-input.nix should result in 1 build in queue");