api-test.t: make it work under yath
[?]
Apr 28, 2021, 10:24 PM
GLJD3PG2EYSB7EWYWEU57TYJQB6VDP2CJF6OLFEFIWZAY7OBXMMACDependencies
- [2]
4YCF3KBGConcurrent hydra-evaluator - [3]
QHOKZZUCFix API tests - [4]
TZEDUWFXapi-test: make created project and jobset visible - [5]
KSFJOFICMake PathInput plugin cache validity configurable - [6]
ZIIXICG7Make the outputs' outpaths available via the Build JSON API - [7]
4VYSDP4IAdd eager fetching of relations and enable that for jobset->jobsetinputs - [8]
UOL7YDDLFix test - [9]
MIMHJSZKAdd json output for the search API endpoint - [10]
2JJP7673tests: move to t, allow `yath test` from root - [11]
VHC5UKOBrename api-test.pl to .t so it runs under yath - [12]
5QYMALGUFix Perl error in tests.api - [13]
WQ2VQ7H3Use hydra-module.nix in the tests - [14]
2DGIP6L4Cleanup build serialization - [15]
SYLVCTT6Start api cleanup with the User model - [16]
KYSBJAYNAllow dashes in jobset input names - [17]
YI3BZG5NCleanup Jobset serialization - [18]
Q3VTDUSQFix the API test - [19]
MQYHIUEECleanup eval serialization - [20]
NP7IOJ4QFlesh out the API a bit - [21]
7ECJWNVXCleanup Project model - [22]
MMHOJIGDTest whether incorrect passwords are rejected - [23]
LZVO64YGMerge in the first bits of the API work
Change contents
- replacement in t/api-test.t at line 1
use LWP::UserAgent;use strict;use Setup; - replacement in t/api-test.t at line 4
use Test::Simple tests => 20;use File::Copy;my %ctx = test_init(hydra_config => q|# No caching for PathInput plugin, otherwise we get wrong values# (as it has a 30s window where no changes to the file are considered).path_input_cache_validity_seconds = 0|);my $jobsetdir = $ctx{tmpdir} . '/jobset';mkdir($jobsetdir);copy($ctx{jobsdir} . '/api-test.nix', "$jobsetdir/default.nix");require Hydra::Schema;use HTTP::Request::Common;use Test2::V0;require Catalyst::Test;Catalyst::Test->import('Hydra');my $db = Hydra::Model::DB->new;hydra_setup($db);{my $user = $db->resultset('Users')->find({ username => 'root' });$user->setPassword('foobar');$user->userroles->update_or_create({ role => 'admin' });} - replacement in t/api-test.t at line 35
my $ua = LWP::UserAgent->new;$ua->cookie_jar({});my $cookie = ""; - replacement in t/api-test.t at line 41
$req->uri("http://localhost:3000$opts->{uri}");$req->uri("http://localhost$opts->{uri}"); - replacement in t/api-test.t at line 43
$req->header(Referer => "http://localhost:3000/") if $opts->{method} eq "POST";$req->header(Content_Type => "application/json");$req->header(Origin => "http://localhost/") if $opts->{method} eq "POST";$req->header(Cookie => $cookie); - replacement in t/api-test.t at line 48
my $res = $ua->request($req);my $res = request($req); - edit in t/api-test.t at line 62
$cookie = $result->header("set-cookie"); - replacement in t/api-test.t at line 77
$result = request_json({ uri => '/jobset/sample/default', method => 'PUT', data => { nixexprpath => "default.nix", nixexprinput => "my-src", inputs => { "my-src" => { type => "path", value => "/run/jobset" } }, enabled => "1", visible => "1", checkinterval => "3600"} });$result = request_json({ uri => '/jobset/sample/default', method => 'PUT', data => { nixexprpath => "default.nix", nixexprinput => "my-src", inputs => { "my-src" => { type => "path", value => $jobsetdir } }, enabled => "1", visible => "1", checkinterval => "3600"} }); - replacement in t/api-test.t at line 84
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 $jobsetdir, "The 'my-src' input is in $jobsetdir"); - replacement in t/api-test.t at line 86
system("hydra-eval-jobset sample default");ok(evalSucceeds($db->resultset('Jobsets')->find({ name => 'default' })), "Evaluating should exit with return code 0"); - replacement in t/api-test.t at line 94
system("echo >> /run/jobset/default.nix; hydra-eval-jobset sample default");open(my $fh, ">>", "${jobsetdir}/default.nix") or die "didn't open?";say $fh "\n";close $fh;ok(evalSucceeds($db->resultset('Jobsets')->find({ name => 'default' })), "Evaluating should exit with return code 0"); - replacement in t/api-test.t at line 107
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'");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'"); - edit in t/api-test.t at line 115[6.742]
done_testing;