Skip to content

Commit

Permalink
find the group for the jobs and filter on them in /tests
Browse files Browse the repository at this point in the history
  • Loading branch information
coolo committed Mar 16, 2015
1 parent 3308881 commit 8b2e59d
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 2 deletions.
6 changes: 6 additions & 0 deletions dbicdh/_common/upgrade/26-27/005-pick-groups.pl
Expand Up @@ -25,6 +25,12 @@
my $products = $schema->resultset('Products');
while (my $r = $products->next) {
my $group = $r->distri;
if ($r->distri eq 'sle' && $r->flavor =~ m/^Server/) {
$group = 'sles';
}
if ($r->distri eq 'sle' && $r->flavor =~ m/^Desktop/) {
$group = 'sled';
}
if ($r->version ne '*') {
$group .= "-" . $r->version;
}
Expand Down
58 changes: 58 additions & 0 deletions dbicdh/_common/upgrade/26-27/007-migrate-jobs.pl
@@ -0,0 +1,58 @@
# Copyright (C) 2015 SUSE Linux GmbH
#
# 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.

#!perl

use strict;
use warnings;

sub {
my $schema = shift;

my $jts = $schema->resultset("JobTemplates");
while (my $jt = $jts->next) {
my $settings = {};
for my $s ($jt->machine->settings->all) {
$settings->{$s->key} = $s->value;
}
$settings->{DISTRI} = $jt->product->distri;
$settings->{VERSION} = $jt->product->version if $jt->product->version ne '*';
$settings->{FLAVOR} = $jt->product->flavor;
$settings->{ARCH} = $jt->product->arch;
for my $s ($jt->product->settings->all) {
$settings->{$s->key} = $s->value;
}
for my $s ($jt->test_suite->settings->all) {
$settings->{$s->key} = $s->value;
}

my $searches;
my @joins;

for my $c (1..20) {
my $key = (sort keys %$settings)[0];
last unless $key;
my $value = delete $settings->{$key};
push(@joins, 'settings');
my $where = "settings_$c";
$where = 'settings' if ($c == 1);
$searches->{"$where.key"} = $key;
$searches->{"$where.value"} = $value;
}
#print $jt->machine->name, " ", $jt->product->name, " ", $jt->test_suite->name, " ", $schema->resultset("Jobs")->search($searches, { join => \@joins })->count, " ", $jt->group_id, "\n";
$schema->resultset("Jobs")->search($searches, { join => \@joins })->update_all({group_id => $jt->group_id});
}
}
6 changes: 4 additions & 2 deletions lib/OpenQA/Controller/Test.pm
Expand Up @@ -36,18 +36,20 @@ sub list {
$self->param(scope => $scope);

my $assetid = $self->param('assetid');
my $groupid = $self->param('groupid');

my $jobs = OpenQA::Scheduler::query_jobs(
state => 'done,cancelled',
match => $match,
scope => $scope,
assetid => $assetid,
groupid => $groupid,
limit => 500,
idsonly => 1
);
$self->stash(jobs => $jobs);

my $running = OpenQA::Scheduler::query_jobs(state => 'running,waiting', match => $match, assetid => $assetid);
my $running = OpenQA::Scheduler::query_jobs(state => 'running,waiting', match => $match, groupid => $groupid, assetid => $assetid);
my $result_stats = OpenQA::Schema::Result::JobModules::job_module_stats($running);
my @list;
while (my $job = $running->next) {
Expand All @@ -60,7 +62,7 @@ sub list {
}
$self->stash(running => \@list);

my $scheduled = OpenQA::Scheduler::query_jobs(state => 'scheduled', match => $match, assetid => $assetid);
my $scheduled = OpenQA::Scheduler::query_jobs(state => 'scheduled', match => $match, groupid => $groupid, assetid => $assetid);
$self->stash(scheduled => $scheduled);

}
Expand Down
8 changes: 8 additions & 0 deletions lib/OpenQA/Scheduler.pm
Expand Up @@ -420,6 +420,14 @@ sub query_jobs {
}
);
}
if ($args{groupid}) {
push(
@conds,
{
'me.group_id' => $args{groupid},
}
);
}

# Search into the following job_settings
for my $setting (qw(build iso distri version flavor)) {
Expand Down

0 comments on commit 8b2e59d

Please sign in to comment.