forked from lix-project/hydra
Fix the API test
This commit is contained in:
parent
62cd9d18b6
commit
48d6f0de2a
|
@ -13,6 +13,7 @@ let
|
||||||
{ imports = [ ./hydra-module.nix ];
|
{ imports = [ ./hydra-module.nix ];
|
||||||
|
|
||||||
virtualisation.memorySize = 1024;
|
virtualisation.memorySize = 1024;
|
||||||
|
virtualisation.writableStore = true;
|
||||||
|
|
||||||
services.hydra.enable = true;
|
services.hydra.enable = true;
|
||||||
services.hydra.package = hydraPkg;
|
services.hydra.package = hydraPkg;
|
||||||
|
@ -216,9 +217,8 @@ in rec {
|
||||||
, "chown -R hydra /run/jobset /tmp/nix"
|
, "chown -R hydra /run/jobset /tmp/nix"
|
||||||
);
|
);
|
||||||
|
|
||||||
# Start the web interface with some weird settings.
|
$machine->succeed("systemctl stop hydra-evaluator hydra-queue-runner");
|
||||||
$machine->succeed("systemctl stop hydra-server hydra-evaluator hydra-queue-runner");
|
$machine->waitForJob("hydra-server");
|
||||||
$machine->mustSucceed("su - hydra -c 'NIX_STORE_DIR=/tmp/nix/store NIX_LOG_DIR=/tmp/nix/var/log/nix NIX_STATE_DIR=/tmp/nix/var/nix NIX_REMOTE= DBIC_TRACE=1 hydra-server -d' >&2 &");
|
|
||||||
$machine->waitForOpenPort("3000");
|
$machine->waitForOpenPort("3000");
|
||||||
|
|
||||||
# Run the API tests.
|
# Run the API tests.
|
||||||
|
|
|
@ -49,20 +49,18 @@ ok(exists $jobset->{jobsetinputs}->{"my-src"}, "The new jobset has a 'my-src' in
|
||||||
|
|
||||||
ok($jobset->{jobsetinputs}->{"my-src"}->{jobsetinputalts}->[0] eq "/run/jobset", "The 'my-src' input is in /run/jobset");
|
ok($jobset->{jobsetinputs}->{"my-src"}->{jobsetinputalts}->[0] eq "/run/jobset", "The 'my-src' input is in /run/jobset");
|
||||||
|
|
||||||
system("NIX_STORE_DIR=/tmp/nix/store NIX_LOG_DIR=/tmp/nix/var/log/nix NIX_STATE_DIR=/tmp/nix/var/nix NIX_REMOTE= hydra-evaluator sample default");
|
system("hydra-evaluator sample default");
|
||||||
$result = request_json({ uri => '/jobset/sample/default/evals' });
|
$result = request_json({ uri => '/jobset/sample/default/evals' });
|
||||||
ok($result->code() == 200, "Can get evals of a jobset");
|
ok($result->code() == 200, "Can get evals of a jobset");
|
||||||
my $evals = decode_json($result->content())->{evals};
|
my $evals = decode_json($result->content())->{evals};
|
||||||
my $eval = $evals->[0];
|
my $eval = $evals->[0];
|
||||||
ok($eval->{hasnewbuilds} == 1, "The first eval of a jobset has new builds");
|
ok($eval->{hasnewbuilds} == 1, "The first eval of a jobset has new builds");
|
||||||
|
|
||||||
# Ugh, cached for 30s
|
system("echo >> /run/jobset/default.nix; hydra-evaluator sample default");
|
||||||
sleep 30;
|
|
||||||
system("echo >> /run/jobset/default.nix; NIX_STORE_DIR=/tmp/nix/store NIX_LOG_DIR=/tmp/nix/var/log/nix NIX_STATE_DIR=/tmp/nix/var/nix hydra-evaluator sample default");
|
|
||||||
my $evals = decode_json(request_json({ uri => '/jobset/sample/default/evals' })->content())->{evals};
|
my $evals = decode_json(request_json({ uri => '/jobset/sample/default/evals' })->content())->{evals};
|
||||||
ok($evals->[0]->{jobsetevalinputs}->{"my-src"}->{revision} != $evals->[1]->{jobsetevalinputs}->{"my-src"}->{revision}, "Changing a jobset source changes its revision");
|
ok($evals->[0]->{jobsetevalinputs}->{"my-src"}->{revision} != $evals->[1]->{jobsetevalinputs}->{"my-src"}->{revision}, "Changing a jobset source changes its revision");
|
||||||
|
|
||||||
my $build = decode_json(request_json({ uri => "/build/" . $evals->[0]->{builds}->[0] })->content());
|
my $build = decode_json(request_json({ uri => "/build/" . $evals->[0]->{builds}->[0] })->content());
|
||||||
ok($build->{job} eq "job", "The build's job name is job");
|
ok($build->{job} eq "job", "The build's job name is job");
|
||||||
ok($build->{finished} == 0, "The build isn't finished yet");
|
ok($build->{finished} == 0, "The build isn't finished yet");
|
||||||
ok($build->{buildoutputs}->{out}->{path} =~ /^\/tmp\/nix\/store\/[a-zA-Z0-9]{32}-job$/, "The build's outpath is in the nix store and named 'job'");
|
ok($build->{buildoutputs}->{out}->{path} =~ /^\/nix\/store\/[a-zA-Z0-9]{32}-job$/, "The build's outpath is in the Nix store and named 'job'");
|
||||||
|
|
Loading…
Reference in a new issue