Skip to content

Commit

Permalink
Add tests for test module flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodion Iafarov committed Oct 16, 2018
1 parent 33248de commit 4969be6
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 14 deletions.
8 changes: 4 additions & 4 deletions t/10-tests_overview.t
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $get->status_is(200);

my $summary = get_summary;
like($summary, qr/Overall Summary of opensuse 13\.1 build 0091/i);
like($summary, qr/Passed: 2 Failed: 0 Scheduled: 2 Running: 2 None: 1/i);
like($summary, qr/Passed: 3 Failed: 0 Scheduled: 2 Running: 2 None: 1/i);

# Check the headers
$get->element_exists('#flavor_DVD_arch_i586');
Expand Down Expand Up @@ -94,7 +94,7 @@ $get = $t->get_ok('/tests/overview' => form => {distri => 'opensuse', version =>
$get->status_is(200);
$summary = get_summary;
like($summary, qr/Summary of opensuse 13\.1 build 0091/i);
like($summary, qr/Passed: 2 Failed: 0 Scheduled: 2 Running: 2 None: 1/i);
like($summary, qr/Passed: 3 Failed: 0 Scheduled: 2 Running: 2 None: 1/i);

$form = {distri => 'opensuse', version => '13.1', groupid => 1001};
$get = $t->get_ok('/tests/overview' => form => $form)->status_is(200);
Expand Down Expand Up @@ -128,7 +128,7 @@ $form = {distri => 'opensuse', version => '13.1', result => 'passed'};
$get = $t->get_ok('/tests/overview' => form => $form)->status_is(200);
$summary = get_summary;
like($summary, qr/Summary of opensuse 13\.1 build 0091/i, "Still references the last build");
like($summary, qr/Passed: 2 Failed: 0/i, "Only passed are shown");
like($summary, qr/Passed: 3 Failed: 0/i, "Only passed are shown");
$get->element_exists('#res_DVD_i586_kde .result_passed');
$get->element_exists('#res_DVD_i586_textmode .result_passed');
$get->element_exists_not('#res_DVD_i586_RAID0 .state_scheduled');
Expand Down Expand Up @@ -210,7 +210,7 @@ $summary = get_summary;
like($summary, qr/Summary of opensuse/i, 'shows all available latest jobs for the only present distri');
like(
$summary,
qr/Passed: 2 Failed: 0 Scheduled: 2 Running: 2 None: 1/i,
qr/Passed: 3 Failed: 0 Scheduled: 2 Running: 2 None: 1/i,
'shows latest jobs from all distri, version, build, flavor, arch'
);
$get->element_exists('#res_DVD_i586_kde');
Expand Down
12 changes: 6 additions & 6 deletions t/api/04-jobs.t
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ $t->app->schema->resultset('Jobs')->find(99963)->update({assigned_worker_id => 1
my $get = $t->get_ok('/api/v1/jobs');
my @jobs = @{$get->tx->res->json->{jobs}};
my $jobs_count = scalar @jobs;
is($jobs_count, 17);
is($jobs_count, 18);
my %jobs = map { $_->{id} => $_ } @jobs;
is($jobs{99981}->{state}, 'cancelled');
is($jobs{99981}->{origin_id}, undef, 'no original job');
Expand All @@ -106,9 +106,9 @@ is($jobs{99963}->{clone_id}, undef, 'no clone');

# That means that only 9 are current and only 10 are relevant
$get = $t->get_ok('/api/v1/jobs' => form => {scope => 'current'});
is(scalar(@{$get->tx->res->json->{jobs}}), 14);
$get = $t->get_ok('/api/v1/jobs' => form => {scope => 'relevant'});
is(scalar(@{$get->tx->res->json->{jobs}}), 15);
$get = $t->get_ok('/api/v1/jobs' => form => {scope => 'relevant'});
is(scalar(@{$get->tx->res->json->{jobs}}), 16);

# check limit quantity
$get = $t->get_ok('/api/v1/jobs' => form => {scope => 'current', limit => 5});
Expand All @@ -129,7 +129,7 @@ is(scalar(@{$get->tx->res->json->{jobs}}), 6);

# query for existing jobs by build
$get = $t->get_ok('/api/v1/jobs?build=0091');
is(scalar(@{$get->tx->res->json->{jobs}}), 10);
is(scalar(@{$get->tx->res->json->{jobs}}), 11);

# query for existing jobs by hdd_1
$get = $t->get_ok('/api/v1/jobs?hdd_1=openSUSE-13.1-x86_64.hda');
Expand Down Expand Up @@ -157,7 +157,7 @@ $get = $t->get_ok('/api/v1/jobs?limit=1&page=2');
is(scalar(@{$get->tx->res->json->{jobs}}), 1);
is($get->tx->res->json->{jobs}->[0]->{id}, 99963);
$get = $t->get_ok('/api/v1/jobs?before=99928');
is(scalar(@{$get->tx->res->json->{jobs}}), 3);
is(scalar(@{$get->tx->res->json->{jobs}}), 4);
$get = $t->get_ok('/api/v1/jobs?after=99945');
is(scalar(@{$get->tx->res->json->{jobs}}), 6);

Expand Down Expand Up @@ -229,7 +229,7 @@ my $cloned = $new_jobs{$new_jobs{99939}->{clone_id}};

# The number of current jobs doesn't change
$get = $t->get_ok('/api/v1/jobs' => form => {scope => 'current'});
is(scalar(@{$get->tx->res->json->{jobs}}), 14, 'job count stay the same');
is(scalar(@{$get->tx->res->json->{jobs}}), 15, 'job count stay the same');

# Test /jobs/X/restart and /jobs/X
$get = $t->get_ok('/api/v1/jobs/99926')->status_is(200);
Expand Down
30 changes: 29 additions & 1 deletion t/fixtures/01-jobs.pl
Original file line number Diff line number Diff line change
Expand Up @@ -491,5 +491,33 @@
{key => 'ISO_MAXSIZE', value => '4700372992'},
{key => 'ISO', value => 'openSUSE-13.1-DVD-x86_64-Build0091-Media.iso'},
{key => 'DVD', value => '1'},
]}]
]
},
## Job 99764 is used to test test module flags (milestone, fatal, etc.)
Jobs => {
id => 99764,
priority => 35,
result => "passed",
state => "done",
t_finished => time2str('%Y-%m-%d %H:%M:%S', time - 542400, 'UTC'), # 149 hours ago
t_started => time2str('%Y-%m-%d %H:%M:%S', time - 546000, 'UTC'), # 150 hours ago
t_created => time2str('%Y-%m-%d %H:%M:%S', time - 7800, 'UTC'), # Two hours ago
TEST => "console tests",
BUILD => '0091',
DISTRI => 'opensuse',
FLAVOR => 'DVD',
MACHINE => '64bit',
VERSION => '13.1',
backend => 'qemu',
jobs_assets => [{asset_id => 2},],
ARCH => 'x86_64',
settings => [
{key => 'DESKTOP', value => 'textmode'},
{key => 'ISO_MAXSIZE', value => '4700372992'},
{key => 'ISO', value => 'openSUSE-13.1-DVD-x86_64-Build0091-Media.iso'},
{key => 'DVD', value => '1'}
],
result_dir => '00099764-opensuse-13.1-DVD-x86_64-Build0091-kde',
},
]
# vim: set sw=4 et:
36 changes: 35 additions & 1 deletion t/fixtures/05-job_modules.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1627,4 +1627,38 @@
category => 'x11',
name => 'shutdown',
result => 'none',
}]
},
JobModules => {
script => 'tests/console/yast2_lan.pm',
job_id => 99764,
category => 'console',
name => 'yast2_lan',
always_rollback => 1,
important => 1,
result => 'passed',
},
JobModules => {
script => 'tests/console/yast2_bootloader.pm',
job_id => 99764,
category => 'console',
name => 'yast2_bootloader',
result => 'passed',
milestone => 1,
important => 1,
},
JobModules => {
script => 'tests/console/sshd.pm',
job_id => 99764,
category => 'console',
name => 'sshd',
result => 'passed',
fatal => '1',
},
JobModules => {
script => 'tests/console/textinfo.pm',
job_id => 99764,
category => 'console',
name => 'textinfo',
result => 'passed',
},
]
4 changes: 2 additions & 2 deletions t/ui/01-list.t
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ $driver->get('/tests');
wait_for_ajax;
my @header = $driver->find_elements('h2');
my @header_texts = map { OpenQA::Test::Case::trim_whitespace($_->get_text()) } @header;
my @expected = ('2 jobs are running', '2 scheduled jobs', 'Last 10 finished jobs');
my @expected = ('2 jobs are running', '2 scheduled jobs', 'Last 11 finished jobs');
is_deeply(\@header_texts, \@expected, 'all headings correctly displayed');

