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

Show bug status in openQA test result matrix #1292

Merged
merged 1 commit into from
Jun 9, 2017
Merged

Conversation

asdil12
Copy link
Member

@asdil12 asdil12 commented Apr 7, 2017

See https://progress.opensuse.org/issues/12092

we really need the icons on the matrix view to also show the status of the bug in bugzilla. Its particually important to identify bugs which Bugzilla reports as closed but are still present in the product - These should probably be flagged with a red bug icon or something similar. ~rbrown

@asdil12 asdil12 force-pushed the bugs branch 3 times, most recently from 98c88da to 69936a2 Compare April 7, 2017 14:31
coolo
coolo previously requested changes Apr 7, 2017
if ($self->assignee eq 'None') {
return 0;
}
elsif ($self->assignee =~ m/\@forge\.provo\.novell\.com/) {
Copy link
Contributor

Choose a reason for hiding this comment

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

no. The progress issue is about displaying the status of the issue/bug within the dashboard. For that we don't need to duplicate bugzilla - or worse: hardcode specific logic about novell assignees.

OpenQA's database can hold the informations necessary to pick the icon - but which icon to display belongs in SUSE specific scripts using some API. I don't want to see bugzilla fetching scripts within openQA. And I thought I made myself clear about that in the past.

Copy link
Member

Choose a reason for hiding this comment

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

so do you want to a field "is_assigned" in the database instead of the sub?

Copy link
Contributor

Choose a reason for hiding this comment

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

for example

Copy link
Member Author

Choose a reason for hiding this comment

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

Wouldn't that be redundancy?

Copy link
Contributor

Choose a reason for hiding this comment

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

I owe @coolo many beers for his stalwart stance against Novell-isms ;) keep fighting the good fight!

@okurz
Copy link
Member

okurz commented Apr 8, 2017 via email

}
else {
return 1;
}
Copy link
Member

Choose a reason for hiding this comment

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

What's with all this verbosity? Why not just

sub is_open {
    return shift->status !~ m/(RESOLVED|REJECTED|VERIFIED|CLOSED)/i;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

changed

}
else {
return 0;
}
Copy link
Member

Choose a reason for hiding this comment

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

Also here I would use early return on error instead of lines L96-L101

return 0 unless $res->is_success;
return $res->json;

Copy link
Member Author

Choose a reason for hiding this comment

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

changed

if ($self->assignee eq 'None') {
return 0;
}
elsif ($self->assignee =~ m/\@forge\.provo\.novell\.com/) {
Copy link
Member

Choose a reason for hiding this comment

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

so do you want to a field "is_assigned" in the database instead of the sub?

@okurz
Copy link
Member

okurz commented Apr 19, 2017

as long as https://progress.opensuse.org/issues/12092 does not have a good description what we want to achieve with that I do not want to approve the PR.

@sysrich
Copy link
Member

sysrich commented Apr 19, 2017

@okurz happy now?

@okurz
Copy link
Member

okurz commented Apr 19, 2017

cool, yes. But this PR does not fully cover this, yet, right?

@asdil12
Copy link
Member Author

asdil12 commented Apr 19, 2017

@okurz
No - this is only the first step.

@sysrich
Copy link
Member

sysrich commented Apr 19, 2017

@okurz remember "commit early and often"? I remember some guy making a lot about that..very often ;)

@coolo
Copy link
Contributor

coolo commented Apr 19, 2017

if this does not mean 'merge pre-maturely' I'm fine. Because I really don't see this bugzilla fetching in openQA

@sysrich
Copy link
Member

sysrich commented Apr 19, 2017

Understood, I consider this PR successful because @asdil12 should now have a better unstanding which bits need to go in openQA and which will be populated by an external script - but I still think we need this PR to provide the DB changes so the script has somewhere to put the necessary data regarding bugs so we can display the appropriate icons.

@okurz
Copy link
Member

okurz commented Apr 19, 2017

yes yes. "commit early, commit often" applies. I was just asking :-)

@coolo
Copy link
Contributor

coolo commented Apr 20, 2017

