Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix show results for multiple groups in /test/overview #3973

Merged
merged 1 commit into from Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/OpenQA/WebAPI/Controller/Test.pm
Expand Up @@ -673,7 +673,7 @@ sub overview {
my %stash = (
# build, version, distri are not mandatory and therefore not
# necessarily come from the search args so they can be undefined.
build => $search_args->{build},
build => ref $search_args->{build} eq 'ARRAY' ? join(',', @{$search_args->{build}}) : $search_args->{build},
version => $search_args->{version},
distri => $search_args->{distri},
groups => $groups,
Expand Down
16 changes: 11 additions & 5 deletions lib/OpenQA/WebAPI/Plugin/Helpers.pm
Expand Up @@ -382,11 +382,17 @@ sub _compose_job_overview_search_args {

# determine build number
if (!$search_args{build}) {
# yield the latest build of the first group if (multiple) groups but not build specified
# note: the search arg 'groupid' is ignored by complex_query() because we later assign 'groupids'
$search_args{groupid} = $groups[0]->id if (@groups);

$search_args{build} = $schema->resultset('Jobs')->latest_build(%search_args);
if (@groups) {
my %builds;
for my $group (@groups) {
my $build = $schema->resultset('Jobs')->latest_build(%search_args, groupid => $group->id) or next;
$builds{$build}++;
}
$search_args{build} = [sort keys %builds];
}
else {
$search_args{build} = $schema->resultset('Jobs')->latest_build(%search_args);
}

# print debug output
if (@groups == 0) {
Expand Down
33 changes: 31 additions & 2 deletions t/10-tests_overview.t
Expand Up @@ -233,11 +233,40 @@ $t->get_ok('/tests/overview?distri=opensuse&version=13.1&groupid=1001&groupid=10
$summary = get_summary;
like(
$summary,
qr/Summary of opensuse, opensuse test/i,
'multiple groups with no build specified yield latest build of first group'
qr/Summary of opensuse, opensuse test build 0091[^,]/i,
'multiple groups with no build specified yield the same, latest build of every group'
);
like($summary, qr/Passed: 2 Failed: 0 Scheduled: 1 Running: 2 None: 1/i);

my $jobGroup = $t->app->schema->resultset('JobGroups')->create(
{
id => 1003,
sort_order => 0,
name => 'opensuse test 2'
});

my $job = $t->app->schema->resultset('Jobs')->create(
{
id => 99964,
BUILD => '0092',
group_id => 1003,
TEST => 'kde',
DISTRI => 'opensuse',
VERSION => '13.1'
});

$t->get_ok('/tests/overview?distri=opensuse&version=13.1&groupid=1001&groupid=1003')->status_is(200);
$summary = get_summary;
like(
$summary,
qr/Summary of opensuse, opensuse test 2 build 0091,0092/i,
'multiple groups with no build specified yield each build for every group'
);
like($summary, qr/Passed: 3 Failed: 0 Scheduled: 2 Running: 1 None: 1/i);

$jobGroup->delete();
$job->delete();

# overview page searches for all available data with less specified parameters
$t->get_ok('/tests/overview' => form => {build => '0091', version => '13.1'})->status_is(200);
$t->get_ok('/tests/overview' => form => {build => '0091', distri => 'opensuse'})->status_is(200);
Expand Down