From e0e8840d8ff34b7e435fe8dbaa43df21c01e3072 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 14 Jan 2022 16:19:20 -0500 Subject: [PATCH 1/3] Test /search --- t/Hydra/Controller/Root/status.t | 54 ++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/t/Hydra/Controller/Root/status.t b/t/Hydra/Controller/Root/status.t index 1b53583e..992f9db6 100644 --- a/t/Hydra/Controller/Root/status.t +++ b/t/Hydra/Controller/Root/status.t @@ -2,26 +2,18 @@ use strict; use warnings; use Setup; use Data::Dumper; -use JSON::MaybeXS qw(decode_json); -my %ctx = test_init(); - -require Hydra::Schema; -require Hydra::Model::DB; -require Hydra::Helper::Nix; - use Test2::V0; -require Catalyst::Test; +use JSON::MaybeXS qw(decode_json); +use Catalyst::Test (); use HTTP::Request::Common; + +my $ctx = test_context(); + Catalyst::Test->import('Hydra'); -my $db = Hydra::Model::DB->new; -hydra_setup($db); - -my $project = $db->resultset('Projects')->create({name => "tests", displayname => "", owner => "root"}); - -my $jobset = createBaseJobset("basic", "basic.nix", $ctx{jobsdir}); - -ok(evalSucceeds($jobset), "Evaluating jobs/basic.nix should exit with return code 0"); +my $builds = $ctx->makeAndEvaluateJobset( + expression => "basic.nix" +); subtest "/machines" => sub { my $response = request(GET '/machines'); @@ -50,6 +42,36 @@ subtest "/queue" => sub { print STDERR Dumper $response->content; } }; + +subtest "/search" => sub { + my $build = $builds->{"empty_dir"}; + my ($build_output_out) = $build->buildoutputs->find({ name => "out" }); + subtest "searching for projects" => sub { + my $response = request(GET "/search?query=${\$build->project->name}"); + is($response->code, 200, "The search page 200's."); + }; + + subtest "searching for jobsets" => sub { + my $response = request(GET "/search?query=${\$build->jobset->name}"); + is($response->code, 200, "The search page 200's."); + }; + + subtest "searching for jobs" => sub { + my $response = request(GET "/search?query=${\$build->job}"); + is($response->code, 200, "The search page 200's."); + }; + + subtest "searching for output paths" => sub { + my $response = request(GET "/search?query=${\$build_output_out->path}"); + is($response->code, 200, "The search page 200's."); + }; + + subtest "searching for derivation path" => sub { + my $response = request(GET "/search?query=${\$build->drvpath}"); + is($response->code, 200, "The search page 200's."); + }; +}; + subtest "/status" => sub { my $response = request(GET '/status', Accept => 'application/json'); ok($response->is_success, "The page showing the status 200's."); From 0b335508716f34afab243de6080f4923ab8ca5ac Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 14 Jan 2022 16:36:19 -0500 Subject: [PATCH 2/3] search.tt: fixup project and jobset reference --- src/root/search.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/root/search.tt b/src/root/search.tt index 71b88e1c..4f35e0c5 100644 --- a/src/root/search.tt +++ b/src/root/search.tt @@ -67,7 +67,7 @@ [% FOREACH j IN jobs %] - [% INCLUDE renderFullJobName project=j.get_column('project') jobset=j.get_column('jobset') job=j.job inRow=1 %] + [% INCLUDE renderFullJobName project=j.jobset.get_column('project') jobset=j.jobset.get_column('name') job=j.job inRow=1 %] [% END %] From c7c47596009687d1652522c556333cefce28ec51 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Sun, 9 Jan 2022 10:14:24 -0500 Subject: [PATCH 3/3] search: fix references to jobset / project info --- src/lib/Hydra/Controller/Root.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index c02602f3..5860c307 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -471,8 +471,10 @@ sub search :Local Args(0) { , "jobset.hidden" => 0 , iscurrent => 1 }, - { order_by => ["project", "jobset", "job"], join => ["project", "jobset"] - , rows => $c->stash->{limit} + 1 + { + order_by => ["jobset.project", "jobset.name", "job"], + join => { "jobset" => "project" }, + rows => $c->stash->{limit} + 1 } ) ];