Let me give you a TODO list from point of view:

  • API to set bug status
  • Tests for that API
  • Concept on how to display the bug status
  • Tests for the display of the bug status
  • bugzilla stuff moved to external repo (I'm fine with it living within os-autoinst project though :)
  • test for bugzilla stuff moved to external script repo
    (and IMO it would even make sense to have this external script in python because we have quite good
    python libraries for bugzilla afaik)

@AdamWill
Copy link
Contributor

https://github.com/python-bugzilla/python-bugzilla is pretty good, and we (RH and Fedora) use it for tons of stuff so it's very actively maintained.

@asdil12
Copy link
Member Author

asdil12 commented Apr 26, 2017

@AdamWill Thanks, but I already have a Python (see openqa_review) and a Perl (see this PR) implementation of bugzilla/redmine bug status fetcher.

@asdil12
Copy link
Member Author

asdil12 commented Apr 26, 2017

@coolo Setting bug status via an external tool using an api in openQA would require us to fetch a list of all bugs from openQA.
Also the approach with an tool would prevent live update when a new bug is added to openQA.
So it would take eg. 24h until we get an initial state for the bug in the openQA database.

Also I don't think, that writing an API with authentication and running an external tool is worth the effort for code that takes <100 loc.

@coolo
Copy link
Contributor

coolo commented Apr 26, 2017

Your concern was noted. Now write the API

@AdamWill
Copy link
Contributor

AdamWill commented Apr 26, 2017

"Also the approach with an tool would prevent live update when a new bug is added to openQA.
So it would take eg. 24h until we get an initial state for the bug in the openQA database."

This isn't necessarily true, is it? IIRC, you guys have a message queue system, right? So you could just have openQA emit an event to that queue whenever a bug is 'added' to openQA, and your external system could listen for those events and immediately do its job. You don't have to only run it once a day or something.

In fact, openQA is probably already set up to emit messages on your bus thing whenever a comment is created or updated; your external system could just listen out for those messages and activate any time it sees a comment text with a bugref in it. Though I suppose that requires duplicating the bugref code.

@okurz
Copy link
Member

okurz commented Apr 27, 2017

This isn't necessarily true, is it?

No, it isn't.

IIRC, you guys have a message queue system, right?

Yes, we do. AMQP. It's enabled on the instances we have.

In fact, openQA is probably already set up to emit messages on your bus thing whenever a comment is created or updated

correct. And @asdil12 was the main guy to set this up so he should know and not come up with that lazy excuse ;-)

@asdil12 API + triggering based on AMQP events sounds right. I don't consider it huge effort. Take a look into https://github.com/okurz/scripts/blob/master/openqa_label_all_tests_with_one_failing_modules#L77 as a "lazy" approach to use the openQA client from within python. And I guess https://github.com/openSUSE/osc-plugin-factory/blob/master/openqa-comments.py and https://github.com/openSUSE/osc-plugin-factory/blob/master/totest-manager.py are also good references how to use the openQA API in that regard

@AdamWill
Copy link
Contributor

@okurz you remember I wrote an Python client library, right? https://github.com/os-autoinst/openQA-python-client ... it reads the same config files as the perl client, so you just have to do something like:

from openqa_client.client import OpenQA_Client
client = OpenQA_Client()

and then you can make requests like:

somejobs = client.openqa_request('GET', 'jobs', params={'build': 'somebuild'})

where 'GET' is the method and 'jobs' is an API endpoint path (if the path doesn't start with '/' it's assumed to be relative to '/api/v1/').

It handles authentication, retry on failure, parses JSON for you, all that fun stuff.

@okurz
Copy link
Member

okurz commented Apr 27, 2017

@AdamWill sure, I remember. Sorry, I did not want to ignore your solution. I just never knew how easy it would be to use it including authentication.

@asdil12 https://github.com/os-autoinst/openQA-python-client/blob/master/README.md#usage explains it well

@asdil12 asdil12 changed the title Bugs database change [WIP] Bugs database change May 18, 2017
@asdil12 asdil12 force-pushed the bugs branch 4 times, most recently from 1908a4b to c175ca3 Compare May 24, 2017 11:05
@asdil12 asdil12 changed the title [WIP] Bugs database change Bugs database change May 24, 2017
@asdil12
Copy link
Member Author

asdil12 commented May 24, 2017

First working version of the feature.

@asdil12 asdil12 changed the title Bugs database change Show bug status in openQA test result matrix May 24, 2017
@coolo
Copy link
Contributor

coolo commented May 24, 2017

looks reasonable - but lacks tests

@okurz
Copy link
Member

okurz commented May 25, 2017

also looks very good to me. Thanks for the integration of the bug icon for closed. I consider it feasible to add a test which makes sure that there is a closed bug icon showing up in the tests overview page, isn't it?

@coolo
Copy link
Contributor

coolo commented May 25, 2017

the new controller has 0 test coverage - and api controllers are really easy to cover, so no excuse there.

@coolo
Copy link
Contributor

coolo commented May 26, 2017

due to the aweful nature of dbix migrations, you need to rebase

@asdil12 asdil12 force-pushed the bugs branch 3 times, most recently from 59cd53c to 952a22c Compare May 31, 2017 14:05
@asdil12
Copy link
Member Author

asdil12 commented May 31, 2017

Added tests for API and UI and rebased.

@okurz
Copy link
Member

okurz commented May 31, 2017

+1

@Martchus ?

@asdil12
Copy link
Member Author

asdil12 commented May 31, 2017

But my tests need some tweaks - so stand by for my next push

@codecov
Copy link

codecov bot commented May 31, 2017

Codecov Report

