-
Notifications
You must be signed in to change notification settings - Fork 209
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
Carry over labels from previous jobs in same scenario if still failing #564
Changes from all commits
0986432
192155a
40303a6
e110f86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
COVERAGE_THRESHOLD ?= 59.8 | ||
COVERAGE_THRESHOLD ?= 60.1 | ||
|
||
.PHONY: all | ||
all: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Copyright (C) 2016 SUSE Linux GmbH | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are you sure:
;-P I would not mind a copyright checker script, until then … There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SUSE Linux GmbH and SUSE LLC are both valid SUSE Linux Products GmbH is no longer valid
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, @lnussel initiated discussion with legal about that and response was:
Then there was this #441 (see outdated diff) and since then we started replacing all to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SUSE LLC is the one we should use for new code. SUSE Linux GmbH only exists to pay our bills There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, write to the Free Software Foundation, Inc., | ||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
|
||
BEGIN { | ||
unshift @INC, 'lib'; | ||
} | ||
|
||
use Mojo::Base -strict; | ||
use Test::More; | ||
use Test::Mojo; | ||
use OpenQA::Test::Case; | ||
use OpenQA::IPC; | ||
use OpenQA::Scheduler; | ||
use OpenQA::WebSockets; | ||
use JSON qw/decode_json/; | ||
|
||
my $ipc = OpenQA::IPC->ipc('', 1); | ||
my $sh = OpenQA::Scheduler->new; | ||
my $ws = OpenQA::WebSockets->new; | ||
|
||
my $test_case; | ||
my $t; | ||
my $auth; | ||
|
||
sub set_up { | ||
$test_case = OpenQA::Test::Case->new; | ||
$test_case->init_data; | ||
$t = Test::Mojo->new('OpenQA::WebAPI'); | ||
$auth = {'X-CSRF-Token' => $t->ua->get('/tests')->res->dom->at('meta[name=csrf-token]')->attr('content')}; | ||
$test_case->login($t, 'percival'); | ||
} | ||
|
||
sub comments { | ||
my ($url) = @_; | ||
my $get = $t->get_ok($url)->status_is(200); | ||
return $get->tx->res->dom->find('div.comments .media-comment ~ p')->map('content'); | ||
} | ||
|
||
sub restart_with_result { | ||
my ($old_job, $result) = @_; | ||
my $get = $t->post_ok("/api/v1/jobs/$old_job/restart", $auth)->status_is(200); | ||
my $res = decode_json($get->tx->res->body); | ||
my $new_job = $res->{result}[0]; | ||
$t->post_ok("/api/v1/jobs/$new_job/set_done", $auth => form => {result => $result})->status_is(200); | ||
return $res; | ||
} | ||
set_up; | ||
|
||
subtest '"happy path": failed->failed carries over last label' => sub { | ||
my $label = 'label:false_positive'; | ||
my $second_label = 'bsc#1234'; | ||
my $simple_comment = 'just another simple comment'; | ||
for my $comment ($label, $second_label, $simple_comment) { | ||
$t->post_ok('/tests/99962/add_comment', $auth => form => {text => $comment})->status_is(302); | ||
} | ||
my @comments_previous = @{comments('/tests/99962')}; | ||
is(scalar @comments_previous, 3, 'all entered comments found'); | ||
is($comments_previous[0], $label, 'comment present on previous test result'); | ||
is($comments_previous[2], $simple_comment, 'another comment present'); | ||
$t->post_ok('/api/v1/jobs/99963/set_done', $auth => form => {result => 'failed'})->status_is(200); | ||
my @comments_current = @{comments('/tests/99963')}; | ||
is(scalar @comments_current, 1, 'only one label is carried over'); | ||
like($comments_current[0], qr/\Q$second_label/, 'last entered label found, it is expanded'); | ||
}; | ||
|
||
my $job; | ||
subtest 'failed->passed discards the label' => sub { | ||
my $res = restart_with_result(99963, 'passed'); | ||
$job = $res->{result}[0]; | ||
my @comments_new = @{comments($res->{test_url}[0])}; | ||
is(scalar @comments_new, 0, 'no labels carried over to passed'); | ||
}; | ||
|
||
subtest 'passed->failed does not carry over old label' => sub { | ||
my $res = restart_with_result($job, 'failed'); | ||
$job = $res->{result}[0]; | ||
my @comments_new = @{comments($res->{test_url}[0])}; | ||
is(scalar @comments_new, 0, 'no old labels on new failure'); | ||
}; | ||
|
||
subtest 'failed->failed without labels does not fail' => sub { | ||
my $res = restart_with_result($job, 'failed'); | ||
$job = $res->{result}[0]; | ||
my @comments_new = @{comments($res->{test_url}[0])}; | ||
is(scalar @comments_new, 0, 'nothing there, nothing appears'); | ||
}; | ||
|
||
subtest 'failed->failed labels which are not bugrefs are also carried over' => sub { | ||
my $label = 'label:any_label'; | ||
$t->post_ok("/tests/$job/add_comment", $auth => form => {text => $label})->status_is(302); | ||
my $res = restart_with_result($job, 'failed'); | ||
my @comments_new = @{comments($res->{test_url}[0])}; | ||
is(scalar @comments_new, 1, 'also simple labels are carried over'); | ||
is($comments_new[0], $label, 'simple label present in new result'); | ||
}; | ||
|
||
done_testing; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using original comment creator is ok, or create something like comment link. For user-less events in audit log I use
undef
asNULL
user id, but that to work you would need to change Schema/Result/Comments:L53 toThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking about extending this further down the road to keep a bit of history, e.g. encode the original author but create the new comment by "the machine". So let's stick the the original author for now and extend this later.