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

Take all incomplete results into account in overview statistics #2564

Merged
merged 1 commit into from Dec 3, 2019
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
8 changes: 8 additions & 0 deletions lib/OpenQA/Jobs/Constants.pm
Expand Up @@ -78,3 +78,11 @@ our @EXPORT = qw(
MODULE_RESULTS
TIMEOUT_EXCEEDED
);

# define mapping from any specific job result to a "generalized" form where the different incomplete results are not distinguished
my %GENERALIZED_RESULTS = ((map { $_ => $_ } COMPLETE_RESULTS), (map { $_ => 'incomplete' } INCOMPLETE_RESULTS));

sub generalize_result {
my ($concrete_result) = @_;
return $GENERALIZED_RESULTS{$concrete_result} // NONE;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. This looks like a similar approach I needed to take in https://github.com/os-autoinst/openQA/pull/2489/files#diff-85ae48e70a5c110c9e439c3a5ea28d5fR233-R246 . So it looks like first we had a manageable list of states+results, then we added more, now we have too many and we need to map them to less. I guess eventually we should look into the "states" and "results" again.

2 changes: 1 addition & 1 deletion lib/OpenQA/WebAPI/Controller/Test.pm
Expand Up @@ -520,7 +520,7 @@ sub prepare_job_results {
label => $job_labels->{$jobid}{label},
comments => $job_labels->{$jobid}{comments},
};
$aggregated->{$overall}++;
$aggregated->{OpenQA::Jobs::Constants::generalize_result($overall)}++;
}
elsif ($job->state eq OpenQA::Jobs::Constants::RUNNING) {
next if $todo;
Expand Down
15 changes: 14 additions & 1 deletion t/10-tests_overview.t
Expand Up @@ -134,7 +134,6 @@ $summary = get_summary;
like($summary, qr/Summary of opensuse Factory build 0048\@0815/i);
like($summary, qr/\QPassed: 0 Failed: 1\E/i);


#
# Still possible to check an old build
#
Expand Down Expand Up @@ -238,6 +237,20 @@ $t->element_exists('#res_DVD_i586_kde');
$t->element_exists('#res_GNOME-Live_i686_RAID0 .state_cancelled');
$t->element_exists('#res_NET_x86_64_kde .state_running');

subtest 'incomplete results generally accounted as "Incomplete"' => sub {
my $schema = $t->app->schema;
$schema->txn_begin;

my $jobs = $schema->resultset('Jobs');
$jobs->search({id => 99937})->update({result => OpenQA::Jobs::Constants::INCOMPLETE});
$jobs->search({id => 99764})->update({result => OpenQA::Jobs::Constants::USER_CANCELLED});
$jobs->search({id => 99946})->update({result => OpenQA::Jobs::Constants::TIMEOUT_EXCEEDED});

$t->get_ok('/tests/overview' => form => {distri => 'opensuse', version => '13.1'})->status_is(200);
like(get_summary, qr/Passed: 0 Incomplete: 3 Failed: 0 Scheduled: 2 Running: 2 None: 1/i);
$schema->txn_rollback;
};

#
# Test filter form
#
Expand Down