$driver->get('/tests?limit=1');
Expand Down Expand Up @@ -229,7 +229,7 @@ $driver->find_element('#finished_jobs_result_filter_chosen .active-result', 'css
# actually this does not use AJAX, but be sure all JavaScript processing is done anyways
wait_for_ajax();
@jobs = map { $_->get_attribute('id') } @{$driver->find_elements('#results tbody tr', 'css')};
is_deeply(\@jobs, [qw(job_99947 job_99946 job_99945 job_80000 job_99937)], 'only passed jobs displayed');
is_deeply(\@jobs, [qw(job_99947 job_99946 job_99945 job_80000 job_99937 job_99764)], 'only passed jobs displayed');
$driver->find_element('#finished_jobs_result_filter_chosen .search-choice-close', 'css')->click();
# enable filter via query parameter, this time disable relevantfilter
$driver->get('/tests?resultfilter=Failed&foo=bar&resultfilter=Softfailed');
Expand Down
39 changes: 39 additions & 0 deletions t/ui/18-tests-details.t
Original file line number Diff line number Diff line change
Expand Up @@ -430,5 +430,44 @@ like($worker_text[0], qr/[ \n]*Assigned worker:[ \n]*localhost:1[ \n]*/, 'worker
# warnings
$get = $t->get_ok('/tests/80000')->status_is(200);

subtest 'test module flags are displayed correctly' => sub {
# for this job we have exactly each flag set once, so check that not to rely on the order of the test modules
$driver->get('/tests/99764');
my $flags = $driver->find_elements("//div[\@class='flags']/i[(starts-with(\@class, 'flag fa fa-'))]", 'xpath');
is(scalar(@{$flags}), 4, 'Expect 4 flags in the job 99764');

my $flag = $driver->find_element("//div[\@class='flags']/i[\@class='flag fa fa-minus']", 'xpath');
ok($flag, 'Ignore failure flag is displayed for test modules which are not important, neither fatal');
is(
$flag->get_attribute('title'),
'Ignore failure: failure or soft failure of this test does not impact overall job result',
'Description of Ignore failure flag is correct'
);

$flag = $driver->find_element("//div[\@class='flags']/i[\@class='flag fa fa-redo']", 'xpath');
ok($flag, 'Always rollback flag is displayed correctly');
is(
$flag->get_attribute('title'),
'Always rollback: revert to the last milestone snapshot even if test module is successful',
'Description of always_rollback flag is correct'
);

$flag = $driver->find_element("//div[\@class='flags']/i[\@class='flag fa fa-anchor']", 'xpath');
ok($flag, 'Milestone flag is displayed correctly');
is(
$flag->get_attribute('title'),
'Milestone: snapshot the state after this test for restoring',
'Description of milestone flag is correct'
);

$flag = $driver->find_element("//div[\@class='flags']/i[\@class='flag fa fa-plug']", 'xpath');
ok($flag, 'Fatal flag is displayed correctly');
is(
$flag->get_attribute('title'),
'Fatal: testsuite is aborted if this test fails',
'Description of fatal flag is correct'
);
};

kill_driver();
done_testing();

0 comments on commit 4969be6

Please sign in to comment.