Merging #1292 into master will increase coverage by 0.08%.
The diff coverage is 97.05%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1292      +/-   ##
=========================================
+ Coverage   87.31%   87.4%   +0.08%     
=========================================
  Files         101     103       +2     
  Lines        7467    7535      +68     
=========================================
+ Hits         6520    6586      +66     
- Misses        947     949       +2
Impacted Files Coverage Δ
lib/OpenQA/Schema.pm 100% <ø> (ø) ⬆️
lib/OpenQA/WebAPI.pm 91.85% <100%> (+0.16%) ⬆️
lib/OpenQA/Schema/Result/Bugs.pm 100% <100%> (ø)
lib/OpenQA/WebAPI/Controller/API/V1/Bug.pm 95.83% <95.83%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2af6d8c...3820bac. Read the comment docs.

@asdil12
Copy link
Member Author

asdil12 commented May 31, 2017

Now.

@coolo coolo dismissed their stale review May 31, 2017 18:28

Need to re-evaluate

Copy link
Contributor

@coolo coolo left a comment

Choose a reason for hiding this comment

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

Now that you have tests, happy refactoring/cleanup - you are on the right track now.

# 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.,
Copy link
Contributor

Choose a reason for hiding this comment

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

@okurz just replaced all FSF addresses with an URL. Better use this form too


my $bugs;
if ($self->param('refreshable')) {
my $delta = $self->param('delta') ? $self->param('delta') : 3600;
Copy link
Contributor

Choose a reason for hiding this comment

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

do not call param twice - but have the default in a 2nd line or e.g. as

my $delta = $self->param('delta') || 3600;

is_refreshed => 0,
t_updated => {'<=' => time2str('%Y-%m-%d %H:%M:%S', time - $delta, 'UTC')}
},
is_existing => 1
Copy link
Contributor

Choose a reason for hiding this comment

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

these is_ prefices to booleans are rather pointless. Remove them. Especially if 'is existing' is strange grammar - and 'is refreshed' even worse grammar.

my $ret = {};

while (my $w = $bugs->next) {
next unless ($w->id);
Copy link
Contributor

Choose a reason for hiding this comment

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

how would they not have an id?


while (my $w = $bugs->next) {
next unless ($w->id);
$ret->{$w->id} = $w->bugid;
Copy link
Contributor

Choose a reason for hiding this comment

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

this whole loop sounds like a map { $_->id => $_->bugid } to me

my ($self) = @_;

my $bug = $self->db->resultset("Bugs")->find($self->param('bugid'));
if ($bug) {
Copy link
Contributor

Choose a reason for hiding this comment

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

again: error handling first

sub update {
my ($self) = @_;

my $bug = $self->db->resultset("Bugs")->find($self->param('bugid'));
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest to stick with 'id' if you mean an id - also in the WebAPI.pm

t/25-bugs.t Outdated
use Test::More;
use Test::Mojo;
use Test::Warnings;
use Test::MockObject;
Copy link
Contributor

Choose a reason for hiding this comment

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

you are not mocking - nor decode json?

@@ -57,7 +57,12 @@ sub register {
$app->helper(
bugicon_for => sub {
my ($c, $text) = @_;
return ($text =~ /(poo|gh)#/) ? 'label_bug fa fa-bolt' : 'label_bug fa fa-bug';
my $css_class = ($text =~ /(poo|gh)#/) ? 'label_bug fa fa-bolt' : 'label_bug fa fa-bug';
my $bug = OpenQA::Schema::Result::Bugs->get_bug($text, $c->db);
Copy link
Contributor

Choose a reason for hiding this comment

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

this is heavy. This comes down to a SQL query per icon - in a view. There must be better ways to gather the information right in the controller, where you can also make use of proper joins and caching

t/api/11-bugs.t Outdated
use OpenQA::Client;
use Mojo::IOLoop;
use Digest::MD5;
use OpenQA::WebSockets;
Copy link
Contributor

Choose a reason for hiding this comment

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

please only add modules you really use

@asdil12 asdil12 force-pushed the bugs branch 4 times, most recently from d149337 to 294ce5c Compare June 9, 2017 10:36
@asdil12
Copy link
Member Author

asdil12 commented Jun 9, 2017

@coolo Updated as requested.

@sysrich This PR now only contains the db and api change.

@coolo coolo merged commit f6e01b0 into os-autoinst:master Jun 9, 2017
coolo pushed a commit that referenced this pull request Jun 9, 2017
commit f6e01b0
Merge: 2af6d8c 3820bac
Author:     Stephan Kulow <coolo@kde.org>
AuthorDate: Fri Jun 9 14:41:15 2017 +0200
Commit:     GitHub <noreply@github.com>
CommitDate: Fri Jun 9 14:41:15 2017 +0200

    Merge pull request #1292 from asdil12/bugs

    Show bug status in openQA test result matrix
@asdil12 asdil12 deleted the bugs branch June 9, 2017 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants