From dcefb8837366f6b4e02ccb63d455c56f846c6981 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 14 Jan 2022 10:36:05 -0500 Subject: [PATCH 01/10] test /project/NAME/all returns a 200 --- t/Hydra/Controller/Project/builds.t | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 t/Hydra/Controller/Project/builds.t diff --git a/t/Hydra/Controller/Project/builds.t b/t/Hydra/Controller/Project/builds.t new file mode 100644 index 00000000..7ea5ed58 --- /dev/null +++ b/t/Hydra/Controller/Project/builds.t @@ -0,0 +1,25 @@ +use strict; +use warnings; +use Setup; +use Test2::V0; +use Catalyst::Test (); +use HTTP::Request::Common; + +my $ctx = test_context(); + +Catalyst::Test->import('Hydra'); + +my $builds = $ctx->makeAndEvaluateJobset( + expression => "basic.nix", + build => 1 +); + +my $build = $builds->{"empty_dir"}; +my $project = $build->project; + +subtest "/project/PROJECT/all" => sub { + my $response = request(GET '/project/' . $project->name . '/all'); + ok($response->is_success, "The page showing the project's builds returns 200."); +}; + +done_testing; From 4086f3bafd5db3eb4b67eaa0d30152d029c85feb Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 14 Jan 2022 10:54:24 -0500 Subject: [PATCH 02/10] Result::Projects: give a builds method to access all of a project's builds --- src/lib/Hydra/Schema/Result/Projects.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/Hydra/Schema/Result/Projects.pm b/src/lib/Hydra/Schema/Result/Projects.pm index 9513d883..ca446048 100644 --- a/src/lib/Hydra/Schema/Result/Projects.pm +++ b/src/lib/Hydra/Schema/Result/Projects.pm @@ -248,6 +248,11 @@ __PACKAGE__->many_to_many("usernames", "projectmembers", "username"); use JSON::MaybeXS; +sub builds { + my ($self) = @_; + return $self->jobsets->related_resultset('builds'); +}; + sub as_json { my $self = shift; From e019028ce918747dcc2316892092441a27d1bde9 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 14 Jan 2022 10:54:45 -0500 Subject: [PATCH 03/10] common.tt: access project and jobset names from respective tables --- src/root/common.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/root/common.tt b/src/root/common.tt index efb11b64..b088e1dc 100644 --- a/src/root/common.tt +++ b/src/root/common.tt @@ -131,7 +131,7 @@ BLOCK renderBuildListBody; [% END %] [% build.id %] [% IF !hideJobName %] - [% IF !hideJobsetName %][%build.get_column("project")%]:[%build.get_column("jobset")%]:[% END %][%build.get_column("job")%] + [% IF !hideJobsetName %][%build.jobset.get_column("project")%]:[%build.jobset.get_column("name")%]:[% END %][%build.get_column("job")%] [% END %] [% t = showSchedulingInfo ? build.timestamp : build.stoptime; IF t; INCLUDE renderRelativeDate timestamp=(showSchedulingInfo ? build.timestamp : build.stoptime); ELSE; "-"; END %] [% !showSchedulingInfo and build.get_column('releasename') ? build.get_column('releasename') : build.nixname %] From 9291cba89fd8f77869d0bdee2c6f51e1b764b846 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 14 Jan 2022 11:01:10 -0500 Subject: [PATCH 04/10] Project: tests we can get the channel for the latest builds --- t/Hydra/Controller/Project/builds.t | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/t/Hydra/Controller/Project/builds.t b/t/Hydra/Controller/Project/builds.t index 7ea5ed58..5337d9da 100644 --- a/t/Hydra/Controller/Project/builds.t +++ b/t/Hydra/Controller/Project/builds.t @@ -22,4 +22,9 @@ subtest "/project/PROJECT/all" => sub { ok($response->is_success, "The page showing the project's builds returns 200."); }; +subtest "/project/PROJECT/channel/latest" => sub { + my $response = request(GET '/project/' . $project->name . '/channel/latest'); + ok($response->is_success, "The page showing the project's builds returns 200."); +}; + done_testing; From 5c5ecdb9fc1c45cc55c0f54dd6f10853d5c22f5b Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 14 Jan 2022 11:04:55 -0500 Subject: [PATCH 05/10] Helper::Nix::isLocalStore: a file store is local --- src/lib/Hydra/Helper/Nix.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Hydra/Helper/Nix.pm b/src/lib/Hydra/Helper/Nix.pm index 9ecb4d7a..7113cb4a 100644 --- a/src/lib/Hydra/Helper/Nix.pm +++ b/src/lib/Hydra/Helper/Nix.pm @@ -568,7 +568,7 @@ sub readNixFile { sub isLocalStore { my $uri = getStoreUri(); - return $uri =~ "^(local|daemon|auto)"; + return $uri =~ "^(local|daemon|auto|file)"; } From 12ff981d2454750f0242634a2657aa3391996cff Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Sun, 9 Jan 2022 09:46:20 -0500 Subject: [PATCH 06/10] Builds: LatestSucceeded*: remove project, jobset references --- src/lib/Hydra/Schema/Result/Builds.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/Hydra/Schema/Result/Builds.pm b/src/lib/Hydra/Schema/Result/Builds.pm index 9f25ff7a..c1d8e13e 100644 --- a/src/lib/Hydra/Schema/Result/Builds.pm +++ b/src/lib/Hydra/Schema/Result/Builds.pm @@ -584,7 +584,7 @@ sub makeSource { sub makeQueries { my ($name, $constraint) = @_; - my $activeJobs = "(select distinct project, jobset, job, system from Builds where isCurrent = 1 $constraint)"; + my $activeJobs = "(select distinct jobset_id, job, system from Builds where isCurrent = 1 $constraint)"; makeSource( "LatestSucceeded$name", @@ -594,7 +594,7 @@ sub makeQueries { (select (select max(b.id) from builds b where - project = activeJobs.project and jobset = activeJobs.jobset + jobset_id = activeJobs.jobset_id and job = activeJobs.job and system = activeJobs.system and finished = 1 and buildstatus = 0 ) as id @@ -606,7 +606,7 @@ QUERY } makeQueries('', ""); -makeQueries('ForProject', "and project = ?"); +makeQueries('ForProject', "and jobset_id in (select id from jobsets j where j.project = ?)"); makeQueries('ForJobset', "and jobset_id = ?"); makeQueries('ForJob', "and jobset_id = ? and job = ?"); makeQueries('ForJobName', "and jobset_id = (select id from jobsets j where j.name = ?) and job = ?"); From 23d70465223e967b5b7964c8f8068d0c3953f6c0 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Sun, 9 Jan 2022 08:59:01 -0500 Subject: [PATCH 07/10] t/Controller/Build/constituents.t: assert the response is valid JSON, dump if it isn't --- t/Hydra/Controller/Build/constituents.t | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/t/Hydra/Controller/Build/constituents.t b/t/Hydra/Controller/Build/constituents.t index 93b4a491..013ac9c0 100644 --- a/t/Hydra/Controller/Build/constituents.t +++ b/t/Hydra/Controller/Build/constituents.t @@ -36,7 +36,14 @@ my $constituents = request(GET $url, ); ok($constituents->is_success, "Getting the constituent builds"); -my $data = decode_json($constituents->content); + +my $data; +my $valid_json = lives { $data = decode_json($constituents->content); }; +ok($valid_json, "We get back valid JSON."); +if (!$valid_json) { + use Data::Dumper; + print STDERR Dumper $constituents->content; +} my ($buildA) = grep { $_->{nixname} eq "empty-dir-a" } @$data; my ($buildB) = grep { $_->{nixname} eq "empty-dir-b" } @$data; From 2803f06e6eeea1b2b54315693b2a5c0e0e5ca02e Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 14 Jan 2022 11:14:01 -0500 Subject: [PATCH 08/10] CatalystUtils::buildListColumns: add jobset_id --- src/lib/Hydra/Helper/CatalystUtils.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Hydra/Helper/CatalystUtils.pm b/src/lib/Hydra/Helper/CatalystUtils.pm index cf4138af..1ae61684 100644 --- a/src/lib/Hydra/Helper/CatalystUtils.pm +++ b/src/lib/Hydra/Helper/CatalystUtils.pm @@ -33,7 +33,7 @@ our @EXPORT = qw( # Columns from the Builds table needed to render build lists. -Readonly::Array our @buildListColumns => ('id', 'finished', 'timestamp', 'stoptime', 'project', 'jobset', 'job', 'nixname', 'system', 'buildstatus', 'releasename'); +Readonly::Array our @buildListColumns => ('id', 'finished', 'timestamp', 'stoptime', 'project', 'jobset', 'jobset_id', 'job', 'nixname', 'system', 'buildstatus', 'releasename'); sub getBuild { From a2adb8cfb656891b50898019471cdb906c363964 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 14 Jan 2022 11:24:01 -0500 Subject: [PATCH 09/10] Test Jobset's builds and channel pages --- t/Hydra/Controller/Jobset/builds.t | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 t/Hydra/Controller/Jobset/builds.t diff --git a/t/Hydra/Controller/Jobset/builds.t b/t/Hydra/Controller/Jobset/builds.t new file mode 100644 index 00000000..f6d7ad64 --- /dev/null +++ b/t/Hydra/Controller/Jobset/builds.t @@ -0,0 +1,31 @@ +use strict; +use warnings; +use Setup; +use Test2::V0; +use Catalyst::Test (); +use HTTP::Request::Common; + +my $ctx = test_context(); + +Catalyst::Test->import('Hydra'); + +my $builds = $ctx->makeAndEvaluateJobset( + expression => "basic.nix", + build => 1 +); + +my $build = $builds->{"empty_dir"}; +my $project = $build->project; +my $jobset = $build->jobset; + +subtest "/jobset/PROJECT/JOBSET/all" => sub { + my $response = request(GET '/jobset/' . $project->name . '/' . $jobset->name . '/all'); + ok($response->is_success, "The page showing the jobset's builds returns 200."); +}; + +subtest "/jobset/PROJECT/JOBSET/channel/latest" => sub { + my $response = request(GET '/jobset/' . $project->name . '/' . $jobset->name . '/channel/latest'); + ok($response->is_success, "The page showing the jobset's builds returns 200."); +}; + +done_testing; From 796cae0fd0f9c37b8bb50732420182a58101db26 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 14 Jan 2022 11:28:22 -0500 Subject: [PATCH 10/10] Test Job's builds and channel pages --- t/Hydra/Controller/Job/builds.t | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 t/Hydra/Controller/Job/builds.t diff --git a/t/Hydra/Controller/Job/builds.t b/t/Hydra/Controller/Job/builds.t new file mode 100644 index 00000000..c44d1b82 --- /dev/null +++ b/t/Hydra/Controller/Job/builds.t @@ -0,0 +1,31 @@ +use strict; +use warnings; +use Setup; +use Test2::V0; +use Catalyst::Test (); +use HTTP::Request::Common; + +my $ctx = test_context(); + +Catalyst::Test->import('Hydra'); + +my $builds = $ctx->makeAndEvaluateJobset( + expression => "basic.nix", + build => 1 +); + +my $build = $builds->{"empty_dir"}; +my $jobset = $build->jobset; +my $project = $build->project; + +subtest "/job/PROJECT/JOBSET/JOB/all" => sub { + my $response = request(GET '/job/' . $project->name . '/' . $jobset->name . '/' . $build->job . '/all'); + ok($response->is_success, "The page showing the job's builds returns 200."); +}; + +subtest "/job/PROJECT/JOBSET/JOB/channel/latest" => sub { + my $response = request(GET '/job/' . $project->name . '/' . $jobset->name . '/' . $build->job . '/channel/latest'); + ok($response->is_success, "The page showing the job's channel returns 200."); +}; + +done_testing;