From c3d8fe81d10fa34913ae351417497d2bc21bbb06 Mon Sep 17 00:00:00 2001 From: Jose Gomez <1josegomezr@gmail.com> Date: Wed, 25 Oct 2023 22:36:49 +0200 Subject: [PATCH] experiment: Unify perl linting rules Testing the perltidy config from os-autoinst/os-autoinst-common#30 --- .perltidyrc | 2 +- lib/OpenQA/CLI/archive.pm | 3 +- lib/OpenQA/CacheService.pm | 3 +- lib/OpenQA/CacheService/Model/Cache.pm | 20 +- lib/OpenQA/Client/Archive.pm | 6 +- lib/OpenQA/Client/Upload.pm | 3 +- lib/OpenQA/Command.pm | 10 +- lib/OpenQA/Constants.pm | 5 +- lib/OpenQA/Files.pm | 3 +- lib/OpenQA/Jobs/Constants.pm | 21 +- lib/OpenQA/LiveHandler.pm | 6 +- .../LiveHandler/Controller/LiveViewHandler.pm | 47 ++--- lib/OpenQA/Parser/Format/IPA.pm | 3 +- lib/OpenQA/Parser/Format/JUnit.pm | 2 +- lib/OpenQA/Resource/Jobs.pm | 3 +- lib/OpenQA/Scheduler/Client.pm | 3 +- lib/OpenQA/Scheduler/Model/Jobs.pm | 27 +-- lib/OpenQA/Schema/Result/GruTasks.pm | 3 +- lib/OpenQA/Schema/Result/JobGroups.pm | 12 +- lib/OpenQA/Schema/Result/Jobs.pm | 49 ++--- lib/OpenQA/Schema/Result/ScheduledProducts.pm | 21 +- lib/OpenQA/Schema/Result/Workers.pm | 14 +- lib/OpenQA/Schema/ResultSet/Assets.pm | 15 +- lib/OpenQA/Schema/ResultSet/AuditEvents.pm | 7 +- .../Schema/ResultSet/JobGroupParents.pm | 3 +- lib/OpenQA/Schema/ResultSet/JobSettings.pm | 3 +- lib/OpenQA/Schema/ResultSet/JobTemplates.pm | 6 +- lib/OpenQA/Schema/ResultSet/Jobs.pm | 6 +- lib/OpenQA/Script/Client.pm | 3 +- lib/OpenQA/Setup.pm | 11 +- lib/OpenQA/Shared/Plugin/Gru.pm | 18 +- lib/OpenQA/Task/Asset/Download.pm | 3 +- lib/OpenQA/Task/Asset/Limit.pm | 4 +- lib/OpenQA/Task/Iso/Schedule.pm | 3 +- lib/OpenQA/Task/Job/Limit.pm | 6 +- lib/OpenQA/Task/Utils.pm | 3 +- lib/OpenQA/Utils.pm | 4 +- lib/OpenQA/WebAPI.pm | 57 ++---- lib/OpenQA/WebAPI/Auth/Fake.pm | 6 +- lib/OpenQA/WebAPI/Auth/OAuth2.pm | 3 +- lib/OpenQA/WebAPI/Controller/API/V1.pm | 6 +- lib/OpenQA/WebAPI/Controller/API/V1/Asset.pm | 3 +- lib/OpenQA/WebAPI/Controller/API/V1/Bug.pm | 3 +- lib/OpenQA/WebAPI/Controller/API/V1/Iso.pm | 3 +- lib/OpenQA/WebAPI/Controller/API/V1/Job.pm | 14 +- .../WebAPI/Controller/API/V1/JobGroup.pm | 3 +- .../WebAPI/Controller/API/V1/JobTemplate.pm | 11 +- lib/OpenQA/WebAPI/Controller/API/V1/Mm.pm | 11 +- lib/OpenQA/WebAPI/Controller/API/V1/Search.pm | 7 +- lib/OpenQA/WebAPI/Controller/API/V1/Table.pm | 5 +- .../WebAPI/Controller/API/V1/Webhook.pm | 3 +- lib/OpenQA/WebAPI/Controller/API/V1/Worker.pm | 6 +- .../WebAPI/Controller/Admin/Influxdb.pm | 6 +- lib/OpenQA/WebAPI/Controller/Admin/Workers.pm | 6 +- lib/OpenQA/WebAPI/Controller/Main.pm | 10 +- lib/OpenQA/WebAPI/Controller/Running.pm | 3 +- lib/OpenQA/WebAPI/Controller/Step.pm | 31 +-- lib/OpenQA/WebAPI/Controller/Test.pm | 29 +-- lib/OpenQA/WebAPI/Plugin/AMQP.pm | 3 +- lib/OpenQA/WebAPI/Plugin/AuditLog.pm | 3 +- lib/OpenQA/WebAPI/Plugin/Helpers.pm | 18 +- lib/OpenQA/WebAPI/Plugin/ObsRsync.pm | 56 ++---- .../Plugin/ObsRsync/Controller/Folders.pm | 7 +- .../WebAPI/Plugin/ObsRsync/Controller/Gru.pm | 10 +- lib/OpenQA/WebAPI/Plugin/ObsRsync/Task.pm | 3 +- lib/OpenQA/WebSockets/Controller/Worker.pm | 15 +- lib/OpenQA/Worker.pm | 3 +- lib/OpenQA/Worker/CommandHandler.pm | 15 +- lib/OpenQA/Worker/Engines/isotovideo.pm | 27 +-- lib/OpenQA/Worker/Job.pm | 18 +- lib/OpenQA/Worker/WebUIConnection.pm | 14 +- script/client | 5 +- script/openqa-clone-job | 9 +- script/openqa-dump-templates | 7 +- script/openqa-load-templates | 8 +- script/worker | 5 +- t/01-style.t | 18 +- t/01-test-utilities.t | 6 +- t/03-auth.t | 6 +- t/04-scheduler.t | 13 +- t/05-scheduler-cancel.t | 9 +- t/05-scheduler-capabilities.t | 6 +- t/05-scheduler-dependencies.t | 73 ++----- t/05-scheduler-full.t | 3 +- t/05-scheduler-restart-and-duplicate.t | 26 +-- ...-serialize-directly-chained-dependencies.t | 24 +-- t/09-job_clone.t | 3 +- t/10-jobs-referal.t | 3 +- t/10-jobs-results.t | 15 +- t/10-jobs.t | 42 ++-- t/10-tests_overview.t | 69 ++----- t/13-joblocks.t | 9 +- t/14-grutasks.t | 81 +++----- t/15-assets.t | 30 +-- t/16-markdown.t | 60 ++---- t/16-utils-job-templates.t | 6 +- t/16-utils-runcmd.t | 18 +- t/16-utils.t | 22 +-- t/17-build_tagging.t | 21 +- t/17-labels_carry_over.t | 17 +- t/20-stale-job-detection.t | 9 +- t/21-needles.t | 47 ++--- t/22-dashboard.t | 148 ++++---------- t/23-amqp.t | 6 +- t/24-worker-engine.t | 36 ++-- t/24-worker-jobs.t | 162 +++++---------- t/24-worker-overall.t | 72 +++---- t/24-worker-settings.t | 3 +- t/24-worker-webui-connection.t | 63 ++---- t/25-cache-client.t | 48 ++--- t/25-cache-service.t | 34 ++-- t/25-cache.t | 64 ++---- t/25-downloader.t | 3 +- t/25-serverstartup.t | 18 +- t/26-controllerrunning.t | 15 +- t/27-errorpages.t | 12 +- t/27-websockets.t | 19 +- t/28-logging.t | 8 +- t/30-test_parser.t | 75 +++---- t/31-client.t | 4 +- t/31-client_archive.t | 3 +- t/31-client_file.t | 21 +- t/32-openqa_client.t | 48 +---- t/33-developer_mode.t | 39 +--- t/34-developer_mode-unit.t | 154 +++++---------- t/35-script_clone_job.t | 27 +-- t/35-script_clone_job_suse.t | 6 +- t/36-job_group_settings.t | 34 +--- t/37-limit_assets.t | 15 +- t/40-job_settings.t | 3 +- t/40-script_openqa-clone-custom-git-refspec.t | 30 +-- t/42-df-based-cleanup.t | 16 +- t/42-screenshots.t | 16 +- t/43-cli-archive.t | 3 +- t/43-cli-schedule.t | 12 +- t/43-scheduling-and-worker-scalability.t | 8 +- t/api/01-workers.t | 43 ++-- t/api/02-assets.t | 22 +-- t/api/02-iso-download.t | 33 +--- t/api/02-iso-yaml.t | 19 +- t/api/02-iso.t | 90 +++------ t/api/03-auth.t | 22 +-- t/api/04-jobs.t | 184 ++++++------------ t/api/05-machines.t | 46 ++--- t/api/06-products.t | 35 ++-- t/api/07-testsuites.t | 26 +-- t/api/08-jobtemplates.t | 160 +++++---------- t/api/09-comments.t | 59 ++---- t/api/10-jobgroups.t | 36 +--- t/api/11-bugs.t | 32 ++- t/api/13-influxdb.t | 12 +- t/api/14-plugin_obs_rsync.t | 52 ++--- t/api/14-plugin_obs_rsync_async.t | 34 ++-- t/api/15-search.t | 9 +- t/api/15-users.t | 6 +- t/api/16-webhooks.t | 6 +- t/config.t | 12 +- t/data/40-templates-more.pl | 3 +- t/data/40-templates.pl | 3 +- t/fixtures/04-products.pl | 9 +- t/full-stack.t | 6 +- t/lib/OpenQA/SeleniumTest.pm | 5 +- t/lib/OpenQA/Test/FullstackUtils.pm | 3 +- t/lib/OpenQA/Test/Utils.pm | 6 +- t/ui/01-list.t | 96 ++------- t/ui/04-api_keys.t | 16 +- t/ui/04-appearance.t | 9 +- t/ui/05-auth.t | 24 +-- t/ui/06-operator_links.t | 3 +- t/ui/07-file.t | 31 ++- t/ui/09-users-list.t | 9 +- t/ui/10-tests_overview.t | 24 +-- t/ui/12-needle-edit.t | 105 +++------- t/ui/13-admin.t | 72 ++----- t/ui/14-dashboard.t | 27 +-- t/ui/15-admin-workers.t | 32 +-- t/ui/15-comments.t | 74 ++----- t/ui/15-search.t | 9 +- t/ui/16-activity-view.t | 5 +- t/ui/16-tests_dependencies.t | 18 +- t/ui/16-tests_job_next_previous.t | 48 ++--- t/ui/17-product-log.t | 30 +-- t/ui/18-tests-details.t | 139 ++++--------- t/ui/19-tests-links.t | 6 +- t/ui/21-admin-needles.t | 33 +--- t/ui/23-audit-log.t | 6 +- t/ui/25-developer_mode.t | 116 +++-------- t/ui/26-jobs_restart.t | 70 ++----- t/ui/27-plugin_obs_rsync.t | 25 +-- t/ui/27-plugin_obs_rsync_gru.t | 12 +- t/ui/27-plugin_obs_rsync_obs_status.t | 11 +- t/ui/27-plugin_obs_rsync_status_details.t | 6 +- t/ui/28-keys_to_render_as_links.t | 6 +- 193 files changed, 1402 insertions(+), 3307 deletions(-) diff --git a/.perltidyrc b/.perltidyrc index 24a694875299..9e1db51fbf19 100644 --- a/.perltidyrc +++ b/.perltidyrc @@ -2,7 +2,7 @@ # # See . --character-encoding=none --no-valign --l=120 # 120 characters per line +-l=160 -fbl # don't change blank lines -nsfs # no spaces before semicolons -baao # space after operators diff --git a/lib/OpenQA/CLI/archive.pm b/lib/OpenQA/CLI/archive.pm index a3cbbbc7e45e..66402da7427f 100644 --- a/lib/OpenQA/CLI/archive.pm +++ b/lib/OpenQA/CLI/archive.pm @@ -22,8 +22,7 @@ sub command ($self, @args) { my $url = $self->url_for("jobs/$job/details"); my $client = $self->client($url); - $client->archive->run( - {url => $url, archive => $path, 'with-thumbnails' => $thumbnails, 'asset-size-limit' => $limit}); + $client->archive->run({url => $url, archive => $path, 'with-thumbnails' => $thumbnails, 'asset-size-limit' => $limit}); return 0; } diff --git a/lib/OpenQA/CacheService.pm b/lib/OpenQA/CacheService.pm index 80db0cc9da91..9c56cb25230c 100644 --- a/lib/OpenQA/CacheService.pm +++ b/lib/OpenQA/CacheService.pm @@ -118,8 +118,7 @@ sub setup_workers { my @args = @_; my $global_settings = OpenQA::Worker::Settings->new->global_settings; - my $cache_workers - = exists $global_settings->{CACHEWORKERS} ? $global_settings->{CACHEWORKERS} : DEFAULT_MINION_WORKERS; + my $cache_workers = exists $global_settings->{CACHEWORKERS} ? $global_settings->{CACHEWORKERS} : DEFAULT_MINION_WORKERS; push @args, '-j', $cache_workers; return @args; diff --git a/lib/OpenQA/CacheService/Model/Cache.pm b/lib/OpenQA/CacheService/Model/Cache.pm index 1bee4cc2d5be..32e88a397604 100644 --- a/lib/OpenQA/CacheService/Model/Cache.pm +++ b/lib/OpenQA/CacheService/Model/Cache.pm @@ -131,8 +131,7 @@ sub get_asset ($self, $host, $job, $type, $asset) { # We can't just throw it away if database locks. my $att = 0; my $ok; - ++$att and sleep 1 and $log->info("Updating cache failed (attempt $att)") - until ($ok = $self->_update_asset($asset, $etag, $size)) || $att > 5; + ++$att and sleep 1 and $log->info("Updating cache failed (attempt $att)") until ($ok = $self->_update_asset($asset, $etag, $size)) || $att > 5; die qq{Updating the cache for "$asset" failed, this should never happen} unless $ok; my $cache_size = human_readable_size($self->{cache_real_size}); my $speed = download_speed($start, $end, $size); @@ -160,8 +159,7 @@ sub track_asset ($self, $asset) { eval { my $db = $self->sqlite->db; my $tx = $db->begin('exclusive'); - my $sql = "INSERT INTO assets (filename, size, last_use) VALUES (?, 0, strftime('%s','now'))" - . "ON CONFLICT (filename) DO UPDATE SET pending=1"; + my $sql = "INSERT INTO assets (filename, size, last_use) VALUES (?, 0, strftime('%s','now'))" . "ON CONFLICT (filename) DO UPDATE SET pending=1"; $db->query($sql, $asset); $tx->commit; }; @@ -180,14 +178,11 @@ sub _exclusive_query ($self, $sql, @args) { } sub _update_metric ($self, $name, $value) { - $self->_exclusive_query('INSERT INTO metrics (name, value) VALUES ($1, $2) ON CONFLICT DO UPDATE SET value = $2', - $name, $value); + $self->_exclusive_query('INSERT INTO metrics (name, value) VALUES ($1, $2) ON CONFLICT DO UPDATE SET value = $2', $name, $value); } sub _increase_metric ($self, $name, $by_value) { - $self->_exclusive_query( - 'INSERT INTO metrics (name, value) VALUES ($1, $2) ON CONFLICT DO UPDATE SET value = value + $2', - $name, $by_value); + $self->_exclusive_query('INSERT INTO metrics (name, value) VALUES ($1, $2) ON CONFLICT DO UPDATE SET value = value + $2', $name, $by_value); } sub reset_download_count ($self) { $self->_update_metric(download_count => 0) } @@ -284,12 +279,9 @@ sub _check_limits ($self, $needed, $to_preserve = undef) { my $cache_size = human_readable_size($self->{cache_real_size}); my $needed_size = human_readable_size($needed); my $limit_size = human_readable_size($limit); - $log->info( - "Cache size $cache_size + needed $needed_size exceeds limit of $limit_size, purging least used assets"); + $log->info("Cache size $cache_size + needed $needed_size exceeds limit of $limit_size, purging least used assets"); eval { - my $results - = $self->sqlite->db->select('assets', [qw(filename size last_use)], {pending => '0'}, - {-asc => 'last_use'}); + my $results = $self->sqlite->db->select('assets', [qw(filename size last_use)], {pending => '0'}, {-asc => 'last_use'}); for my $asset ($results->hashes->each) { my $filename = $asset->{filename}; next if $to_preserve && $to_preserve->{$filename}; diff --git a/lib/OpenQA/Client/Archive.pm b/lib/OpenQA/Client/Archive.pm index 07ef50107abb..c35a30a88502 100644 --- a/lib/OpenQA/Client/Archive.pm +++ b/lib/OpenQA/Client/Archive.pm @@ -54,8 +54,7 @@ sub _download_test_result_details ($self, $url, $path, $module, $options) { if ($options->{'with-thumbnails'}) { $url->path("/image/$dir/.thumbs/$module->{md5_basename}"); - $ua->get($url) - ->res->content->asset->move_to($path->child('testresults', 'thumbnails', $module->{md5_basename})); + $ua->get($url)->res->content->asset->move_to($path->child('testresults', 'thumbnails', $module->{md5_basename})); } } @@ -174,8 +173,7 @@ sub _progress_monitior ($ua, $tx) { my $msg = shift; return unless my $len = $msg->headers->content_length; if ($limit && $msg->headers->content_length >= $limit) { - $msg->error( - {message => path($filename)->basename . " exceeeds maximum size limit of $limit", code => 509}); + $msg->error({message => path($filename)->basename . " exceeeds maximum size limit of $limit", code => 509}); } }); diff --git a/lib/OpenQA/Client/Upload.pm b/lib/OpenQA/Client/Upload.pm index 7bac8792af9f..48af66f8ee6e 100644 --- a/lib/OpenQA/Client/Upload.pm +++ b/lib/OpenQA/Client/Upload.pm @@ -41,8 +41,7 @@ sub asset ($self, $job_id, $opts) { my $parts = OpenQA::File->new(file => Mojo::File->new($opts->{file}))->split($chunk_size); $self->emit('upload_chunk.prepare', $parts); - $self->once('upload_chunk.error', - sub { $self->_upload_asset_fail($uri => {filename => $file_name, scope => $opts->{asset}}) }); + $self->once('upload_chunk.error', sub { $self->_upload_asset_fail($uri => {filename => $file_name, scope => $opts->{asset}}) }); # Each chunk of the file should get the full number of retry attempts my $max_retries = $opts->{retries} // 10; diff --git a/lib/OpenQA/Command.pm b/lib/OpenQA/Command.pm index 2cfe2a302eb0..3224c69faa4d 100644 --- a/lib/OpenQA/Command.pm +++ b/lib/OpenQA/Command.pm @@ -12,8 +12,8 @@ use Mojo::URL; use Mojo::File qw(path); use Term::ANSIColor qw(colored); -my $JSON = Cpanel::JSON::XS->new->utf8->canonical->allow_nonref->allow_unknown->allow_blessed->convert_blessed - ->stringify_infnan->escape_slash->allow_dupkeys->pretty; +my $JSON + = Cpanel::JSON::XS->new->utf8->canonical->allow_nonref->allow_unknown->allow_blessed->convert_blessed->stringify_infnan->escape_slash->allow_dupkeys->pretty; my $PARAM_RE = qr/^([[:alnum:]_\[\]\.\:]+)=(.*)$/s; has apibase => '/api/v1'; @@ -23,8 +23,7 @@ has host => 'http://localhost'; has options => undef; sub client ($self, $url) { - my $client = OpenQA::Client->new(apikey => $self->apikey, apisecret => $self->apisecret, api => $url->host) - ->ioloop(Mojo::IOLoop->singleton); + my $client = OpenQA::Client->new(apikey => $self->apikey, apisecret => $self->apisecret, api => $url->host)->ioloop(Mojo::IOLoop->singleton); $client->transactor->name($self->name); return $client; } @@ -125,8 +124,7 @@ sub retry_tx ($self, $client, $tx, $retries = undef, $delay = undef) { $tx = $client->start($tx); my $res_code = $tx->res->code // 0; return $self->handle_result($tx) unless $res_code =~ /50[23]/ && $retries > 0; - print encode('UTF-8', - "Request failed, hit error $res_code, retrying up to $retries more times after waiting …\n"); + print encode('UTF-8', "Request failed, hit error $res_code, retrying up to $retries more times after waiting …\n"); sleep $delay; } } diff --git a/lib/OpenQA/Constants.pm b/lib/OpenQA/Constants.pm index 45c9133f3a19..84daec3f3762 100644 --- a/lib/OpenQA/Constants.pm +++ b/lib/OpenQA/Constants.pm @@ -69,7 +69,7 @@ use constant WORKER_STOP_REASONS => ( # Define error categories used alongside the reasons defined above for finer error handling where needed use constant { WORKER_EC_CACHE_FAILURE => 'cache failure', # the cache service made problems - WORKER_EC_ASSET_FAILURE => 'asset failure', # a problem occurred when handling assets, e.g. an asset was not found + WORKER_EC_ASSET_FAILURE => 'asset failure', # a problem occurred when handling assets, e.g. an asset was not found }; # Time verification to use with the "worker_timeout" configuration. @@ -98,8 +98,7 @@ use constant VIDEO_FILE_NAME_REGEX => qr/^.*\/video\.[^\/]*$/; use constant FRAGMENT_REGEX => qr'(#([-?/:@.~!$&\'()*+,;=\w]|%[0-9a-fA-F]{2})*)*'; -use constant JOBS_OVERVIEW_SEARCH_CRITERIA => - (qw(distri version flavor build test modules modules_result module_re group groupid id)); +use constant JOBS_OVERVIEW_SEARCH_CRITERIA => (qw(distri version flavor build test modules modules_result module_re group groupid id)); our @EXPORT_OK = qw( WEBSOCKET_API_VERSION DEFAULT_WORKER_TIMEOUT diff --git a/lib/OpenQA/Files.pm b/lib/OpenQA/Files.pm index 6127b0d01e48..6aaaa69744ea 100644 --- a/lib/OpenQA/Files.pm +++ b/lib/OpenQA/Files.pm @@ -65,8 +65,7 @@ sub verify_chunks ($class, $chunk_path, $verify_file) { $chunk->decode_content; $sum = $chunk->total_cksum if !$sum; - return Mojo::Exception->new( - "Chunk: " . $chunk->id() . " differs in total checksum, expected $sum given " . $chunk->total_cksum) + return Mojo::Exception->new("Chunk: " . $chunk->id() . " differs in total checksum, expected $sum given " . $chunk->total_cksum) if $sum ne $chunk->total_cksum; return Mojo::Exception->new("Can't verify written data from chunk") unless $chunk->verify_content($verify_file); diff --git a/lib/OpenQA/Jobs/Constants.pm b/lib/OpenQA/Jobs/Constants.pm index 9aa724902f4f..4f04140326e4 100644 --- a/lib/OpenQA/Jobs/Constants.pm +++ b/lib/OpenQA/Jobs/Constants.pm @@ -63,10 +63,8 @@ use constant { USER_RESTARTED => 'user_restarted', # restarted by user via job_restart TIMEOUT_EXCEEDED => 'timeout_exceeded', # killed by the worker after MAX_JOB_TIME has been exceeded }; -use constant RESULTS => ( - NONE, PASSED, SOFTFAILED, FAILED, INCOMPLETE, SKIPPED, - OBSOLETED, PARALLEL_FAILED, PARALLEL_RESTARTED, USER_CANCELLED, USER_RESTARTED, TIMEOUT_EXCEEDED -); +use constant RESULTS => + (NONE, PASSED, SOFTFAILED, FAILED, INCOMPLETE, SKIPPED, OBSOLETED, PARALLEL_FAILED, PARALLEL_RESTARTED, USER_CANCELLED, USER_RESTARTED, TIMEOUT_EXCEEDED); # note: See the "Jobs" section of "GettingStarted.asciidoc" for the difference between SOFTFAILED and FAILED and # further details. @@ -75,8 +73,7 @@ use constant RESULTS => ( use constant COMPLETE_RESULTS => (PASSED, SOFTFAILED, FAILED); use constant OK_RESULTS => (PASSED, SOFTFAILED); use constant NOT_COMPLETE_RESULTS => (INCOMPLETE, TIMEOUT_EXCEEDED); -use constant ABORTED_RESULTS => - (SKIPPED, OBSOLETED, PARALLEL_FAILED, PARALLEL_RESTARTED, USER_CANCELLED, USER_RESTARTED); +use constant ABORTED_RESULTS => (SKIPPED, OBSOLETED, PARALLEL_FAILED, PARALLEL_RESTARTED, USER_CANCELLED, USER_RESTARTED); use constant NOT_OK_RESULTS => (FAILED, NOT_COMPLETE_RESULTS, ABORTED_RESULTS); use constant { COMPLETE => 'complete', @@ -143,16 +140,8 @@ our @EXPORT = qw( ); # mapping from any specific job state/result to a meta state/result -my %META_STATE_MAPPING = ( - (map { $_ => PRE_EXECUTION } PRE_EXECUTION_STATES), - (map { $_ => EXECUTION } EXECUTION_STATES), - (map { $_ => FINAL } FINAL_STATES), -); -my %META_RESULT_MAPPING = ( - (map { $_ => $_ } COMPLETE_RESULTS), - (map { $_ => NOT_COMPLETE } NOT_COMPLETE_RESULTS), - (map { $_ => ABORTED } ABORTED_RESULTS), -); +my %META_STATE_MAPPING = ((map { $_ => PRE_EXECUTION } PRE_EXECUTION_STATES), (map { $_ => EXECUTION } EXECUTION_STATES), (map { $_ => FINAL } FINAL_STATES),); +my %META_RESULT_MAPPING = ((map { $_ => $_ } COMPLETE_RESULTS), (map { $_ => NOT_COMPLETE } NOT_COMPLETE_RESULTS), (map { $_ => ABORTED } ABORTED_RESULTS),); sub meta_state ($state) { $META_STATE_MAPPING{$state} // NONE } sub meta_result ($result) { $META_RESULT_MAPPING{$result} // NONE } sub is_ok_result ($result) { diff --git a/lib/OpenQA/LiveHandler.pm b/lib/OpenQA/LiveHandler.pm index 79fa4c54b0fc..31c2c244cc26 100644 --- a/lib/OpenQA/LiveHandler.pm +++ b/lib/OpenQA/LiveHandler.pm @@ -12,8 +12,7 @@ has secrets => sub { shift->schema->read_application_secrets }; # add attributes to store ws connections/transactions by job # (see LiveViewHandler.pm for further descriptions of the paricular attributes) -has [qw(cmd_srv_transactions_by_job devel_java_script_transactions_by_job status_java_script_transactions_by_job)] => - sub { {} }; +has [qw(cmd_srv_transactions_by_job devel_java_script_transactions_by_job status_java_script_transactions_by_job)] => sub { {} }; # This method will run once at server start sub startup ($self) { @@ -53,8 +52,7 @@ sub startup ($self) { # register API routes my $job_r = $api_ro->any('/jobs/'); - $job_r->post('/upload_progress')->name('developer_post_upload_progress') - ->to('live_view_handler#post_upload_progress'); + $job_r->post('/upload_progress')->name('developer_post_upload_progress')->to('live_view_handler#post_upload_progress'); OpenQA::Setup::setup_plain_exception_handler($self); } diff --git a/lib/OpenQA/LiveHandler/Controller/LiveViewHandler.pm b/lib/OpenQA/LiveHandler/Controller/LiveViewHandler.pm index 45ad18c8eff8..01a7e4d6c732 100644 --- a/lib/OpenQA/LiveHandler/Controller/LiveViewHandler.pm +++ b/lib/OpenQA/LiveHandler/Controller/LiveViewHandler.pm @@ -66,9 +66,7 @@ sub send_message_to_java_script_clients { my ($self, $job_id, $type, $what, $data, $status_code_to_quit_on_finished) = @_; my @all_java_script_transactions_for_job; - for my $java_script_transaction_container ($self->devel_java_script_transactions_by_job, - $self->status_java_script_transactions_by_job) - { + for my $java_script_transaction_container ($self->devel_java_script_transactions_by_job, $self->status_java_script_transactions_by_job) { if (my $java_script_transactions_for_job = $java_script_transaction_container->{$job_id}) { push(@all_java_script_transactions_for_job, @$java_script_transactions_for_job); } @@ -132,9 +130,7 @@ sub send_message_to_java_script_client_and_finish { sub finish_all_connections { my ($self, $job_id, $status_code) = @_; - for my $java_script_transaction_container ($self->devel_java_script_transactions_by_job, - $self->status_java_script_transactions_by_job) - { + for my $java_script_transaction_container ($self->devel_java_script_transactions_by_job, $self->status_java_script_transactions_by_job) { my $java_script_transactions_for_current_job = delete $java_script_transaction_container->{$job_id} or next; $_->finish($status_code) for (@$java_script_transactions_for_current_job); } @@ -317,10 +313,8 @@ sub handle_message_from_os_autoinst { if ($is_status_message) { if (!$self->check_os_autoinst_devel_mode_version($json)) { my $actual_version_str = "$json->{devel_mode_major_version}.$json->{devel_mode_minor_version}"; - my $required_version_str - = OS_AUTOINST_DEVEL_MODE_MAJOR_VERSION . '.' . OS_AUTOINST_DEVEL_MODE_MINOR_VERSION; - my $disconnect_reason - = "os-autoinst version \"$actual_version_str\" is incompatible, version \"$required_version_str\" is required"; + my $required_version_str = OS_AUTOINST_DEVEL_MODE_MAJOR_VERSION . '.' . OS_AUTOINST_DEVEL_MODE_MINOR_VERSION; + my $disconnect_reason = "os-autoinst version \"$actual_version_str\" is incompatible, version \"$required_version_str\" is required"; $self->disconnect_from_os_autoinst($job_id, $disconnect_reason); return; } @@ -353,14 +347,12 @@ sub connect_to_cmd_srv { my ($self, $job_id, $cmd_srv_raw_url, $cmd_srv_url) = @_; log_debug("connecting to os-autoinst command server for job $job_id at $cmd_srv_raw_url"); - $self->send_message_to_java_script_clients($job_id, - info => 'connecting to os-autoinst command server at ' . $cmd_srv_raw_url); + $self->send_message_to_java_script_clients($job_id, info => 'connecting to os-autoinst command server at ' . $cmd_srv_raw_url); # prevent opening the same connection to os-autoinst cmd srv twice if (my $cmd_srv_tx = $self->cmd_srv_transactions_by_job->{$job_id}) { $self->query_os_autoinst_status($job_id); - $self->send_message_to_java_script_clients($job_id, - info => 'reusing previous connection to os-autoinst command server at ' . $cmd_srv_raw_url); + $self->send_message_to_java_script_clients($job_id, info => 'reusing previous connection to os-autoinst command server at ' . $cmd_srv_raw_url); return $cmd_srv_tx; } @@ -373,11 +365,10 @@ sub connect_to_cmd_srv { my ($ua, $tx) = @_; # upgrade to ws connection if not already a websocket connection - return $self->send_message_to_java_script_clients_and_finish($job_id, - error => 'unable to upgrade ws to command server') + return $self->send_message_to_java_script_clients_and_finish($job_id, error => 'unable to upgrade ws to command server') unless $tx->is_websocket; -# assign transaction: don't do this before to prevent regular HTTP connections to be used in send_message_to_os_autoinst + # assign transaction: don't do this before to prevent regular HTTP connections to be used in send_message_to_os_autoinst $self->cmd_srv_transactions_by_job->{$job_id} = $tx; # instantly query the os-autoinst status @@ -407,8 +398,7 @@ sub send_message_to_os_autoinst { my $cmd_srv_tx = $self->cmd_srv_transactions_by_job->{$job_id}; if (!$cmd_srv_tx) { - $self->send_message_to_java_script_clients($job_id, - error => 'failed to pass message to os-autoinst command server because not connected yet'); + $self->send_message_to_java_script_clients($job_id, error => 'failed to pass message to os-autoinst command server because not connected yet'); return; } $cmd_srv_tx->send({json => $msg}); @@ -496,27 +486,22 @@ sub ws_proxy { my $developer_session = $developer_sessions->register($job_id, $user_id); $app->log->debug('client connected: ' . $user->name); if (!$developer_session) { - return $self->send_message_to_java_script_client_and_finish($java_script_tx, - error => 'unable to create (further) development session'); + return $self->send_message_to_java_script_client_and_finish($java_script_tx, error => 'unable to create (further) development session'); } # mark session as active - $developer_session->update({ws_connection_count => \'ws_connection_count + 1'}); #'restore syntax highlighting + $developer_session->update({ws_connection_count => \'ws_connection_count + 1'}); #'restore syntax highlighting } # add JavaScript transaction to the list of JavaScript transactions for this job # (needed for broadcasting to all clients) - my $java_script_transaction_container - = $status_only ? $self->status_java_script_transactions_by_job : $self->devel_java_script_transactions_by_job; + my $java_script_transaction_container = $status_only ? $self->status_java_script_transactions_by_job : $self->devel_java_script_transactions_by_job; my $java_script_transactions_for_current_job = ($java_script_transaction_container->{$job_id} //= []); push(@$java_script_transactions_for_current_job, $java_script_tx); # determine url to os-autoinst command server my $cmd_srv_raw_url = $self->determine_os_autoinst_web_socket_url($job); if (!$cmd_srv_raw_url) { - $app->log->debug('attempt to open ws proxy for job ' - . $job->name . ' (' - . $job_id - . ') where URL to os-autoinst command server is unknown'); + $app->log->debug('attempt to open ws proxy for job ' . $job->name . ' (' . $job_id . ') where URL to os-autoinst command server is unknown'); $self->send_message_to_java_script_clients_and_finish( $job_id, error => 'os-autoinst command server not available, job is likely not running', @@ -534,8 +519,7 @@ sub ws_proxy { $self->on(message => sub { }); return $self->on( finish => sub { - $self->remove_java_script_transaction($job_id, $self->status_java_script_transactions_by_job, - $java_script_tx); + $self->remove_java_script_transaction($job_id, $self->status_java_script_transactions_by_job, $java_script_tx); }); } @@ -574,8 +558,7 @@ sub post_upload_progress { $worker->update({upload_progress => $progress_info}); # broadcast the upload progress to all connected java script web socket clients for this job - my $broadcast_count - = $self->send_message_to_java_script_clients($job_id, info => 'upload progress', $progress_info); + my $broadcast_count = $self->send_message_to_java_script_clients($job_id, info => 'upload progress', $progress_info); return $self->render(json => {broadcast_count => $broadcast_count}, status => 200); } diff --git a/lib/OpenQA/Parser/Format/IPA.pm b/lib/OpenQA/Parser/Format/IPA.pm index b75f7fe17130..7a0fda1af001 100644 --- a/lib/OpenQA/Parser/Format/IPA.pm +++ b/lib/OpenQA/Parser/Format/IPA.pm @@ -28,8 +28,7 @@ sub parse { my $t_name = $res->{nodeid} // $res->{name}; die 'IPA result misses test name / node ID' unless $t_name; - if ($t_name =~ /^(?[\w\/]+\/)?(?\w+)\.py::(?\w+)\[\w+:\/\/(\d+\.){3}\d+(-(?.+))?\]$/) - { + if ($t_name =~ /^(?[\w\/]+\/)?(?\w+)\.py::(?\w+)\[\w+:\/\/(\d+\.){3}\d+(-(?.+))?\]$/) { $t_name = ''; $t_name .= $+{path} if ($+{path}); $t_name .= $+{file}; diff --git a/lib/OpenQA/Parser/Format/JUnit.pm b/lib/OpenQA/Parser/Format/JUnit.pm index a194c1be0ef0..34219e404a61 100644 --- a/lib/OpenQA/Parser/Format/JUnit.pm +++ b/lib/OpenQA/Parser/Format/JUnit.pm @@ -77,7 +77,7 @@ sub parse { my $num = 1; for my $tc ($ts, $ts->children('testcase')->each) { - # create extra entry for whole testsuite if there is any system-out or system-err outside of particular testcase + # create extra entry for whole testsuite if there is any system-out or system-err outside of particular testcase next if ($tc->tag eq 'testsuite' && $tc->children('system-out, system-err')->size == 0); my $tc_result = $ts_result; # use overall testsuite result as fallback diff --git a/lib/OpenQA/Resource/Jobs.pm b/lib/OpenQA/Resource/Jobs.pm index fe97ef9b76a3..8efa597c7713 100644 --- a/lib/OpenQA/Resource/Jobs.pm +++ b/lib/OpenQA/Resource/Jobs.pm @@ -49,8 +49,7 @@ sub job_restart { if (@$missing_assets) { my $message = "Job $job_id misses the following mandatory assets: " . join(', ', @$missing_assets); if ($job->count_related('parents')) { - $message - .= "\nYou may try to retrigger the parent job that should create the assets and will implicitly retrigger this job as well."; + $message .= "\nYou may try to retrigger the parent job that should create the assets and will implicitly retrigger this job as well."; } else { $message .= "\nEnsure to provide mandatory assets and/or force retriggering if necessary."; diff --git a/lib/OpenQA/Scheduler/Client.pm b/lib/OpenQA/Scheduler/Client.pm index d603d22e291c..ea6f3f365d97 100644 --- a/lib/OpenQA/Scheduler/Client.pm +++ b/lib/OpenQA/Scheduler/Client.pm @@ -26,8 +26,7 @@ sub wakeup ($self) { return if $self->{wakeup}; $self->{wakeup}++; $self->client->max_connections(0)->request_timeout(5)->get_p($self->_api('wakeup')) - ->catch(sub { log_debug("Unable to wakeup scheduler: $_[0]. Retry scheduled") }) - ->finally(sub { delete $self->{wakeup} })->wait; + ->catch(sub { log_debug("Unable to wakeup scheduler: $_[0]. Retry scheduled") })->finally(sub { delete $self->{wakeup} })->wait; } sub singleton { state $client ||= __PACKAGE__->new } diff --git a/lib/OpenQA/Scheduler/Model/Jobs.pm b/lib/OpenQA/Scheduler/Model/Jobs.pm index dc24cfa8e204..b1218284b735 100644 --- a/lib/OpenQA/Scheduler/Model/Jobs.pm +++ b/lib/OpenQA/Scheduler/Model/Jobs.pm @@ -61,8 +61,7 @@ sub _allocate_jobs ($self, $free_workers) { my @rejected = sort { $rejected{$b} <=> $rejected{$a} || $a cmp $b } keys %rejected; splice @rejected, MAX_REPORT_MISSING_WORKER_CLASSES; my $stats = join ',', map { "$_:$rejected{$_}" } @rejected; - my $info = sprintf "Skipping %d jobs because of no free workers for requested worker classes (%s)", - sum(values %rejected), $stats; + my $info = sprintf "Skipping %d jobs because of no free workers for requested worker classes (%s)", sum(values %rejected), $stats; log_debug($info); } @@ -154,8 +153,7 @@ sub schedule ($self) { } my $scheduled_jobs = $self->determine_scheduled_jobs; - log_debug( - "Scheduling: Free workers: $free_worker_count/$worker_count; Scheduled jobs: " . scalar(keys %$scheduled_jobs)); + log_debug("Scheduling: Free workers: $free_worker_count/$worker_count; Scheduled jobs: " . scalar(keys %$scheduled_jobs)); my ($allocated_workers, $allocated_jobs) = $self->_allocate_jobs($free_workers); return [] unless keys %$allocated_workers; @@ -257,8 +255,7 @@ sub schedule ($self) { $_->update(\%worker_assignment) for @jobs; $worker->set_current_job($jobs[0]); }); - $res - = $self->_assign_multiple_jobs_to_worker(\@jobs, $worker, $directly_chained_job_sequence, $job_ids); + $res = $self->_assign_multiple_jobs_to_worker(\@jobs, $worker, $directly_chained_job_sequence, $job_ids); } else { $schema->txn_do( @@ -306,8 +303,7 @@ sub schedule ($self) { } my $elapsed_rounded = sprintf("%.5f", (time - $start_time)); - log_debug "Scheduler took ${elapsed_rounded}s to perform operations and allocated " - . scalar(@successfully_allocated) . " jobs"; + log_debug "Scheduler took ${elapsed_rounded}s to perform operations and allocated " . scalar(@successfully_allocated) . " jobs"; log_debug "Allocated: " . pp($_) for @successfully_allocated; $self->emit('conclude'); @@ -397,8 +393,7 @@ sub _update_scheduled_jobs ($self) { # consider all scheduled jobs not being blocked by a parent job or Gru task my $schema = OpenQA::Schema->singleton; my $waiting_jobs = $schema->resultset('GruDependencies')->get_column('job_id')->as_query; - my $jobs = $schema->resultset('Jobs') - ->search({id => {-not_in => $waiting_jobs}, blocked_by_id => undef, state => SCHEDULED}); + my $jobs = $schema->resultset('Jobs')->search({id => {-not_in => $waiting_jobs}, blocked_by_id => undef, state => SCHEDULED}); my $scheduled_jobs = $self->scheduled_jobs; my %currently_scheduled; @@ -459,22 +454,16 @@ sub _update_scheduled_jobs ($self) { # t/05-scheduler-serialize-directly-chained-dependencies.t for examples. sub _serialize_directly_chained_job_sequence ($first_job_id, $cluster_info, $sort_function = undef) { my %visited = ($first_job_id => 1); - my $sequence - = _serialize_directly_chained_job_sub_sequence([$first_job_id], \%visited, - $cluster_info->{$first_job_id}->{directly_chained_children}, + my $sequence = _serialize_directly_chained_job_sub_sequence([$first_job_id], \%visited, $cluster_info->{$first_job_id}->{directly_chained_children}, $cluster_info, $sort_function // sub { return shift }); return ($sequence, [keys %visited]); } -sub _serialize_directly_chained_job_sub_sequence ($output_array, $visited, $child_job_ids, $cluster_info, - $sort_function) -{ +sub _serialize_directly_chained_job_sub_sequence ($output_array, $visited, $child_job_ids, $cluster_info, $sort_function) { for my $current_job_id (@{$sort_function->($child_job_ids)}) { my $current_job_info = $cluster_info->{$current_job_id}; next unless $current_job_info->{state} eq SCHEDULED; die "detected cycle at $current_job_id\n" if $visited->{$current_job_id}++; - my $sub_sequence - = _serialize_directly_chained_job_sub_sequence([$current_job_id], $visited, - $current_job_info->{directly_chained_children}, + my $sub_sequence = _serialize_directly_chained_job_sub_sequence([$current_job_id], $visited, $current_job_info->{directly_chained_children}, $cluster_info, $sort_function); push(@$output_array, scalar @$sub_sequence > 1 ? $sub_sequence : $sub_sequence->[0]) if @$sub_sequence; } diff --git a/lib/OpenQA/Schema/Result/GruTasks.pm b/lib/OpenQA/Schema/Result/GruTasks.pm index 780838421062..193996d1d9e1 100644 --- a/lib/OpenQA/Schema/Result/GruTasks.pm +++ b/lib/OpenQA/Schema/Result/GruTasks.pm @@ -74,8 +74,7 @@ sub fail { name => 'background_process', result => 'fail', test => OpenQA::Parser::Result::Test->new(name => 'GRU', category => 'background_task')); - my $output - = OpenQA::Parser::Result::Output->new(file => $detail_text, content => "Gru job failed\nReason: $reason"); + my $output = OpenQA::Parser::Result::Output->new(file => $detail_text, content => "Gru job failed\nReason: $reason"); while (my $d = $deps->next) { $d->job->custom_module($result => $output); diff --git a/lib/OpenQA/Schema/Result/JobGroups.pm b/lib/OpenQA/Schema/Result/JobGroups.pm index 18e85300d612..796fa62de59f 100644 --- a/lib/OpenQA/Schema/Result/JobGroups.pm +++ b/lib/OpenQA/Schema/Result/JobGroups.pm @@ -144,14 +144,12 @@ around 'keep_important_results_in_days' => sub { around 'default_priority' => sub { my ($orig, $self) = @_; - return $self->get_column('default_priority') - // ($self->parent ? $self->parent->default_priority : OpenQA::JobGroupDefaults::PRIORITY); + return $self->get_column('default_priority') // ($self->parent ? $self->parent->default_priority : OpenQA::JobGroupDefaults::PRIORITY); }; around 'carry_over_bugrefs' => sub { my ($orig, $self) = @_; - return $self->get_column('carry_over_bugrefs') - // ($self->parent ? $self->parent->carry_over_bugrefs : OpenQA::JobGroupDefaults::CARRY_OVER_BUGREFS); + return $self->get_column('carry_over_bugrefs') // ($self->parent ? $self->parent->carry_over_bugrefs : OpenQA::JobGroupDefaults::CARRY_OVER_BUGREFS); }; sub rendered_description { @@ -261,8 +259,7 @@ sub find_jobs_with_expired_results ($self) { } sub find_jobs_with_expired_logs ($self, $preserved_important_jobs_out = undef) { - my $expired = $self->_find_expired_jobs($self->keep_logs_in_days, $self->keep_important_logs_in_days, - $preserved_important_jobs_out); + my $expired = $self->_find_expired_jobs($self->keep_logs_in_days, $self->keep_important_logs_in_days, $preserved_important_jobs_out); return $expired ? [$expired->search({logs_present => 1})->all] : []; } @@ -419,8 +416,7 @@ sub template_data_from_yaml { $machine_names = [$machine_names] if ref($machine_names) ne 'ARRAY'; foreach my $machine_name (@{$machine_names}) { - my $job_template_key - = $arch . $product_name . $machine_name . ($testsuite_name // '') . ($job_template_name // ''); + my $job_template_key = $arch . $product_name . $machine_name . ($testsuite_name // '') . ($job_template_name // ''); if ($job_template_names{$job_template_key}) { my $name = $job_template_name // $testsuite_name; my $error = "Job template name '$name' is defined more than once. " diff --git a/lib/OpenQA/Schema/Result/Jobs.pm b/lib/OpenQA/Schema/Result/Jobs.pm index 0a5ce49a2c83..9732b40989cf 100644 --- a/lib/OpenQA/Schema/Result/Jobs.pm +++ b/lib/OpenQA/Schema/Result/Jobs.pm @@ -539,12 +539,8 @@ sub missing_assets ($self) { # https://github.com/os-autoinst/openQA/pull/2676#issuecomment-616312026 my @relevant_assets = grep { $_->{name} ne '' && $_->{type} ne 'repo' } values %$assets_settings; - my @assets_query = map { - { - type => $_->{type}, - name => {-in => _compute_asset_names_considering_parent_jobs($parent_job_ids, $_->{name})}, - } - } @relevant_assets; + my @assets_query + = map { {type => $_->{type}, name => {-in => _compute_asset_names_considering_parent_jobs($parent_job_ids, $_->{name})},} } @relevant_assets; return [] unless @assets_query; my $assets = $self->result_source->schema->resultset('Assets'); my @undetermined_assets = $assets->search({-or => \@assets_query, size => \'is null'}, {order_by => 'id'}); @@ -666,16 +662,11 @@ sub _create_clones ($self, $jobs, @clone_args) { dependency => OpenQA::JobDependencies::Constants::PARALLEL, }); } - _create_clone_with_parent($res, \%clones, $_, OpenQA::JobDependencies::Constants::CHAINED) - for @{$info->{chained_parents}}; - _create_clone_with_parent($res, \%clones, $_, OpenQA::JobDependencies::Constants::DIRECTLY_CHAINED) - for @{$info->{directly_chained_parents}}; - _create_clone_with_child($res, \%clones, $_, OpenQA::JobDependencies::Constants::PARALLEL) - for @{$info->{parallel_children}}; - _create_clone_with_child($res, \%clones, $_, OpenQA::JobDependencies::Constants::CHAINED) - for @{$info->{chained_children}}; - _create_clone_with_child($res, \%clones, $_, OpenQA::JobDependencies::Constants::DIRECTLY_CHAINED) - for @{$info->{directly_chained_children}}; + _create_clone_with_parent($res, \%clones, $_, OpenQA::JobDependencies::Constants::CHAINED) for @{$info->{chained_parents}}; + _create_clone_with_parent($res, \%clones, $_, OpenQA::JobDependencies::Constants::DIRECTLY_CHAINED) for @{$info->{directly_chained_parents}}; + _create_clone_with_child($res, \%clones, $_, OpenQA::JobDependencies::Constants::PARALLEL) for @{$info->{parallel_children}}; + _create_clone_with_child($res, \%clones, $_, OpenQA::JobDependencies::Constants::CHAINED) for @{$info->{chained_children}}; + _create_clone_with_child($res, \%clones, $_, OpenQA::JobDependencies::Constants::DIRECTLY_CHAINED) for @{$info->{directly_chained_children}}; # when dependency network is recreated, associate assets $res->register_assets_from_settings; @@ -1114,8 +1105,7 @@ sub custom_module ($self, $module, $output) { } sub modules_with_job_prefetched ($self) { - $self->result_source->schema->resultset('JobModules') - ->search({job_id => $self->id}, {prefetch => 'job', order_by => 'me.id'}); + $self->result_source->schema->resultset('JobModules')->search({job_id => $self->id}, {prefetch => 'job', order_by => 'me.id'}); } sub _delete_returning_size ($file_path) { @@ -1149,7 +1139,7 @@ sub delete_videos ($self) { my @files = (find_video_files($result_dir), Mojo::Collection->new(path($result_dir, 'video_time.vtt'))); my $deleted_size = _delete_returning_size_from_array(\@files); - $self->update({result_size => \"greatest(0, result_size - $deleted_size)"}); # considering logs still present here + $self->update({result_size => \"greatest(0, result_size - $deleted_size)"}); # considering logs still present here return $deleted_size; } @@ -1168,8 +1158,7 @@ sub delete_results ($self) { my $exclusively_used_screenshot_ids = $self->exclusively_used_screenshot_ids; my $schema = $self->result_source->schema; my $screenshots = $schema->resultset('Screenshots'); - my $screenshot_deletion - = OpenQA::ScreenshotDeletion->new(dbh => $schema->storage->dbh, deleted_size => \$deleted_size); + my $screenshot_deletion = OpenQA::ScreenshotDeletion->new(dbh => $schema->storage->dbh, deleted_size => \$deleted_size); $self->screenshot_links->delete; $screenshot_deletion->delete_screenshot($_, $screenshots->find($_)->filename) for @$exclusively_used_screenshot_ids; $self->update({logs_present => 0, result_size => 0}); @@ -1814,13 +1803,10 @@ sub has_autoinst_log ($self) { sub git_log_diff ($self, $dir, $refspec_range, $limit = undef) { return "Invalid range $refspec_range" if $refspec_range =~ m/UNKNOWN|unreadable git hash/; - my $res = run_cmd_with_log_return_error( - [ - 'git', '-C', $dir, 'log', ($limit ? "-$limit" : ()), - '--stat', '--pretty=oneline', '--abbrev-commit', '--no-merges', $refspec_range - ], - stdout => 'trace' - ); + my $res + = run_cmd_with_log_return_error( + ['git', '-C', $dir, 'log', ($limit ? "-$limit" : ()), '--stat', '--pretty=oneline', '--abbrev-commit', '--no-merges', $refspec_range], + stdout => 'trace'); # regardless of success or not the output contains the information we need return $res->{stdout} . $res->{stderr}; } @@ -2216,9 +2202,7 @@ sub should_skip_review ($self, $overall, $reviewed) { && !$self->has_failed_modules); } -sub _overview_result_done ($self, $jobid, $job_labels, $aggregated, $failed_modules, $actually_failed_modules, - $todo = undef) -{ +sub _overview_result_done ($self, $jobid, $job_labels, $aggregated, $failed_modules, $actually_failed_modules, $todo = undef) { return undef if $failed_modules && !OpenQA::Utils::any_array_item_contained_by_hash($actually_failed_modules, $failed_modules); @@ -2246,8 +2230,7 @@ sub _overview_result_done ($self, $jobid, $job_labels, $aggregated, $failed_modu sub overview_result ($self, $job_labels, $aggregated, $failed_modules, $actually_failed_modules, $todo = undef) { my $jobid = $self->id; if ($self->state eq OpenQA::Jobs::Constants::DONE) { - return $self->_overview_result_done($jobid, $job_labels, $aggregated, $failed_modules, - $actually_failed_modules, $todo); + return $self->_overview_result_done($jobid, $job_labels, $aggregated, $failed_modules, $actually_failed_modules, $todo); } return undef if $todo; my $result = { diff --git a/lib/OpenQA/Schema/Result/ScheduledProducts.pm b/lib/OpenQA/Schema/Result/ScheduledProducts.pm index ef2f5656eabd..ce242efd3ece 100644 --- a/lib/OpenQA/Schema/Result/ScheduledProducts.pm +++ b/lib/OpenQA/Schema/Result/ScheduledProducts.pm @@ -361,9 +361,7 @@ sub _schedule_iso { # jobs are created, now recreate dependencies and extract ids for my $job (@created_jobs) { - my $error_messages - = $self->_create_dependencies_for_job($job, \%job_ids_by_test_machine, \%created_jobs, \%cluster_parents, - $skip_chained_deps); + my $error_messages = $self->_create_dependencies_for_job($job, \%job_ids_by_test_machine, \%created_jobs, \%cluster_parents, $skip_chained_deps); if (!@$error_messages) { push(@successful_job_ids, $job->id); } @@ -394,11 +392,7 @@ sub _schedule_iso { for my $job (@created_jobs) { $job->calculate_blocked_by; } - my %downloads = map { - $_ => [ - [keys %{$tmp_downloads{$_}->{destination}}], $tmp_downloads{$_}->{do_extract}, - $tmp_downloads{$_}->{blocked_job_id}] - } + my %downloads = map { $_ => [[keys %{$tmp_downloads{$_}->{destination}}], $tmp_downloads{$_}->{do_extract}, $tmp_downloads{$_}->{blocked_job_id}] } keys %tmp_downloads; $gru->enqueue_download_jobs(\%downloads); }; @@ -586,7 +580,7 @@ sub _generate_jobs { } for my $job_template (@templates) { # compose settings from product, machine, testsuite and job template itself - # note: That order also defines the precedence from lowest to highest. The only exception is the WORKER_CLASS + # note: That order also defines the precedence from lowest to highest. The only exception is the WORKER_CLASS # variable where all occurrences are merged. my %settings; my %params = ( @@ -711,8 +705,7 @@ sub _create_dependencies_for_parents { $parent_worker_class = $parent_worker_class ? $parent_worker_class->value : ''; if ($worker_class ne $parent_worker_class) { my $test_name = $job->settings_hash->{TEST}; - die -"Worker class of $test_name ($worker_class) does not match the worker class of its directly chained parent ($parent_worker_class)"; + die "Worker class of $test_name ($worker_class) does not match the worker class of its directly chained parent ($parent_worker_class)"; } } $job_dependencies->create( @@ -817,9 +810,7 @@ sub _schedule_from_yaml ($self, $args, $skip_chained_deps, $include_children, @l } return { - settings_result => _populate_wanted_jobs_for_parent_dependencies( - \@job_templates, \%wanted, $skip_chained_deps, $include_children - ), + settings_result => _populate_wanted_jobs_for_parent_dependencies(\@job_templates, \%wanted, $skip_chained_deps, $include_children), error_message => $error_msg, }; } @@ -951,7 +942,7 @@ sub cancel ($self, $reason = undef) { # update status to CANCELLING if (!$self->_update_status_if(CANCELLING, -not => {status => SCHEDULING})) { - # the scheduled product is SCHEDULING; set it nevertheless to CANCELLING but back off from cancelling immediately + # the scheduled product is SCHEDULING; set it nevertheless to CANCELLING but back off from cancelling immediately # unless it is not SCHEDULING anymore after all return 0 if $self->_update_status_if(CANCELLING, status => SCHEDULING); } diff --git a/lib/OpenQA/Schema/Result/Workers.pm b/lib/OpenQA/Schema/Result/Workers.pm index 1abb976c7d14..2cf518eb960d 100644 --- a/lib/OpenQA/Schema/Result/Workers.pm +++ b/lib/OpenQA/Schema/Result/Workers.pm @@ -89,8 +89,7 @@ sub get_property { my ($self, $key) = @_; # Optimized because this is a performance hot spot for the websocket server - my $sth = $self->result_source->schema->storage->dbh->prepare( - 'SELECT value FROM worker_properties WHERE key = ? AND worker_id = ? LIMIT 1'); + my $sth = $self->result_source->schema->storage->dbh->prepare('SELECT value FROM worker_properties WHERE key = ? AND worker_id = ? LIMIT 1'); $sth->bind_param(1, $key, SQL_CHAR); $sth->bind_param(2, $self->id, SQL_BIGINT); $sth->execute; @@ -223,8 +222,7 @@ sub send_command { } try { - OpenQA::App->singleton->emit_event( - openqa_command_enqueue => {workerid => $self->id, command => $args{command}}); + OpenQA::App->singleton->emit_event(openqa_command_enqueue => {workerid => $self->id, command => $args{command}}); }; # prevent ws server querying itself (which would cause it to hang until the connection times out) @@ -235,11 +233,7 @@ sub send_command { my $client = OpenQA::WebSockets::Client->singleton; try { $client->send_msg($self->id, $args{command}, $args{job_id}) } catch { - log_error( - sprintf( - 'Failed dispatching message to websocket server over ipc for worker "%s:%n": %s', - $self->host, $self->instance, $_ - )); + log_error(sprintf('Failed dispatching message to websocket server over ipc for worker "%s:%n": %s', $self->host, $self->instance, $_)); return undef; }; return 1; @@ -281,7 +275,7 @@ sub reschedule_assigned_jobs { } catch { my $worker_id = $self->id; # uncoverable statement - log_warning("Unable to re-schedule job $job_id abandoned by worker $worker_id: $_"); # uncoverable statement + log_warning("Unable to re-schedule job $job_id abandoned by worker $worker_id: $_"); # uncoverable statement }; } } diff --git a/lib/OpenQA/Schema/ResultSet/Assets.pm b/lib/OpenQA/Schema/ResultSet/Assets.pm index 28c8ce251902..0ee9f4f20791 100644 --- a/lib/OpenQA/Schema/ResultSet/Assets.pm +++ b/lib/OpenQA/Schema/ResultSet/Assets.pm @@ -37,8 +37,7 @@ sub register ($self, $type, $name, $options = {}) { sub { $sth->execute($type, $name); # ensure asset exists return undef - unless my $asset - = $self->find({type => $type, name => $name}, {key => 'assets_type_name', for => 'update'}); + unless my $asset = $self->find({type => $type, name => $name}, {key => 'assets_type_name', for => 'update'}); $asset->refresh_size if $options->{refresh_size}; if (my $created_by = $options->{created_by}) { my $scope = $options->{scope} // 'public'; @@ -176,8 +175,7 @@ sub status { # set transaction-level so "all statements of the current transaction can only see rows committed # before the first query [...] statement was executed in this transaction" # (quote from https://www.postgresql.org/docs/9.6/sql-set-transaction.html) - $schema->storage->dbh->prepare('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ READ ONLY DEFERRABLE;') - ->execute(); + $schema->storage->dbh->prepare('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ READ ONLY DEFERRABLE;')->execute(); # note: only affects the current transaction (so no reason to reset again) # prefetch all assets @@ -220,8 +218,7 @@ sub status { my $parent_id; if (defined $parent) { my $parent_size_limit_gb = $parent->size_limit_gb; - my $parent_size - = (defined $parent_size_limit_gb ? $parent_size_limit_gb * 1024 * 1024 * 1024 : undef); + my $parent_size = (defined $parent_size_limit_gb ? $parent_size_limit_gb * 1024 * 1024 * 1024 : undef); $parent_id = $parent->id; $parent_group_info{$parent_id} = { id => $parent_id, @@ -254,8 +251,7 @@ sub status { # check whether the data from the 2nd select is inconsistent with what we've got from the 1st # (pure pre-caution, shouldn't happen due to the transaction) - die "$asset_info->{name} was scheduled during cleanup" - . " (max job initially $init_max_job, now $res_max_job)" + die "$asset_info->{name} was scheduled during cleanup" . " (max job initially $init_max_job, now $res_max_job)" if $fail_on_inconsistent_status && $res_max_job && ($res_max_job > $init_max_job); } } @@ -279,8 +275,7 @@ sub status { my $parent_group_info = defined $parent_group_id ? $parent_group_info{$parent_group_id} : undef; my $parent_group_size = defined $parent_group_info ? $parent_group_info->{size} : undef; if (defined $parent_group_size) { - log_debug("Checking whether asset $asset_name ($asset_size) fits into" - . " parent $parent_group_id ($parent_group_size)"); + log_debug("Checking whether asset $asset_name ($asset_size) fits into" . " parent $parent_group_id ($parent_group_size)"); next unless $largest_size < $parent_group_size && $parent_group_size >= $asset_size; log_debug("Asset $asset_name ($asset_size) picked into parent $parent_group_id"); diff --git a/lib/OpenQA/Schema/ResultSet/AuditEvents.pm b/lib/OpenQA/Schema/ResultSet/AuditEvents.pm index 2b96ad0641e6..bcfd7cbdee1d 100644 --- a/lib/OpenQA/Schema/ResultSet/AuditEvents.pm +++ b/lib/OpenQA/Schema/ResultSet/AuditEvents.pm @@ -39,8 +39,7 @@ sub delete_entries_exceeding_storage_duration { # parse time constraint my $time_constraint = parsedate("$duration_in_days days ago", PREFER_PAST => 1, DATE_REQUIRED => 1) - or - log_warning("Ignoring invalid storage duration '$duration_in_days' for audit event type '$event_category'.") + or log_warning("Ignoring invalid storage duration '$duration_in_days' for audit event type '$event_category'.") and next; $time_constraint = localtime($time_constraint)->ymd; @@ -65,8 +64,8 @@ sub delete_entries_exceeding_storage_duration { my @category_patterns = values %patterns_for_event_categories; my $delete_other_query = $other_time_constraint - ? $self->result_source->schema->storage->dbh->prepare('DELETE FROM audit_events WHERE t_created < ? AND ' - . join(' AND ', map { 'event NOT LIKE ?' } @category_patterns)) + ? $self->result_source->schema->storage->dbh->prepare( + 'DELETE FROM audit_events WHERE t_created < ? AND ' . join(' AND ', map { 'event NOT LIKE ?' } @category_patterns)) : undef; # perform queries diff --git a/lib/OpenQA/Schema/ResultSet/JobGroupParents.pm b/lib/OpenQA/Schema/ResultSet/JobGroupParents.pm index 4b6735cdd4cb..c0a764e3175c 100644 --- a/lib/OpenQA/Schema/ResultSet/JobGroupParents.pm +++ b/lib/OpenQA/Schema/ResultSet/JobGroupParents.pm @@ -12,8 +12,7 @@ sub job_groups_and_parents { my @parents = $self->search({}, {order_by => [{-asc => 'sort_order'}, {-asc => 'name'}]})->all; my $schema = $self->result_source->schema; - my @groups_without_parent = $schema->resultset('JobGroups') - ->search({parent_id => undef}, {order_by => [{-asc => 'sort_order'}, {-asc => 'name'}]})->all; + my @groups_without_parent = $schema->resultset('JobGroups')->search({parent_id => undef}, {order_by => [{-asc => 'sort_order'}, {-asc => 'name'}]})->all; my @res; my $first_parent = shift @parents; my $first_group = shift @groups_without_parent; diff --git a/lib/OpenQA/Schema/ResultSet/JobSettings.pm b/lib/OpenQA/Schema/ResultSet/JobSettings.pm index 8d588088de7e..739184d8389e 100644 --- a/lib/OpenQA/Schema/ResultSet/JobSettings.pm +++ b/lib/OpenQA/Schema/ResultSet/JobSettings.pm @@ -25,8 +25,7 @@ sub jobs_for_setting ($self, $options) { # Instead of limiting the number of jobs, this query could also use a trigram gin index to achieve even better # performance (at the cost of disk space and setup complexity) - $sth = $dbh->prepare( - 'SELECT job_id, value FROM job_settings WHERE key LIKE ? AND value LIKE ? AND job_id > ? ORDER BY job_id DESC'); + $sth = $dbh->prepare('SELECT job_id, value FROM job_settings WHERE key LIKE ? AND value LIKE ? AND job_id > ? ORDER BY job_id DESC'); $sth->execute($key_like, $list_value_like, $min_id); # Match list values diff --git a/lib/OpenQA/Schema/ResultSet/JobTemplates.pm b/lib/OpenQA/Schema/ResultSet/JobTemplates.pm index 9993f1780f96..37ddc07dc236 100644 --- a/lib/OpenQA/Schema/ResultSet/JobTemplates.pm +++ b/lib/OpenQA/Schema/ResultSet/JobTemplates.pm @@ -7,8 +7,7 @@ package OpenQA::Schema::ResultSet::JobTemplates; use Mojo::Base 'DBIx::Class::ResultSet'; use constant EMPTY_TESTSUITE_NAME => '-'; -use constant EMPTY_TESTSUITE_DESCRIPTION => - 'The base test suite is used for job templates defined in YAML documents. It has no settings of its own.'; +use constant EMPTY_TESTSUITE_DESCRIPTION => 'The base test suite is used for job templates defined in YAML documents. It has no settings of its own.'; sub create_or_update_job_template { my ($job_templates, $group_id, $args) = @_; @@ -39,8 +38,7 @@ sub create_or_update_job_template { return {error => "Testsuite '$args->{testsuite_name}' is invalid"} unless $test_suite; } else { - $test_suite - = $test_suites->find_or_create({name => EMPTY_TESTSUITE_NAME, description => EMPTY_TESTSUITE_DESCRIPTION}); + $test_suite = $test_suites->find_or_create({name => EMPTY_TESTSUITE_NAME, description => EMPTY_TESTSUITE_DESCRIPTION}); } # Create/update job template diff --git a/lib/OpenQA/Schema/ResultSet/Jobs.pm b/lib/OpenQA/Schema/ResultSet/Jobs.pm index bb9d03014764..b4a171920fb4 100644 --- a/lib/OpenQA/Schema/ResultSet/Jobs.pm +++ b/lib/OpenQA/Schema/ResultSet/Jobs.pm @@ -350,8 +350,7 @@ sub cancel_by_settings { # this might be even the tag 'not important' but not much is lost if # we still not cancel these builds my $groups_query = $jobs->get_column('group_id')->as_query; - my @important_builds = grep defined, - map { ($_->tag)[0] } $schema->resultset('Comments')->search({'me.group_id' => {-in => $groups_query}}); + my @important_builds = grep defined, map { ($_->tag)[0] } $schema->resultset('Comments')->search({'me.group_id' => {-in => $groups_query}}); my @unimportant_jobs; while (my $j = $jobs_to_cancel->next) { # the value we get from that @important_builds search above @@ -392,8 +391,7 @@ sub _cancel_or_deprioritize { return 0; } } - return $job->cancel($newbuild ? OpenQA::Jobs::Constants::OBSOLETED : OpenQA::Jobs::Constants::USER_CANCELLED, - 'cancelled based on job settings') // 0; + return $job->cancel($newbuild ? OpenQA::Jobs::Constants::OBSOLETED : OpenQA::Jobs::Constants::USER_CANCELLED, 'cancelled based on job settings') // 0; } sub next_previous_jobs_query { diff --git a/lib/OpenQA/Script/Client.pm b/lib/OpenQA/Script/Client.pm index 955c0e023c90..f3eafab6f59d 100644 --- a/lib/OpenQA/Script/Client.pm +++ b/lib/OpenQA/Script/Client.pm @@ -141,8 +141,7 @@ sub run ($options, $operation, @args) { = OpenQA::Client->new(apikey => $options->{apikey}, apisecret => $options->{apisecret}, api => $url->host); return handle_result($options, $client->$method($url, form => \%params)->res) if $options->{form}; - return handle_result($options, - $client->$method($url, {'Content-Type' => 'application/json'} => $options->{'json-data'})->res) + return handle_result($options, $client->$method($url, {'Content-Type' => 'application/json'} => $options->{'json-data'})->res) if $options->{'json-data'}; # Either the user wants to call a command or wants to interact with diff --git a/lib/OpenQA/Setup.pm b/lib/OpenQA/Setup.pm index 41bff36dfe5c..7c62be542bb0 100644 --- a/lib/OpenQA/Setup.pm +++ b/lib/OpenQA/Setup.pm @@ -250,8 +250,7 @@ sub read_config ($app) { my $global_config = $config->{global}; $global_config->{recognized_referers} = [split(/\s+/, $global_config->{recognized_referers})]; if (my $regex = $global_config->{auto_clone_regex}) { - $app->log->warn( - "Specified auto_clone_regex is invalid: $@Not restarting any jobs reported as incomplete by workers.") + $app->log->warn("Specified auto_clone_regex is invalid: $@Not restarting any jobs reported as incomplete by workers.") unless eval { $global_config->{auto_clone_regex} = qr/$regex/ }; } $config->{_openid_secret} = random_string(16); @@ -276,10 +275,7 @@ sub _validate_worker_timeout ($app) { my $configured_worker_timeout = $global_config->{worker_timeout}; if (!looks_like_number($configured_worker_timeout) || $configured_worker_timeout < MAX_TIMER) { $global_config->{worker_timeout} = DEFAULT_WORKER_TIMEOUT; - $app->log->warn( - 'The specified worker_timeout is invalid and will be ignored. The timeout must be an integer greater than ' - . MAX_TIMER - . '.'); + $app->log->warn('The specified worker_timeout is invalid and will be ignored. The timeout must be an integer greater than ' . MAX_TIMER . '.'); } } @@ -385,8 +381,7 @@ sub load_plugins ($server, $monitoring_root_route = undef, %options) { sub set_secure_flag_on_cookies ($c) { $c->app->sessions->secure(1) if $c->req->is_secure; if (my $days = $c->app->config->{global}->{hsts}) { - $c->res->headers->header( - 'Strict-Transport-Security' => sprintf('max-age=%d; includeSubDomains', $days * 24 * 60 * 60)); + $c->res->headers->header('Strict-Transport-Security' => sprintf('max-age=%d; includeSubDomains', $days * 24 * 60 * 60)); } } diff --git a/lib/OpenQA/Shared/Plugin/Gru.pm b/lib/OpenQA/Shared/Plugin/Gru.pm index 7a451b184643..9898828b8fdd 100644 --- a/lib/OpenQA/Shared/Plugin/Gru.pm +++ b/lib/OpenQA/Shared/Plugin/Gru.pm @@ -25,16 +25,11 @@ sub register_tasks ($self) { my $app = $self->app; $app->plugin($_) for ( - qw(OpenQA::Task::AuditEvents::Limit), - qw(OpenQA::Task::Asset::Download OpenQA::Task::Asset::Limit), - qw(OpenQA::Task::Needle::Scan OpenQA::Task::Needle::Save OpenQA::Task::Needle::Delete), - qw(OpenQA::Task::Job::Limit), - qw(OpenQA::Task::Job::ArchiveResults), - qw(OpenQA::Task::Job::FinalizeResults), - qw(OpenQA::Task::Job::HookScript), - qw(OpenQA::Task::Job::Restart), - qw(OpenQA::Task::Iso::Schedule), - qw(OpenQA::Task::Bug::Limit), + qw(OpenQA::Task::AuditEvents::Limit), qw(OpenQA::Task::Asset::Download OpenQA::Task::Asset::Limit), + qw(OpenQA::Task::Needle::Scan OpenQA::Task::Needle::Save OpenQA::Task::Needle::Delete), qw(OpenQA::Task::Job::Limit), + qw(OpenQA::Task::Job::ArchiveResults), qw(OpenQA::Task::Job::FinalizeResults), + qw(OpenQA::Task::Job::HookScript), qw(OpenQA::Task::Job::Restart), + qw(OpenQA::Task::Iso::Schedule), qw(OpenQA::Task::Bug::Limit), ); } @@ -172,8 +167,7 @@ sub enqueue_and_keep_track { # check whether Minion worker are available to get a nice error message instead of an inactive job if (!$self->has_workers) { - return Mojo::Promise->reject( - {error => 'No Minion worker available. The openqa-gru service is likely not running.'}); + return Mojo::Promise->reject({error => 'No Minion worker available. The openqa-gru service is likely not running.'}); } # enqueue Minion job diff --git a/lib/OpenQA/Task/Asset/Download.pm b/lib/OpenQA/Task/Asset/Download.pm index 82390796c875..d0e764431c4f 100644 --- a/lib/OpenQA/Task/Asset/Download.pm +++ b/lib/OpenQA/Task/Asset/Download.pm @@ -19,8 +19,7 @@ sub _create_symlinks { my @error_message; for my $link_path (@$other_destinations) { $ctx->debug(qq{Creating symlink "$link_path" to "$assetpath"}); - symlink($assetpath, $link_path) || push @error_message, - "Cannot create symlink from $assetpath to $link_path: $!"; + symlink($assetpath, $link_path) || push @error_message, "Cannot create symlink from $assetpath to $link_path: $!"; } if (scalar(@error_message) > 0) { $ctx->error(my $msg = join("\n", @error_message)); diff --git a/lib/OpenQA/Task/Asset/Limit.pm b/lib/OpenQA/Task/Asset/Limit.pm index 6e9d527ce184..7848057a60bb 100644 --- a/lib/OpenQA/Task/Asset/Limit.pm +++ b/lib/OpenQA/Task/Asset/Limit.pm @@ -116,9 +116,7 @@ sub _limit { my $age_in_days = $age->delta_days($now)->in_units('days'); if ($age_in_days >= $limit_in_days) { - _remove_if($schema, $asset, - "Removing asset $asset_name (not in any group, age " - . "($age_in_days days) exceeds limit ($limit_in_days days)"); + _remove_if($schema, $asset, "Removing asset $asset_name (not in any group, age " . "($age_in_days days) exceeds limit ($limit_in_days days)"); } else { my $limit = $age->add(days => $limit_in_days); diff --git a/lib/OpenQA/Task/Iso/Schedule.pm b/lib/OpenQA/Task/Iso/Schedule.pm index 5076445a4e37..e7e5112e660a 100644 --- a/lib/OpenQA/Task/Iso/Schedule.pm +++ b/lib/OpenQA/Task/Iso/Schedule.pm @@ -10,8 +10,7 @@ use Mojo::UserAgent; use constant SCENARIO_DEFS_YAML_MAX_REDIRECTS => $ENV{OPENQA_SCENARIO_DEFINITIONS_YAML_MAX_REDIRECTS} // 2; use constant SCENARIO_DEFS_YAML_MAX_SIZE => $ENV{OPENQA_SCENARIO_DEFINITIONS_YAML_MAX_SIZE} // (512 * 1024); -use constant SCENARIO_DEFS_YAML_UA_ARGS => - (max_redirects => SCENARIO_DEFS_YAML_MAX_REDIRECTS, max_response_size => SCENARIO_DEFS_YAML_MAX_SIZE); +use constant SCENARIO_DEFS_YAML_UA_ARGS => (max_redirects => SCENARIO_DEFS_YAML_MAX_REDIRECTS, max_response_size => SCENARIO_DEFS_YAML_MAX_SIZE); sub register ($self, $app, @) { $app->minion->add_task(schedule_iso => sub { _schedule_iso($app, @_) }); diff --git a/lib/OpenQA/Task/Job/Limit.pm b/lib/OpenQA/Task/Job/Limit.pm index 65e1401786b9..b8f188a2e51a 100644 --- a/lib/OpenQA/Task/Job/Limit.pm +++ b/lib/OpenQA/Task/Job/Limit.pm @@ -72,8 +72,7 @@ sub _limit ($job, $args = undef) { my $limit_screenshots_jobs = $app->minion->jobs({tasks => ['limit_screenshots'], states => ['inactive', 'active']})->total; if ($limit_screenshots_jobs > 0) { - return $job->note(screenshot_cleanup => - "skipping, there are still $limit_screenshots_jobs inactive/active limit_screenshots jobs"); + return $job->note(screenshot_cleanup => "skipping, there are still $limit_screenshots_jobs inactive/active limit_screenshots jobs"); } # enqueue further Minion jobs to delete unused screenshots in batches @@ -81,8 +80,7 @@ sub _limit ($job, $args = undef) { return undef unless $min_id && $max_id; my $config = $app->config->{misc_limits}; my $screenshots_per_batch = $args->{screenshots_per_batch} // $config->{screenshot_cleanup_batch_size}; - my $batches_per_minion_job = $args->{batches_per_minion_job} - // $config->{screenshot_cleanup_batches_per_minion_job}; + my $batches_per_minion_job = $args->{batches_per_minion_job} // $config->{screenshot_cleanup_batches_per_minion_job}; my $screenshots_per_minion_job = $batches_per_minion_job * $screenshots_per_batch; my @screenshot_cleanup_info; my @parent_minion_job_ids = ($job->id); diff --git a/lib/OpenQA/Task/Utils.pm b/lib/OpenQA/Task/Utils.pm index 717cedf6676b..fd5342ad34c7 100644 --- a/lib/OpenQA/Task/Utils.pm +++ b/lib/OpenQA/Task/Utils.pm @@ -43,8 +43,7 @@ sub finish_job_if_disk_usage_below_percentage (%args) { my $free_percentage = $available_bytes / $total_bytes * 100; return undef if $free_percentage <= $percentage; - $job->finish("Skipping, free disk space on '$dir' exceeds configured percentage $percentage %" - . " (free percentage: $free_percentage %)"); + $job->finish("Skipping, free disk space on '$dir' exceeds configured percentage $percentage %" . " (free percentage: $free_percentage %)"); return 1; } diff --git a/lib/OpenQA/Utils.pm b/lib/OpenQA/Utils.pm index bbcc254021c8..4c636b7aca2c 100644 --- a/lib/OpenQA/Utils.pm +++ b/lib/OpenQA/Utils.pm @@ -304,9 +304,7 @@ sub image_md5_filename { } my $imagesdir = imagesdir(); - return ( - catfile($imagesdir, $prefix1, $prefix2, "$md5.png"), - catfile($imagesdir, $prefix1, $prefix2, '.thumbs', "$md5.png")); + return (catfile($imagesdir, $prefix1, $prefix2, "$md5.png"), catfile($imagesdir, $prefix1, $prefix2, '.thumbs', "$md5.png")); } # returns the url to the web socket proxy started via openqa-livehandler diff --git a/lib/OpenQA/WebAPI.pm b/lib/OpenQA/WebAPI.pm index 02f0f7b8152e..eb30b638a0f9 100644 --- a/lib/OpenQA/WebAPI.pm +++ b/lib/OpenQA/WebAPI.pm @@ -92,8 +92,7 @@ sub startup ($self) { OpenQA::Setup::set_secure_flag_on_cookies($c); unless ($c->req->url->path =~ m{^/(?:api/|asset/|tests/.*ajax)}) { # only retrieve job groups if we deliver HTML - $c->stash('job_groups_and_parents', - OpenQA::Schema->singleton->resultset('JobGroupParents')->job_groups_and_parents); + $c->stash('job_groups_and_parents', OpenQA::Schema->singleton->resultset('JobGroupParents')->job_groups_and_parents); } }); @@ -127,8 +126,7 @@ sub startup ($self) { # we have to set this and some later routes up differently on Mojo # < 9 and Mojo >= 9.11 if ($Mojolicious::VERSION > 9.10) { - $r->get('/tests/overview' => [format => ['json', 'html']])->name('tests_overview') - ->to('test#overview', format => undef); + $r->get('/tests/overview' => [format => ['json', 'html']])->name('tests_overview')->to('test#overview', format => undef); } elsif ($Mojolicious::VERSION < 9) { $r->get('/tests/overview')->name('tests_overview')->to('test#overview'); @@ -200,15 +198,13 @@ sub startup ($self) { $r->get('/image/:md5_1/:md5_2/.thumbs/#md5_basename')->to('file#thumb_image'); if ($Mojolicious::VERSION > 9.10) { - $r->get('/group_overview/' => [format => ['json', 'html']])->name('group_overview') - ->to('main#job_group_overview', format => undef); + $r->get('/group_overview/' => [format => ['json', 'html']])->name('group_overview')->to('main#job_group_overview', format => undef); $r->get('/parent_group_overview/' => [format => ['json', 'html']])->name('parent_group_overview') ->to('main#parent_group_overview', format => undef); } elsif ($Mojolicious::VERSION < 9) { $r->get('/group_overview/')->name('group_overview')->to('main#job_group_overview'); - $r->get('/parent_group_overview/')->name('parent_group_overview') - ->to('main#parent_group_overview'); + $r->get('/parent_group_overview/')->name('parent_group_overview')->to('main#parent_group_overview'); } else { die "Unsupported Mojolicious version $Mojolicious::VERSION!"; @@ -259,16 +255,14 @@ sub startup ($self) { $pub_admin_r->get('/groups')->name('admin_groups')->to('job_group#index'); $pub_admin_r->get('/job_group/')->name('admin_job_group_row')->to('job_group#job_group_row'); $pub_admin_r->get('/parent_group/')->name('admin_parent_group_row')->to('job_group#parent_group_row'); - $pub_admin_r->get('/edit_parent_group/')->name('admin_edit_parent_group') - ->to('job_group#edit_parent_group'); + $pub_admin_r->get('/edit_parent_group/')->name('admin_edit_parent_group')->to('job_group#edit_parent_group'); $pub_admin_r->get('/groups/connect/')->name('job_group_new_media')->to('job_group#connect'); $pub_admin_r->get('/assets')->name('admin_assets')->to('asset#index'); $pub_admin_r->get('/assets/status')->name('admin_asset_status_json')->to('asset#status_json'); if ($Mojolicious::VERSION > 9.10) { - $pub_admin_r->get('/workers' => [format => ['json', 'html']])->name('admin_workers') - ->to('workers#index', format => undef); + $pub_admin_r->get('/workers' => [format => ['json', 'html']])->name('admin_workers')->to('workers#index', format => undef); } elsif ($Mojolicious::VERSION < 9) { $pub_admin_r->get('/workers')->name('admin_workers')->to('workers#index'); @@ -277,8 +271,7 @@ sub startup ($self) { die "Unsupported Mojolicious version $Mojolicious::VERSION!"; } $pub_admin_r->get('/workers/')->name('admin_worker_show')->to('workers#show'); - $pub_admin_r->get('/workers//ajax')->name('admin_worker_previous_jobs_ajax') - ->to('workers#previous_jobs_ajax'); + $pub_admin_r->get('/workers//ajax')->name('admin_worker_previous_jobs_ajax')->to('workers#previous_jobs_ajax'); $pub_admin_r->get('/productlog')->name('admin_product_log')->to('audit_log#productlog'); $pub_admin_r->get('/productlog/ajax')->name('admin_product_log_ajax')->to('audit_log#productlog_ajax'); @@ -399,14 +392,12 @@ sub startup ($self) { # api/v1/mm my $mm_api = $api_r_job->any('/mm'); push @api_routes, $mm_api; - $mm_api->get('/children/:state' => [state => [qw(running scheduled done)]])->name('apiv1_mm_running_children') - ->to('mm#get_children_status'); + $mm_api->get('/children/:state' => [state => [qw(running scheduled done)]])->name('apiv1_mm_running_children')->to('mm#get_children_status'); $mm_api->get('/children')->name('apiv1_mm_children')->to('mm#get_children'); $mm_api->get('/parents')->name('apiv1_mm_parents')->to('mm#get_parents'); # api/v1/isos - $api_ro->get('/isos/')->name('apiv1_show_scheduled_product') - ->to('iso#show_scheduled_product'); + $api_ro->get('/isos/')->name('apiv1_show_scheduled_product')->to('iso#show_scheduled_product'); $api_ro->post('/isos')->name('apiv1_create_iso')->to('iso#create'); $api_ra->delete('/isos/#name')->name('apiv1_destroy_iso')->to('iso#destroy'); $api_ro->post('/isos/#name/cancel')->name('apiv1_cancel_iso')->to('iso#cancel'); @@ -457,13 +448,11 @@ sub startup ($self) { $api_ra->delete('job_templates/<:job_template_id:num>')->to('job_template#destroy'); # api/v1/job_templates_scheduling - $api_public_r->get('job_templates_scheduling/')->name('apiv1_job_templates_schedules') - ->to('job_template#schedules', id => undef); + $api_public_r->get('job_templates_scheduling/')->name('apiv1_job_templates_schedules')->to('job_template#schedules', id => undef); $api_public_r->get('job_templates_scheduling/')->to('job_template#schedules', name => undef); $api_ra->post('job_templates_scheduling/')->to('job_template#update', id => undef); # Deprecated experimental aliases for the above routes - $api_public_r->get('experimental/job_templates_scheduling/')->name('apiv1_job_templates_schedules') - ->to('job_template#schedules', id => undef); + $api_public_r->get('experimental/job_templates_scheduling/')->name('apiv1_job_templates_schedules')->to('job_template#schedules', id => undef); $api_public_r->get('experimental/job_templates_scheduling/')->to('job_template#schedules', name => undef); $api_ra->post('experimental/job_templates_scheduling/')->to('job_template#update', id => undef); @@ -474,23 +463,15 @@ sub startup ($self) { $api_ru->put('/jobs//comments/')->name('apiv1_put_comment')->to('comment#update'); $api_ra->delete('/jobs//comments/')->name('apiv1_delete_comment')->to('comment#delete'); $api_public_r->get('/groups//comments')->name('apiv1_list_group_comment')->to('comment#list'); - $api_public_r->get('/groups//comments/')->name('apiv1_get_group_comment') - ->to('comment#text'); + $api_public_r->get('/groups//comments/')->name('apiv1_get_group_comment')->to('comment#text'); $api_ru->post('/groups//comments')->name('apiv1_post_group_comment')->to('comment#create'); - $api_ru->put('/groups//comments/')->name('apiv1_put_group_comment') - ->to('comment#update'); - $api_ra->delete('/groups//comments/')->name('apiv1_delete_group_comment') - ->to('comment#delete'); - $api_public_r->get('/parent_groups//comments')->name('apiv1_list_parent_group_comment') - ->to('comment#list'); - $api_public_r->get('/parent_groups//comments/') - ->name('apiv1_get_parent_group_comment')->to('comment#text'); - $api_ru->post('/parent_groups//comments')->name('apiv1_post_parent_group_comment') - ->to('comment#create'); - $api_ru->put('/parent_groups//comments/') - ->name('apiv1_put_parent_group_comment')->to('comment#update'); - $api_ra->delete('/parent_groups//comments/') - ->name('apiv1_delete_parent_group_comment')->to('comment#delete'); + $api_ru->put('/groups//comments/')->name('apiv1_put_group_comment')->to('comment#update'); + $api_ra->delete('/groups//comments/')->name('apiv1_delete_group_comment')->to('comment#delete'); + $api_public_r->get('/parent_groups//comments')->name('apiv1_list_parent_group_comment')->to('comment#list'); + $api_public_r->get('/parent_groups//comments/')->name('apiv1_get_parent_group_comment')->to('comment#text'); + $api_ru->post('/parent_groups//comments')->name('apiv1_post_parent_group_comment')->to('comment#create'); + $api_ru->put('/parent_groups//comments/')->name('apiv1_put_parent_group_comment')->to('comment#update'); + $api_ra->delete('/parent_groups//comments/')->name('apiv1_delete_parent_group_comment')->to('comment#delete'); $api_ra->delete('/user/')->name('apiv1_delete_user')->to('user#delete'); diff --git a/lib/OpenQA/WebAPI/Auth/Fake.pm b/lib/OpenQA/WebAPI/Auth/Fake.pm index 3697c6310ce8..b26a7151027e 100644 --- a/lib/OpenQA/WebAPI/Auth/Fake.pm +++ b/lib/OpenQA/WebAPI/Auth/Fake.pm @@ -11,10 +11,8 @@ sub auth_login ($self) { my $headers = $self->req->headers; my %users; - $users{Demo} - = {fullname => 'Demo User', email => 'demo@user.org', admin => 1, operator => 1, key => '1234567890ABCDEF'}; - $users{nobody} - = {fullname => 'Nobody', email => 'nobody@example.com', admin => 0, operator => 0, key => '1111111111111111'}; + $users{Demo} = {fullname => 'Demo User', email => 'demo@user.org', admin => 1, operator => 1, key => '1234567890ABCDEF'}; + $users{nobody} = {fullname => 'Nobody', email => 'nobody@example.com', admin => 0, operator => 0, key => '1111111111111111'}; $users{otherdeveloper} = { fullname => 'Other developer', email => 'dev@example.com', diff --git a/lib/OpenQA/WebAPI/Auth/OAuth2.pm b/lib/OpenQA/WebAPI/Auth/OAuth2.pm index 8245fed34b7e..0e8c336a6262 100644 --- a/lib/OpenQA/WebAPI/Auth/OAuth2.pm +++ b/lib/OpenQA/WebAPI/Auth/OAuth2.pm @@ -93,8 +93,7 @@ sub auth_login ($controller) { my $get_token_args = {redirect_uri => $controller->url_for('login')->userinfo(undef)->to_abs}; $get_token_args->{scope} = $provider_config->{token_scope}; $controller->oauth2->get_token_p($main_config->{provider} => $get_token_args) - ->then(sub { update_user($controller, $main_config, $provider_config, shift) }) - ->catch(sub { $controller->render(text => shift, status => 403) }); + ->then(sub { update_user($controller, $main_config, $provider_config, shift) })->catch(sub { $controller->render(text => shift, status => 403) }); return (manual => 1); } diff --git a/lib/OpenQA/WebAPI/Controller/API/V1.pm b/lib/OpenQA/WebAPI/Controller/API/V1.pm index 4be388fa30ca..fe8f1e6c6208 100644 --- a/lib/OpenQA/WebAPI/Controller/API/V1.pm +++ b/lib/OpenQA/WebAPI/Controller/API/V1.pm @@ -8,9 +8,9 @@ sub auth_jobtoken ($self) { $self->render(json => {error => 'no JobToken received'}, status => 403) && return unless my $token = $self->req->headers->header('X-API-JobToken'); $self->render(json => {error => 'invalid jobtoken'}, status => 403) && return - unless my $job = $self->schema->resultset('Jobs')->search( - {'properties.key' => 'JOBTOKEN', 'properties.value' => $token}, - {columns => ['id'], join => {worker => 'properties'}})->single; + unless my $job + = $self->schema->resultset('Jobs') + ->search({'properties.key' => 'JOBTOKEN', 'properties.value' => $token}, {columns => ['id'], join => {worker => 'properties'}})->single; $self->stash('job_id', $job->id); $self->app->log->trace('Found associated job ' . $job->id); return 1; diff --git a/lib/OpenQA/WebAPI/Controller/API/V1/Asset.pm b/lib/OpenQA/WebAPI/Controller/API/V1/Asset.pm index a8fca993f12f..c238bad5f49f 100644 --- a/lib/OpenQA/WebAPI/Controller/API/V1/Asset.pm +++ b/lib/OpenQA/WebAPI/Controller/API/V1/Asset.pm @@ -143,8 +143,7 @@ sub delete { my $asset = $self->schema->resultset("Assets")->search(\%args); return $self->render( - json => - {error => 'The asset might have already been removed and only the cached view has not been updated yet.'}, + json => {error => 'The asset might have already been removed and only the cached view has not been updated yet.'}, status => 404 ) if $asset->count == 0; my $rs; diff --git a/lib/OpenQA/WebAPI/Controller/API/V1/Bug.pm b/lib/OpenQA/WebAPI/Controller/API/V1/Bug.pm index f5971422e3e9..14c235e24b8a 100644 --- a/lib/OpenQA/WebAPI/Controller/API/V1/Bug.pm +++ b/lib/OpenQA/WebAPI/Controller/API/V1/Bug.pm @@ -105,8 +105,7 @@ sub show ($self) { my $bug = $self->schema->resultset("Bugs")->find($self->param('id')); return $self->reply->not_found unless $bug; - my %json = map { $_ => $bug->get_column($_) } - qw(assigned assignee bugid existing id open priority refreshed resolution status t_created t_updated title); + my %json = map { $_ => $bug->get_column($_) } qw(assigned assignee bugid existing id open priority refreshed resolution status t_created t_updated title); $self->render(json => \%json); } diff --git a/lib/OpenQA/WebAPI/Controller/API/V1/Iso.pm b/lib/OpenQA/WebAPI/Controller/API/V1/Iso.pm index d95e8466ac50..5b6cc219f608 100644 --- a/lib/OpenQA/WebAPI/Controller/API/V1/Iso.pm +++ b/lib/OpenQA/WebAPI/Controller/API/V1/Iso.pm @@ -102,8 +102,7 @@ sub create { my $params = $self->req->params->to_hash; my $async = delete $params->{async}; # whether to run the operation as a Minion job - my $scheduled_product_clone_id - = delete $params->{scheduled_product_clone_id}; # ID of a previous product to clone settings from + my $scheduled_product_clone_id = delete $params->{scheduled_product_clone_id}; # ID of a previous product to clone settings from my $log = $self->app->log; my $validation = $self->validation; my $scheduled_products = $self->schema->resultset('ScheduledProducts'); diff --git a/lib/OpenQA/WebAPI/Controller/API/V1/Job.pm b/lib/OpenQA/WebAPI/Controller/API/V1/Job.pm index 6c8de8ae5dd6..95fb9873e60e 100644 --- a/lib/OpenQA/WebAPI/Controller/API/V1/Job.pm +++ b/lib/OpenQA/WebAPI/Controller/API/V1/Job.pm @@ -173,9 +173,7 @@ sub list ($self) { push @{$children{$dep->parent_job_id}}, $dep; push @{$parents{$dep->child_job_id}}, $dep; } - my $js - = $schema->resultset('JobSettings') - ->search(\['job_id = ANY(?)', [{}, \@jobids]], {select => [qw(job_id key value)]}); + my $js = $schema->resultset('JobSettings')->search(\['job_id = ANY(?)', [{}, \@jobids]], {select => [qw(job_id key value)]}); while (my $set = $js->next) { push @{$settings{$set->job_id}}, $set; } @@ -531,8 +529,7 @@ sub update_status ($self) { } else { my $job_status = $job->status_info; - my $err = "Got status update for job $job_id and worker $worker_id but there is" - . " not even a worker assigned to this job (job is $job_status)"; + my $err = "Got status update for job $job_id and worker $worker_id but there is" . " not even a worker assigned to this job (job is $job_status)"; log_info($err); return $self->render(json => {error => $err}, status => 400); } @@ -541,9 +538,7 @@ sub update_status ($self) { if (!$worker || $worker->id != $worker_id) { my $expected_worker_id = $worker ? $worker->id : 'no updates anymore'; my $job_status = $job->status_info; - my $err - = "Got status update for job $job_id with unexpected worker ID $worker_id" - . " (expected $expected_worker_id, job is $job_status)"; + my $err = "Got status update for job $job_id with unexpected worker ID $worker_id" . " (expected $expected_worker_id, job is $job_status)"; log_info($err); return $self->render(json => {error => $err}, status => 400); } @@ -684,8 +679,7 @@ sub create_artefact ($self) { } elsif ($self->param('extra_test')) { return $self->render(text => 'OK') - if $job->parse_extra_tests($validation->param('file'), $validation->param('type'), - $validation->param('script')); + if $job->parse_extra_tests($validation->param('file'), $validation->param('type'), $validation->param('script')); return $self->render(json => {error => 'Unable to parse extra test'}, status => 400); } elsif (my $scope = $self->param('asset')) { diff --git a/lib/OpenQA/WebAPI/Controller/API/V1/JobGroup.pm b/lib/OpenQA/WebAPI/Controller/API/V1/JobGroup.pm index cf7d2718e190..d10486ed3d3d 100644 --- a/lib/OpenQA/WebAPI/Controller/API/V1/JobGroup.pm +++ b/lib/OpenQA/WebAPI/Controller/API/V1/JobGroup.pm @@ -336,8 +336,7 @@ sub delete { } my $res = $group->delete; - return $self->render( - json => {error => 'Specified job group ' . $group->id . ' exist but can not be deleted, though'}) + return $self->render(json => {error => 'Specified job group ' . $group->id . ' exist but can not be deleted, though'}) unless $res; my $event_data = {id => $res->id}; $self->emit_event(openqa_jobgroup_delete => $event_data); diff --git a/lib/OpenQA/WebAPI/Controller/API/V1/JobTemplate.pm b/lib/OpenQA/WebAPI/Controller/API/V1/JobTemplate.pm index ea1943b79ecd..a0ab7bb27d06 100644 --- a/lib/OpenQA/WebAPI/Controller/API/V1/JobTemplate.pm +++ b/lib/OpenQA/WebAPI/Controller/API/V1/JobTemplate.pm @@ -123,9 +123,8 @@ sub _get_job_groups { my ($self, $id, $name) = @_; my %yaml; - my $groups = $self->schema->resultset("JobGroups")->search( - $id ? {id => $id} : ($name ? {name => $name} : undef), - {select => [qw(id name parent_id default_priority template)]}); + my $groups = $self->schema->resultset("JobGroups") + ->search($id ? {id => $id} : ($name ? {name => $name} : undef), {select => [qw(id name parent_id default_priority template)]}); while (my $group = $groups->next) { # Use stored YAML template from the database if available $yaml{$group->name} = $group->to_yaml; @@ -225,8 +224,7 @@ sub update { my $yaml = $validation->param('template') // ''; try { $data = load_yaml(string => $validation->param('template')); - $user_errors - = $self->app->validate_yaml($data, $validation->param('schema'), $self->app->log->level eq 'debug'); + $user_errors = $self->app->validate_yaml($data, $validation->param('schema'), $self->app->log->level eq 'debug'); } catch { # Push the exception to the list of errors without the trailing new line @@ -242,8 +240,7 @@ sub update { try { my $id = $self->param('id'); my $name = $validation->param('name'); - my $job_group = $job_groups->find($id ? {id => $id} : ($name ? {name => $name} : undef), - {select => [qw(id name template)]}); + my $job_group = $job_groups->find($id ? {id => $id} : ($name ? {name => $name} : undef), {select => [qw(id name template)]}); return push @$user_errors, 'Job group ' . ($name // $id) . ' not found' unless $job_group; my $group_id = $job_group->id; $json->{job_group_id} = $group_id; diff --git a/lib/OpenQA/WebAPI/Controller/API/V1/Mm.pm b/lib/OpenQA/WebAPI/Controller/API/V1/Mm.pm index 63fd9c333521..1c5162cf5050 100644 --- a/lib/OpenQA/WebAPI/Controller/API/V1/Mm.pm +++ b/lib/OpenQA/WebAPI/Controller/API/V1/Mm.pm @@ -52,8 +52,7 @@ sub get_children_status { } my $jobid = $self->stash('job_id'); - my @res = $self->schema->resultset('Jobs') - ->search({'parents.parent_job_id' => $jobid, state => $state}, {columns => ['id'], join => 'parents'}); + my @res = $self->schema->resultset('Jobs')->search({'parents.parent_job_id' => $jobid, state => $state}, {columns => ['id'], join => 'parents'}); my @res_ids = map { $_->id } @res; return $self->render(json => {jobs => \@res_ids}, status => 200); } @@ -74,9 +73,7 @@ sub get_children { my $jobid = $self->stash('job_id'); my @res - = $self->schema->resultset('Jobs') - ->search( - {'parents.parent_job_id' => $jobid, 'parents.dependency' => OpenQA::JobDependencies::Constants::PARALLEL}, + = $self->schema->resultset('Jobs')->search({'parents.parent_job_id' => $jobid, 'parents.dependency' => OpenQA::JobDependencies::Constants::PARALLEL}, {columns => ['id', 'state'], join => 'parents'}); my %res_ids = map { ($_->id, $_->state) } @res; return $self->render(json => {jobs => \%res_ids}, status => 200); @@ -98,9 +95,7 @@ sub get_parents { my $jobid = $self->stash('job_id'); my @res - = $self->schema->resultset('Jobs') - ->search( - {'children.child_job_id' => $jobid, 'children.dependency' => OpenQA::JobDependencies::Constants::PARALLEL}, + = $self->schema->resultset('Jobs')->search({'children.child_job_id' => $jobid, 'children.dependency' => OpenQA::JobDependencies::Constants::PARALLEL}, {columns => ['id'], join => 'children'}); my @res_ids = map { $_->id } @res; return $self->render(json => {jobs => \@res_ids}, status => 200); diff --git a/lib/OpenQA/WebAPI/Controller/API/V1/Search.pm b/lib/OpenQA/WebAPI/Controller/API/V1/Search.pm index 1df04a48775d..7736bcb862b1 100644 --- a/lib/OpenQA/WebAPI/Controller/API/V1/Search.pm +++ b/lib/OpenQA/WebAPI/Controller/API/V1/Search.pm @@ -68,9 +68,7 @@ sub _search_perl_modules { next unless -d $distri; # Test module filenames - for my $filename ( - $distri->list_tree()->head($cap)->map('to_rel', $distris)->grep(qr/.*\Q$keywords\E.*\.p[my]$/)->each) - { + for my $filename ($distri->list_tree()->head($cap)->map('to_rel', $distris)->grep(qr/.*\Q$keywords\E.*\.p[my]$/)->each) { push(@results, {occurrence => $filename}); $cap--; } @@ -117,8 +115,7 @@ sub _search_job_modules { {-or => {name => $like}}, { join => 'job', - group_by => - ['me.id', 'job.DISTRI', 'job.VERSION', 'job.FLAVOR', 'job.TEST', 'job.ARCH', 'job.MACHINE', 'job.id'], + group_by => ['me.id', 'job.DISTRI', 'job.VERSION', 'job.FLAVOR', 'job.TEST', 'job.ARCH', 'job.MACHINE', 'job.id'], prefetch => [qw(job)], select => [qw(me.id me.script me.job_id job.DISTRI job.VERSION job.FLAVOR job.ARCH job.BUILD job.TEST)], order_by => {-desc => 'job_id'}})->slice(0, $limit); diff --git a/lib/OpenQA/WebAPI/Controller/API/V1/Table.pm b/lib/OpenQA/WebAPI/Controller/API/V1/Table.pm index 46c1bb8784c9..74ce94bc7c6d 100644 --- a/lib/OpenQA/WebAPI/Controller/API/V1/Table.pm +++ b/lib/OpenQA/WebAPI/Controller/API/V1/Table.pm @@ -221,10 +221,7 @@ sub _verify_table_usage { } return scalar(keys %groups) - ? 'Group' - . (scalar(keys %groups) > 1 ? 's' : '') . ' ' - . join(', ', sort keys(%groups)) - . " must be updated through the YAML template" + ? 'Group' . (scalar(keys %groups) > 1 ? 's' : '') . ' ' . join(', ', sort keys(%groups)) . " must be updated through the YAML template" : undef; } diff --git a/lib/OpenQA/WebAPI/Controller/API/V1/Webhook.pm b/lib/OpenQA/WebAPI/Controller/API/V1/Webhook.pm index e981f5175ec9..6510aa4d983d 100644 --- a/lib/OpenQA/WebAPI/Controller/API/V1/Webhook.pm +++ b/lib/OpenQA/WebAPI/Controller/API/V1/Webhook.pm @@ -110,8 +110,7 @@ sub product ($self) { # cancel previously scheduled jobs for this PR my $webhook_id = "gh:pr:$pr_id"; my $scheduled_products = $self->schema->resultset('ScheduledProducts'); - my $cancellation - = $action ne 'opened' ? $scheduled_products->cancel_by_webhook_id($webhook_id, "PR $action_str") : undef; + my $cancellation = $action ne 'opened' ? $scheduled_products->cancel_by_webhook_id($webhook_id, "PR $action_str") : undef; return $self->render(json => $cancellation) if $action eq 'closed'; # compute parameters diff --git a/lib/OpenQA/WebAPI/Controller/API/V1/Worker.pm b/lib/OpenQA/WebAPI/Controller/API/V1/Worker.pm index 2785fdf2d866..c4e5c2e0fe69 100644 --- a/lib/OpenQA/WebAPI/Controller/API/V1/Worker.pm +++ b/lib/OpenQA/WebAPI/Controller/API/V1/Worker.pm @@ -172,11 +172,9 @@ Initializes and registers a worker. sub create { my ($self) = @_; my $validation = $self->validation; - my @validation_params - = qw(cpu_arch cpu_modelname cpu_opmode cpu_flags mem_max isotovideo_interface_version websocket_api_version worker_class); + my @validation_params = qw(cpu_arch cpu_modelname cpu_opmode cpu_flags mem_max isotovideo_interface_version websocket_api_version worker_class); $validation->required($_) for qw(host instance cpu_arch mem_max worker_class); - $validation->optional($_) - for qw(cpu_modelname cpu_opmode cpu_flags isotovideo_interface_version job_id websocket_api_version); + $validation->optional($_) for qw(cpu_modelname cpu_opmode cpu_flags isotovideo_interface_version job_id websocket_api_version); return $self->reply->validation_error({format => 'json'}) if $validation->has_error; my $host = $validation->param('host'); diff --git a/lib/OpenQA/WebAPI/Controller/Admin/Influxdb.pm b/lib/OpenQA/WebAPI/Controller/Admin/Influxdb.pm index 259ec22dd59d..cc5dd0181f06 100644 --- a/lib/OpenQA/WebAPI/Controller/Admin/Influxdb.pm +++ b/lib/OpenQA/WebAPI/Controller/Admin/Influxdb.pm @@ -9,8 +9,7 @@ use OpenQA::Jobs::Constants; sub _queue_sub_stats ($query, $state, $result) { $result->{openqa_jobs}->{$state} = $query->count; - my $counts = $query->search({}, - {select => ['group_id', {count => 'id'}], as => [qw(group_id count)], group_by => 'group_id'}); + my $counts = $query->search({}, {select => ['group_id', {count => 'id'}], as => [qw(group_id count)], group_by => 'group_id'}); while (my $c = $counts->next) { $result->{by_group}->{$c->get_column('group_id') // 0}->{$state} = $c->get_column('count'); } @@ -129,8 +128,7 @@ sub minion ($self) { my $url = $self->app->config->{global}->{base_url} || $self->req->url->base->to_string; my $text = ''; $text .= _queue_output_measure($url, 'openqa_minion_jobs', undef, $jobs); - $text .= _queue_output_measure($url, 'openqa_minion_jobs_hook_rc_failed', - undef, $jobs_hook_rc_failed, $rc_fail_timespan_end); + $text .= _queue_output_measure($url, 'openqa_minion_jobs_hook_rc_failed', undef, $jobs_hook_rc_failed, $rc_fail_timespan_end); $text .= _queue_output_measure($url, 'openqa_minion_workers', undef, $workers); $self->render(text => $text, format => 'txt'); diff --git a/lib/OpenQA/WebAPI/Controller/Admin/Workers.pm b/lib/OpenQA/WebAPI/Controller/Admin/Workers.pm index e558e01ce473..11d6fc72e77d 100644 --- a/lib/OpenQA/WebAPI/Controller/Admin/Workers.pm +++ b/lib/OpenQA/WebAPI/Controller/Admin/Workers.pm @@ -69,11 +69,7 @@ sub previous_jobs_ajax ($self) { OpenQA::WebAPI::ServerSideDataTable::render_response( controller => $self, resultset => 'Jobs', - columns => [ - [qw(BUILD DISTRI VERSION FLAVOR ARCH)], - [qw(passed_module_count softfailed_module_count failed_module_count)], - qw(t_finished), - ], + columns => [[qw(BUILD DISTRI VERSION FLAVOR ARCH)], [qw(passed_module_count softfailed_module_count failed_module_count)], qw(t_finished),], initial_conds => [{assigned_worker_id => $self->param('worker_id')}], additional_params => {prefetch => [qw(children parents)]}, prepare_data_function => sub { diff --git a/lib/OpenQA/WebAPI/Controller/Main.pm b/lib/OpenQA/WebAPI/Controller/Main.pm index cf1e14daa3e7..cdfafd5090e0 100644 --- a/lib/OpenQA/WebAPI/Controller/Main.pm +++ b/lib/OpenQA/WebAPI/Controller/Main.pm @@ -54,9 +54,7 @@ sub dashboard_build_results ($self) { } my $tags = $show_tags || $only_tagged ? $group->tags : undef; my $build_results - = OpenQA::BuildResults::compute_build_results($group, $limit_builds, $time_limit_days, - $only_tagged ? $tags : undef, - $group_params); + = OpenQA::BuildResults::compute_build_results($group, $limit_builds, $time_limit_days, $only_tagged ? $tags : undef, $group_params); my $build_results_for_group = $build_results->{build_results}; _map_tags_into_build($build_results_for_group, $tags) if $show_tags; @@ -134,11 +132,7 @@ sub _group_overview ($self, $resultset, $template) { my @pinned_comments = grep { $_->user->is_operator } $comments->search({text => $pinned_cond})->all; my $tags = $group->tags; - my $cbr = eval { - OpenQA::BuildResults::compute_build_results($group, $limit_builds, $time_limit_days, - $only_tagged ? $tags : undef, - $group_params); - }; + my $cbr = eval { OpenQA::BuildResults::compute_build_results($group, $limit_builds, $time_limit_days, $only_tagged ? $tags : undef, $group_params); }; if (my $error = $@) { die $error unless $error =~ qr/^invalid regex: /; return $self->_respond_error_for_group_overview($error); diff --git a/lib/OpenQA/WebAPI/Controller/Running.pm b/lib/OpenQA/WebAPI/Controller/Running.pm index 65e057b3dce4..e39e61fbe2cd 100644 --- a/lib/OpenQA/WebAPI/Controller/Running.pm +++ b/lib/OpenQA/WebAPI/Controller/Running.pm @@ -40,8 +40,7 @@ sub init ($self, $page_name = undef) { # render a 404 error page for other routes my $test_name = $job->name; my $what = $page_name ? "the page \"$page_name\"" : 'this route'; - $self->render_specific_not_found($page_name // 'Page not found', - "The test $test_name has no worker assigned so $what is not available."); + $self->render_specific_not_found($page_name // 'Page not found', "The test $test_name has no worker assigned so $what is not available."); return 0; } diff --git a/lib/OpenQA/WebAPI/Controller/Step.pm b/lib/OpenQA/WebAPI/Controller/Step.pm index 1b44b4f0788f..ecbb06d171a5 100644 --- a/lib/OpenQA/WebAPI/Controller/Step.pm +++ b/lib/OpenQA/WebAPI/Controller/Step.pm @@ -57,8 +57,7 @@ sub check_tabmode ($self) { sub needle_url ($self, $distri, $name, $version, $jsonfile) { if (defined($jsonfile) && $jsonfile) { if (defined($version) && $version) { - $self->url_for('needle_file', distri => $distri, name => $name) - ->query(version => $version, jsonfile => $jsonfile); + $self->url_for('needle_file', distri => $distri, name => $name)->query(version => $version, jsonfile => $jsonfile); } else { $self->url_for('needle_file', distri => $distri, name => $name)->query(jsonfile => $jsonfile); @@ -128,9 +127,7 @@ sub edit ($self) { $screenshot = $self->_new_screenshot($tags, $imgname, $module_detail->{area}); # Second position: the only needle (with the same matches) - my $needle_info - = $self->_extended_needle_info($needle_dir, $needle_name, \%basic_needle_data, $module_detail->{json}, - 0, \@error_messages); + my $needle_info = $self->_extended_needle_info($needle_dir, $needle_name, \%basic_needle_data, $module_detail->{json}, 0, \@error_messages); if ($needle_info) { $needle_info->{matches} = $screenshot->{matches}; push(@needles, $needle_info); @@ -144,10 +141,8 @@ sub edit ($self) { # $needle contains information from result, in which 'areas' refers to the best matches. # We also use $area for transforming the match information into a real area for my $needle (@$module_detail_needles) { - my $needle_info = $self->_extended_needle_info( - $needle_dir, $needle->{name}, \%basic_needle_data, - $needle->{json}, $needle->{error}, \@error_messages - ) || next; + my $needle_info + = $self->_extended_needle_info($needle_dir, $needle->{name}, \%basic_needle_data, $needle->{json}, $needle->{error}, \@error_messages) || next; my $matches = $needle_info->{matches}; for my $match (@{$needle->{area}}) { my %area = ( @@ -179,16 +174,10 @@ sub edit ($self) { my $new_needle_tags = $new_needle->tags; my $joined_tags = $new_needle_tags ? join(', ', @$new_needle_tags) : 'none'; # show warning for new needle with matching tags - push( - @error_messages, - sprintf( - 'A new needle with matching tags has been created since the job started: %s (tags: %s)', - $new_needle->filename, $joined_tags - )); + push(@error_messages, + sprintf('A new needle with matching tags has been created since the job started: %s (tags: %s)', $new_needle->filename, $joined_tags)); # get needle info to show the needle also in selection - my $needle_info - = $self->_extended_needle_info($needle_dir, $new_needle->name, \%basic_needle_data, $new_needle->path, - undef, \@error_messages) + my $needle_info = $self->_extended_needle_info($needle_dir, $new_needle->name, \%basic_needle_data, $new_needle->path, undef, \@error_messages) || next; $needle_info->{title} = 'new: ' . $needle_info->{title}; push(@needles, $needle_info); @@ -477,8 +466,7 @@ sub viewimg ($self) { my $append_needle_info = sub ($tags, $needle_info) { # add timestamps and URLs from database - $self->populate_hash_with_needle_timestamps_and_urls( - $needles_rs->find_needle($real_needle_dir, "$needle_info->{name}.json"), $needle_info); + $self->populate_hash_with_needle_timestamps_and_urls($needles_rs->find_needle($real_needle_dir, "$needle_info->{name}.json"), $needle_info); # handle case when the needle has (for some reason) no tags if (!$tags) { @@ -541,8 +529,7 @@ sub viewimg ($self) { # sort needles by average similarity my $has_selection = defined($primary_match); for my $tag (keys %needles_by_tag) { - my @sorted_needles = sort { $b->{avg_similarity} <=> $a->{avg_similarity} || $a->{name} cmp $b->{name} } - @{$needles_by_tag{$tag}}; + my @sorted_needles = sort { $b->{avg_similarity} <=> $a->{avg_similarity} || $a->{name} cmp $b->{name} } @{$needles_by_tag{$tag}}; $needles_by_tag{$tag} = \@sorted_needles; # preselect a rather good needle diff --git a/lib/OpenQA/WebAPI/Controller/Test.pm b/lib/OpenQA/WebAPI/Controller/Test.pm index 6e00ec746fb7..b4819b982b28 100644 --- a/lib/OpenQA/WebAPI/Controller/Test.pm +++ b/lib/OpenQA/WebAPI/Controller/Test.pm @@ -136,10 +136,7 @@ sub list_ajax ($self) { scope => $scope, match => $self->get_match_param, groupid => $self->param('groupid'), - limit => min( - $limits->{all_tests_max_finished_jobs}, - $self->param('limit') // $limits->{all_tests_default_finished_jobs} - ), + limit => min($limits->{all_tests_max_finished_jobs}, $self->param('limit') // $limits->{all_tests_default_finished_jobs}), order_by => \'COALESCE(me.t_finished, me.t_updated) DESC, me.id DESC', columns => [ qw(id MACHINE DISTRI VERSION FLAVOR ARCH BUILD TEST @@ -478,8 +475,7 @@ sub infopanel { sub _get_current_job ($self, $with_assets = 0) { return $self->reply->not_found unless defined $self->param('testid'); - my $job = $self->schema->resultset("Jobs") - ->find($self->param('testid'), {$with_assets ? (prefetch => qw(jobs_assets)) : ()}); + my $job = $self->schema->resultset("Jobs")->find($self->param('testid'), {$with_assets ? (prefetch => qw(jobs_assets)) : ()}); return $job; } @@ -542,8 +538,7 @@ sub job_next_previous_ajax ($self) { my $main_jobid = $main_job->id; my $limits = OpenQA::App->singleton->config->{misc_limits}; - my $p_limit = min($limits->{previous_jobs_max_limit}, - $self->param('previous_limit') // $limits->{previous_jobs_default_limit}); + my $p_limit = min($limits->{previous_jobs_max_limit}, $self->param('previous_limit') // $limits->{previous_jobs_default_limit}); my $n_limit = min($limits->{next_jobs_max_limit}, $self->param('next_limit') // $limits->{next_jobs_default_limit}); my $schema = $self->schema; @@ -586,8 +581,7 @@ sub job_next_previous_ajax ($self) { iscurrent => $job_id == $main_jobid ? 1 : undef, islatest => $job_id == $latest ? 1 : undef, finished => $job->t_finished ? $job->t_finished->datetime() . 'Z' : undef, - duration => $job->t_started - && $job->t_finished ? $self->format_time_duration($job->t_finished - $job->t_started) : 0, + duration => $job->t_started && $job->t_finished ? $self->format_time_duration($job->t_finished - $job->t_started) : 0, comment_data => $rendered_data, }); } @@ -657,8 +651,7 @@ sub _prepare_job_results ($self, $all_jobs, $limit) { # prefetch test suite names from job settings my $job_settings - = $schema->resultset('JobSettings') - ->search({job_id => {-in => [map { $_->id } @jobs]}, key => {-in => [qw(JOB_DESCRIPTION TEST_SUITE_NAME)]}}); + = $schema->resultset('JobSettings')->search({job_id => {-in => [map { $_->id } @jobs]}, key => {-in => [qw(JOB_DESCRIPTION TEST_SUITE_NAME)]}}); my %settings_by_job_id; for my $js ($job_settings->all) { $settings_by_job_id{$js->job_id}->{$js->key} = $js->value; @@ -676,10 +669,7 @@ sub _prepare_job_results ($self, $all_jobs, $limit) { my ($children_by_job, $parents_by_job) = $self->_fetch_dependencies_by_jobs(\@jobids); foreach my $job (@jobs) { my $id = $job->id; - my $result = $job->overview_result( - $comment_data, $aggregated, $failed_modules, - $failed_modules_by_job->{$id} || [], - $self->param('todo')) or next; + my $result = $job->overview_result($comment_data, $aggregated, $failed_modules, $failed_modules_by_job->{$id} || [], $self->param('todo')) or next; my $test = $job->TEST; my $flavor = $job->FLAVOR || 'sweet'; my $arch = $job->ARCH || 'noarch'; @@ -722,8 +712,8 @@ sub _prepare_job_results ($self, $all_jobs, $limit) { # avoid running a SELECT for each job sub _fetch_failed_modules_by_jobs ($self, $ids) { my $schema = $self->schema; - my $modules = $schema->resultset('JobModules') - ->search({job_id => {-in => $ids}, result => 'failed'}, {select => [qw(name job_id)], order_by => 't_updated'},); + my $modules + = $schema->resultset('JobModules')->search({job_id => {-in => $ids}, result => 'failed'}, {select => [qw(name job_id)], order_by => 't_updated'},); my %failed; push @{$failed{$_->job_id}}, $_->name for $modules->all; return \%failed; @@ -813,8 +803,7 @@ sub overview { my @summary_parts; if (@$groups) { # use groups if present - push(@summary_parts, - map { ($self->link_to($_->name => $self->url_for('group_overview', groupid => $_->id)), ', ') } @$groups); + push(@summary_parts, map { ($self->link_to($_->name => $self->url_for('group_overview', groupid => $_->id)), ', ') } @$groups); pop(@summary_parts); } else { diff --git a/lib/OpenQA/WebAPI/Plugin/AMQP.pm b/lib/OpenQA/WebAPI/Plugin/AMQP.pm index a3aae9aac1a9..4b84b3282be9 100644 --- a/lib/OpenQA/WebAPI/Plugin/AMQP.pm +++ b/lib/OpenQA/WebAPI/Plugin/AMQP.pm @@ -71,8 +71,7 @@ sub publish_amqp ($self, $topic, $event_data, $headers = {}, $remaining_attempts $remaining_attempts //= $config->{publish_attempts}; $retry_delay //= $config->{publish_retry_delay}; - $publisher->publish_p($event_data, $headers, routing_key => $topic)->then(sub { log_debug "$topic published" }) - ->catch( + $publisher->publish_p($event_data, $headers, routing_key => $topic)->then(sub { log_debug "$topic published" })->catch( sub ($error) { my $left = looks_like_number $remaining_attempts && $remaining_attempts > 1 ? $remaining_attempts - 1 : 0; my $delay = $retry_delay * $config->{publish_retry_delay_factor}; diff --git a/lib/OpenQA/WebAPI/Plugin/AuditLog.pm b/lib/OpenQA/WebAPI/Plugin/AuditLog.pm index 36c0974c6f87..811a532a6656 100644 --- a/lib/OpenQA/WebAPI/Plugin/AuditLog.pm +++ b/lib/OpenQA/WebAPI/Plugin/AuditLog.pm @@ -43,8 +43,7 @@ sub register { # log restart my $schema = $app->schema; my $user = $schema->resultset('Users')->find({username => 'system'}); - $schema->resultset('AuditEvents') - ->create({user_id => $user->id, connection_id => 0, event => 'startup', event_data => 'openQA restarted'}); + $schema->resultset('AuditEvents')->create({user_id => $user->id, connection_id => 0, event => 'startup', event_data => 'openQA restarted'}); } # table events diff --git a/lib/OpenQA/WebAPI/Plugin/Helpers.pm b/lib/OpenQA/WebAPI/Plugin/Helpers.pm index 18b7f2c24103..8250fdef486e 100644 --- a/lib/OpenQA/WebAPI/Plugin/Helpers.pm +++ b/lib/OpenQA/WebAPI/Plugin/Helpers.pm @@ -77,8 +77,7 @@ sub register ($self, $app, $config) { stepaction_for => sub { my ($c, $title, $url, $icon, $class) = @_; $class //= ''; - my $icons = $c->t(i => (class => "step_action fa $icon fa-lg fa-stack-1x")) - . $c->t(i => (class => 'new fa fa-plus fa-stack-1x')); + my $icons = $c->t(i => (class => "step_action fa $icon fa-lg fa-stack-1x")) . $c->t(i => (class => 'new fa fa-plus fa-stack-1x')); my $content = $c->t(span => (class => 'fa-stack') => sub { $icons }); return $c->link_to($url => (title => $title, class => $class) => sub { $content }); }); @@ -119,8 +118,8 @@ sub register ($self, $app, $config) { $query{groupid} = $group_id; $crumbs .= "\n
  • "; $crumbs - .= $c->link_to($c->url_for('group_overview', groupid => $group_id) => (class => 'dropdown-item') => - sub { return $job->group->name . ' (current)' }); + .= $c->link_to( + $c->url_for('group_overview', groupid => $group_id) => (class => 'dropdown-item') => sub { return $job->group->name . ' (current)' }); $crumbs .= "
  • "; $overview_text = 'Build ' . $job->BUILD; } @@ -130,8 +129,7 @@ sub register ($self, $app, $config) { my $overview_url = $c->url_for('tests_overview')->query(%query); $crumbs .= "\n
  • "; - $crumbs .= $c->link_to($overview_url => (class => 'dropdown-item') => - sub { ' ' . $overview_text }); + $crumbs .= $c->link_to($overview_url => (class => 'dropdown-item') => sub { ' ' . $overview_text }); $crumbs .= "
  • "; $crumbs .= "\n\n"; return Mojo::ByteStream->new($crumbs); @@ -183,14 +181,10 @@ sub register ($self, $app, $config) { # Examples: # help_popover 'Help for me' => 'This is me' # help_popover 'Help for button' => 'Do not press this button!', 'http://nuke.me' => 'Nuke' - help_popover => - sub ($c, $title, $content, $details_url = undef, $details_text = undef, $placement = undef, @args) { + help_popover => sub ($c, $title, $content, $details_url = undef, $details_text = undef, $placement = undef, @args) { my $class = 'help_popover fa fa-question-circle'; if ($details_url) { - $content - .= '

    See ' - . $c->link_to($details_text ? $details_text : here => $details_url, target => 'blank') - . ' for details

    '; + $content .= '

    See ' . $c->link_to($details_text ? $details_text : here => $details_url, target => 'blank') . ' for details

    '; } my $data = {toggle => 'popover', trigger => 'focus', title => $title, content => $content}; $data->{placement} = $placement if $placement; diff --git a/lib/OpenQA/WebAPI/Plugin/ObsRsync.pm b/lib/OpenQA/WebAPI/Plugin/ObsRsync.pm index 6ac8edd5317d..18ddc0081b4b 100644 --- a/lib/OpenQA/WebAPI/Plugin/ObsRsync.pm +++ b/lib/OpenQA/WebAPI/Plugin/ObsRsync.pm @@ -29,10 +29,8 @@ sub register_common_routes { $prefix .= $suffix . '_' if $suffix; # These routes will be as well accessible without authorization!! - $r->get('/obs_rsync/#alias/latest_test')->name($prefix . 'latest_test') - ->to('Plugin::ObsRsync::Controller::Folders#test_result'); - $r->get('/obs_rsync/#alias/test_result')->name($prefix . 'test_result') - ->to('Plugin::ObsRsync::Controller::Folders#test_result'); + $r->get('/obs_rsync/#alias/latest_test')->name($prefix . 'latest_test')->to('Plugin::ObsRsync::Controller::Folders#test_result'); + $r->get('/obs_rsync/#alias/test_result')->name($prefix . 'test_result')->to('Plugin::ObsRsync::Controller::Folders#test_result'); } sub register { @@ -97,25 +95,21 @@ sub register { $app->helper('obs_rsync.unlock' => \&_unlock); # Templates - push @{$app->renderer->paths}, - Mojo::File->new(__FILE__)->dirname->child('ObsRsync')->child('templates')->to_string; + push @{$app->renderer->paths}, Mojo::File->new(__FILE__)->dirname->child('ObsRsync')->child('templates')->to_string; # terminology: # * project - Obs Project name alone, e.g. 'openSUSE:Factory:ToTest' -# * batch - abstraction used by openqa-trigger-from-obs to split actions, needed to be taken when Obs Project is ready for testing, + # * batch - abstraction used by openqa-trigger-from-obs to split actions, needed to be taken when Obs Project is ready for testing, # e.g. 'base, 'jeos', 'migration'. # * alias - Obs Project name alone or with corresponding batch concatenated with '|': 'projectname|batchname' # e.g. 'openSUSE:Factory:ToTest|base', 'openSUSE:Factory:ToTest|microos', 'openSUSE:Factory:ToTest|jeos' - # * subfolder - folder, containing artifacts from paricular synch actions. Most often if form `.run_YYYYMMDDhhmmss`. + # * subfolder - folder, containing artifacts from paricular synch actions. Most often if form `.run_YYYYMMDDhhmmss`. # - # routes which have parameter #alias, can be called for simple project, for batched project or for particular batch + # routes which have parameter #alias, can be called for simple project, for batched project or for particular batch # routes which have parameter #project, can not be called for single batch - $plugin_r->get('/obs_rsync/queue')->name('plugin_obs_rsync_queue') - ->to('Plugin::ObsRsync::Controller::Gru#index'); - $plugin_r->post('/obs_rsync/#project/runs')->name('plugin_obs_rsync_queue_run') - ->to('Plugin::ObsRsync::Controller::Gru#run'); - $plugin_r->get('/obs_rsync/#project/dirty_status')->name('plugin_obs_rsync_get_dirty_status') - ->to('Plugin::ObsRsync::Controller::Gru#get_dirty_status'); + $plugin_r->get('/obs_rsync/queue')->name('plugin_obs_rsync_queue')->to('Plugin::ObsRsync::Controller::Gru#index'); + $plugin_r->post('/obs_rsync/#project/runs')->name('plugin_obs_rsync_queue_run')->to('Plugin::ObsRsync::Controller::Gru#run'); + $plugin_r->get('/obs_rsync/#project/dirty_status')->name('plugin_obs_rsync_get_dirty_status')->to('Plugin::ObsRsync::Controller::Gru#get_dirty_status'); $plugin_r->post('/obs_rsync/#project/dirty_status')->name('plugin_obs_rsync_update_dirty_status') ->to('Plugin::ObsRsync::Controller::Gru#update_dirty_status'); $plugin_r->get('/obs_rsync/#alias/obs_builds_text')->name('plugin_obs_rsync_get_builds_text') @@ -125,20 +119,13 @@ sub register { $plugin_r->get('/obs_rsync/#alias/runs/#subfolder/download/#filename')->name('plugin_obs_rsync_download_file') ->to('Plugin::ObsRsync::Controller::Folders#download_file'); - $plugin_r->get('/obs_rsync/#alias/runs/#subfolder')->name('plugin_obs_rsync_run') - ->to('Plugin::ObsRsync::Controller::Folders#run'); - $plugin_r->get('/obs_rsync/#alias/runs')->name('plugin_obs_rsync_runs') - ->to('Plugin::ObsRsync::Controller::Folders#runs'); - $plugin_r->get('/obs_rsync/#alias')->name('plugin_obs_rsync_folder') - ->to('Plugin::ObsRsync::Controller::Folders#folder'); - $plugin_r->get('/obs_rsync/')->name('plugin_obs_rsync_index') - ->to('Plugin::ObsRsync::Controller::Folders#index'); - $plugin_r->get('/obs_rsync_list')->name('plugin_obs_rsync_list') - ->to('Plugin::ObsRsync::Controller::Folders#list'); - $plugin_r->get('/obs_rsync/#alias/run_last')->name('plugin_obs_rsync_get_run_last') - ->to('Plugin::ObsRsync::Controller::Folders#get_run_last'); - $plugin_r->post('/obs_rsync/#alias/run_last')->name('plugin_obs_rsync_forget_run_last') - ->to('Plugin::ObsRsync::Controller::Folders#forget_run_last'); + $plugin_r->get('/obs_rsync/#alias/runs/#subfolder')->name('plugin_obs_rsync_run')->to('Plugin::ObsRsync::Controller::Folders#run'); + $plugin_r->get('/obs_rsync/#alias/runs')->name('plugin_obs_rsync_runs')->to('Plugin::ObsRsync::Controller::Folders#runs'); + $plugin_r->get('/obs_rsync/#alias')->name('plugin_obs_rsync_folder')->to('Plugin::ObsRsync::Controller::Folders#folder'); + $plugin_r->get('/obs_rsync/')->name('plugin_obs_rsync_index')->to('Plugin::ObsRsync::Controller::Folders#index'); + $plugin_r->get('/obs_rsync_list')->name('plugin_obs_rsync_list')->to('Plugin::ObsRsync::Controller::Folders#list'); + $plugin_r->get('/obs_rsync/#alias/run_last')->name('plugin_obs_rsync_get_run_last')->to('Plugin::ObsRsync::Controller::Folders#get_run_last'); + $plugin_r->post('/obs_rsync/#alias/run_last')->name('plugin_obs_rsync_forget_run_last')->to('Plugin::ObsRsync::Controller::Folders#forget_run_last'); $self->register_common_routes($plugin_r); # we create the common routes without authentication as well @@ -151,10 +138,8 @@ sub register { $app->log->error('API routes not configured, plugin ObsRsync will not have API configured') unless $plugin_r; } else { - $plugin_api_r->get('/obs_rsync')->name('plugin_obs_rsync_api_list') - ->to('Plugin::ObsRsync::Controller::Folders#list'); - $plugin_api_r->put('/obs_rsync/#project/runs')->name('plugin_obs_rsync_api_run') - ->to('Plugin::ObsRsync::Controller::Gru#run'); + $plugin_api_r->get('/obs_rsync')->name('plugin_obs_rsync_api_list')->to('Plugin::ObsRsync::Controller::Folders#list'); + $plugin_api_r->put('/obs_rsync/#project/runs')->name('plugin_obs_rsync_api_run')->to('Plugin::ObsRsync::Controller::Gru#run'); $self->register_common_routes($plugin_api_r, 'api'); } @@ -274,8 +259,9 @@ sub _get_version_test_id { my ($c, $project, $version) = @_; return undef unless $version; my $home = $c->obs_rsync->home; - my $runs = Mojo::File->new($home, $project)->list({dir => 1, hidden => 1})->map('basename')->grep(qr/\.run_.*/) - ->grep(qr/_$version$/)->sort(sub { $b cmp $a })->to_array; + my $runs + = Mojo::File->new($home, $project)->list({dir => 1, hidden => 1})->map('basename')->grep(qr/\.run_.*/)->grep(qr/_$version$/)->sort(sub { $b cmp $a }) + ->to_array; return undef unless $runs && @$runs; return _read_test_id(Mojo::File->new($home, $project, $runs->[0])); } diff --git a/lib/OpenQA/WebAPI/Plugin/ObsRsync/Controller/Folders.pm b/lib/OpenQA/WebAPI/Plugin/ObsRsync/Controller/Folders.pm index c501924a5ea7..f0fca6c4f687 100644 --- a/lib/OpenQA/WebAPI/Plugin/ObsRsync/Controller/Folders.pm +++ b/lib/OpenQA/WebAPI/Plugin/ObsRsync/Controller/Folders.pm @@ -32,9 +32,7 @@ sub index { my $helper = $self->obs_rsync; my %folder_info_by_name; if (!$folders) { - $folders - = Mojo::File->new($helper->home, $obs_project // '')->list({dir => 1})->grep(sub { -d $_ })->map('basename') - ->to_array; + $folders = Mojo::File->new($helper->home, $obs_project // '')->list({dir => 1})->grep(sub { -d $_ })->map('basename')->to_array; @$folders = grep { !/$non_project_folders/ } @$folders; } @@ -65,8 +63,7 @@ sub index { } if (!$obs_project) { - my $running_jobs = $self->app->minion->backend->list_jobs(0, undef, - {tasks => ['obs_rsync_run'], states => ['active', 'inactive']}); + my $running_jobs = $self->app->minion->backend->list_jobs(0, undef, {tasks => ['obs_rsync_run'], states => ['active', 'inactive']}); for my $job (@{$running_jobs->{jobs}}) { my $args = $job->{args}; diff --git a/lib/OpenQA/WebAPI/Plugin/ObsRsync/Controller/Gru.pm b/lib/OpenQA/WebAPI/Plugin/ObsRsync/Controller/Gru.pm index e2c75331012e..e39f03e20ec2 100644 --- a/lib/OpenQA/WebAPI/Plugin/ObsRsync/Controller/Gru.pm +++ b/lib/OpenQA/WebAPI/Plugin/ObsRsync/Controller/Gru.pm @@ -39,10 +39,7 @@ sub index { my $self = shift; my $helper = $self->obs_rsync; my %jobs; - my $results = $self->app->minion->backend->list_jobs( - 0, - 4 * $helper->queue_limit, - {tasks => ['obs_rsync_run'], states => ['active', 'inactive']}); + my $results = $self->app->minion->backend->list_jobs(0, 4 * $helper->queue_limit, {tasks => ['obs_rsync_run'], states => ['active', 'inactive']}); for my $job (@{$results->{jobs}}) { $jobs{$job->{id}} = _extend_job_info($job); @@ -109,10 +106,7 @@ sub run { my $app = $self->app; my $queue_limit = $helper->queue_limit; - my $results = $app->minion->backend->list_jobs( - 0, - 4 * $queue_limit, - {tasks => ['obs_rsync_run'], states => ['active', 'inactive']}); + my $results = $app->minion->backend->list_jobs(0, 4 * $queue_limit, {tasks => ['obs_rsync_run'], states => ['active', 'inactive']}); my $has_active_job = 0; for my $job (@{$results->{jobs}}) { diff --git a/lib/OpenQA/WebAPI/Plugin/ObsRsync/Task.pm b/lib/OpenQA/WebAPI/Plugin/ObsRsync/Task.pm index 06fe47914f09..56cd663d5ec2 100644 --- a/lib/OpenQA/WebAPI/Plugin/ObsRsync/Task.pm +++ b/lib/OpenQA/WebAPI/Plugin/ObsRsync/Task.pm @@ -22,8 +22,7 @@ sub _retry_or_finish { if !$retry_max_count || $job->retries < $retry_max_count; $helper->unlock($project) if $project; - return $job->finish( - {code => 2, message => "Exceeded retry count $retry_max_count. Consider job will be re-triggered later"}); + return $job->finish({code => 2, message => "Exceeded retry count $retry_max_count. Consider job will be re-triggered later"}); } sub run { diff --git a/lib/OpenQA/WebSockets/Controller/Worker.pm b/lib/OpenQA/WebSockets/Controller/Worker.pm index 044d74575093..1cbbfac6dd7e 100644 --- a/lib/OpenQA/WebSockets/Controller/Worker.pm +++ b/lib/OpenQA/WebSockets/Controller/Worker.pm @@ -84,8 +84,7 @@ sub _message { if (($worker_db->websocket_api_version || 0) != WEBSOCKET_API_VERSION) { log_warning("Received a message from an incompatible worker $worker_id"); $self->send({json => {type => 'incompatible'}}); - $self->finish( - 1008 => 'Connection terminated from WebSocket server - incompatible communication protocol version'); + $self->finish(1008 => 'Connection terminated from WebSocket server - incompatible communication protocol version'); return undef; } @@ -106,8 +105,7 @@ sub _message { try { $schema->txn_do( sub { - my @jobs = $schema->resultset('Jobs') - ->search({id => {-in => $job_ids}, assigned_worker_id => $worker_id, state => ASSIGNED}); + my @jobs = $schema->resultset('Jobs')->search({id => {-in => $job_ids}, assigned_worker_id => $worker_id, state => ASSIGNED}); $_->reschedule_state for @jobs; }); } @@ -131,8 +129,7 @@ sub _message { } # assume the job setup is done by the worker - $schema->resultset('Jobs')->search({id => $job_id, state => ASSIGNED, t_finished => undef}) - ->update({state => SETUP}); + $schema->resultset('Jobs')->search({id => $job_id, state => ASSIGNED, t_finished => undef})->update({state => SETUP}); # update the worker's current job, log that we 'saw' the worker $worker_db->update({job_id => $job_id, t_seen => now()}); @@ -156,8 +153,7 @@ sub _message { # (the status "working" is special because it will be sent immediately after a worker started a new job) my ($last_seen, $now) = ($worker_status->{last_seen}, time); if ($last_seen && ($last_seen + MIN_TIMER) > $now) { - log_info("Received worker $worker_id status too close to the last update," - . " websocket server possibly overloaded or worker misconfigured") + log_info("Received worker $worker_id status too close to the last update," . " websocket server possibly overloaded or worker misconfigured") if $current_worker_status ne 'working'; } $worker_status->{last_seen} = $now; @@ -232,8 +228,7 @@ sub _message { }; # consider the worker idle unless it claims to be broken or work on a job - $worker_status->{idle_despite_job_assignment} - = !$worker_is_broken && !defined $job_id && defined $current_job_id; + $worker_status->{idle_despite_job_assignment} = !$worker_is_broken && !defined $job_id && defined $current_job_id; } else { log_error(sprintf('Received unknown message type "%s" from worker %u', $message_type, $worker_status->{id})); diff --git a/lib/OpenQA/Worker.pm b/lib/OpenQA/Worker.pm index 5cb1b9e812de..f2544da9a8a2 100644 --- a/lib/OpenQA/Worker.pm +++ b/lib/OpenQA/Worker.pm @@ -39,8 +39,7 @@ use Mojo::File 'path'; use POSIX; use Try::Tiny; use Scalar::Util 'looks_like_number'; -use OpenQA::Constants - qw(WEBSOCKET_API_VERSION WORKER_COMMAND_QUIT WORKER_SR_BROKEN WORKER_SR_DONE WORKER_SR_DIED WORKER_SR_FINISH_OFF); +use OpenQA::Constants qw(WEBSOCKET_API_VERSION WORKER_COMMAND_QUIT WORKER_SR_BROKEN WORKER_SR_DONE WORKER_SR_DIED WORKER_SR_FINISH_OFF); use OpenQA::Client; use OpenQA::Log qw(log_error log_warning log_info log_debug add_log_channel remove_log_channel); use OpenQA::Utils qw(prjdir); diff --git a/lib/OpenQA/Worker/CommandHandler.pm b/lib/OpenQA/Worker/CommandHandler.pm index 86b37066b35d..3cc31661608f 100644 --- a/lib/OpenQA/Worker/CommandHandler.pm +++ b/lib/OpenQA/Worker/CommandHandler.pm @@ -79,17 +79,13 @@ sub handle_command { else { # ignore messages which belong to a job if (defined $job_id) { - log_warning("Ignoring WS message from $webui_host with type $type and job ID $job_id " - . "(currently not executing a job):\n" - . pp($json)); + log_warning("Ignoring WS message from $webui_host with type $type and job ID $job_id " . "(currently not executing a job):\n" . pp($json)); return undef; } } # verify that the web UI host for the job ID matches as well if ($job_id && $webui_host ne $current_webui_host) { - log_warning( - "Ignoring job-specific WS message from $webui_host; currently occupied by $current_webui_host:\n" - . pp($json)); + log_warning("Ignoring job-specific WS message from $webui_host; currently occupied by $current_webui_host:\n" . pp($json)); return undef; } } @@ -231,15 +227,12 @@ sub _handle_command_grab_jobs { my $job_data = $job_info->{data}; my $job_sequence = $job_info->{sequence}; if (ref($job_data) ne 'HASH') { - log_error( - "Refusing to grab jobs from $webui_host: the provided job info lacks job data or execution sequence: " - . pp($job_info)); + log_error("Refusing to grab jobs from $webui_host: the provided job info lacks job data or execution sequence: " . pp($job_info)); return undef; } my @job_ids_to_grab = keys %$job_data; if (ref($job_sequence) ne 'ARRAY') { - log_error( - "Refusing to grab jobs from $webui_host: the provided job info lacks execution sequence: " . pp($job_info)); + log_error("Refusing to grab jobs from $webui_host: the provided job info lacks execution sequence: " . pp($job_info)); $client->reject_jobs(\@job_ids_to_grab, 'job info lacks execution sequence'); return undef; } diff --git a/lib/OpenQA/Worker/Engines/isotovideo.pm b/lib/OpenQA/Worker/Engines/isotovideo.pm index 4f6df679cc0b..a54142d330ba 100644 --- a/lib/OpenQA/Worker/Engines/isotovideo.pm +++ b/lib/OpenQA/Worker/Engines/isotovideo.pm @@ -7,8 +7,7 @@ use Mojo::Base -base, -signatures; use Mojo::Base -signatures; use OpenQA::Constants qw(WORKER_SR_DONE WORKER_EC_CACHE_FAILURE WORKER_EC_ASSET_FAILURE WORKER_SR_DIED); use OpenQA::Log qw(log_error log_info log_debug log_warning get_channel_handle format_settings); -use OpenQA::Utils - qw(asset_type_from_setting base_host locate_asset looks_like_url_with_scheme testcasedir productdir needledir); +use OpenQA::Utils qw(asset_type_from_setting base_host locate_asset looks_like_url_with_scheme testcasedir productdir needledir); use POSIX qw(:sys_wait_h strftime uname _exit); use Mojo::JSON 'encode_json'; # booleans use Cpanel::JSON::XS (); @@ -88,8 +87,7 @@ sub _poll_cache_service ($job, $cache_client, $request, $delay, $callback) { return $callback->({error => 'Status updates interrupted'}, undef) unless $job->post_setup_status; my $status = $cache_client->status($request); - return Mojo::IOLoop->singleton->timer( - $delay => sub { _poll_cache_service($job, $cache_client, $request, $delay, $callback) }) + return Mojo::IOLoop->singleton->timer($delay => sub { _poll_cache_service($job, $cache_client, $request, $delay, $callback) }) if !$status->is_processed && !$status->has_error; return $callback->({error => 'Job has been cancelled'}, undef) if $job->is_stopped_or_stopping; return $callback->({error => $status->error}, undef) if $status->has_error; @@ -123,12 +121,10 @@ sub cache_assets ($cache_client, $job, $vars, $assets_to_cache, $assetkeys, $web $asset_request, CACHE_SERVICE_POLL_DELAY, sub ($error, $status) { - $error - = _handle_asset_processed($cache_client, $this_asset, $asset_uri, $status, $vars, $webui_host, $pooldir) + $error = _handle_asset_processed($cache_client, $this_asset, $asset_uri, $status, $vars, $webui_host, $pooldir) unless $error; return $callback->($error) if $error; - return cache_assets($cache_client, $job, $vars, $assets_to_cache, $assetkeys, $webui_host, $pooldir, - $callback); + return cache_assets($cache_client, $job, $vars, $assets_to_cache, $assetkeys, $webui_host, $pooldir, $callback); }); } @@ -243,8 +239,7 @@ sub sync_tests ($cache_client, $job, $vars, $shared_cache, $rsync_source, $remai } elsif ($remaining_tries > 1 && ($exit_code && $rsync_retry_code{$exit_code})) { log_info("$rsync_retry_code{$exit_code} ($result), trying again", channels => 'autoinst'); - return sync_tests($cache_client, $job, $vars, $shared_cache, $rsync_source, $remaining_tries - 1, - $callback); + return sync_tests($cache_client, $job, $vars, $shared_cache, $rsync_source, $remaining_tries - 1, $callback); } else { my $error_msg = "Failed to rsync tests: $result"; @@ -290,8 +285,7 @@ sub engine_workit ($job, $callback) { my ($sysname, $hostname, $release, $version, $machine) = POSIX::uname(); log_info('+++ setup notes +++', channels => 'autoinst'); - log_info(sprintf("Running on $hostname:%d ($sysname $release $version $machine)", $instance), - channels => 'autoinst'); + log_info(sprintf("Running on $hostname:%d ($sysname $release $version $machine)", $instance), channels => 'autoinst'); log_error("Failed enabling subreaper mode", channels => 'autoinst') unless session->subreaper; @@ -379,8 +373,7 @@ sub _configure_cgroupv2 ($job_info) { $cgroup = c(); chomp $error; log_warning("Disabling cgroup usage because cgroup creation failed: $error"); - log_info( - 'You can define a custom slice with OPENQA_CGROUP_SLICE or indicating the base mount with MOJO_CGROUP_FS.'); + log_info('You can define a custom slice with OPENQA_CGROUP_SLICE or indicating the base mount with MOJO_CGROUP_FS.'); } return $cgroup; } @@ -500,10 +493,8 @@ sub _engine_workit_step_2 ($job, $job_settings, $vars, $shared_cache, $callback) eval { log_debug('Registered process:' . shift->pid, channels => 'worker'); }; }); - my $container - = container(clean_cgroup => 1, pre_migrate => 1, cgroups => $cgroup, process => $child, subreaper => 0); - $container->on( - container_error => sub { shift; my $e = shift; log_error("Container error: @{$e}", channels => 'worker') }); + my $container = container(clean_cgroup => 1, pre_migrate => 1, cgroups => $cgroup, process => $child, subreaper => 0); + $container->on(container_error => sub { shift; my $e = shift; log_error("Container error: @{$e}", channels => 'worker') }); log_info('Starting isotovideo container'); $container->start(); diff --git a/lib/OpenQA/Worker/Job.pm b/lib/OpenQA/Worker/Job.pm index 5b8fa8bc1392..083c7631b690 100644 --- a/lib/OpenQA/Worker/Job.pm +++ b/lib/OpenQA/Worker/Job.pm @@ -175,8 +175,7 @@ sub accept { my $webui_host = $client->webui_host; return $self->_set_status( stopped => { - error_message => - "Unable to accept job $id because the websocket connection to $webui_host has been lost.", + error_message => "Unable to accept job $id because the websocket connection to $webui_host has been lost.", reason => WORKER_SR_API_FAILURE, }); } @@ -275,8 +274,7 @@ sub start { # start isotovideo # FIXME: isotovideo.pm could be a class inheriting from Job.pm or simply be merged - return OpenQA::Worker::Engines::isotovideo::engine_workit($self, - sub ($engine) { $self->_handle_engine_startup($engine, $max_job_time) }); + return OpenQA::Worker::Engines::isotovideo::engine_workit($self, sub ($engine) { $self->_handle_engine_startup($engine, $max_job_time) }); } sub _handle_engine_startup ($self, $engine, $max_job_time) { @@ -363,8 +361,7 @@ sub stop ($self, $reason = undef) { sub { my ($params_for_finalize, $duplication_res) = @_; my $duplication_failed = defined $duplication_res && !$duplication_res; - $self->_stop_step_5_finalize($duplication_failed ? WORKER_SR_API_FAILURE : $reason, - $params_for_finalize); + $self->_stop_step_5_finalize($duplication_failed ? WORKER_SR_API_FAILURE : $reason, $params_for_finalize); }); }); }); @@ -593,8 +590,7 @@ sub _format_reason ($self, $state, $result, $reason) { # when a job is incomplete with an unknown QEMU issue, # we parse the autoinst-log to get more details in some scenario. - my @match_content - = ('Failed to allocate KVM .* Cannot allocate memory', 'Could not find .*smbd.*please install it'); + my @match_content = ('Failed to allocate KVM .* Cannot allocate memory', 'Could not find .*smbd.*please install it'); if ($reason =~ /backend died: QEMU exited unexpectedly|backend died: QEMU terminated/) { my $msg = $self->_parse_log_file(join('|', @match_content)); $reason = "QEMU terminated$msg, see log output of details" if $msg; @@ -819,8 +815,7 @@ sub _upload_results_step_0_prepare { $status{log} = $self->_log_snippet("$pool_directory/autoinst-log.txt", 'autoinst_log_offset'); $status{serial_log} = $self->_log_snippet("$pool_directory/serial0", 'serial_log_offset'); $status{serial_terminal} = $self->_log_snippet("$pool_directory/virtio_console.log", 'serial_terminal_offset'); - $status{serial_terminal_user} - = $self->_log_snippet("$pool_directory/virtio_console_user.log", 'serial_terminal_user_offset'); + $status{serial_terminal_user} = $self->_log_snippet("$pool_directory/virtio_console_user.log", 'serial_terminal_user_offset'); if (my $screen = $self->_read_last_screen) { $status{screen} = $screen; } @@ -842,8 +837,7 @@ sub _upload_results_step_0_prepare { log_error('Unable to make final image uploads. Maybe the web UI considers this job already dead.'); } else { - log_error('Aborting job because web UI doesn\'t accept new images anymore' - . ' (likely considers this job dead)'); + log_error('Aborting job because web UI doesn\'t accept new images anymore' . ' (likely considers this job dead)'); $self->stop(WORKER_SR_API_FAILURE); } $self->{_result_upload_error} = 'Unable to upload images: posting status failed'; diff --git a/lib/OpenQA/Worker/WebUIConnection.pm b/lib/OpenQA/Worker/WebUIConnection.pm index 137e14728b5f..62b96aa185bf 100644 --- a/lib/OpenQA/Worker/WebUIConnection.pm +++ b/lib/OpenQA/Worker/WebUIConnection.pm @@ -100,8 +100,7 @@ sub register ($self) { $error_message = "Failed to register at $webui_host - $error_class: $error_message"; my $status = (defined $error_code && $error_code =~ /^4\d\d$/ ? 'disabled' : 'failed'); $status = 'failed' - if $error_message - =~ /timestamp mismatch - check whether clocks on the local host and the web UI host are in sync/; + if $error_message =~ /timestamp mismatch - check whether clocks on the local host and the web UI host are in sync/; $self->{_last_error} = $error_message; $self->_set_status($status => {error_message => $error_message}); return undef; @@ -109,8 +108,7 @@ sub register ($self) { my $worker_id = $json_res->{id}; $self->worker_id($worker_id); if (!defined $worker_id) { - $self->_set_status( - disabled => {error_message => "Failed to register at $webui_host: host did not return a worker ID"}); + $self->_set_status(disabled => {error_message => "Failed to register at $webui_host: host did not return a worker ID"}); return undef; } @@ -123,7 +121,7 @@ sub _setup_websocket_connection ($self, $websocket_url = undef) { # prevent messing around when there's still an active websocket connection return undef if $self->websocket_connection; - # make URL for websocket connection unless specified as argument (which would be the case when following redirection) + # make URL for websocket connection unless specified as argument (which would be the case when following redirection) if (!$websocket_url) { my $worker_id = $self->worker_id; my $webui_host = $self->webui_host; @@ -188,8 +186,7 @@ sub _setup_websocket_connection ($self, $websocket_url = undef) { $self->websocket_connection(undef)->_set_status( # uncoverable statement failed => { - error_message => - "Websocket connection to $websocket_url finished by remote side with code $code, $reason" + error_message => "Websocket connection to $websocket_url finished by remote side with code $code, $reason" }); # note: The worker is supposed to handle this event and e.g. try to re-register again. @@ -397,8 +394,7 @@ sub quit ($self, $callback) { sub reject_jobs ($self, $job_ids, $reason, $callback = undef) { # send rejection message via web sockets if connected my $websocket_connection = $self->websocket_connection; - return $websocket_connection->send({json => {type => 'rejected', job_ids => $job_ids, reason => $reason}}, - $callback) + return $websocket_connection->send({json => {type => 'rejected', job_ids => $job_ids, reason => $reason}}, $callback) if defined $websocket_connection; # try sending the message when the web socket connection becomes available again diff --git a/script/client b/script/client index 03ca2fff4e7d..96df63dea0f6 100755 --- a/script/client +++ b/script/client @@ -170,9 +170,8 @@ sub usage($) { } GetOptions( - \%options, 'host=s', 'apibase=s', 'json-output', - 'verbose|v', 'apikey:s', 'apisecret:s', 'params=s', - 'form', 'json-data:s', 'help|h|?', 'archive|a:s', + \%options, 'host=s', 'apibase=s', 'json-output', 'verbose|v', 'apikey:s', + 'apisecret:s', 'params=s', 'form', 'json-data:s', 'help|h|?', 'archive|a:s', 'asset-size-limit:i', 'with-thumbnails', 'accept=s', 'yaml-output', ) or usage(1); diff --git a/script/openqa-clone-job b/script/openqa-clone-job index 9cb149c7e3db..ed8f082df1ff 100755 --- a/script/openqa-clone-job +++ b/script/openqa-clone-job @@ -198,11 +198,10 @@ sub usage ($r) { sub parse_options () { GetOptions( - \%options, "from=s", "host=s", "dir=s", - "apikey:s", "apisecret:s", "verbose|v", "json-output|j", - "skip-deps", "skip-chained-deps", "skip-download", "parental-inheritance", - "help|h", "show-progress", "within-instance|w=s", "clone-children", - "max-depth:i", "repeat|r:i", "ignore-missing-assets", "export-command", + \%options, "from=s", "host=s", "dir=s", "apikey:s", "apisecret:s", + "verbose|v", "json-output|j", "skip-deps", "skip-chained-deps", "skip-download", "parental-inheritance", + "help|h", "show-progress", "within-instance|w=s", "clone-children", "max-depth:i", "repeat|r:i", + "ignore-missing-assets", "export-command", ) or usage(1); usage(0) if $options{help}; usage(1) if $options{help} || ($options{'within-instance'} && $options{from}); diff --git a/script/openqa-dump-templates b/script/openqa-dump-templates index 3a8f7bf3745a..824825c5fbe1 100755 --- a/script/openqa-dump-templates +++ b/script/openqa-dump-templates @@ -118,11 +118,8 @@ sub usage ($r) { exit $r; } -GetOptions( - \%options, "json", "host=s", "apibase=s", "apikey:s", "apisecret:s", - "group=s@", "name=s@", "test=s@", "product=s@", "machine=s@", "full", - "help|h", -) or usage(1); +GetOptions(\%options, "json", "host=s", "apibase=s", "apikey:s", "apisecret:s", "group=s@", "name=s@", "test=s@", "product=s@", "machine=s@", "full", "help|h",) + or usage(1); usage(0) if $options{help}; diff --git a/script/openqa-load-templates b/script/openqa-load-templates index 66e5ace35142..3f700a68de6c 100755 --- a/script/openqa-load-templates +++ b/script/openqa-load-templates @@ -125,10 +125,7 @@ sub post_entry ($table, $entry) { # Post the job template YAML my $job_templates_url = $url->clone->path($options{apibase} . '/job_templates_scheduling'); - $res - = $client->post($job_templates_url, - form => {name => $entry->{group_name}, template => $entry->{template}, schema => 'JobTemplates-01.yaml'}) - ->res; + $res = $client->post($job_templates_url, form => {name => $entry->{group_name}, template => $entry->{template}, schema => 'JobTemplates-01.yaml'})->res; print_error $res unless $res->is_success; return 1; } @@ -179,8 +176,7 @@ sub post_entry ($table, $entry) { if (!$options{clean}) { # with --clean the entry should not exist at this point, no need to check my $res = $client->get($table_url->clone, form => \%param)->res; if ($res->is_success && @{$res->json->{$table}} > 0 && $res->json->{$table}[0]{id}) { - if ($options{update} && $table ne 'JobTemplates') - { # there is nothing to update in JobTemplates, the entry just exists or not + if ($options{update} && $table ne 'JobTemplates') { # there is nothing to update in JobTemplates, the entry just exists or not my $id = $res->json->{$table}[0]{id}; my $table_url_id = $url->clone->path($options{apibase} . '/' . decamelize($table) . "/$id"); my $res = $client->put($table_url_id, form => \%param)->res; diff --git a/script/worker b/script/worker index 314604728f23..b8cf0a3577ab 100755 --- a/script/worker +++ b/script/worker @@ -104,10 +104,7 @@ sub usage($) { } } -GetOptions( - \%options, "no-cleanup", "instance=i", "isotovideo=s", "host=s", "apikey:s", - "apisecret:s", "verbose|v|debug|d", "help|h", -) or usage(1); +GetOptions(\%options, "no-cleanup", "instance=i", "isotovideo=s", "host=s", "apikey:s", "apisecret:s", "verbose|v|debug|d", "help|h",) or usage(1); usage(0) if ($options{help}); diff --git a/t/01-style.t b/t/01-style.t index a50cc6719dd9..d6cc068beed7 100755 --- a/t/01-style.t +++ b/t/01-style.t @@ -4,20 +4,14 @@ use Test::Most; -ok system(qq{git grep -I -l 'Copyright \((C)\|(c)\|©\)' ':!COPYING' ':!external/'}) != 0, - 'No redundant copyright character'; -ok - system( -qq{git grep -I -l 'This program is free software.*if not, see sub { # Give Utils.pm a chance to install $SIG{CHLD} sleep 1; # uncoverable statement OpenQA::Test::Utils::_setup_sub_process 'test-process-1'; # uncoverable statement - '' . undef; # uncoverable statement: provoke Perl warning "Use of uninitialized value in concatenation …" + '' . undef; # uncoverable statement: provoke Perl warning "Use of uninitialized value in concatenation …" }; note "waiting at most $signal_timeout seconds for SIGCHLD (sleep is supposed to be interrupted by SIGCHLD)"; sleep $signal_timeout; }; - like $out, - qr/Stopping test-process-1 process because a Perl warning occurred: Use of uninitialized value in concatenation/, - 'warning logged'; + like $out, qr/Stopping test-process-1 process because a Perl warning occurred: Use of uninitialized value in concatenation/, 'warning logged'; ok($test_would_have_failed, 'test would have failed'); # stop the process via stop_service diff --git a/t/03-auth.t b/t/03-auth.t index 99ad19a3fade..16543d5c7b12 100644 --- a/t/03-auth.t +++ b/t/03-auth.t @@ -33,8 +33,7 @@ sub test_auth_method_startup ($auth, @options) { sub mojo_has_request_debug { $Mojolicious::VERSION <= 9.21 } -combined_like { test_auth_method_startup('Fake')->status_is(302) } mojo_has_request_debug ? qr/302 Found/ : qr//, - 'Plugin loaded'; +combined_like { test_auth_method_startup('Fake')->status_is(302) } mojo_has_request_debug ? qr/302 Found/ : qr//, 'Plugin loaded'; subtest OpenID => sub { # OpenID relies on external server which we mock to not rely on external dependencies @@ -134,7 +133,6 @@ subtest OAuth2 => sub { }; }; -throws_ok { test_auth_method_startup('nonexistant') } qr/Unable to load auth module/, - 'refused to start with non existent auth module'; +throws_ok { test_auth_method_startup('nonexistant') } qr/Unable to load auth module/, 'refused to start with non existent auth module'; done_testing; diff --git a/t/04-scheduler.t b/t/04-scheduler.t index 7d1e76c2cb89..4100a0a3ae07 100644 --- a/t/04-scheduler.t +++ b/t/04-scheduler.t @@ -301,8 +301,7 @@ subtest 'job grab (failed to send job to worker)' => sub { $ws_send_error = 'fake error'; my $allocated; - combined_like { $allocated = OpenQA::Scheduler::Model::Jobs->singleton->schedule() } qr/reason: fake error/, - 'error logged'; + combined_like { $allocated = OpenQA::Scheduler::Model::Jobs->singleton->schedule() } qr/reason: fake error/, 'error logged'; $worker_db_obj->discard_changes; is_deeply($allocated, [], 'no workers/jobs allocated'); }; @@ -369,8 +368,7 @@ subtest 'scheduler limits' => sub { my $free_workers = OpenQA::Scheduler::Model::Jobs::determine_free_workers(); my %rejected; for my $jobinfo (values %$scheduled_jobs) { - $jobinfo->{matching_workers} - = OpenQA::Scheduler::Model::Jobs::_matching_workers($jobinfo, $free_workers, \%rejected); + $jobinfo->{matching_workers} = OpenQA::Scheduler::Model::Jobs::_matching_workers($jobinfo, $free_workers, \%rejected); } my $expected = {atari => 3, c64 => 3, quantum => 3}; is_deeply \%rejected, $expected, 'Rejected worker classes statistics like expected'; @@ -378,9 +376,7 @@ subtest 'scheduler limits' => sub { my $log = ''; $log_mock->redefine(log_debug => sub { $log .= "$_[0]\n" }); $scheduler->schedule; - like $log, - qr/Skipping 9 jobs because of no free workers for requested worker classes .atari:3,c64:3,quantum:3./, - 'Log message about rejected jobs'; + like $log, qr/Skipping 9 jobs because of no free workers for requested worker classes .atari:3,c64:3,quantum:3./, 'Log message about rejected jobs'; }; $jobs->find($_->id)->delete for @jobs; @@ -541,8 +537,7 @@ subtest 'allocating network' => sub { # causing it and what behavior would make most sense in that situation. my $jobs_mock = Test::MockModule->new('OpenQA::Schema::Result::Jobs'); $jobs_mock->redefine(_find_network => undef); - throws_ok { $job->prepare_for_work($worker) } qr/unable to alloc.*foo.*already exists/i, - 'explicit error if network to be created already exists'; + throws_ok { $job->prepare_for_work($worker) } qr/unable to alloc.*foo.*already exists/i, 'explicit error if network to be created already exists'; $networks = _get_job_networks($job_networks); is_deeply $networks, \@expected_networks, 'still only 2 job networks' or diag explain $networks; }; diff --git a/t/05-scheduler-cancel.t b/t/05-scheduler-cancel.t index dafbe88054a0..c869a379da98 100644 --- a/t/05-scheduler-cancel.t +++ b/t/05-scheduler-cancel.t @@ -117,8 +117,7 @@ my $ret = $schema->resultset('Jobs')->cancel_by_settings($form); is($ret, 3, "two jobs cancelled by hash"); $job = job_get(99963); is($job->reason, 'cancelled based on job settings', "jobs reason points to settings"); -is_deeply(OpenQA::Test::Case::find_most_recent_event($schema, 'job_cancel_by_settings'), - $form, 'Cancellation was logged with settings'); +is_deeply(OpenQA::Test::Case::find_most_recent_event($schema, 'job_cancel_by_settings'), $form, 'Cancellation was logged with settings'); $job = $new_job; @@ -163,8 +162,7 @@ lj; $form = {ISO => 'openSUSE-13.1-GNOME-Live-i686-Build0091-Media.iso'}; $ret = $schema->resultset('Jobs')->cancel_by_settings($form); is($ret, 1, "one job cancelled by iso"); -is_deeply(OpenQA::Test::Case::find_most_recent_event($schema, 'job_cancel_by_settings'), - $form, 'Cancellation was logged with settings'); +is_deeply(OpenQA::Test::Case::find_most_recent_event($schema, 'job_cancel_by_settings'), $form, 'Cancellation was logged with settings'); $job = job_get(99927); is($job->state, 'scheduled', "unrelated job 99927 still scheduled"); @@ -276,8 +274,7 @@ subtest 'parallel parent fails -> children are cancelled (parallel_failed)' => s my $w2 = $workers->find($c->_register($schema, 'host', '2', \%workercaps)); my $w3 = $workers->find($c->_register($schema, 'host', '3', \%workercaps)); for my $job_and_worker ([$jobA, $w1], [$jobB, $w2], [$jobC, $w3]) { - $job_and_worker->[0] - ->update({state => OpenQA::Jobs::Constants::RUNNING, assigned_worker_id => $job_and_worker->[1]->id}); + $job_and_worker->[0]->update({state => OpenQA::Jobs::Constants::RUNNING, assigned_worker_id => $job_and_worker->[1]->id}); $job_and_worker->[1]->update({job_id => $job_and_worker->[0]->id}); } diff --git a/t/05-scheduler-capabilities.t b/t/05-scheduler-capabilities.t index 2d74901ac77a..cd23cd349179 100644 --- a/t/05-scheduler-capabilities.t +++ b/t/05-scheduler-capabilities.t @@ -170,8 +170,7 @@ my $w8_id = $c->_register($schema, "host", "8", \%workercaps64); my $w9_id = $c->_register($schema, "host", "9", \%workercaps64_client); schedule() for ($jobA, $jobB, $jobE, $jobF, $jobD, $jobC, $jobH, $jobJ, $jobI); -ok exists $sent->{job}->{$_}, "$_ exists" - for (map { $_->id } $jobA, $jobB, $jobE, $jobF, $jobD, $jobC, $jobH, $jobJ, $jobI); +ok exists $sent->{job}->{$_}, "$_ exists" for (map { $_->id } $jobA, $jobB, $jobE, $jobF, $jobD, $jobC, $jobH, $jobJ, $jobI); my $job = $sent->{$w1_id}->{job}->to_hash; is($job->{id}, $jobA->id, "'client' worker should get 'client' job even though 'server' job has higher prio"); @@ -196,8 +195,7 @@ is($job->{id}, $jobH->id, "next job by prio, parent - server"); $job = $sent->{$w8_id}->{job}->to_hash; is($job->{id}, $jobJ->id, -"I is a scheduled child of running H so it should have the highest prio, but this worker can't do it because of class -> take next job by prio instead" -); + "I is a scheduled child of running H so it should have the highest prio, but this worker can't do it because of class -> take next job by prio instead"); $job = $sent->{$w9_id}->{job}->to_hash; is($job->{id}, $jobI->id, "this worker can do jobI, child - client"); diff --git a/t/05-scheduler-dependencies.t b/t/05-scheduler-dependencies.t index 87114dae39b2..fd2e00d877d8 100644 --- a/t/05-scheduler-dependencies.t +++ b/t/05-scheduler-dependencies.t @@ -150,8 +150,7 @@ subtest 'cycle in directly chained dependencies is handled' => sub { is($scheduled_jobs->{99928}->{priority}, 46, 'regular prio for job 99928 assumed'); is($scheduled_jobs->{$_}->{priority_offset}, 0, "job $_ not deprioritized yet") for (99927, 99928); combined_like { $scheduler->schedule } - qr/Unable to serialize directly chained job sequence of 9992(7|8): detected cycle at 9992(7|8)/, - 'info about cycle logged'; + qr/Unable to serialize directly chained job sequence of 9992(7|8): detected cycle at 9992(7|8)/, 'info about cycle logged'; $scheduler->_update_scheduled_jobs; # apply deprioritization is($scheduled_jobs->{99927}->{priority}, 46, 'reduced prio for job 99927 assumed'); is($scheduled_jobs->{99928}->{priority}, 47, 'reduced prio for job 99928 assumed'); @@ -199,8 +198,7 @@ subtest 'vlan setting' => sub { for my $i (0 .. 5) { my $job = $sent->{job}->{$jobs_in_expected_order[$i * 2]->id}->{job}; ok(defined $job, $jobs_in_expected_order[$i * 2 + 1]) or die; - is($sent->{job}->{$jobs_in_expected_order[$i * 2]->id}->{jobhash}->{settings}->{NICVLAN}, - 1, 'same vlan for whole group'); + is($sent->{job}->{$jobs_in_expected_order[$i * 2]->id}->{jobhash}->{settings}->{NICVLAN}, 1, 'same vlan for whole group'); } }; @@ -485,11 +483,7 @@ subtest 'simple chained dependency cloning' => sub { # current state: # X <---- Y # done sch. - is_deeply( - $jobY->to_hash(deps => 1)->{parents}, - {Chained => [$jobX->id], Parallel => [], 'Directly chained' => []}, - 'parents of jobY' - ); + is_deeply($jobY->to_hash(deps => 1)->{parents}, {Chained => [$jobX->id], Parallel => [], 'Directly chained' => []}, 'parents of jobY'); # when Y is scheduled and X is duplicated, Y must be cancelled and Y2 needs to depend on X2 my $jobX2 = $jobX->auto_duplicate; @@ -499,11 +493,7 @@ subtest 'simple chained dependency cloning' => sub { my $jobY2 = $jobY->clone; ok(defined $jobY2, "jobY was cloned too"); is($jobY2->blocked_by_id, $jobX2->id, "JobY2 is blocked"); - is_deeply( - $jobY2->to_hash(deps => 1)->{parents}, - {Chained => [$jobX2->id], Parallel => [], 'Directly chained' => []}, - "JobY parents fit" - ); + is_deeply($jobY2->to_hash(deps => 1)->{parents}, {Chained => [$jobX2->id], Parallel => [], 'Directly chained' => []}, "JobY parents fit"); is($jobX2->id, $jobY2->parents->single->parent_job_id, 'jobY2 parent is now jobX clone'); is($jobX2->clone, undef, 'no clone'); is($jobY2->clone, undef, 'no clone'); @@ -552,11 +542,7 @@ subtest 'simple chained dependency cloning' => sub { my $jobY3_id = $jobY2->clone_id; my $jobY3 = _job_deps($jobY3_id); is($jobY2->clone->blocked_by_id, $jobX3->id, 'jobY3 blocked'); - is_deeply( - $jobY3->{parents}, - {Chained => [$jobX3->id], Parallel => [], 'Directly chained' => []}, - 'jobY3 parent is now jobX3' - ); + is_deeply($jobY3->{parents}, {Chained => [$jobX3->id], Parallel => [], 'Directly chained' => []}, 'jobY3 parent is now jobX3'); }; subtest 'duplicate parallel siblings' => sub { @@ -595,11 +581,7 @@ subtest 'duplicate parallel siblings' => sub { is($jobJ2, $jobJ->clone->id, 'J2 cloned with parallel parent dep'); my $jobH2 = _job_deps($jobJ2)->{parents}->{Parallel}->[0]; is($jobH2, $jobH->clone->id, 'H2 cloned with parallel parent dep'); - is_deeply( - _job_deps($jobH2)->{children}->{Parallel}, - [$jobK->clone->id, $jobJ2], - 'K2 cloned with parallel children dep' - ); + is_deeply(_job_deps($jobH2)->{children}->{Parallel}, [$jobK->clone->id, $jobJ2], 'K2 cloned with parallel children dep'); }; subtest 'duplicate parallel parent in tree with all dependency types' => sub { @@ -662,11 +644,9 @@ subtest 'duplicate parallel parent in tree with all dependency types' => sub { ok($jobQ->clone_id, 'jobQ cloned (direct parent of jobTA)'); # check certain job states - is($jobU->state, RUNNING, - 'original job state not altered (expected to be set to USER_RESTARTED after auto_duplicate is called)'); + is($jobU->state, RUNNING, 'original job state not altered (expected to be set to USER_RESTARTED after auto_duplicate is called)'); is($jobQ->state, DONE, 'state of original parent jobQ is unaffected'); - is($_->result, PARALLEL_RESTARTED, 'parallel jobs are considered PARALLEL_RESTARTED') - for ($jobW, $jobR, $jobT, $jobTA); + is($_->result, PARALLEL_RESTARTED, 'parallel jobs are considered PARALLEL_RESTARTED') for ($jobW, $jobR, $jobT, $jobTA); # determine dependencies of existing and cloned jobs for further checks # note 3: The variables of cloned jobs have a "2" suffix here. So jobQ2 is the clone of jobQ. @@ -688,8 +668,7 @@ subtest 'duplicate parallel parent in tree with all dependency types' => sub { or diag explain \@sorted_got; @sorted_got = sort(@{$jobQ2->{children}->{Chained}}); @sorted_exp = sort(($jobW2->{id}, $jobU2->id, $jobR2->{id}, $jobT2->{id})); - is_deeply(\@sorted_got, \@sorted_exp, - 'jobQ2 is chained parent to all cloned jobs (except jobTA2 which is directly chained)') + is_deeply(\@sorted_got, \@sorted_exp, 'jobQ2 is chained parent to all cloned jobs (except jobTA2 which is directly chained)') or diag explain \@sorted_got; # check directly chained children @@ -748,17 +727,17 @@ subtest 'duplicate parallel parent in tree with all dependency types' => sub { is_deeply( $jobW2->{parents}, {Chained => [$jobQ2->{id}], Parallel => [], 'Directly chained' => []}, -'jobW2 has clone of jobQ as chained parent (although jobQ has only been cloned because it is a direct parent of jobTA)' + 'jobW2 has clone of jobQ as chained parent (although jobQ has only been cloned because it is a direct parent of jobTA)' ) or diag explain $jobW2->{parents}; is_deeply( $jobU2->to_hash(deps => 1)->{parents}, {Chained => [$jobQ2->{id}], Parallel => [], 'Directly chained' => []}, -'jobU2 has clone of jobQ as chained parent (although jobQ has only been cloned because it is a direct parent of jobTA)' + 'jobU2 has clone of jobQ as chained parent (although jobQ has only been cloned because it is a direct parent of jobTA)' ) or diag explain $jobU2->to_hash(deps => 1)->{parents}; is_deeply( $jobR2->{parents}, {Chained => [$jobQ2->{id}], Parallel => [], 'Directly chained' => []}, -'jobR2 has clone of jobQ as chained parent (although jobQ has only been cloned because it is a direct parent of jobTA)' + 'jobR2 has clone of jobQ as chained parent (although jobQ has only been cloned because it is a direct parent of jobTA)' ) or diag explain $jobR2->{parents}; }; @@ -824,8 +803,7 @@ subtest 'clonging of clones' => sub { is_deeply($jobO3->{parents}->{Parallel}, [$jobP3->{id}], 'clone jobO3 gets new parent jobP3'); }; -subtest 'clone chained child with siblings; then clone chained parent' => - sub { # see https://progress.opensuse.org/issues/10456 +subtest 'clone chained child with siblings; then clone chained parent' => sub { # see https://progress.opensuse.org/issues/10456 $jobA = _job_create('116539'); $jobB = _job_create('116569', undef, [$jobA->id]); $jobC = _job_create('116570', undef, [$jobA->id]); @@ -913,7 +891,7 @@ subtest 'clone chained child with siblings; then clone chained parent' => my @clone_deps = sort { $a <=> $b } @{$jobA2_h->{children}->{Chained}}; my @deps = sort { $a <=> $b } ($jobB2_h->{id}, $jobC2_h->{id}, $jobD2_h->{id}); is_deeply(\@clone_deps, \@deps, 'jobA2 has jobB2, jobC2 and jobD2 as children'); - }; +}; subtest 'clone chained parent while children are running' => sub { # situation parent is done, children running -> parent is cloned -> parent is running -> parent is cloned. Check all @@ -1029,16 +1007,8 @@ subtest 'clone chained parent with chained sub-tree' => sub { $_->discard_changes for ($jobSUS, $jobAS, $jobIS, $jobIS2, $jobBS, $jobT); # check dependencies of clones - my @related_jobs = ( - [$jobSUS, $jobAS], - [$jobSUS, $jobIS], - [$jobSUS, $jobBS], - [$jobAS, $jobIS], - [$jobAS, $jobIS2], - [$jobAS, $jobBS], - [$jobBS, $jobT]); - ok(_job_cloned_and_related($_->[0], $_->[1]), 'job ' . $_->[0]->TEST . ' and job ' . $_->[1]->TEST) - for @related_jobs; + my @related_jobs = ([$jobSUS, $jobAS], [$jobSUS, $jobIS], [$jobSUS, $jobBS], [$jobAS, $jobIS], [$jobAS, $jobIS2], [$jobAS, $jobBS], [$jobBS, $jobT]); + ok(_job_cloned_and_related($_->[0], $_->[1]), 'job ' . $_->[0]->TEST . ' and job ' . $_->[1]->TEST) for @related_jobs; }; # This enforces order in the processing of the nodes, to test PR#1623 @@ -1056,8 +1026,7 @@ subtest 'clone chained parent with chained sub-tree' => sub { } }; -subtest 'blocked-by computation in complicated mix of chained and parallel dependencies (SAP setup)' => - sub { # see https://progress.opensuse.org/issues/52928 +subtest 'blocked-by computation in complicated mix of chained and parallel dependencies (SAP setup)' => sub { # see https://progress.opensuse.org/issues/52928 my $jobA = _job_create_set_done('hdd_gnome', DONE); my $jobB = _job_create('gnome_netweaver', undef, [$jobA->id]); my $jobC = _job_create_set_done('hdd_textmode', DONE); @@ -1069,7 +1038,7 @@ subtest 'blocked-by computation in complicated mix of chained and parallel depen is($jobB->blocked_by_parent_job, undef); is($jobD->blocked_by_parent_job, $jobB->id); is($jobG->blocked_by_parent_job, $jobD->id); - }; +}; ok $mock_send_called, 'mocked ws_send method has been called'; @@ -1077,8 +1046,7 @@ subtest 'WORKER_CLASS validated when creating directly chained dependencies' => $jobA = _job_create({%default_job_settings, TEST => 'chained-A', WORKER_CLASS => 'foo'}); is($jobA->settings->find({key => 'WORKER_CLASS'})->value, 'foo', 'job A has class foo'); $jobB = _job_create({%default_job_settings, TEST => 'chained-B', WORKER_CLASS => 'bar'}, undef, [$jobA->id]); - is($jobB->settings->find({key => 'WORKER_CLASS'})->value, - 'bar', 'job B has different class bar (ok for regularly chained dependencies)'); + is($jobB->settings->find({key => 'WORKER_CLASS'})->value, 'bar', 'job B has different class bar (ok for regularly chained dependencies)'); $jobC = _job_create({%default_job_settings, TEST => 'chained-C'}, undef, [], [$jobB->id]); is($jobC->settings->find({key => 'WORKER_CLASS'})->value, 'bar', 'job C inherits worker class from B'); throws_ok( @@ -1213,8 +1181,7 @@ subtest 'starvation of parallel jobs prevented' => sub { my $free_workers = OpenQA::Scheduler::Model::Jobs::determine_free_workers(); my $allocated_workers; combined_like { $allocated_workers = OpenQA::Scheduler::Model::Jobs->singleton->_allocate_jobs($free_workers) } - qr/Need to schedule 3 parallel jobs for job 1.*Discarding job (1|2|3).*Discarding job (1|2|3)/s, - 'discarding jobs due to incomplete parallel cluster'; + qr/Need to schedule 3 parallel jobs for job 1.*Discarding job (1|2|3).*Discarding job (1|2|3)/s, 'discarding jobs due to incomplete parallel cluster'; is $mocked_jobs{1}->{priority_offset}, 10, 'priority of parallel parent increased (once per child)'; is_deeply $allocated_workers, {}, 'no workers "held" so far while still increased prio' or diag explain $allocated_workers; diff --git a/t/05-scheduler-full.t b/t/05-scheduler-full.t index 6d41c71121c7..812a385644bd 100644 --- a/t/05-scheduler-full.t +++ b/t/05-scheduler-full.t @@ -80,8 +80,7 @@ sub stop_workers { stop_service($_, 1) for @workers } sub dead_workers { my $schema = shift; - $_->update({t_seen => DateTime->from_epoch(epoch => time - DEFAULT_WORKER_TIMEOUT - DB_TIMESTAMP_ACCURACY)}) - for $schema->resultset("Workers")->all(); + $_->update({t_seen => DateTime->from_epoch(epoch => time - DEFAULT_WORKER_TIMEOUT - DB_TIMESTAMP_ACCURACY)}) for $schema->resultset("Workers")->all(); } sub wait_for_worker { diff --git a/t/05-scheduler-restart-and-duplicate.t b/t/05-scheduler-restart-and-duplicate.t index abf603f7d574..14687d214bce 100644 --- a/t/05-scheduler-restart-and-duplicate.t +++ b/t/05-scheduler-restart-and-duplicate.t @@ -60,11 +60,7 @@ my $job = job_get_rs(99927)->auto_duplicate; is($job, 'Job 99927 is still scheduled', 'duplication rejected'); $job1 = job_get(99926); -is_deeply( - job_get_rs(99926)->cluster_jobs, - {99926 => {is_parent_or_initial_job => 1, @empty_deps}}, - '99926 has no siblings and is DONE' -); +is_deeply(job_get_rs(99926)->cluster_jobs, {99926 => {is_parent_or_initial_job => 1, @empty_deps}}, '99926 has no siblings and is DONE'); $job = job_get_rs(99926)->auto_duplicate; ok(defined $job, "duplication works"); isnt($job->id, $job1->{id}, 'clone id is different than original job id'); @@ -130,12 +126,10 @@ subtest 'restart with (directly) chained child' => sub { my $job_data_99926; subtest 'cluster jobs for 99937 which has one chained child and one chained parent' => sub { job_get_rs(99926)->update({result => FAILED}); - is_deeply job_get_rs(99937)->cluster_jobs, \%expected_cluster, - 'chained parent considered for restarting as its result is failed'; + is_deeply job_get_rs(99937)->cluster_jobs, \%expected_cluster, 'chained parent considered for restarting as its result is failed'; job_get_rs(99926)->update({result => SOFTFAILED}); $job_data_99926 = delete $expected_cluster{99926}; - is_deeply job_get_rs(99937)->cluster_jobs, \%expected_cluster, - 'only child considered for restarting as the parent result is not failed'; + is_deeply job_get_rs(99937)->cluster_jobs, \%expected_cluster, 'only child considered for restarting as the parent result is not failed'; }; # restart the job @@ -171,9 +165,8 @@ subtest 'restart with (directly) chained child' => sub { }, 99938 => {is_parent_or_initial_job => 0, @empty_deps, directly_chained_parents => [99937]}, ); - is_deeply(job_get_rs(99937)->cluster_jobs, \%expected_cluster, - '99937 has one directly chained child and one directly chained parent; ' - . 'parent considered for restarting but not siblings'); + is_deeply(job_get_rs(99937)->cluster_jobs, + \%expected_cluster, '99937 has one directly chained child and one directly chained parent; ' . 'parent considered for restarting but not siblings'); $job_before_restart = job_get(99937); # restart the job @@ -282,10 +275,8 @@ subtest 'restarting one of two independent root jobs (only related indirectly vi $deps_rs->create({parent_job_id => $root_1->id, child_job_id => $parallel_parent->id, dependency => CHAINED}); $deps_rs->create({parent_job_id => $root_2->id, child_job_id => $parallel_child->id, dependency => CHAINED}); $deps_rs->create({parent_job_id => $root_2->id, child_job_id => $chained_child->id, dependency => CHAINED}); - $deps_rs->create( - {parent_job_id => $parallel_child->id, child_job_id => $nested_chained_child->id, dependency => CHAINED}); - $deps_rs->create( - {parent_job_id => $parallel_parent->id, child_job_id => $parallel_child->id, dependency => PARALLEL}); + $deps_rs->create({parent_job_id => $parallel_child->id, child_job_id => $nested_chained_child->id, dependency => CHAINED}); + $deps_rs->create({parent_job_id => $parallel_parent->id, child_job_id => $parallel_child->id, dependency => PARALLEL}); # print the job cluster info to verify whether the setup is correct my @jobs = ($root_1, $root_2, $parallel_parent, $parallel_child, $nested_chained_child, $chained_child); @@ -340,8 +331,7 @@ subtest 'restarting one of two independent root jobs (only related indirectly vi is_deeply $res, {enforceable => 0, errors => [], warnings => []}, 'no warnings or errors' or expain $res; $_->discard_changes for @jobs; - is $root_1->state, RUNNING, - 'root1 is still running (cancelled would work as well), worker is supposed to set it to DONE'; + is $root_1->state, RUNNING, 'root1 is still running (cancelled would work as well), worker is supposed to set it to DONE'; is $root_1->result, USER_RESTARTED, 'root1 itself has been marked as USER_RESTARTED'; is $_->result, SKIPPED, $_->TEST . ' has been skipped' for @should_have_been_skipped; is $root_2->state, RUNNING, 'root2 is still running'; diff --git a/t/05-scheduler-serialize-directly-chained-dependencies.t b/t/05-scheduler-serialize-directly-chained-dependencies.t index 31d6d5157f2e..aca87d2e39f2 100644 --- a/t/05-scheduler-serialize-directly-chained-dependencies.t +++ b/t/05-scheduler-serialize-directly-chained-dependencies.t @@ -99,29 +99,25 @@ my %cluster_info = ( # are two distinct clusters of directly chained dependencies present. my @expected_sequence = (2, 3); -my ($computed_sequence, $visited) - = OpenQA::Scheduler::Model::Jobs::_serialize_directly_chained_job_sequence(2, \%cluster_info); +my ($computed_sequence, $visited) = OpenQA::Scheduler::Model::Jobs::_serialize_directly_chained_job_sequence(2, \%cluster_info); is_deeply($computed_sequence, \@expected_sequence, 'sub sequence starting from job 2') or diag explain $computed_sequence; is_deeply([sort @$visited], [2, 3], 'relevant jobs visited'); @expected_sequence = (1, [2, 3], [4, 5]); -($computed_sequence, $visited) - = OpenQA::Scheduler::Model::Jobs::_serialize_directly_chained_job_sequence(1, \%cluster_info); +($computed_sequence, $visited) = OpenQA::Scheduler::Model::Jobs::_serialize_directly_chained_job_sequence(1, \%cluster_info); is_deeply($computed_sequence, \@expected_sequence, 'sub sequence starting from job 1') or diag explain $computed_sequence; is_deeply([sort @$visited], [1, 2, 3, 4, 5], 'relevant jobs visited'); @expected_sequence = (0, [1, [2, 3], [4, 5]], 6, 7, [8, 9, [10, 11]], 12); -($computed_sequence, $visited) - = OpenQA::Scheduler::Model::Jobs::_serialize_directly_chained_job_sequence(0, \%cluster_info); +($computed_sequence, $visited) = OpenQA::Scheduler::Model::Jobs::_serialize_directly_chained_job_sequence(0, \%cluster_info); is_deeply($computed_sequence, \@expected_sequence, 'whole sequence starting from job 0') or diag explain $computed_sequence; is_deeply([sort @$visited], [0, 1, 10, 11, 12, 2, 3, 4, 5, 6, 7, 8, 9], 'relevant jobs visited'); @expected_sequence = (13, 14); -($computed_sequence, $visited) - = OpenQA::Scheduler::Model::Jobs::_serialize_directly_chained_job_sequence(13, \%cluster_info); +($computed_sequence, $visited) = OpenQA::Scheduler::Model::Jobs::_serialize_directly_chained_job_sequence(13, \%cluster_info); is_deeply($computed_sequence, \@expected_sequence, 'whole sequence starting from job 13') or diag explain $computed_sequence; is_deeply([sort @$visited], [13, 14], 'relevant jobs visited'); @@ -129,8 +125,7 @@ is_deeply([sort @$visited], [13, 14], 'relevant jobs visited'); subtest 'jobs which are not scheduled anymore are skipped' => sub { $cluster_info{$_}->{state} = DONE for (1, 9); @expected_sequence = (0, 6, 7, [8, [10, 11]], 12); - ($computed_sequence, $visited) - = OpenQA::Scheduler::Model::Jobs::_serialize_directly_chained_job_sequence(0, \%cluster_info); + ($computed_sequence, $visited) = OpenQA::Scheduler::Model::Jobs::_serialize_directly_chained_job_sequence(0, \%cluster_info); is_deeply($computed_sequence, \@expected_sequence, 'subchains starting from 1 and 9 skipped') or diag explain $computed_sequence; is_deeply([sort @$visited], [0, 10, 11, 12, 6, 7, 8], 'relevant jobs visited'); @@ -144,8 +139,7 @@ my $sort_function = sub { return [sort { ($sort_criteria{$a} // $a) cmp($sort_criteria{$b} // $b) } @{shift()}]; }; @expected_sequence = (0, 12, 7, 6, [8, [10, 11], 9], [1, [2, 3], [4, 5]]); -($computed_sequence, $visited) - = OpenQA::Scheduler::Model::Jobs::_serialize_directly_chained_job_sequence(0, \%cluster_info, $sort_function); +($computed_sequence, $visited) = OpenQA::Scheduler::Model::Jobs::_serialize_directly_chained_job_sequence(0, \%cluster_info, $sort_function); is_deeply($computed_sequence, \@expected_sequence, 'sorting criteria overrides sorting by ID') or diag explain $computed_sequence; @@ -162,8 +156,7 @@ throws_ok( subtest 'simple tree with one root and just leafs' => sub { $cluster_info{$_}->{directly_chained_children} = [] for (1 .. 14); @expected_sequence = (0, 1, 6, 7, 8, 12); - ($computed_sequence, $visited) - = OpenQA::Scheduler::Model::Jobs::_serialize_directly_chained_job_sequence(0, \%cluster_info); + ($computed_sequence, $visited) = OpenQA::Scheduler::Model::Jobs::_serialize_directly_chained_job_sequence(0, \%cluster_info); is_deeply($computed_sequence, \@expected_sequence, 'whole sequence starting from job 0') or diag explain $computed_sequence; is_deeply([sort @$visited], [0, 1, 12, 6, 7, 8], 'relevant jobs visited'); @@ -176,8 +169,7 @@ subtest 'simple tree with one root and just leafs' => sub { subtest 'simple chain with only one job after another' => sub { $cluster_info{$_}->{directly_chained_children} = [$_ + 1] for (0 .. 6); @expected_sequence = (0, [1, [2, [3, [4, [5, [6, 7]]]]]]); - ($computed_sequence, $visited) - = OpenQA::Scheduler::Model::Jobs::_serialize_directly_chained_job_sequence(0, \%cluster_info); + ($computed_sequence, $visited) = OpenQA::Scheduler::Model::Jobs::_serialize_directly_chained_job_sequence(0, \%cluster_info); is_deeply($computed_sequence, \@expected_sequence, 'whole sequence starting from job 0') or diag explain $computed_sequence; is_deeply([sort @$visited], [0, 1, 2, 3, 4, 5, 6, 7], 'relevant jobs visited'); diff --git a/t/09-job_clone.t b/t/09-job_clone.t index 5df559922fb5..7dc39f52cb11 100644 --- a/t/09-job_clone.t +++ b/t/09-job_clone.t @@ -95,8 +95,7 @@ subtest 'get job with verbose output' => sub { my $temp_assetdir = tempdir; my %options = (@common_options, dir => $temp_assetdir, verbose => 1); my $url_handler; - combined_like { $url_handler = create_url_handler(\%options); } qr/^$/, - 'Configured user agent without unexpected output'; + combined_like { $url_handler = create_url_handler(\%options); } qr/^$/, 'Configured user agent without unexpected output'; my $job_id = 99937; combined_like { clone_job_get_job($job_id, $url_handler, \%options) } qr/"id" : $job_id/, 'Job settings logged'; }; diff --git a/t/10-jobs-referal.t b/t/10-jobs-referal.t index 72fa334c4a88..39b97dea0985 100644 --- a/t/10-jobs-referal.t +++ b/t/10-jobs-referal.t @@ -57,8 +57,7 @@ subtest 'job is marked as linked if accessed from recognized referal' => sub { $job->update; $linked = job_is_linked($job); is($linked, 0, 'new job is not linked'); - $t->get_ok('/tests/' . $job->id . '/modules/' . $module->id . '/steps/1' => {Referer => $test_referer}) - ->status_is(302); + $t->get_ok('/tests/' . $job->id . '/modules/' . $module->id . '/steps/1' => {Referer => $test_referer})->status_is(302); $linked = job_is_linked($job); is($linked, 1, 'job linked after accessed from known referer'); }; diff --git a/t/10-jobs-results.t b/t/10-jobs-results.t index 1a27b7f8db62..ab77bebf568a 100644 --- a/t/10-jobs-results.t +++ b/t/10-jobs-results.t @@ -92,8 +92,7 @@ subtest 'create result dir, delete results' => sub { $job->delete_logs; $job->discard_changes; is $job->logs_present, 0, 'logs not present anymore'; - is $job->result_size, $initially_assumed_result_size - length($file_content) * (@fake_results + @ulogs), - 'deleted size subtracted from result size'; + is $job->result_size, $initially_assumed_result_size - length($file_content) * (@fake_results + @ulogs), 'deleted size subtracted from result size'; is $result_dir->list_tree({hidden => 1})->size, 0, 'no more files left'; is_deeply $job->video_file_paths->to_array, [], 'no more videos found' or diag explain $job->video_file_paths->to_array; @@ -109,8 +108,7 @@ subtest 'create result dir, delete results' => sub { $job->delete_videos; $job->discard_changes; is $job->logs_present, 1, 'logs still considered present'; - is $job->result_size, $initially_assumed_result_size - length($file_content) * 3 - $symlink_size, - 'deleted size subtracted from result size'; + is $job->result_size, $initially_assumed_result_size - length($file_content) * 3 - $symlink_size, 'deleted size subtracted from result size'; is_deeply $job->video_file_paths->to_array, [], 'no more videos found' or diag explain $job->video_file_paths->to_array; ok -e path($result_dir, $_), "$_ still present" for qw(autoinst-log.txt serial0.txt serial_terminal.txt); @@ -134,8 +132,7 @@ subtest 'create result dir, delete results' => sub { is $job->archive, undef, 'early return if job has not been concluded yet'; my $result_dir = path($job->result_dir); - like $result_dir, qr|$base_dir/openqa/testresults/\d{5}/\d{8}-to-be-archived|, - 'normal result directory returned by default'; + like $result_dir, qr|$base_dir/openqa/testresults/\d{5}/\d{8}-to-be-archived|, 'normal result directory returned by default'; $result_dir->child('subdir')->make_path->child('some-file')->spew('test'); $job->update({state => DONE}); $job->discard_changes; @@ -154,8 +151,7 @@ subtest 'create result dir, delete results' => sub { undef $signal_guard; $result_dir = path($job->result_dir); - like $result_dir, qr|$base_dir/openqa/archive/testresults/\d{5}/\d{8}-to-be-archived|, - 'archive result directory returned if archived'; + like $result_dir, qr|$base_dir/openqa/archive/testresults/\d{5}/\d{8}-to-be-archived|, 'archive result directory returned if archived'; is $result_dir->child('subdir')->make_path->child('some-file')->slurp, 'test', 'nested file moved'; is $job->archive, undef, 'early return if job has already been archived'; @@ -207,8 +203,7 @@ subtest 'loading results with missing file in details' => sub { my $arbitrary_job_module = $schema->resultset('JobModules')->first; $arbitrary_job_module->save_results($some_test_results); - ok -f path($arbitrary_job_module->job->result_dir, 'details-' . $arbitrary_job_module->name . '.json'), - 'details file exists'; + ok -f path($arbitrary_job_module->job->result_dir, 'details-' . $arbitrary_job_module->name . '.json'), 'details file exists'; $some_test_results->{details}[0]{text_data} = 'Unable to read before_test-1.txt.'; is_deeply($arbitrary_job_module->results, $some_test_results); }; diff --git a/t/10-jobs.t b/t/10-jobs.t index d12934b426e8..917ec7d19c27 100644 --- a/t/10-jobs.t +++ b/t/10-jobs.t @@ -259,9 +259,7 @@ subtest 'job with all modules passed and at least one ignore_failure failed => o is($job->result, OpenQA::Jobs::Constants::PASSED, 'job result is passed'); }; -subtest -'job with important modules passed and at least one softfailed and at least one ignore_failure failed => overall softfailed' - => sub { +subtest 'job with important modules passed and at least one softfailed and at least one ignore_failure failed => overall softfailed' => sub { my %_settings = %settings; $_settings{TEST} = 'F'; my $job = _job_create(\%_settings); @@ -279,11 +277,9 @@ subtest $job->done; $job->discard_changes; is($job->result, OpenQA::Jobs::Constants::SOFTFAILED, 'job result is softfailed'); - }; +}; -subtest -'job with one "important" (old flag we now ignore) module failed and at least one ignore_failure passed => overall failed' - => sub { +subtest 'job with one "important" (old flag we now ignore) module failed and at least one ignore_failure passed => overall failed' => sub { my %_settings = %settings; $_settings{TEST} = 'G'; my $job = _job_create(\%_settings); @@ -299,7 +295,7 @@ subtest $job->done; $job->discard_changes; is($job->result, OpenQA::Jobs::Constants::FAILED, 'job result is failed'); - }; +}; subtest 'job with first ignore_failure failed and rest softfails => overall is softfailed' => sub { my %_settings = %settings; @@ -449,8 +445,7 @@ subtest 'carry over, including soft-fails' => sub { }); path('t/data/last_good.json')->copy_to(path(($job->_previous_scenario_jobs)[1]->result_dir(), 'vars.json')); path('t/data/first_bad.json')->copy_to(path($job->result_dir(), 'vars.json')); - path('t/data/last_good_packages.txt') - ->copy_to(path(($job->_previous_scenario_jobs)[1]->result_dir(), 'worker_packages.txt')); + path('t/data/last_good_packages.txt')->copy_to(path(($job->_previous_scenario_jobs)[1]->result_dir(), 'worker_packages.txt')); path('t/data/first_bad_packages.txt')->copy_to(path($job->result_dir(), 'worker_packages.txt')); $job->done; is($job->result, OpenQA::Jobs::Constants::FAILED, 'job result is failed'); @@ -616,8 +611,7 @@ subtest 'carry over, including soft-fails' => sub { $job->done; perform_minion_jobs($t->app->minion); $job_info = $t->app->minion->jobs({tasks => ['hook_script']})->next; - is_deeply($job_info->{args}[2], - {delay => 60, retries => 1440, skip_rc => 142, kill_timeout => '30s', timeout => '5m'}); + is_deeply($job_info->{args}[2], {delay => 60, retries => 1440, skip_rc => 142, kill_timeout => '30s', timeout => '5m'}); $notes = $job_info->{notes}; is($notes->{hook_cmd}, 'echo retried && exit 143;', 'real hook cmd in notes if result matches (3)'); like($notes->{hook_result}, qr/retried/, 'real hook cmd from config called if result matches (3)'); @@ -632,8 +626,7 @@ subtest 'carry over, including soft-fails' => sub { $job->done; perform_minion_jobs($t->app->minion); $job_info = $t->app->minion->jobs({tasks => ['hook_script']})->next; - is_deeply($job_info->{args}[2], - {delay => 0, retries => 2, skip_rc => 143, kill_timeout => '30s', timeout => '5m'}); + is_deeply($job_info->{args}[2], {delay => 0, retries => 2, skip_rc => 143, kill_timeout => '30s', timeout => '5m'}); $notes = $job_info->{notes}; is($notes->{hook_cmd}, 'echo retried && exit 143;', 'real hook cmd in notes if result matches (4)'); like($notes->{hook_result}, qr/retried/, 'real hook cmd from config called if result matches (4)'); @@ -652,8 +645,7 @@ subtest 'carry over, including soft-fails' => sub { perform_minion_jobs($t->app->minion); $job_info = $t->app->minion->jobs({tasks => ['hook_script']})->next; is $job_info->{state}, 'finished', 'hook script has been retried without delay'; - is_deeply($job_info->{args}[2], - {delay => 0, retries => 4, skip_rc => 143, kill_timeout => '30s', timeout => '5m'}); + is_deeply($job_info->{args}[2], {delay => 0, retries => 4, skip_rc => 143, kill_timeout => '30s', timeout => '5m'}); $notes = $job_info->{notes}; is($notes->{hook_cmd}, 'echo retried && exit 143;', 'real hook cmd in notes if result matches (4)'); like($notes->{hook_result}, qr/retried/, 'real hook cmd from config called if result matches (4)'); @@ -670,8 +662,7 @@ subtest 'carry over, including soft-fails' => sub { perform_minion_jobs($t->app->minion); $job_info = $t->app->minion->jobs({tasks => ['hook_script']})->next; is $job_info->{state}, 'inactive', 'hook script has been retried with long delay'; - is_deeply($job_info->{args}[2], - {delay => 60, retries => 1440, skip_rc => 142, kill_timeout => '30s', timeout => '5m'}); + is_deeply($job_info->{args}[2], {delay => 60, retries => 1440, skip_rc => 142, kill_timeout => '30s', timeout => '5m'}); $notes = $job_info->{notes}; is($notes->{hook_cmd}, 'echo delayed && exit 142;', 'real hook cmd in notes if result matches (5)'); like($notes->{hook_result}, qr/delayed/, 'real hook cmd from config called if result matches (5)'); @@ -843,8 +834,7 @@ subtest 'job setting based retriggering' => sub { is $jobs->count, $jobs_nr + 2, 'job retriggered as it FAILED (with retry)'; $job->update; $job->discard_changes; - is $job->comments->first->text, 'Restarting because RETRY is set to 2 (and only restarted 0 times so far)', - 'comment about retry'; + is $job->comments->first->text, 'Restarting because RETRY is set to 2 (and only restarted 0 times so far)', 'comment about retry'; is $jobs->count, $jobs_nr + 2, 'job is automatically retriggered'; my $restart_jobs = $get_jobs->('restart_job'); my $finalize_jobs = $get_jobs->('finalize_job_results'); @@ -874,8 +864,7 @@ subtest 'job setting based retriggering' => sub { subtest '"race" between status updates and stale job detection' => sub { my $job = $jobs->create({TEST => 'test-job'}); is_deeply $job->update_status({}), {result => 0}, 'status update rejected for scheduled job'; - is_deeply $job->update_status({uploading => 1}), {result => !!0}, - 'status update rejected for scheduled job (uploading)'; + is_deeply $job->update_status({uploading => 1}), {result => !!0}, 'status update rejected for scheduled job (uploading)'; $job->discard_changes; is $job->state, SCHEDULED, 'job is still scheduled'; @@ -924,13 +913,8 @@ subtest 'special cases when restarting job via Minion task' => sub { return $job_id; }; }; - $test->([], 'failed', 'No job ID specified.', - 'error without openQA job ID (can happen if job is enqueued via CLI)'); - $test->( - [45678], 'finished', - 'Job 45678 does not exist.', - 'no error if openQA job does not exist (maybe job has already been deleted)' - ); + $test->([], 'failed', 'No job ID specified.', 'error without openQA job ID (can happen if job is enqueued via CLI)'); + $test->([45678], 'finished', 'Job 45678 does not exist.', 'no error if openQA job does not exist (maybe job has already been deleted)'); $test->( [99945], 'finished', 'Specified job 99945 has already been cloned as 99946', diff --git a/t/10-tests_overview.t b/t/10-tests_overview.t index 5f0216a2a8b6..06953a510eb3 100644 --- a/t/10-tests_overview.t +++ b/t/10-tests_overview.t @@ -44,10 +44,8 @@ $t->element_exists_not('#res_DVD_x86_64_doc'); # Check distinction between scheduled and blocked my $dom = $t->tx->res->dom; -is_deeply($dom->find('.status.state_scheduled')->map('parent')->map(attr => 'href')->to_array, - ['/tests/99927'], '99927 is scheduled'); -is_deeply($dom->find('.status.state_blocked')->map('parent')->map(attr => 'href')->to_array, - ['/tests/99928'], '99928 is blocked'); +is_deeply($dom->find('.status.state_scheduled')->map('parent')->map(attr => 'href')->to_array, ['/tests/99927'], '99927 is scheduled'); +is_deeply($dom->find('.status.state_blocked')->map('parent')->map(attr => 'href')->to_array, ['/tests/99928'], '99928 is blocked'); my $form = {distri => 'opensuse', version => '13.1', build => '0091', group => 'opensuse 13.1'}; $t->get_ok('/tests/overview' => form => $form)->status_is(200); @@ -67,11 +65,7 @@ subtest 'escaping works' => sub { unlike($body, qr/.*/, 'no unescaped image tags for version'); unlike($body, qr//, 'no unescaped image tag for build'); like($body, qr/<img src="distri">/, 'image tag for distri escaped'); - like( - $body, - qr/<img src="version1">.*<img src="version2">/, - 'image tags for version escaped' - ); + like($body, qr/<img src="version1">.*<img src="version2">/, 'image tags for version escaped'); like($body, qr/<img src="build">/, 'image tag for build escaped'); }; @@ -104,11 +98,7 @@ like($summary, qr/Passed: 3 Scheduled: 2 Running: 2 None: 1$/i, 'summary badges $form = {distri => 'opensuse', version => '13.1', groupid => 1001}; $t->get_ok('/tests/overview' => form => $form)->status_is(200); -like( - get_summary, - qr/Summary of opensuse build 0091/i, - 'specifying job group but with no build yields latest build in this group' -); +like(get_summary, qr/Summary of opensuse build 0091/i, 'specifying job group but with no build yields latest build in this group'); sub flash_msg { $t->tx->res->dom->at('#flash-messages')->all_text } unlike flash_msg, qr/Specified "groupid" is invalid/i, 'no msg about invalid groupid'; @@ -126,8 +116,7 @@ like($summary, qr/\QFailed: 1\E/i); # # Still possible to check an old build # -$t->get_ok('/tests/overview' => form => {distri => 'opensuse', version => 'Factory', build => '87.5011'}) - ->status_is(200); +$t->get_ok('/tests/overview' => form => {distri => 'opensuse', version => 'Factory', build => '87.5011'})->status_is(200); $summary = get_summary; like($summary, qr/Summary of opensuse Factory build 87.5011/); like($summary, qr/Incomplete: 1/); @@ -200,11 +189,7 @@ subtest 'todo-flag on test overview' => sub { } $t->get_ok('/tests/overview' => form => $form)->status_is(200); - like( - get_summary, - qr/current time Soft-Failed: 1 Failed: 1 Aborted: 1$/i, - 'todo=1 shows only unlabeled left failed (previously softfailed)' - ); + like(get_summary, qr/current time Soft-Failed: 1 Failed: 1 Aborted: 1$/i, 'todo=1 shows only unlabeled left failed (previously softfailed)'); $t->element_exists_not('#res-99939', 'softfailed filtered out'); $t->element_exists('#res-99936', 'unreviewed failed because of new failing module present'); @@ -215,11 +200,7 @@ subtest 'todo-flag on test overview' => sub { user_id => 99903, }); $t->get_ok('/tests/overview' => form => $form)->status_is(200); - like( - get_summary, - qr/current time Failed: 1 Aborted: 1$/i, - 'todo=1 shows only unlabeled left failed after labelling' - ); + like(get_summary, qr/current time Failed: 1 Aborted: 1$/i, 'todo=1 shows only unlabeled left failed after labelling'); $t->element_exists_not('#res-99936', 'reviewed failed filtered out'); $schema->txn_rollback; }; @@ -228,22 +209,14 @@ subtest 'todo-flag on test overview' => sub { $t->get_ok('/tests/overview?distri=opensuse&version=13.1&groupid=1001&groupid=1002&build=0091')->status_is(200); $summary = get_summary; like($summary, qr/Summary of opensuse, opensuse test/i, 'references both groups selected by query'); -like( - $summary, - qr/current time Passed: 2 Scheduled: 1 Running: 2 None: 1$/i, - 'shows latest jobs from both groups 1001/1002' -); +like($summary, qr/current time Passed: 2 Scheduled: 1 Running: 2 None: 1$/i, 'shows latest jobs from both groups 1001/1002'); $t->element_exists('#res_DVD_i586_kde', 'job from group 1001 is shown'); $t->element_exists('#res_GNOME-Live_i686_RAID0 .state_cancelled', 'another job from group 1001'); $t->element_exists('#res_NET_x86_64_kde .state_running', 'job from group 1002 is shown'); $t->get_ok('/tests/overview?distri=opensuse&version=13.1&groupid=1001&groupid=1002')->status_is(200); $summary = get_summary; -like( - $summary, - qr/Summary of opensuse, opensuse test build 0091[^,]/i, - 'multiple groups with no build specified yield the same, latest build of every group' -); +like($summary, qr/Summary of opensuse, opensuse test build 0091[^,]/i, 'multiple groups with no build specified yield the same, latest build of every group'); like($summary, qr/current time Passed: 2 Scheduled: 1 Running: 2 None: 1$/i); my $jobGroup = $schema->resultset('JobGroups')->create( @@ -265,11 +238,7 @@ my $job = $jobs->create( $t->get_ok('/tests/overview?distri=opensuse&version=13.1&groupid=1001&groupid=1003')->status_is(200); $summary = get_summary; -like( - $summary, - qr/Summary of opensuse, opensuse test 2 build 0091,0092/i, - 'multiple groups with no build specified yield each build for every group' -); +like($summary, qr/Summary of opensuse, opensuse test 2 build 0091,0092/i, 'multiple groups with no build specified yield each build for every group'); like($summary, qr/current time Passed: 3 Scheduled: 2 Running: 1 None: 1$/i, 'summary of 0091,0092'); $t->get_ok('/tests/overview?arch=&flavor=&machine=&test=&modules=kate&module_re=&groupid=1001')->status_is(200); @@ -291,11 +260,7 @@ $t->get_ok('/tests/overview' => form => {build => '0091'})->status_is(200); $t->get_ok('/tests/overview')->status_is(200); $summary = get_summary; like($summary, qr/Summary of opensuse/i, 'shows all available latest jobs for the only present distri'); -like( - $summary, - qr/current time Passed: 3 Scheduled: 2 Running: 2 None: 1$/i, - 'shows latest jobs from all distri, version, build, flavor, arch' -); +like($summary, qr/current time Passed: 3 Scheduled: 2 Running: 2 None: 1$/i, 'shows latest jobs from all distri, version, build, flavor, arch'); $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'); @@ -328,8 +293,7 @@ $t->get_ok('/tests/overview' => form => $form)->status_is(200); $t->get_ok('/tests/999379999/modules/kate/fails')->status_is(404, 'Error condition when test not existing'); $t->get_ok('/tests/99937/modules/kate/fails')->json_is('/failed_needles' => ["test-kate-1"], 'correct failed needles'); -$t->get_ok('/tests/99937/modules/zypper_up/fails') - ->json_is('/first_failed_step' => 1, 'failed module: fallback to first step'); +$t->get_ok('/tests/99937/modules/zypper_up/fails')->json_is('/first_failed_step' => 1, 'failed module: fallback to first step'); # Check if logpackages has failed, filtering with failed_modules $form = {distri => 'opensuse', version => 'Factory', failed_modules => 'logpackages'}; @@ -404,14 +368,11 @@ like(get_summary, qr/current time$/i, 'Job was successful, so failed_modules doe $t->element_exists_not('#res-99946', 'no module has failed'); subtest 'Maximum jobs limit' => sub { - $t->get_ok('/tests/overview')->status_is(200)->element_exists_not('#max-jobs-limit') - ->element_count_is('table.overview td.name', 7); + $t->get_ok('/tests/overview')->status_is(200)->element_exists_not('#max-jobs-limit')->element_count_is('table.overview td.name', 7); local OpenQA::App->singleton->config->{misc_limits}->{tests_overview_max_jobs} = 2; $t->get_ok('/tests/overview')->status_is(200)->element_exists('#max-jobs-limit') - ->text_like('#max-jobs-limit', qr/Only 2 results included, please narrow down your search parameters/) - ->element_count_is('table.overview td.name', 2); - $t->get_ok('/tests/overview?result=incomplete')->status_is(200)->element_exists_not('#max-jobs-limit') - ->element_count_is('table.overview td.name', 0); + ->text_like('#max-jobs-limit', qr/Only 2 results included, please narrow down your search parameters/)->element_count_is('table.overview td.name', 2); + $t->get_ok('/tests/overview?result=incomplete')->status_is(200)->element_exists_not('#max-jobs-limit')->element_count_is('table.overview td.name', 0); }; done_testing(); diff --git a/t/13-joblocks.t b/t/13-joblocks.t index 9a35d87b59f1..899bdc928a4e 100644 --- a/t/13-joblocks.t +++ b/t/13-joblocks.t @@ -321,11 +321,8 @@ $t->post_ok($b_prefix . '/barrier2', form => {action => 'wait', check_dead_job = # input validation $t->post_ok($m_prefix)->status_is(400)->content_is('Erroneous parameters (name missing)'); $t->post_ok("$m_prefix/foo")->status_is(400)->content_is('Erroneous parameters (action missing)'); -$t->post_ok($b_prefix => form => {tasks => 'abc'})->status_is(400) - ->content_is('Erroneous parameters (name missing, tasks invalid)'); -$t->post_ok("$b_prefix/foo" => form => {where => 'abc'})->status_is(400) - ->content_is('Erroneous parameters (where invalid)'); -$t->delete_ok("$b_prefix/foo" => form => {where => 'abc'})->status_is(400) - ->content_is('Erroneous parameters (where invalid)'); +$t->post_ok($b_prefix => form => {tasks => 'abc'})->status_is(400)->content_is('Erroneous parameters (name missing, tasks invalid)'); +$t->post_ok("$b_prefix/foo" => form => {where => 'abc'})->status_is(400)->content_is('Erroneous parameters (where invalid)'); +$t->delete_ok("$b_prefix/foo" => form => {where => 'abc'})->status_is(400)->content_is('Erroneous parameters (where invalid)'); done_testing(); diff --git a/t/14-grutasks.t b/t/14-grutasks.t index 73358c1e6656..72ef3460de3e 100644 --- a/t/14-grutasks.t +++ b/t/14-grutasks.t @@ -156,8 +156,7 @@ sub find_kept_assets_with_last_jobs { return [map { {asset => $_->name, job => $_->last_use_job_id} } $last_used_jobs->all]; } is_deeply(find_kept_assets_with_last_jobs, [], 'initially, none of the assets has the job of its last use assigned'); -is($job_groups->find(1001)->exclusively_kept_asset_size, - undef, 'initially no size for exclusively kept assets accumulated'); +is($job_groups->find(1001)->exclusively_kept_asset_size, undef, 'initially no size for exclusively kept assets accumulated'); # understanding / revising these tests requires understanding the # assets in the test database. As I write this, there are 6 assets @@ -202,14 +201,11 @@ my @expected_last_jobs_no_removal = ( is_deeply(find_kept_assets_with_last_jobs, \@expected_last_jobs_no_removal, 'last jobs correctly assigned'); # job group 1001 should exclusively keep 3, 1, 5 and 4 -is($job_groups->find(1001)->exclusively_kept_asset_size, - 72 * $gib, 'kept assets for group 1001 accumulated (18 GiB per asset)'); +is($job_groups->find(1001)->exclusively_kept_asset_size, 72 * $gib, 'kept assets for group 1001 accumulated (18 GiB per asset)'); # parent group 1 should exclusively keep 2 and 6 belonging to its job group 1002 -is($parent_groups->find(1)->exclusively_kept_asset_size, - 36 * $gib, 'kept assets for group 1 accumulated (18 GiB per asset)'); +is($parent_groups->find(1)->exclusively_kept_asset_size, 36 * $gib, 'kept assets for group 1 accumulated (18 GiB per asset)'); # 1002 should exclusively keep 2 and 6 -is($job_groups->find(1002)->exclusively_kept_asset_size, - 0, 'nothing accumulated for individual job group within parent'); +is($job_groups->find(1002)->exclusively_kept_asset_size, 0, 'nothing accumulated for individual job group within parent'); # at size 24GiB, group 1001 is over the 80% threshold but under the 100GiB @@ -229,11 +225,7 @@ is( 'kept assets for group 1001 accumulated, job over threshold not taken into account (24 GiB per asset)' ); # parent group 1 should exclusively keep the same as above -is( - $parent_groups->find(1)->exclusively_kept_asset_size, - 2 * 24 * $gib, - 'kept assets for group 1002 accumulated (24 GiB per asset)' -); +is($parent_groups->find(1)->exclusively_kept_asset_size, 2 * 24 * $gib, 'kept assets for group 1002 accumulated (24 GiB per asset)'); # at size 26GiB, 1001 is over the limit, so removal should occur. Removing # just one asset - #4 - will get under the 80GiB threshold. @@ -262,11 +254,7 @@ is( 'kept assets for group 1001 accumulated and deleted asset not taken into account (26 GiB per asset)' ); # parent group 1 should exclusively keep 2 and 6 belonging to its job group 1002 -is( - $parent_groups->find(1)->exclusively_kept_asset_size, - 2 * 26 * $gib, - 'kept assets for group 1002 accumulated (26 GiB per asset)' -); +is($parent_groups->find(1)->exclusively_kept_asset_size, 2 * 26 * $gib, 'kept assets for group 1002 accumulated (26 GiB per asset)'); reset_mocked_asset_deletions; @@ -296,11 +284,7 @@ is( 'kept assets for group 1001 accumulated and deleted asset not taken into account (34 GiB per asset)' ); # parent group 1 should exclusively keep 2 and 6 belonging to its job group 1002 -is( - $parent_groups->find(1)->exclusively_kept_asset_size, - 2 * 34 * $gib, - 'kept assets for group 1002 accumulated (34 GiB per asset)' -); +is($parent_groups->find(1)->exclusively_kept_asset_size, 2 * 34 * $gib, 'kept assets for group 1002 accumulated (34 GiB per asset)'); reset_mocked_asset_deletions; @@ -312,8 +296,7 @@ subtest 'assets associated with pending jobs are preserved' => sub { my $other_asset_name = 'openSUSE-Factory-staging_e-x86_64-Build87.5011-Media.iso'; my $most_reject_job_for_asset_1 = $job_assets->find({asset_id => 1}, {order_by => {-desc => 'job_id'}, rows => 1}); $most_reject_job_for_asset_1 = $most_reject_job_for_asset_1->job if $most_reject_job_for_asset_1; - is($most_reject_job_for_asset_1->id, - 99947, "job 99947 is actually the most recent job of asset $pending_asset_name"); + is($most_reject_job_for_asset_1->id, 99947, "job 99947 is actually the most recent job of asset $pending_asset_name"); my $pending_job = $jobs->find(99947); $pending_job->update({state => RUNNING, result => NONE, t_finished => undef}); @@ -326,11 +309,9 @@ subtest 'assets associated with pending jobs are preserved' => sub { subtest 'pending asset preserved' => sub { run_gru_job($t->app, 'limit_assets'); my ($removed_assets, $deleted_assets) = (mock_removed, mock_deleted); - is_deeply($removed_assets, [$other_asset_name], - "only other asset $other_asset_name has been removed with 99947 pending") + is_deeply($removed_assets, [$other_asset_name], "only other asset $other_asset_name has been removed with 99947 pending") or diag explain $removed_assets; - is_deeply($deleted_assets, [$other_asset_name], - "only other asset $other_asset_name has been deleted with 99947 pending") + is_deeply($deleted_assets, [$other_asset_name], "only other asset $other_asset_name has been deleted with 99947 pending") or diag explain $deleted_assets; }; @@ -338,17 +319,14 @@ subtest 'assets associated with pending jobs are preserved' => sub { subtest 'pending asset preserved even though the most recent job associated with the asset is not pending' => sub { # add another job associated with the asset which is *not* pending - my $another_associated_job - = $jobs->create({id => 199947, TEST => 'job-with-asset-1', state => DONE, result => PASSED}); + my $another_associated_job = $jobs->create({id => 199947, TEST => 'job-with-asset-1', state => DONE, result => PASSED}); $job_assets->create({asset_id => 1, job_id => $another_associated_job->id}); run_gru_job($t->app, 'limit_assets'); my ($removed_assets, $deleted_assets) = (mock_removed, mock_deleted); - is_deeply($removed_assets, [$other_asset_name], - "only other asset $other_asset_name has been removed with 99947 pending") + is_deeply($removed_assets, [$other_asset_name], "only other asset $other_asset_name has been removed with 99947 pending") or diag explain $removed_assets; - is_deeply($deleted_assets, [$other_asset_name], - "only other asset $other_asset_name has been deleted with 99947 pending") + is_deeply($deleted_assets, [$other_asset_name], "only other asset $other_asset_name has been deleted with 99947 pending") or diag explain $deleted_assets; $another_associated_job->discard_changes; $another_associated_job->delete; @@ -360,18 +338,12 @@ subtest 'assets associated with pending jobs are preserved' => sub { $pending_job->update({state => DONE, result => PASSED}); run_gru_job($t->app, 'limit_assets'); my ($removed_assets, $deleted_assets) = (mock_removed, mock_deleted); - is_deeply( - [sort @$removed_assets], - [$pending_asset_name, $other_asset_name], - "asset $pending_asset_name has been removed with 99947 no longer pending" - ) or diag explain $removed_assets; - is_deeply( - [sort @$deleted_assets], - [$pending_asset_name, $other_asset_name], - "asset $pending_asset_name has been deleted with 99947 no longer pending" - ) or diag explain $deleted_assets; - # note: The main purpose of this subtest is to cross-check whether this test is actually working. If the asset would - # still not be cleaned up here that would mean the pending state makes no difference for this test and it is + is_deeply([sort @$removed_assets], [$pending_asset_name, $other_asset_name], "asset $pending_asset_name has been removed with 99947 no longer pending") + or diag explain $removed_assets; + is_deeply([sort @$deleted_assets], [$pending_asset_name, $other_asset_name], "asset $pending_asset_name has been deleted with 99947 no longer pending") + or diag explain $deleted_assets; + # note: The main purpose of this subtest is to cross-check whether this test is actually working. If the asset would + # still not be cleaned up here that would mean the pending state makes no difference for this test and it is # therefore meaningless. }; }; @@ -453,8 +425,7 @@ subtest 'labeled jobs considered important' => sub { my $minion_jobs = $minion->jobs({tasks => ['archive_job_results']}); if (is $minion_jobs->total, 1, 'archiving job enqueued') { my $archiving_job = $minion_jobs->next; - my $expected_archive_path - = 't/data/openqa/archive/testresults/00099/00099938-opensuse-Factory-DVD-x86_64-Build0048-doc'; + my $expected_archive_path = 't/data/openqa/archive/testresults/00099/00099938-opensuse-Factory-DVD-x86_64-Build0048-doc'; is_deeply $archiving_job->{args}, [99938], 'archiving job is for right openQA job' or diag explain $archiving_job->{args}; is $archiving_job->{state}, 'finished', 'archiving job succeeded'; @@ -591,8 +562,7 @@ subtest 'handling user error occurring in GRU task' => sub { is $t->app->minion->job($ids->{minion_id})->info->{state}, 'inactive', 'minion job is inactive'; combined_unlike { perform_minion_jobs($t->app->minion) } qr/Gru job error/, 'no error logged'; ok !$schema->resultset('GruTasks')->find($ids->{gru_id}), 'gru task no longer exists'; - is $t->app->minion->job($ids->{minion_id})->info->{state}, 'finished', - 'minion job is still considered finished (and not failed)'; + is $t->app->minion->job($ids->{minion_id})->info->{state}, 'finished', 'minion job is still considered finished (and not failed)'; is $t->app->minion->job($ids->{minion_id})->info->{result}, 'Manual user error', 'minion job has the right result'; $associated_job->discard_changes; is $associated_job->result, INCOMPLETE, 'associated job is incomplete'; @@ -628,8 +598,7 @@ subtest 'handling dying GRU task' => sub { qr/Gru job error: Thrown fail/, 'exception logged'; ok !$schema->resultset('GruTasks')->find($ids->{gru_id}), 'gru task no longer exists'; is $t->app->minion->job($ids->{minion_id})->info->{state}, 'failed', 'minion job is finished'; - like $t->app->minion->job($ids->{minion_id})->info->{result}, qr/Thrown fail/, - 'minion job has the right error message'; + like $t->app->minion->job($ids->{minion_id})->info->{result}, qr/Thrown fail/, 'minion job has the right error message'; $associated_job->discard_changes; is $associated_job->result, INCOMPLETE, 'associated job is incomplete'; like $associated_job->reason, qr/^preparation failed: Thrown fail at/, 'reason of associated job set'; @@ -672,8 +641,7 @@ subtest 'download assets with correct permissions' => sub { my $good_res = Mojo::Message::Response->new->code(200); # fake a response where $res->is_success returns true my $downloader_mock = Test::MockModule->new('OpenQA::Downloader'); - $downloader_mock->redefine( - download => sub ($self, $url, $assetpath, $options) { $self->res($good_res); return 'fake error' }); + $downloader_mock->redefine(download => sub ($self, $url, $assetpath, $options) { $self->res($good_res); return 'fake error' }); combined_like { $info = run_gru_job($t->app, 'download_asset' => [$assetsource, $assetpath, 0]) } qr/.*Downloading.*failed with: fake error/s, 'error from download function logged'; is $info->{state}, 'finished', 'job considered finished, errors from download function are likely external problem'; @@ -773,8 +741,7 @@ subtest 'finalize job results' => sub { subtest 'enqueue finalize_job_results without job or job which (no longer) exists' => sub { my $job; - combined_like { $job = run_gru_job($app, finalize_job_results => [undef]) } qr/error: No job ID/, - 'no job id handled'; + combined_like { $job = run_gru_job($app, finalize_job_results => [undef]) } qr/error: No job ID/, 'no job id handled'; is $job->{state}, 'failed', 'no job id treated as failure'; $job = run_gru_job($app, finalize_job_results => [98765]); is $job->{state}, 'finished', 'non-existing job id treated as success'; diff --git a/t/15-assets.t b/t/15-assets.t index 9e98d11e7e23..83bd6d1beca8 100644 --- a/t/15-assets.t +++ b/t/15-assets.t @@ -199,12 +199,10 @@ ok($fixed->is_fixed(), 'fixed should be considered a fixed asset'); # test OpenQA::Utils::locate_asset # fixed HDD asset my $expected = path(assetdir, 'hdd', 'fixed', 'fixed.img'); -is(locate_asset('hdd', 'fixed.img', mustexist => 1), - $expected, 'locate_asset should find fixed asset in fixed location'); +is(locate_asset('hdd', 'fixed.img', mustexist => 1), $expected, 'locate_asset should find fixed asset in fixed location'); # relative $expected = path('hdd', 'fixed', 'fixed.img'); -is(locate_asset('hdd', 'fixed.img', mustexist => 1, relative => 1), - $expected, 'locate_asset should return fixed path as relative'); +is(locate_asset('hdd', 'fixed.img', mustexist => 1, relative => 1), $expected, 'locate_asset should return fixed path as relative'); # transient repo asset $expected = path(assetdir, 'repo', 'tmprepo'); @@ -251,8 +249,7 @@ subtest 'asset status' => sub { # ensure cache file does not exist from a previous test run unlink($asset_cache_file); - $t->get_ok('/admin/assets/status?force_refresh=1') - ->status_is(400, 'viewing assets page without cache file not possible during cleanup') + $t->get_ok('/admin/assets/status?force_refresh=1')->status_is(400, 'viewing assets page without cache file not possible during cleanup') ->json_is('/error' => 'Asset cleanup is currently ongoing.'); $limit_assets_active = 0; @@ -264,11 +261,9 @@ subtest 'asset status' => sub { ok(-f $asset_cache_file, 'asset cache file has been created'); $limit_assets_active = 1; - $t->get_ok('/admin/assets/status?force_refresh=1') - ->status_is(400, 'viewing assets page with force_refresh not possible during cleanup') + $t->get_ok('/admin/assets/status?force_refresh=1')->status_is(400, 'viewing assets page with force_refresh not possible during cleanup') ->json_is('/error' => 'Asset cleanup is currently ongoing.'); - $t->get_ok('/admin/assets/status') - ->status_is(200, 'asset status rendered from cache file although cleanup is ongoing'); + $t->get_ok('/admin/assets/status')->status_is(200, 'asset status rendered from cache file although cleanup is ongoing'); }; @@ -287,11 +282,9 @@ subtest 'check for missing assets' => sub { subtest 'one asset is missing' => sub { my $job_with_2_assets = $jobs->create_from_settings(\%settings); @assets = sort map { $_->asset->name } $job_with_2_assets->jobs_assets; - is_deeply \@assets, [qw(not_existent whatever.iso whatever.sha256)], - 'two existing and one missing assets assigned' + is_deeply \@assets, [qw(not_existent whatever.iso whatever.sha256)], 'two existing and one missing assets assigned' or diag explain \@assets; - is_deeply $job_with_2_assets->missing_assets, - ['hdd/not_existent'], 'assets are considered missing if at least one is missing' + is_deeply $job_with_2_assets->missing_assets, ['hdd/not_existent'], 'assets are considered missing if at least one is missing' or diag explain $job_with_2_assets->missing_assets; }; subtest 'repo assets are ignored' => sub { @@ -315,8 +308,7 @@ subtest 'check for missing assets' => sub { parent_job_id => $parent_job->id, dependency => OpenQA::JobDependencies::Constants::CHAINED }); - $schema->resultset('Assets') - ->create({type => 'hdd', name => sprintf("%08d-disk_from_parent", $parent_job->id), size => 0}); + $schema->resultset('Assets')->create({type => 'hdd', name => sprintf("%08d-disk_from_parent", $parent_job->id), size => 0}); $missing_assets = $job_with_2_assets->missing_assets; is_deeply $missing_assets, [], 'private asset created by parent so no asset missing' or diag explain $missing_assets; @@ -331,12 +323,10 @@ subtest 'check for missing assets' => sub { parent_job_id => $parent_job->id, dependency => OpenQA::JobDependencies::Constants::CHAINED }); - $schema->resultset('Assets') - ->create({type => 'hdd', name => sprintf("%08d-disk_from_parent", $parent_job->id), size => 0}); + $schema->resultset('Assets')->create({type => 'hdd', name => sprintf("%08d-disk_from_parent", $parent_job->id), size => 0}); @assets = sort map { $_->asset->name } $job_with_2_assets->jobs_assets->all; $missing_assets = $job_with_2_assets->missing_assets; - is_deeply $missing_assets, ['hdd/non_existent'], - 'private assets correctly detected also when other asset is missing' + is_deeply $missing_assets, ['hdd/non_existent'], 'private assets correctly detected also when other asset is missing' or diag explain $missing_assets; }; }; diff --git a/t/16-markdown.t b/t/16-markdown.t index b7152abdeb71..d0a28bd51d16 100644 --- a/t/16-markdown.t +++ b/t/16-markdown.t @@ -26,16 +26,14 @@ subtest 'standard markdown' => sub { is markdown_to_html("* a\n* b\n* c\n"), qq{
      \n
    • a
    • \n
    • b
    • \n
    • c
    • \n
    \n}, 'HTML rendered'; is markdown_to_html('[Test](http://test.com)'), qq{

    Test

    \n}, 'HTML rendered'; is markdown_to_html('[Test](/test.html)'), qq{

    Test

    \n}, 'HTML rendered'; - is markdown_to_html('![Test](http://test.com)'), qq{

    Test

    \n}, - 'HTML rendered'; + is markdown_to_html('![Test](http://test.com)'), qq{

    Test

    \n}, 'HTML rendered'; is markdown_to_html('Test `123` 123'), "

    Test 123 123

    \n", 'HTML rendered'; is markdown_to_html("> test\n> 123"), "
    \n

    test\n123

    \n
    \n", 'HTML rendered'; is markdown_to_html('---'), "
    \n", 'HTML rendered'; }; subtest 'bugrefs' => sub { - is markdown_to_html('boo#123'), - qq{

    boo#123

    \n}, 'bugref expanded'; + is markdown_to_html('boo#123'), qq{

    boo#123

    \n}, 'bugref expanded'; is markdown_to_html('testing boo#123 123'), qq{

    testing boo#123 123

    \n}, 'bugref expanded'; @@ -58,19 +56,17 @@ subtest 'bugrefs' => sub { qq{

    related issue: bsc#1234, yada yada

    \n}, 'bugref expanded'; is markdown_to_html('label:force_result:passed:bsc#1234'), - qq{

    label:force_result:passed:} - . qq{bsc#1234

    \n}, + qq{

    label:force_result:passed:} . qq{bsc#1234

    \n}, 'bugref expaned within label'; }; subtest 'openQA additions' => sub { - is markdown_to_html('https://example.com'), - qq{

    https://example.com

    \n}, 'URL turned into a link'; + is markdown_to_html('https://example.com'), qq{

    https://example.com

    \n}, 'URL turned into a link'; is markdown_to_html('https://example.com/#fragment_-'), qq{

    https://example.com/#fragment_-

    \n}, 'URL with fragment turned into a link'; is markdown_to_html('https://example.com/#fragment/'), -qq{

    https://example.com/#fragment/test

    \n}, + qq{

    https://example.com/#fragment/test

    \n}, 'URL with fragment + script turned into a link'; is markdown_to_html('https://example.com/#?(.-/\' some text'), qq{

    https://example.com/#?(.-/' some text

    \n}, @@ -82,18 +78,12 @@ qq{

    https://example.com/#fragment/t\ntesting https://example.com 123\n123

    \n}, 'URL turned into a link'; is markdown_to_html('t#123'), qq{

    t#123

    \n}, 'testref expanded'; - is markdown_to_html('testing t#123 123'), qq{

    testing t#123 123

    \n}, - 'testref expanded'; - is markdown_to_html("t\ntesting t#123 123\n123"), qq{

    t\ntesting t#123 123\n123

    \n}, - 'testref expanded'; + is markdown_to_html('testing t#123 123'), qq{

    testing t#123 123

    \n}, 'testref expanded'; + is markdown_to_html("t\ntesting t#123 123\n123"), qq{

    t\ntesting t#123 123\n123

    \n}, 'testref expanded'; - is markdown_to_html(qq{{{color:#ffffff|"Text"}}}), - qq{

    "Text"

    \n}, - 'White text'; - is markdown_to_html("test {{color:#ff0000|Text}} 123"), - qq{

    test Text 123

    \n}, 'Red text'; - is markdown_to_html("test {{color:#FFFFFF|Text}} 123"), - qq{

    test Text 123

    \n}, 'White text'; + is markdown_to_html(qq{{{color:#ffffff|"Text"}}}), qq{

    "Text"

    \n}, 'White text'; + is markdown_to_html("test {{color:#ff0000|Text}} 123"), qq{

    test Text 123

    \n}, 'Red text'; + is markdown_to_html("test {{color:#FFFFFF|Text}} 123"), qq{

    test Text 123

    \n}, 'White text'; is markdown_to_html("test {{color:#00ff00|Some Text}} 123"), qq{

    test Some Text 123

    \n}, 'Green text'; is markdown_to_html("test {{color:#00ff00|Some Text}} 123 {{color:#0000ff|Also {w}orks}}"), @@ -102,8 +92,7 @@ qq{

    https://example.com/#fragment/test {{ color: #00ff00 | Some Text }} 123

    \n", 'Extra whitespace is not allowed'; - is markdown_to_html("test {{color:javascript|Text}} 123"), - qq{

    test {{color:javascript|Text}} 123

    \n}, 'Invalid custom tag'; + is markdown_to_html("test {{color:javascript|Text}} 123"), qq{

    test {{color:javascript|Text}} 123

    \n}, 'Invalid custom tag'; is markdown_to_html(qq{test {{javascript:alert("test")|Text}} 123}), qq{

    test {{javascript:alert("test")|Text}} 123

    \n}, 'Invalid custom tag'; }; @@ -112,47 +101,38 @@ subtest 'unsafe HTML filtered out' => sub { is markdown_to_html('Test 123'), "

    Test alert("boom!"); 123

    \n", 'unsafe HTML filtered'; - is markdown_to_html('Test'), "

    Test

    \n", - 'unsafe HTML filtered'; - is markdown_to_html('Test [Boom!](javascript:alert("boom!")) 123'), qq{

    Test Boom! 123

    \n}, - 'unsafe HTML filtered'; + is markdown_to_html('Test'), "

    Test

    \n", 'unsafe HTML filtered'; + is markdown_to_html('Test [Boom!](javascript:alert("boom!")) 123'), qq{

    Test Boom! 123

    \n}, 'unsafe HTML filtered'; is markdown_to_html('Totally safe'), "

    Totally safe

    \n", 'unsafe HTML filtered'; is markdown_to_html(qq{> hello href="javascript:alert('boom!')">*you*}), qq{
    \n

    hello you

    \n
    \n}, 'unsafe HTML filtered'; is markdown_to_html('{{color:#0000ff|Test}}'), - qq{

    } - . qq{Test

    \n}, + qq{

    } . qq{Test

    \n}, 'unsafe HTML filtered'; }; subtest 'bugrefs to markdown' => sub { is bugref_to_markdown('bnc#9876'), '[bnc#9876](https://bugzilla.suse.com/show_bug.cgi?id=9876)', 'right markdown'; is bugref_to_markdown('bsc#9876'), '[bsc#9876](https://bugzilla.suse.com/show_bug.cgi?id=9876)', 'right markdown'; - is bugref_to_markdown('boo#9876'), '[boo#9876](https://bugzilla.opensuse.org/show_bug.cgi?id=9876)', - 'right markdown'; + is bugref_to_markdown('boo#9876'), '[boo#9876](https://bugzilla.opensuse.org/show_bug.cgi?id=9876)', 'right markdown'; is bugref_to_markdown('bgo#9876'), '[bgo#9876](https://bugzilla.gnome.org/show_bug.cgi?id=9876)', 'right markdown'; is bugref_to_markdown('brc#9876'), '[brc#9876](https://bugzilla.redhat.com/show_bug.cgi?id=9876)', 'right markdown'; is bugref_to_markdown('bko#9876'), '[bko#9876](https://bugzilla.kernel.org/show_bug.cgi?id=9876)', 'right markdown'; is bugref_to_markdown('poo#9876'), '[poo#9876](https://progress.opensuse.org/issues/9876)', 'right markdown'; - is bugref_to_markdown('gh#foo/bar#1234'), '[gh#foo/bar#1234](https://github.com/foo/bar/issues/1234)', - 'right markdown'; + is bugref_to_markdown('gh#foo/bar#1234'), '[gh#foo/bar#1234](https://github.com/foo/bar/issues/1234)', 'right markdown'; is bugref_to_markdown('kde#9876'), '[kde#9876](https://bugs.kde.org/show_bug.cgi?id=9876)', 'right markdown'; - is bugref_to_markdown('fdo#9876'), '[fdo#9876](https://bugs.freedesktop.org/show_bug.cgi?id=9876)', - 'right markdown'; + is bugref_to_markdown('fdo#9876'), '[fdo#9876](https://bugs.freedesktop.org/show_bug.cgi?id=9876)', 'right markdown'; is bugref_to_markdown('jsc#9876'), '[jsc#9876](https://jira.suse.de/browse/9876)', 'right markdown'; is bugref_to_markdown('pio#foo#1234'), '[pio#foo#1234](https://pagure.io/foo/issue/1234)', 'right markdown'; - is bugref_to_markdown('pio#foo/bar#1234'), '[pio#foo/bar#1234](https://pagure.io/foo/bar/issue/1234)', - 'right markdown'; - is bugref_to_markdown('ggo#GNOME/foo#1234'), - '[ggo#GNOME/foo#1234](https://gitlab.gnome.org/GNOME/foo/issues/1234)', 'right markdown'; + is bugref_to_markdown('pio#foo/bar#1234'), '[pio#foo/bar#1234](https://pagure.io/foo/bar/issue/1234)', 'right markdown'; + is bugref_to_markdown('ggo#GNOME/foo#1234'), '[ggo#GNOME/foo#1234](https://gitlab.gnome.org/GNOME/foo/issues/1234)', 'right markdown'; is bugref_to_markdown('gfs#flatpak/fedora-flatpaks#26'), '[gfs#flatpak/fedora-flatpaks#26](https://gitlab.com/fedora/sigs/flatpak/fedora-flatpaks/issues/26)', 'right markdown'; is bugref_to_markdown("boo#9876\n\ntest boo#211\n"), - "[boo#9876](https://bugzilla.opensuse.org/show_bug.cgi?id=9876)\n\n" - . "test [boo#211](https://bugzilla.opensuse.org/show_bug.cgi?id=211)\n", + "[boo#9876](https://bugzilla.opensuse.org/show_bug.cgi?id=9876)\n\n" . "test [boo#211](https://bugzilla.opensuse.org/show_bug.cgi?id=211)\n", 'right markdown'; is bugref_to_markdown('label:force_result:passed:bsc#1234'), 'label:force_result:passed:bsc#1234', 'right markdown'; }; diff --git a/t/16-utils-job-templates.t b/t/16-utils-job-templates.t index a1d03029daa8..6d00b2e4bd8a 100644 --- a/t/16-utils-job-templates.t +++ b/t/16-utils-job-templates.t @@ -42,11 +42,7 @@ like($errors->[0], qr{Unable to load schema}, "non-existent absolute schema file $errors = validate_data(schema_file => $invalid_yaml_schema, data => $template); is scalar @$errors, 1, "Schema file with invalid YAML errors" or diag "Error: $_" for @$errors; -like( - $errors->[0], - qr{YAML::XS::Load Error.*document: 1, line: 2, column: 1}s, - 'Schema file with invalid YAML returns full error message' -); +like($errors->[0], qr{YAML::XS::Load Error.*document: 1, line: 2, column: 1}s, 'Schema file with invalid YAML returns full error message'); $errors = validate_data(%default_args, data => load_yaml(file => $template_openqa)); if (@$errors) { diag "Error: $_" for @$errors } diff --git a/t/16-utils-runcmd.t b/t/16-utils-runcmd.t index b19e55618437..89ed5b0ff811 100644 --- a/t/16-utils-runcmd.t +++ b/t/16-utils-runcmd.t @@ -102,10 +102,7 @@ subtest 'git commands with mocked run_cmd_with_log_return_error' => sub { is($git->set_to_latest_master, undef, 'no error'); is_deeply( \@executed_commands, - [ - [qw(git -C foo/bar remote update origin)], [qw(git -C foo/bar reset --hard HEAD)], - [qw(git -C foo/bar rebase origin/master)], - ], + [[qw(git -C foo/bar remote update origin)], [qw(git -C foo/bar reset --hard HEAD)], [qw(git -C foo/bar rebase origin/master)],], 'git remote update and rebase executed', ) or diag explain \@executed_commands; @@ -114,11 +111,7 @@ subtest 'git commands with mocked run_cmd_with_log_return_error' => sub { $mock_return_value{status} = 0; $mock_return_value{stderr} = 'mocked error'; $mock_return_value{stdout} = ''; - is( - $git->set_to_latest_master, - 'Unable to fetch from origin master: mocked error', - 'an error occurred on remote update' - ); + is($git->set_to_latest_master, 'Unable to fetch from origin master: mocked error', 'an error occurred on remote update'); is_deeply(\@executed_commands, [[qw(git -C foo/bar remote update origin)],], 'git reset not attempted',) or diag explain \@executed_commands; @@ -141,12 +134,7 @@ subtest 'git commands with mocked run_cmd_with_log_return_error' => sub { [ [qw(git -C /repo/path add foo.png foo.json)], [qw(git -C /repo/path rm bar.png bar.json)], - [ - qw(git -C /repo/path commit -q -m), - 'some test', - '--author=openQA system user ', - qw(foo.png foo.json bar.png bar.json) - ], + [qw(git -C /repo/path commit -q -m), 'some test', '--author=openQA system user ', qw(foo.png foo.json bar.png bar.json)], ], 'changes staged and committed', ) or diag explain \@executed_commands; diff --git a/t/16-utils.t b/t/16-utils.t index 96ad20b69e66..0e8c7a84c019 100644 --- a/t/16-utils.t +++ b/t/16-utils.t @@ -116,8 +116,7 @@ is bugurl('poo#1234'), 'https://progress.opensuse.org/issues/1234'; is href_to_bugref('https://progress.opensuse.org/issues/1234'), 'poo#1234'; is bugref_to_href('boo#9876'), 'boo#9876'; is href_to_bugref('https://github.com/foo/bar/issues/1234'), 'gh#foo/bar#1234'; -is href_to_bugref('https://github.com/os-autoinst/os-autoinst/pull/960'), 'gh#os-autoinst/os-autoinst#960', - 'github pull are also transformed same as issues'; +is href_to_bugref('https://github.com/os-autoinst/os-autoinst/pull/960'), 'gh#os-autoinst/os-autoinst#960', 'github pull are also transformed same as issues'; is bugref_to_href('gh#foo/bar#1234'), 'gh#foo/bar#1234'; like bugref_to_href('bsc#2345 poo#3456 and more'), qr{a href="https://bugzilla.suse.com/show_bug.cgi\?id=2345">bsc\#2345 and more}, @@ -129,13 +128,9 @@ is bugref_to_href('jsc#SLE-3275'), ' { @@ -401,11 +395,9 @@ subtest 'project directory functions' => sub { $mocked_git->remove_tree if -e $mocked_git; is gitrepodir(distri => $distri), '', 'empty when .git is missing'; $mocked_git->make_path; - $mocked_git->child('config') - ->spew(qq{[remote "origin"]\n url = git\@github.com:fakerepo/os-autoinst-distri-opensuse.git}); + $mocked_git->child('config')->spew(qq{[remote "origin"]\n url = git\@github.com:fakerepo/os-autoinst-distri-opensuse.git}); is gitrepodir(distri => $distri) =~ /github\.com.+os-autoinst-distri-opensuse\/commit/, 1, 'correct git url'; - $mocked_git->child('config') - ->spew(qq{[remote "origin"]\n url = https://github.com/fakerepo/os-autoinst-distri-opensuse.git}); + $mocked_git->child('config')->spew(qq{[remote "origin"]\n url = https://github.com/fakerepo/os-autoinst-distri-opensuse.git}); is gitrepodir(distri => $distri) =~ /github\.com.+os-autoinst-distri-opensuse\/commit/, 1, 'correct git url'; }; subtest 'custom OPENQA_BASEDIR and OPENQA_SHAREDIR' => sub { diff --git a/t/17-build_tagging.t b/t/17-build_tagging.t index 46c1871fc5f5..692bb0215f67 100644 --- a/t/17-build_tagging.t +++ b/t/17-build_tagging.t @@ -136,10 +136,8 @@ subtest 'only_tagged=1 query parameter shows only tagged (poo#11052)' => sub { subtest 'show_tags query parameter enables/disables tags on index page' => sub { for my $enabled (0, 1) { $t->get_ok('/dashboard_build_results?show_tags=' . $enabled)->status_is(200); - is(scalar @{$t->tx->res->dom->find('a[href^=/tests/]')}, - 9, "all builds shown on index page (show_tags=$enabled)"); - is(scalar @{$t->tx->res->dom->find("i[title='important']")}, - $enabled, "tag (not) shown on index page (show_tags=$enabled)"); + is(scalar @{$t->tx->res->dom->find('a[href^=/tests/]')}, 9, "all builds shown on index page (show_tags=$enabled)"); + is(scalar @{$t->tx->res->dom->find("i[title='important']")}, $enabled, "tag (not) shown on index page (show_tags=$enabled)"); } }; @@ -276,8 +274,7 @@ subtest 'expired jobs' => sub { is_deeply($jg->$m, [], 'no jobs with expired ' . $file_type); - $t->app->schema->resultset('Jobs')->find(99938) - ->update({t_finished => time2str('%Y-%m-%d %H:%M:%S', time - ONE_DAY * 12, 'UTC')}); + $t->app->schema->resultset('Jobs')->find(99938)->update({t_finished => time2str('%Y-%m-%d %H:%M:%S', time - ONE_DAY * 12, 'UTC')}); is_deeply($jg->$m, [], 'still no jobs with expired ' . $file_type); $jg->update({"keep_${file_type}_in_days" => 5}); # now the unimportant jobs are expired @@ -287,13 +284,11 @@ subtest 'expired jobs' => sub { is_deeply(_map_expired($jg, $m), [qw(99937 99981)], 'still 2 jobs with expired ' . $file_type); $jg->update({"keep_important_${file_type}_in_days" => 10}); - is_deeply(_map_expired($jg, $m), - [qw(99937 99938 99981)], 'now also important job 99938 with expired ' . $file_type); + is_deeply(_map_expired($jg, $m), [qw(99937 99938 99981)], 'now also important job 99938 with expired ' . $file_type); } $t->app->schema->resultset('Jobs')->find(99938)->update({logs_present => 0}); - is_deeply(_map_expired($jg, $m), - [qw(99937 99981)], 'job with deleted logs not return among jobs with expired logs'); + is_deeply(_map_expired($jg, $m), [qw(99937 99981)], 'job with deleted logs not return among jobs with expired logs'); }; =pod @@ -357,11 +352,9 @@ subtest 'version tagging' => sub { subtest 'content negotiation' => sub { $t->get_ok('/group_overview/1001')->status_is(200)->content_type_is('text/html;charset=UTF-8'); $t->get_ok('/group_overview/1001.html')->status_is(200)->content_type_is('text/html;charset=UTF-8'); - $t->get_ok('/group_overview/1001' => {Accept => 'text/html'})->status_is(200) - ->content_type_is('text/html;charset=UTF-8'); + $t->get_ok('/group_overview/1001' => {Accept => 'text/html'})->status_is(200)->content_type_is('text/html;charset=UTF-8'); $t->get_ok('/group_overview/1001.json')->status_is(200)->content_type_is('application/json;charset=UTF-8'); - $t->get_ok('/group_overview/1001' => {Accept => 'application/json'})->status_is(200) - ->content_type_is('application/json;charset=UTF-8'); + $t->get_ok('/group_overview/1001' => {Accept => 'application/json'})->status_is(200)->content_type_is('application/json;charset=UTF-8'); }; subtest 'tags with datetime' => sub { diff --git a/t/17-labels_carry_over.t b/t/17-labels_carry_over.t index db85cd2e38d2..139ae7327219 100644 --- a/t/17-labels_carry_over.t +++ b/t/17-labels_carry_over.t @@ -25,8 +25,7 @@ my $auth = {'X-CSRF-Token' => $t->ua->get('/tests')->res->dom->at('meta[name=csr $test_case->login($t, 'percival'); assume_all_assets_exist; -my $comment_must - = 'bsc#1234(Automatic takeover from t#99962)'; +my $comment_must = 'bsc#1234(Automatic takeover from t#99962)'; my $carry_over_note = "\n(The hook script will not be executed.)"; sub comments ($url) { $t->get_ok("$url/comments_ajax")->status_is(200)->tx->res->dom->find('.media-comment > p')->map('content'); @@ -66,7 +65,7 @@ subtest '"happy path": failed->failed carries over last issue reference' => sub local $ENV{OPENQA_JOB_DONE_HOOK_FAILED} = 'foo'; my $bugs = $t->app->schema->resultset('Bugs'); - $bugs->search({bugid => 'bsc#1234'})->delete; # ensure the bugref supposed to be inserted does not exist anyways + $bugs->search({bugid => 'bsc#1234'})->delete; # ensure the bugref supposed to be inserted does not exist anyways $t->app->log->level('debug'); $group->update({carry_over_bugrefs => 1}); my $output = combined_from { @@ -80,8 +79,7 @@ subtest '"happy path": failed->failed carries over last issue reference' => sub like $output, qr{\Q_carry_over_candidate(99963): _failure_reason=amarok:none}; like $output, qr{\Q_carry_over_candidate(99963): checking take over from 99962: _failure_reason=amarok:none}; like $output, qr{\Q_carry_over_candidate(99963): found a good candidate (99962)}; - ok $bugs->find({bugid => 'bsc#1234'}, {limit => 1}), - 'bugref inserted as part of comment contents being handled on takeover'; + ok $bugs->find({bugid => 'bsc#1234'}, {limit => 1}), 'bugref inserted as part of comment contents being handled on takeover'; }; }; @@ -132,8 +130,7 @@ subtest 'failed in different modules *without* bugref in details' => sub { # Fail second module, so carry over is not triggered due to the failure in the same module $curr_job->update_module('yast2_lan', {result => 'fail', details => [{title => 'not a bug reference'}]}); $t->post_ok('/api/v1/jobs/99963/set_done', $auth => form => {result => 'failed'})->status_is(200); - is @{comments('/tests/99963')}, 0, - 'no carry-over when not bug reference is used and job fails on different modules'; + is @{comments('/tests/99963')}, 0, 'no carry-over when not bug reference is used and job fails on different modules'; }; subtest 'failed in different modules with different bugref in details' => sub { @@ -141,8 +138,7 @@ subtest 'failed in different modules with different bugref in details' => sub { $rs->find(99962)->update_module('aplay', {result => 'fail', details => [{title => 'bsc#999888'}]}); $curr_job->update_module('yast2_lan', {result => 'fail', details => [{title => 'bsc#77777'}]}); $t->post_ok('/api/v1/jobs/99963/set_done', $auth => form => {result => 'failed'})->status_is(200); - is scalar @{comments('/tests/99963')}, 0, - 'no carry-over when bug references differ and jobs fail on different modules'; + is scalar @{comments('/tests/99963')}, 0, 'no carry-over when bug references differ and jobs fail on different modules'; }; subtest 'failed in different modules with same bugref in details' => sub { @@ -151,8 +147,7 @@ subtest 'failed in different modules with same bugref in details' => sub { $curr_job->update_module('yast2_lan', {result => 'fail', details => [{title => 'bsc#77777'}]}); $curr_job->update_module('bootloader', {result => 'softfail'}); $t->post_ok('/api/v1/jobs/99963/set_done', $auth => form => {result => 'failed'})->status_is(200); - is @{comments('/tests/99963')}, 0, - 'no carry-over when 3rd module fails, despite a matching bugref between other modules'; + is @{comments('/tests/99963')}, 0, 'no carry-over when 3rd module fails, despite a matching bugref between other modules'; # Remove failure in 3rd module $curr_job->update_module('bootloader', {result => 'passed'}); diff --git a/t/20-stale-job-detection.t b/t/20-stale-job-detection.t index 2167c77c7b9f..e419c17c1502 100644 --- a/t/20-stale-job-detection.t +++ b/t/20-stale-job-detection.t @@ -49,11 +49,7 @@ subtest 'worker with job and not updated in last 120s is considered dead' => sub is($job->state, DONE, "running job $job_id is now done"); is($job->result, INCOMPLETE, "running job $job_id has been marked as incomplete"); isnt($job->clone_id, undef, "running job $job_id a clone"); - like( - $job->reason, - qr/abandoned: associated worker (remote|local)host:1 has not sent any status updates for too long/, - "job $job_id set as incomplete" - ); + like($job->reason, qr/abandoned: associated worker (remote|local)host:1 has not sent any status updates for too long/, "job $job_id set as incomplete"); } my $assigned_job = $jobs->find(80000); @@ -62,8 +58,7 @@ subtest 'worker with job and not updated in last 120s is considered dead' => sub is($assigned_job->clone_id, undef, 'assigned job has not been cloned'); is($assigned_job->assigned_worker_id, undef, 'assigned job has no worker assigned'); - is($app->minion->jobs({tasks => ['finalize_job_results']})->total, - 2, 'minion job to finalize incomplete jobs enqueued'); + is($app->minion->jobs({tasks => ['finalize_job_results']})->total, 2, 'minion job to finalize incomplete jobs enqueued'); }; subtest 'exception during stale job detection handled and logged' => sub { diff --git a/t/21-needles.t b/t/21-needles.t index 5b08e895a66b..4a56d9233742 100644 --- a/t/21-needles.t +++ b/t/21-needles.t @@ -90,10 +90,7 @@ subtest 'handling of last update' => sub { $needle->discard_changes; my $last_actual_update2 = $needle->last_updated; - ok( - $last_actual_update lt $last_actual_update2, - "last_updated changed after updating needle from editor ($last_actual_update < $last_actual_update2)", - ); + ok($last_actual_update lt $last_actual_update2, "last_updated changed after updating needle from editor ($last_actual_update < $last_actual_update2)",); }; sub needle_count ($filename, $path = '%fedora/needles') { @@ -101,17 +98,12 @@ sub needle_count ($filename, $path = '%fedora/needles') { } subtest 'querying needles' => sub { - is $needles->count({filename => 'test-rootneedle.json'}), 2, - 'two files called test-rootneedle (should not be a problem as needledir differes)'; + is $needles->count({filename => 'test-rootneedle.json'}), 2, 'two files called test-rootneedle (should not be a problem as needledir differes)'; is needle_count('test-rootneedle.json'), 1, 'one test-rootneedle needle in fedora/needles needledir'; - is needle_count('gnome/browser/test-nestedneedle-2.json'), 1, - 'one needle that has fedora/needles needledir and relative path in its filename'; - is needle_count('test-duplicate-needle.json'), 1, - 'there can be two needles with the same names in different directories (1)'; - is needle_count('installer/test-duplicate-needle.json'), 1, - 'there can be two needles with the same names in different directories (2)'; - is needle_count('test-kdeneedle.json', '%archlinux/needles/kde'), 1, - 'needledir for nested needles placed under non-project needledir'; + is needle_count('gnome/browser/test-nestedneedle-2.json'), 1, 'one needle that has fedora/needles needledir and relative path in its filename'; + is needle_count('test-duplicate-needle.json'), 1, 'there can be two needles with the same names in different directories (1)'; + is needle_count('installer/test-duplicate-needle.json'), 1, 'there can be two needles with the same names in different directories (2)'; + is needle_count('test-kdeneedle.json', '%archlinux/needles/kde'), 1, 'needledir for nested needles placed under non-project needledir'; is $_->file_present, 1, 'file_present set to 1 (' . $_->path . ')' for $needles->all; }; @@ -127,36 +119,23 @@ subtest 'needle scan' => sub { }); # check that it was created is $needles->count({filename => 'test-nonexistent.json'}), 1, 'needle created'; - is $needles->find({filename => 'test-nonexistent.json'})->file_present, 1, - 'needle assumed to be present by default'; + is $needles->find({filename => 'test-nonexistent.json'})->file_present, 1, 'needle assumed to be present by default'; # update info about whether needles are present OpenQA::Task::Needle::Scan::_needles($t->app, undef); - is $needles->find({filename => 'test-nonexistent.json'})->file_present, 0, - 'file_present set to 0 when scanning as it does not actually exist'; - is $needles->find({filename => 'installer/test-nestedneedle-1.json'})->file_present, 1, - 'existing needle still flagged as present'; + is $needles->find({filename => 'test-nonexistent.json'})->file_present, 0, 'file_present set to 0 when scanning as it does not actually exist'; + is $needles->find({filename => 'installer/test-nestedneedle-1.json'})->file_present, 1, 'existing needle still flagged as present'; }; subtest 'handling relative paths in update_needle' => sub { - is($module->job->needle_dir, - $needledir_fedora, 'needle dir of job deduced from settings (prerequisite for handling relative paths)'); + is($module->job->needle_dir, $needledir_fedora, 'needle dir of job deduced from settings (prerequisite for handling relative paths)'); subtest 'handle needle path relative to share dir (legacy os-autoinst)' => sub { - my $needle - = OpenQA::Schema::Result::Needles::update_needle('tests/fedora/needles/test-rootneedle.json', $module, 0); - is( - $needle->path, - abs_path('t/data/openqa/share/tests/fedora/needles/test-rootneedle.json'), - 'needle path correct' - ); + my $needle = OpenQA::Schema::Result::Needles::update_needle('tests/fedora/needles/test-rootneedle.json', $module, 0); + is($needle->path, abs_path('t/data/openqa/share/tests/fedora/needles/test-rootneedle.json'), 'needle path correct'); }; subtest 'handle needle path relative to needle dir' => sub { my $needle = OpenQA::Schema::Result::Needles::update_needle('test-rootneedle.json', $module, 0); - is( - $needle->path, - abs_path('t/data/openqa/share/tests/fedora/needles/test-rootneedle.json'), - 'needle path correct' - ); + is($needle->path, abs_path('t/data/openqa/share/tests/fedora/needles/test-rootneedle.json'), 'needle path correct'); }; subtest 'handle needle path to non existent needle' => sub { my $needle; diff --git a/t/22-dashboard.t b/t/22-dashboard.t index bf99694dc79b..bfbf30b4a558 100644 --- a/t/22-dashboard.t +++ b/t/22-dashboard.t @@ -44,40 +44,27 @@ my $test_parent = $parent_groups->create({name => 'Test parent', sort_order => 2 subtest 'Validation errors' => sub { $t->get_ok('/dashboard_build_results/?group=opensuse')->status_is(200)->content_like(qr{/group_overview/1002}); - $t->get_ok('/dashboard_build_results/?group=[')->status_is(400) - ->json_like('/error', qr/group parameter is invalid: Unmatched \[ in regex/i); - - $t->get_ok('/group_overview/1002?limit_builds=a')->status_is(400) - ->content_like(qr/Erroneous parameters.*limit_builds/); - $t->get_ok('/group_overview/1002.json?limit_builds=a')->status_is(400) - ->json_like('/error', qr/Erroneous parameters.*limit_builds/); - $t->get_ok('/group_overview/1002?comments_page=a')->status_is(400) - ->content_like(qr/Erroneous parameters.*comments_page/); - $t->get_ok('/group_overview/1002?comments_limit=a')->status_is(400) - ->content_like(qr/Erroneous parameters.*comments_limit/); - $t->get_ok('/group_overview/1002?group=$*')->status_is(400) - ->content_like(qr/group parameter is invalid.*matches null string many times/i); + $t->get_ok('/dashboard_build_results/?group=[')->status_is(400)->json_like('/error', qr/group parameter is invalid: Unmatched \[ in regex/i); + + $t->get_ok('/group_overview/1002?limit_builds=a')->status_is(400)->content_like(qr/Erroneous parameters.*limit_builds/); + $t->get_ok('/group_overview/1002.json?limit_builds=a')->status_is(400)->json_like('/error', qr/Erroneous parameters.*limit_builds/); + $t->get_ok('/group_overview/1002?comments_page=a')->status_is(400)->content_like(qr/Erroneous parameters.*comments_page/); + $t->get_ok('/group_overview/1002?comments_limit=a')->status_is(400)->content_like(qr/Erroneous parameters.*comments_limit/); + $t->get_ok('/group_overview/1002?group=$*')->status_is(400)->content_like(qr/group parameter is invalid.*matches null string many times/i); my $id = $test_parent->id; - $t->get_ok("/parent_group_overview/$id?limit_builds=a")->status_is(400) - ->content_like(qr/Erroneous parameters.*limit_builds/); - $t->get_ok("/parent_group_overview/$id.json?limit_builds=a")->status_is(400) - ->json_like('/error', qr/Erroneous parameters.*limit_builds/); - $t->get_ok("/parent_group_overview/$id?comments_page=a")->status_is(400) - ->content_like(qr/Erroneous parameters.*comments_page/); - $t->get_ok("/parent_group_overview/$id?comments_limit=a")->status_is(400) - ->content_like(qr/Erroneous parameters.*comments_limit/); - $t->get_ok("/parent_group_overview/$id?group=\$*")->status_is(400) - ->content_like(qr/group parameter is invalid.*matches null string many times/i); + $t->get_ok("/parent_group_overview/$id?limit_builds=a")->status_is(400)->content_like(qr/Erroneous parameters.*limit_builds/); + $t->get_ok("/parent_group_overview/$id.json?limit_builds=a")->status_is(400)->json_like('/error', qr/Erroneous parameters.*limit_builds/); + $t->get_ok("/parent_group_overview/$id?comments_page=a")->status_is(400)->content_like(qr/Erroneous parameters.*comments_page/); + $t->get_ok("/parent_group_overview/$id?comments_limit=a")->status_is(400)->content_like(qr/Erroneous parameters.*comments_limit/); + $t->get_ok("/parent_group_overview/$id?group=\$*")->status_is(400)->content_like(qr/group parameter is invalid.*matches null string many times/i); my $groups_mock = Test::MockModule->new('OpenQA::Schema::Result::JobGroups'); $groups_mock->redefine(regex_match => sub { die 'invalid regex: fake regex error after validation' }); - $t->get_ok('/dashboard_build_results/?group=opensuse')->status_is(400) - ->json_like('/error', qr/invalid regex: fake regex error after validation/i); + $t->get_ok('/dashboard_build_results/?group=opensuse')->status_is(400)->json_like('/error', qr/invalid regex: fake regex error after validation/i); my $build_results_mock = Test::MockModule->new('OpenQA::BuildResults'); $build_results_mock->redefine(filter_subgroups => sub { die 'invalid regex: fake regex error after validation' }); - $t->get_ok("/parent_group_overview/$id?group=opensuse")->status_is(400) - ->content_like(qr/invalid regex: fake regex error after validation/i); + $t->get_ok("/parent_group_overview/$id?group=opensuse")->status_is(400)->content_like(qr/invalid regex: fake regex error after validation/i); }; subtest 'Regex-specific validation' => sub { @@ -90,16 +77,14 @@ subtest 'Regex-specific validation' => sub { like $c->regex_problem(['[a-\d]']), qr/false.*range/i, 'False [] range "%s" in regex'; lives_ok { regex_match('', '') } 'passing empty regex to regex_match is ok'; - throws_ok { regex_match('[:alpha:]', '') } qr/posix syntax.*/i, - 'POSIX syntax [%c %c] belongs inside character classes%s'; + throws_ok { regex_match('[:alpha:]', '') } qr/posix syntax.*/i, 'POSIX syntax [%c %c] belongs inside character classes%s'; throws_ok { regex_match('.{2,1}', '') } qr/quantifier/i, 'Quantifier {n,m} with n > m can not match'; }; subtest 'Changelog' => sub { my $global_cfg = $t->app->config->{global}; $global_cfg->{changelog_file} = 'does not exist'; - $t->get_ok('/changelog')->status_is(200)->content_like(qr/No changelog available/) - ->content_unlike(qr/Custom changelog works/); + $t->get_ok('/changelog')->status_is(200)->content_like(qr/No changelog available/)->content_unlike(qr/Custom changelog works/); my $changelog = tempfile; $changelog->spew('Custom changelog works!'); $global_cfg->{changelog_file} = $changelog->to_string; @@ -118,20 +103,12 @@ $opensuse_group->update({parent_id => $test_parent->id}); $t->get_ok('/group_overview/' . $opensuse_group->id)->status_is(200); @h2 = $t->tx->res->dom->find('h2')->map('all_text')->each; -like( - $h2[0], - qr/[ \n]*Last Builds for[ \n]*Test parent[ \n]*\/[ \n]*opensuse[ \n]*/, - 'parent name also shown on group overview' -); +like($h2[0], qr/[ \n]*Last Builds for[ \n]*Test parent[ \n]*\/[ \n]*opensuse[ \n]*/, 'parent name also shown on group overview'); $t->get_ok('/dashboard_build_results')->status_is(200); @h2 = $t->tx->res->dom->find('h2 a')->map(sub ($e) { $e->text . ($e->attr('title') // '') })->each; my $test_overview_tooltip = 'Shows the latest test results for all job groups within this parent job group'; -is_deeply( - \@h2, - ['opensuse test', 'Test parent', $test_overview_tooltip], - 'parent group shown and opensuse is no more on top-level' -); +is_deeply(\@h2, ['opensuse test', 'Test parent', $test_overview_tooltip], 'parent group shown and opensuse is no more on top-level'); my $tests_overview_dashboard = $t->tx->res->dom->find("#test_result_overview_link_1")->first; is( $tests_overview_dashboard->attr('href'), @@ -160,29 +137,18 @@ $opensuse_group->jobs->find({BUILD => '0048@0815'})->comments->create({text => ' $t->get_ok('/dashboard_build_results?limit_builds=20&show_tags=1')->status_is(200); @h2 = $t->tx->res->dom->find('h2 a')->map(sub ($e) { $e->text . ($e->attr('title') // '') })->each; -is_deeply( - \@h2, - ['Test parent', $test_overview_tooltip], - 'only link to parent (and related overview) shown, no more top-level job groups' -); +is_deeply(\@h2, ['Test parent', $test_overview_tooltip], 'only link to parent (and related overview) shown, no more top-level job groups'); sub check_test_parent { my ($default_expanded) = @_; @h4 = $t->tx->res->dom->find("div.children-$default_expanded .h4 a")->map('text')->each; - is_deeply( - \@h4, - ['Build87.5011', 'Build0048@0815', 'Build0048', 'Build0092', 'Build0091'], - 'builds on parent-level shown' - ); + is_deeply(\@h4, ['Build87.5011', 'Build0048@0815', 'Build0048', 'Build0092', 'Build0091'], 'builds on parent-level shown'); - $t->element_count_is('#review-' . $test_parent->id . '-Factory-0048_0815', - 1, 'review badge for build 0048@0815 shown'); - $t->element_count_is('#child-review-' . $test_parent->id . '-Factory-0048_0815', - 1, 'review badge for build 0048@0815 also shown on child-level'); + $t->element_count_is('#review-' . $test_parent->id . '-Factory-0048_0815', 1, 'review badge for build 0048@0815 shown'); + $t->element_count_is('#child-review-' . $test_parent->id . '-Factory-0048_0815', 1, 'review badge for build 0048@0815 also shown on child-level'); $t->element_count_is('#review-' . $test_parent->id . '-0048', 0, 'review badge for build 0048 NOT shown yet'); - $t->element_count_is('#child-review-' . $test_parent->id . '-0048', - 0, 'review badge for build 0048 also on child-level NOT shown yet'); + $t->element_count_is('#child-review-' . $test_parent->id . '-0048', 0, 'review badge for build 0048 also on child-level NOT shown yet'); my @progress_bars = $t->tx->res->dom->find("div.children-$default_expanded .progress")->map('attr', 'title')->each; is_deeply( @@ -199,25 +165,13 @@ sub check_test_parent { @h4 = $t->tx->res->dom->find('div#group' . $test_parent->id . '_build13_1-0091 .h4 a')->map('text')->each; is_deeply(\@h4, ['opensuse', 'opensuse test'], 'both child groups shown under common build'); - @progress_bars - = $t->tx->res->dom->find('div#group' . $test_parent->id . '_build13_1-0091 .progress')->map('attr', 'title') - ->each; - is_deeply( - \@progress_bars, - ["passed: 2\nunfinished: 2\nskipped: 1\ntotal: 5", "unfinished: 1\ntotal: 1"], - 'progress bars for child groups shown correctly' - ); + @progress_bars = $t->tx->res->dom->find('div#group' . $test_parent->id . '_build13_1-0091 .progress')->map('attr', 'title')->each; + is_deeply(\@progress_bars, ["passed: 2\nunfinished: 2\nskipped: 1\ntotal: 5", "unfinished: 1\ntotal: 1"], 'progress bars for child groups shown correctly'); - my @urls - = $t->tx->res->dom->find('div#group' . $test_parent->id . '_build13_1-0091 .h4 a')->map('attr', 'href')->each; - is_deeply( - \@urls, - [ - '/tests/overview?distri=opensuse&version=13.1&build=0091&groupid=1001', - '/tests/overview?distri=opensuse&version=13.1&build=0091&groupid=1002' - ], - 'link URLs' - ); + my @urls = $t->tx->res->dom->find('div#group' . $test_parent->id . '_build13_1-0091 .h4 a')->map('attr', 'href')->each; + is_deeply(\@urls, + ['/tests/overview?distri=opensuse&version=13.1&build=0091&groupid=1001', '/tests/overview?distri=opensuse&version=13.1&build=0091&groupid=1002'], + 'link URLs'); $t->element_count_is("div.children-$default_expanded .badge-all-passed", 1, 'badge shown on parent-level'); $t->element_count_is("div.children-$default_expanded .h4 span i.tag", 0, 'no tags shown yet'); @@ -275,8 +229,7 @@ is_deeply(\@h4, [], 'also no tagged builds on parent-level shown'); # now tag build 0091 to check build tagging when there are common builds $tag_for_0092_comment->delete(); -my $tag_for_0091_comment - = $opensuse_test_group->comments->create({text => 'tag:0091:important:some_tag', user_id => 99901}); +my $tag_for_0091_comment = $opensuse_test_group->comments->create({text => 'tag:0091:important:some_tag', user_id => 99901}); $t->get_ok('/dashboard_build_results?limit_builds=20&only_tagged=1')->status_is(200); @h4 = $t->tx->res->dom->find("div.children-collapsed .h4 a")->map('text')->each; @@ -310,10 +263,8 @@ $t->app->schema->resultset('JobModules')->create( my $review_build_id = '-Factory-0048_0815'; $t->get_ok('/dashboard_build_results?limit_builds=20')->status_is(200); -$t->element_count_is('#review-' . $test_parent->id . $review_build_id, - 0, 'review badge NOT shown for build 0048@0815 anymore'); -$t->element_count_is('#child-review-' . $test_parent->id . $review_build_id, - 1, 'review badge review badge for build 0048@0815 still shown on child-level'); +$t->element_count_is('#review-' . $test_parent->id . $review_build_id, 0, 'review badge NOT shown for build 0048@0815 anymore'); +$t->element_count_is('#child-review-' . $test_parent->id . $review_build_id, 1, 'review badge review badge for build 0048@0815 still shown on child-level'); $not_reviewed_job->delete(); @@ -427,16 +378,8 @@ $opensuse_group->jobs->update({VERSION => '14.2', DISTRI => 'suse'}); $t->get_ok('/dashboard_build_results?limit_builds=20&show_tags=0')->status_is(200); @urls = $t->tx->res->dom->find('.h4 a')->each; is(scalar @urls, 12, 'now builds belong to different versions and are split'); -is( - $urls[1]->attr('href'), - '/tests/overview?distri=suse&version=14.2&build=87.5011&groupid=1001', - 'most recent version/build' -); -is( - $urls[-1]->attr('href'), - '/tests/overview?distri=opensuse&version=13.1&build=0091&groupid=1002', - 'oldest version/build still shown' -); +is($urls[1]->attr('href'), '/tests/overview?distri=suse&version=14.2&build=87.5011&groupid=1001', 'most recent version/build'); +is($urls[-1]->attr('href'), '/tests/overview?distri=opensuse&version=13.1&build=0091&groupid=1002', 'oldest version/build still shown'); subtest 'build which has jobs with different DISTRIs links to overview with all DISTRIs' => sub { my $job_with_different_distri = $opensuse_group->jobs->create( @@ -453,11 +396,7 @@ subtest 'build which has jobs with different DISTRIs links to overview with all my @urls = $t->tx->res->dom->find('.h4 a')->each; is(scalar @urls, 12, 'still 12 builds shown'); my $first_url = $urls[1]->attr('href'); - is( - $first_url, - '/tests/overview?distri=opensuse&distri=suse&version=14.2&build=87.5011&groupid=1001', - 'both distris present in overview link' - ); + is($first_url, '/tests/overview?distri=opensuse&distri=suse&version=14.2&build=87.5011&groupid=1001', 'both distris present in overview link'); $job_with_different_distri->delete; }; @@ -536,8 +475,7 @@ subtest 'job parent groups with multiple version and builds' => sub { $t->get_ok('/parent_group_overview/' . $test_parent->id)->status_is(200); my @build_names = qw(Build87.5011 Build0092 14.2-Build0091 Build0048@0815 Build0048 13.1-Build0091); - check_builds(\@build_names, $test_parent, 'parent group builds shown sorted by dotted versions', - 'parent_group_overview'); + check_builds(\@build_names, $test_parent, 'parent group builds shown sorted by dotted versions', 'parent_group_overview'); my @entire_build_url_list = $t->tx->res->dom->find('.h4 a:first-child')->each(); my $first_entire_build_url = $entire_build_url_list[0]->attr('href'); @@ -562,26 +500,22 @@ subtest 'job parent groups with multiple version and builds' => sub { $multi_version_group->update({parent_id => $second_test_parent->id}); @build_names = qw(42.3-Build0002 Build0001 Build2192 Build2191 42.2-Build0002); - check_builds(\@build_names, $second_test_parent, 'parent group builds shown sorted by dotted versions', - 'parent_group_overview'); + check_builds(\@build_names, $second_test_parent, 'parent group builds shown sorted by dotted versions', 'parent_group_overview'); $second_test_parent->update({build_version_sort => 0}); @build_names = reverse @build_names; - check_builds(\@build_names, $second_test_parent, 'parent group builds shown sorted by date', - 'parent_group_overview'); + check_builds(\@build_names, $second_test_parent, 'parent group builds shown sorted by date', 'parent_group_overview'); }; subtest 'extra plugin links' => sub { $t->app->config->{plugin_links}{operator}{Test1} = 'tests_overview'; $t->app->config->{plugin_links}{operator}{Test2} = 'latest'; - $t->get_ok('/')->status_is(200)->element_exists('a[href*="/tests/overview"]') - ->text_like('a[href*="/tests/overview"]', qr/Test1/)->element_exists('a[href*="/tests/latest"]') - ->text_like('a[href*="/tests/latest"]', qr/Test2/); + $t->get_ok('/')->status_is(200)->element_exists('a[href*="/tests/overview"]')->text_like('a[href*="/tests/overview"]', qr/Test1/) + ->element_exists('a[href*="/tests/latest"]')->text_like('a[href*="/tests/latest"]', qr/Test2/); $t->app->schema->resultset('Users')->search({username => 'percival'})->next->update({is_admin => 1}); - $t->get_ok('/')->status_is(200)->element_exists('a[href*="/tests/overview"]') - ->element_exists('a[href*="/tests/latest"]'); + $t->get_ok('/')->status_is(200)->element_exists('a[href*="/tests/overview"]')->element_exists('a[href*="/tests/latest"]'); }; subtest 'SUSE branding' => sub { diff --git a/t/23-amqp.t b/t/23-amqp.t index 8d1119442ce4..988818b900cb 100644 --- a/t/23-amqp.t +++ b/t/23-amqp.t @@ -295,8 +295,7 @@ subtest 'amqp_publish call with headers' => sub { is_deeply($published{args}->{routing_key}, 'some.topic', 'topic appears as routing key'); $app->log(Mojo::Log->new(level => 'debug')); - combined_like { $amqp->publish_amqp('some.topic', 'some message', 'some headers') } qr/headers are not a hashref/, - 'error logged if headers are no hashref'; + combined_like { $amqp->publish_amqp('some.topic', 'some message', 'some headers') } qr/headers are not a hashref/, 'error logged if headers are no hashref'; }; subtest 'promise handlers' => sub { @@ -322,8 +321,7 @@ $app->config->{amqp}{keyfile} = '/some/key.pem'; subtest 'extra TLS query params' => sub { combined_like { $amqp->publish_amqp('some.topic', 'some message') } qr/Sending.*some\.topic/, 'publishing logged'; # because of exactly how this URL is constructed, only the slashes in the extra params get escaped - my $expected - = 'amqp://guest:guest@localhost:5672/?exchange=pubsub&cacertfile=%2Fsome%2Fcacert.pem&certfile=%2Fsome%2Fcert.pem&keyfile=%2Fsome%2Fkey.pem'; + my $expected = 'amqp://guest:guest@localhost:5672/?exchange=pubsub&cacertfile=%2Fsome%2Fcacert.pem&certfile=%2Fsome%2Fcert.pem&keyfile=%2Fsome%2Fkey.pem'; is($last_publisher->url, $expected, 'url has all params'); }; diff --git a/t/24-worker-engine.t b/t/24-worker-engine.t index 53e236395668..f4edfcf1a27d 100644 --- a/t/24-worker-engine.t +++ b/t/24-worker-engine.t @@ -160,8 +160,7 @@ subtest 'caching' => sub { subtest 'asset caching' => sub { my $asset_mock = Test::MockModule->new('OpenQA::Worker::Engines::isotovideo'); $asset_mock->redefine( - cache_assets => - sub ($cache_client, $job, $vars, $assets_to_cache, $assetkeys, $webui_host, $pooldir, $callback) { + cache_assets => sub ($cache_client, $job, $vars, $assets_to_cache, $assetkeys, $webui_host, $pooldir, $callback) { $callback->(undef); }); my $job = Test::MockObject->new; @@ -188,10 +187,8 @@ subtest 'asset caching' => sub { sub _mock_cache_service_client ($status_data, $error = undef) { my $cache_client_mock = Test::MockModule->new('OpenQA::CacheService::Client'); $cache_client_mock->redefine(enqueue => 'some enqueue error'); - $cache_client_mock->redefine( - info => OpenQA::CacheService::Response::Info->new(data => {active_workers => 1}, error => undef)); - $cache_client_mock->redefine( - status => OpenQA::CacheService::Response::Status->new(data => $status_data, error => $error)); + $cache_client_mock->redefine(info => OpenQA::CacheService::Response::Info->new(data => {active_workers => 1}, error => undef)); + $cache_client_mock->redefine(status => OpenQA::CacheService::Response::Status->new(data => $status_data, error => $error)); return $cache_client_mock; } @@ -208,8 +205,7 @@ subtest 'problems when caching assets' => sub { my @args = ($job, {ISO_1 => 'FOO'}, \@assets, {ISO_1 => 'iso'}, 'webuihost', undef, $cb); OpenQA::Worker::Engines::isotovideo::cache_assets(OpenQA::CacheService::Client->new, @args); Mojo::IOLoop->start; - is $error->{error}, 'Failed to send asset request for FOO: some enqueue error', - 'failed to enqueue request for asset download'; + is $error->{error}, 'Failed to send asset request for FOO: some enqueue error', 'failed to enqueue request for asset download'; is $error->{category}, undef, 'no category set so problem is treated as cache service failure'; $cache_client_mock->redefine(enqueue => 0); @@ -278,9 +274,7 @@ subtest 'syncing tests' => sub { my $cb = sub ($res) { $result = $res; Mojo::IOLoop->stop }; my @args = (Test::FakeJob->new(worker => $worker), {ISO_1 => 'iso'}, 'cache-dir/webuihost', 'rsync-source', 2, $cb); OpenQA::Worker::Engines::isotovideo::sync_tests(OpenQA::CacheService::Client->new, @args); - is $result->{error}, - "Failed to send rsync from 'rsync-source' to 'cache-dir/webuihost': some enqueue error", - 'failed to enqueue request for rsync'; + is $result->{error}, "Failed to send rsync from 'rsync-source' to 'cache-dir/webuihost': some enqueue error", 'failed to enqueue request for rsync'; is $result->{category}, undef, 'no category set so problem is treated as cache service failure (1)'; $cache_client_mock->redefine(enqueue => 0); @@ -305,8 +299,7 @@ subtest 'symlink testrepo, logging behavior' => sub { my $job = OpenQA::Worker::Job->new($worker, $client, {id => 12, settings => {DISTRI => 'foo'}}); my $result = _run_engine($job); my $casedir = testcasedir('foo', undef, undef); - like $result->{error}, qr/The source directory $casedir does not exist/, - 'symlink failed because the source directory does not exist'; + like $result->{error}, qr/The source directory $casedir does not exist/, 'symlink failed because the source directory does not exist'; }; subtest 'error case: permission denied' => sub { @@ -385,8 +378,7 @@ subtest 'symlink testrepo, logging behavior' => sub { }; - subtest 'error case: custom CASEDIR specified, fail to symlink needles because cache directory does not exist' => - sub { + subtest 'error case: custom CASEDIR specified, fail to symlink needles because cache directory does not exist' => sub { my $isotovideo_mock = Test::MockModule->new('OpenQA::Worker::Engines::isotovideo'); $isotovideo_mock->redefine( do_asset_caching => sub ($job, $vars, $cache_dir, $assetkeys, $webui_host, $pooldir, $callback) { @@ -399,9 +391,8 @@ subtest 'symlink testrepo, logging behavior' => sub { my $check_dir = $cache_dir . $client->webui_host . "/$job_settings{settings}->{DISTRI}" . '/needles'; my ($job, $result) = OpenQA::Worker::Job->new($worker, $client, \%job_settings); $result = _run_engine($job); - like $result->{error}, qr/The source directory $check_dir does not exist/, - 'the needledir is under the cache directory'; - }; + like $result->{error}, qr/The source directory $check_dir does not exist/, 'the needledir is under the cache directory'; + }; }; subtest 'behavior with ABSOLUTE_TEST_CONFIG_PATHS=1' => sub { @@ -418,8 +409,7 @@ subtest 'behavior with ABSOLUTE_TEST_CONFIG_PATHS=1' => sub { my $vars_data = get_job_json_data($pool_directory); is $vars_data->{PRODUCTDIR}, productdir('fedora', undef, undef), 'default PRODUCTDIR assigned'; is $vars_data->{CASEDIR}, testcasedir('fedora', undef, undef), 'default CASEDIR assigned'; - is $vars_data->{HDD_1}, locate_asset('hdd', 'foo.qcow2'), - 'don\'t symlink asset when using ABSOLUTE_TEST_CONFIG_PATHS=>1'; + is $vars_data->{HDD_1}, locate_asset('hdd', 'foo.qcow2'), 'don\'t symlink asset when using ABSOLUTE_TEST_CONFIG_PATHS=>1'; is $vars_data->{NEEDLES_DIR}, undef, 'no NEEDLES_DIR assigned'; }; @@ -432,8 +422,7 @@ subtest 'behavior with ABSOLUTE_TEST_CONFIG_PATHS=1' => sub { my $expected_productdir = abs2rel(productdir('fedora', undef, undef), testcasedir('fedora', undef, undef)); is $vars_data->{NEEDLES_DIR}, needledir('fedora', undef, undef), 'default NEEDLES_DIR assigned'; is $vars_data->{CASEDIR}, $settings{CASEDIR}, 'custom CASEDIR not touched'; - is $vars_data->{PRODUCTDIR}, $expected_productdir, - 'nevertheless relative PRODUCTDIR assigned to load main.pm from custom CASEDIR'; + is $vars_data->{PRODUCTDIR}, $expected_productdir, 'nevertheless relative PRODUCTDIR assigned to load main.pm from custom CASEDIR'; }; }; @@ -461,8 +450,7 @@ subtest 'link asset' => sub { ok -l $linked_hdd2, 'the hdd 2 is symlinked to pool directory'; is((stat $linked_hdd)[1], (stat $orig_hdd)[1], 'hdd is hardlinked'); is((stat $linked_iso)[1], (stat $orig_iso)[1], 'iso is hardlinked'); - is $vars_data->{ISO}, 'openSUSE-13.1-DVD-x86_64-Build0091-Media.iso', - 'the value of ISO is basename when doing link'; + is $vars_data->{ISO}, 'openSUSE-13.1-DVD-x86_64-Build0091-Media.iso', 'the value of ISO is basename when doing link'; is $vars_data->{HDD_1}, 'foo.qcow2', 'the value of HDD_1 is basename when doing link'; }; diff --git a/t/24-worker-jobs.t b/t/24-worker-jobs.t index 86a3b39b2dcf..c24ac4eae36e 100644 --- a/t/24-worker-jobs.t +++ b/t/24-worker-jobs.t @@ -216,20 +216,14 @@ subtest 'Format reason' => sub { my $job = OpenQA::Worker::Job->new($worker, $client, {id => 1234}); is($job->_format_reason({}, PASSED, WORKER_SR_DONE), undef, 'no reason added if it is just "done"'); $job->{_result_upload_error} = 'Unable…'; - is( - $job->_format_reason({}, PASSED, WORKER_SR_DONE), - 'api failure: Unable…', - 'upload error considered API failure' - ); + is($job->_format_reason({}, PASSED, WORKER_SR_DONE), 'api failure: Unable…', 'upload error considered API failure'); like($job->_format_reason({}, INCOMPLETE, WORKER_SR_DIED), qr/died: .+/, 'generic phrase appended to died'); is($job->_format_reason({}, 'foo', 'foo'), undef, 'no reason added if it equals the result'); - is($job->_format_reason({}, 'foo', 'foobar'), - 'foobar', 'unknown reason "passed as-is" if it differs from the result'); + is($job->_format_reason({}, 'foo', 'foobar'), 'foobar', 'unknown reason "passed as-is" if it differs from the result'); is($job->_format_reason({}, USER_CANCELLED, WORKER_COMMAND_CANCEL), undef, 'cancel omitted'); like $job->_format_reason({}, TIMEOUT_EXCEEDED, WORKER_SR_TIMEOUT), qr/timeout: setup exceeded/, 'setup timeout'; $job->{_engine} = 1; # pretend isotovideo has been started - like $job->_format_reason({}, TIMEOUT_EXCEEDED, WORKER_SR_TIMEOUT), qr/timeout: test execution exceeded/, - 'test timeout'; + like $job->_format_reason({}, TIMEOUT_EXCEEDED, WORKER_SR_TIMEOUT), qr/timeout: test execution exceeded/, 'test timeout'; }; subtest 'Lost WebSocket connection' => sub { @@ -242,8 +236,7 @@ subtest 'Lost WebSocket connection' => sub { $job->accept; is $job->status, 'stopped', 'job has been stopped as retry attepts have been exhausted'; is $event_data->{reason}, WORKER_SR_API_FAILURE, 'reason'; - like $event_data->{error_message}, qr/Unable to accept.*websocket connection to not relevant here has been lost./, - 'error message'; + like $event_data->{error_message}, qr/Unable to accept.*websocket connection to not relevant here has been lost./, 'error message'; }; subtest 'Interrupted WebSocket connection' => sub { @@ -253,14 +246,10 @@ subtest 'Interrupted WebSocket connection' => sub { is $job->status, 'accepting', 'job is now being accepted'; $job->client->websocket_connection->emit_finish; wait_until_job_status_ok($job, 'accepted'); - is $job->status, 'accepted', - 'ws disconnects are not considered fatal one the job is accepted so it is still in accepted state'; + is $job->status, 'accepted', 'ws disconnects are not considered fatal one the job is accepted so it is still in accepted state'; - is_deeply( - $client->websocket_connection->sent_messages, - [{json => {jobid => 1, type => 'accepted'}}], - 'job accepted via WebSocket' - ) or diag explain $client->websocket_connection->sent_messages; + is_deeply($client->websocket_connection->sent_messages, [{json => {jobid => 1, type => 'accepted'}}], 'job accepted via WebSocket') + or diag explain $client->websocket_connection->sent_messages; $client->websocket_connection->sent_messages([]); }; @@ -273,27 +262,16 @@ subtest 'Interrupted WebSocket connection (before we can tell the WebUI that we is $job->status, 'accepting', 'job is now being accepted'; $job->stop_if_out_of_acceptance_attempts; is $job->status, 'stopped', 'job is abandoned if unable to confirm to the web UI that we are working on it'; - like( - exception { $job->start }, - qr/attempt to start job which is not accepted/, - 'starting job prevented unless accepted' - ); + like(exception { $job->start }, qr/attempt to start job which is not accepted/, 'starting job prevented unless accepted'); - is_deeply( - $client->websocket_connection->sent_messages, - [{json => {jobid => 2, type => 'accepted'}}], - 'job accepted via WebSocket' - ) or diag explain $client->websocket_connection->sent_messages; + is_deeply($client->websocket_connection->sent_messages, [{json => {jobid => 2, type => 'accepted'}}], 'job accepted via WebSocket') + or diag explain $client->websocket_connection->sent_messages; $client->websocket_connection->sent_messages([]); }; subtest 'Job without id' => sub { my $job = OpenQA::Worker::Job->new($worker, $client, {id => undef, URL => $engine_url}); - like( - exception { $job->start }, - qr/attempt to start job without ID and job info/, - 'starting job without id prevented' - ); + like(exception { $job->start }, qr/attempt to start job without ID and job info/, 'starting job without id prevented'); }; subtest 'Clean up pool directory' => sub { @@ -335,19 +313,13 @@ subtest 'Clean up pool directory' => sub { ) or diag explain $client->sent_messages; $client->sent_messages([]); - is_deeply( - $client->websocket_connection->sent_messages, - [{json => {jobid => 3, type => 'accepted'}}], - 'job accepted via WebSocket' - ) or diag explain $client->websocket_connection->sent_messages; + is_deeply($client->websocket_connection->sent_messages, [{json => {jobid => 3, type => 'accepted'}}], 'job accepted via WebSocket') + or diag explain $client->websocket_connection->sent_messages; $client->websocket_connection->sent_messages([]); my $uploaded_files = $upload_stats->{uploaded_files}; - is_deeply( - $uploaded_files, - [[{file => {file => "$pool_directory/worker-log.txt", filename => 'worker-log.txt'}}]], - 'would have uploaded logs' - ) or diag explain $uploaded_files; + is_deeply($uploaded_files, [[{file => {file => "$pool_directory/worker-log.txt", filename => 'worker-log.txt'}}]], 'would have uploaded logs') + or diag explain $uploaded_files; my $uploaded_assets = $upload_stats->{uploaded_assets}; is_deeply($uploaded_assets, [], 'no assets uploaded because this test so far has none') or diag explain $uploaded_assets; @@ -431,18 +403,11 @@ subtest 'Job aborted, broken state file' => sub { wait_until_job_status_ok($job, 'accepted'); $job->start; combined_like { wait_until_job_status_ok($job, 'stopped') } qr/failed to parse.*JSON/, 'warning about corrupt JSON'; - is( - @{$client->sent_messages}[-1]->{reason}, - 'terminated prematurely: Encountered corrupted state file, see log output for details', - 'reason propagated' - ) or diag explain $client->sent_messages; + is(@{$client->sent_messages}[-1]->{reason}, 'terminated prematurely: Encountered corrupted state file, see log output for details', 'reason propagated') + or diag explain $client->sent_messages; combined_like { my $state = $job->_read_state_file; - is( - $job->_format_reason($state, PASSED, 'done'), - 'done: terminated with corrupted state file', - 'reason in case the job is nevertheless done' - ) + is($job->_format_reason($state, PASSED, 'done'), 'done: terminated with corrupted state file', 'reason in case the job is nevertheless done') or diag explain $client->sent_messages } qr/but failed to parse the JSON/, 'JSON error logged'; @@ -500,11 +465,8 @@ subtest 'Job aborted during setup' => sub { ) or diag explain $client->sent_messages; $client->sent_messages([]); - is_deeply( - $client->websocket_connection->sent_messages, - [{json => {jobid => 8, type => 'accepted'}}], - 'job accepted via WebSocket' - ) or diag explain $client->websocket_connection->sent_messages; + is_deeply($client->websocket_connection->sent_messages, [{json => {jobid => 8, type => 'accepted'}}], 'job accepted via WebSocket') + or diag explain $client->websocket_connection->sent_messages; $client->websocket_connection->sent_messages([]); my $uploaded_assets = $upload_stats->{uploaded_assets}; @@ -591,12 +553,9 @@ subtest 'Successful job' => sub { qr/isotovideo has been started/, 'isotovideo startup logged'; subtest 'settings only allowed to be set within worker config deleted' => sub { my $settings = $job->settings; - is($settings->{EXTERNAL_VIDEO_ENCODER_CMD}, - undef, 'video encoder settings deleted (should only be set within worker config)'); - is($settings->{GENERAL_HW_CMD_DIR}, - undef, 'general hw cmd dir deleted (should only be set within worker config)'); - is($settings->{EXTERNAL_VIDEO_ENCODER_BAR}, - 'foo', 'settings (including video encoder settings) added from config'); + is($settings->{EXTERNAL_VIDEO_ENCODER_CMD}, undef, 'video encoder settings deleted (should only be set within worker config)'); + is($settings->{GENERAL_HW_CMD_DIR}, undef, 'general hw cmd dir deleted (should only be set within worker config)'); + is($settings->{EXTERNAL_VIDEO_ENCODER_BAR}, 'foo', 'settings (including video encoder settings) added from config'); is($settings->{FOO}, 'bar', 'arbitrary settings kept'); }; @@ -631,11 +590,8 @@ subtest 'Successful job' => sub { ) or diag explain $client->sent_messages; $client->sent_messages([]); - is_deeply( - $client->websocket_connection->sent_messages, - [{json => {jobid => 4, type => 'accepted'}}], - 'job accepted via WebSocket' - ) or diag explain $client->websocket_connection->sent_messages; + is_deeply($client->websocket_connection->sent_messages, [{json => {jobid => 4, type => 'accepted'}}], 'job accepted via WebSocket') + or diag explain $client->websocket_connection->sent_messages; $client->websocket_connection->sent_messages([]); # check whether asset upload has succeeded @@ -798,11 +754,8 @@ subtest 'Livelog' => sub { ) or diag explain $client->sent_messages; $client->sent_messages([]); - is_deeply( - $client->websocket_connection->sent_messages, - [{json => {jobid => 5, type => 'accepted'}}], - 'job accepted via WebSocket' - ) or diag explain $client->websocket_connection->sent_messages; + is_deeply($client->websocket_connection->sent_messages, [{json => {jobid => 5, type => 'accepted'}}], 'job accepted via WebSocket') + or diag explain $client->websocket_connection->sent_messages; $client->websocket_connection->sent_messages([]); my $uploaded_files = $upload_stats->{uploaded_files}; @@ -894,11 +847,8 @@ subtest 'handling API failures' => sub { ) or diag explain $client->sent_messages; $client->sent_messages([]); - is_deeply( - $client->websocket_connection->sent_messages, - [{json => {jobid => 6, type => 'accepted'}}], - 'job accepted via WebSocket' - ) or diag explain $client->websocket_connection->sent_messages; + is_deeply($client->websocket_connection->sent_messages, [{json => {jobid => 6, type => 'accepted'}}], 'job accepted via WebSocket') + or diag explain $client->websocket_connection->sent_messages; $client->websocket_connection->sent_messages([]); my $uploaded_files = $upload_stats->{uploaded_files}; @@ -983,11 +933,8 @@ subtest 'handle upload failure' => sub { # note: It is intended that there are not further details about the API failure. The API error # set for job 6 in the previous subtest is *not* supposed to be reported for the next job. - is_deeply( - $client->websocket_connection->sent_messages, - [{json => {jobid => 7, type => 'accepted'}}], - 'job accepted via WebSocket' - ) or diag explain $client->websocket_connection->sent_messages; + is_deeply($client->websocket_connection->sent_messages, [{json => {jobid => 7, type => 'accepted'}}], 'job accepted via WebSocket') + or diag explain $client->websocket_connection->sent_messages; $client->websocket_connection->sent_messages([]); # Verify that the upload has been skipped @@ -1038,8 +985,7 @@ subtest 'Job stopped while uploading' => sub { # never invoked. In this case the test gets stuck because the job is never stopped. This shows that the worker # really waits until the upload is done before continuing stopping the job. my ($final_result_upload_invoked, $final_image_upload_invoked); - $job_mock->redefine( - _upload_results => sub { $final_result_upload_invoked = 1; $job_mock->original('_upload_results')->(@_) }); + $job_mock->redefine(_upload_results => sub { $final_result_upload_invoked = 1; $job_mock->original('_upload_results')->(@_) }); $job_mock->redefine( _upload_results_step_2_upload_images => sub { $final_image_upload_invoked = 1; @@ -1104,8 +1050,7 @@ $job_mock->unmock('stop'); subtest 'Scheduling failure handled correctly' => sub { my $job = OpenQA::Worker::Job->new($worker, $client, {id => 7, URL => $engine_url}); my $callback_invoked; - $pool_directory->child(OpenQA::Worker::Job::AUTOINST_STATUSFILE) - ->spew(encode_json({status => 'running', current_test => undef})); + $pool_directory->child(OpenQA::Worker::Job::AUTOINST_STATUSFILE)->spew(encode_json({status => 'running', current_test => undef})); $testresults_dir->child('test_order.json')->remove; combined_like { $job->_upload_results_step_0_prepare(sub { $callback_invoked = 1 }) @@ -1237,13 +1182,11 @@ subtest '_read_result_file and _reduce_test_order' => sub { $job->{_current_test_module} = 'our_result'; my $extra_test_order; my ($ret, $last_test_module) = $job->_read_result_file('your_result', $extra_test_order); - is $last_test_module, 'my_result', - 'last test module is my_result because only for the one $job_mock provides a result'; + is $last_test_module, 'my_result', 'last test module is my_result because only for the one $job_mock provides a result'; is $ret->{my_extra}->{name}, 'my_extra', 'extra_test_results covered' or diag explain $ret; is $extra_test_order, undef, 'the passed reference is not updated (do we need this?)'; $job->_reduce_test_order('my_result'); - is_deeply $job->test_order, [{name => 'your_result'}, {name => 'our_result'}], - 'my_result removed from test order but not further test modules'; + is_deeply $job->test_order, [{name => 'your_result'}, {name => 'our_result'}], 'my_result removed from test order but not further test modules'; $module_res{$_} = {name => $_} for qw(your_result our_result); ($ret, $last_test_module) = $job->_read_result_file('your_result', $extra_test_order); @@ -1296,8 +1239,7 @@ subtest 'handling timeout' => sub { $job->_handle_timeout($engine); is $job->status, 'stopping', 'stop has been triggered'; is $event_data->{reason}, WORKER_SR_TIMEOUT, 'stop reason is timeout'; - combined_like { wait_until_job_status_ok($job, 'stopped') } qr/stopped because it exceeded MAX_JOB_TIME/, - 'timeout logged'; + combined_like { wait_until_job_status_ok($job, 'stopped') } qr/stopped because it exceeded MAX_JOB_TIME/, 'timeout logged'; }; subtest 'ignoring known images and files' => sub { @@ -1336,19 +1278,16 @@ subtest 'override job reason when qemu terminated with known issues by parsing a my @known_issues = ( { reason => 'QEMU terminated: Failed to allocate KVM .* Cannot allocate memory', - log_file_content => -'[warn] !!! : qemu-system-ppc64: Failed to allocate KVM HPT of order 25 (try smaller maxmem?): Cannot allocate memory.', + log_file_content => '[warn] !!! : qemu-system-ppc64: Failed to allocate KVM HPT of order 25 (try smaller maxmem?): Cannot allocate memory.', base_state_content => '{"component": "backend", "msg": "QEMU exited unexpectedly, see log for details"}' }, { reason => 'QEMU terminated: Could not find .*smbd.*please install it', - log_file_content => - '[debug] QEMU: qemu-system-x86_64: Could not find \'/usr/sbin/smbd\', please install it.', + log_file_content => '[debug] QEMU: qemu-system-x86_64: Could not find \'/usr/sbin/smbd\', please install it.', base_state_content => '{"component": "backend", "msg": "QEMU exited unexpectedly, see log for details"}' }, { - reason => -'terminated prematurely: Encountered corrupted state file: No space left on device, see log output for details', + reason => 'terminated prematurely: Encountered corrupted state file: No space left on device, see log output for details', log_file_content => '[debug] Unable to serialize fatal error: Can\'t write to file "base_state.json": No space left on device at /usr/lib/os-autoinst/bmwqemu.pm line 86.', base_state_content => 'foo boo', @@ -1410,14 +1349,13 @@ subtest 'asset upload' => sub { my $upload_mock = Test::MockModule->new('OpenQA::Client::Upload'); my @params; my $mock_failure; - my $chunk = Test::MockObject->new->set_always(index => 2)->set_always(total => 20)->set_always(end => 50) - ->set_always(start => 25)->set_always(is_last => 0); + my $chunk + = Test::MockObject->new->set_always(index => 2)->set_always(total => 20)->set_always(end => 50)->set_always(start => 25)->set_always(is_last => 0); my $normal_res = Test::MockObject->new->set_always(is_server_error => 0); my $failure_res = Test::MockObject->new->set_always(is_server_error => 1)->set_always(json => {error => 'fake error'}); my $normal_tx = Test::MockObject->new->set_always(error => undef)->set_always(res => $normal_res); - my $failure_tx = Test::MockObject->new->set_always(error => {code => 404, message => 'not found'}) - ->set_always(res => $failure_res); + my $failure_tx = Test::MockObject->new->set_always(error => {code => 404, message => 'not found'})->set_always(res => $failure_res); $upload_mock->redefine( asset => sub ($upload, @args) { # emit all events here to test the handlers (although in reality some events wouldn't occur together within @@ -1440,12 +1378,9 @@ subtest 'asset upload' => sub { my %params = (file => {file => 'foo', filename => 'bar'}); my $upload_res; - combined_like { $upload_res = $job->_upload_asset(\%params) } qr/fake error.*404.*Upload failed for chunk 3/s, - 'upload logged'; + combined_like { $upload_res = $job->_upload_asset(\%params) } qr/fake error.*404.*Upload failed for chunk 3/s, 'upload logged'; is $upload_res, 1, 'upload succeeded'; - is_deeply \@params, - [[14, {asset => undef, chunk_size => 1000000, file => 'foo', name => 'bar', local => 1, retries => 10}]], - 'expected params passed' + is_deeply \@params, [[14, {asset => undef, chunk_size => 1000000, file => 'foo', name => 'bar', local => 1, retries => 10}]], 'expected params passed' or diag explain \@params; $mock_failure = 1; @@ -1477,8 +1412,7 @@ subtest 'log file upload' => sub { my $upload_res; $mock_failure = 1; combined_like { $upload_res = $job->_upload_log_file({file => {filename => 'bar', some => 'param'}}) } - qr|Uploading artefact bar.*500 resp.*attempts.*4/5.*1/5.*All 5 upload attempts have failed for bar.*500 resp|s, - 'attempts and errors logged'; + qr|Uploading artefact bar.*500 resp.*attempts.*4/5.*1/5.*All 5 upload attempts have failed for bar.*500 resp|s, 'attempts and errors logged'; is $upload_res, 0, 'upload failed'; my $callback_invoked = 0; @@ -1488,10 +1422,8 @@ subtest 'log file upload' => sub { $job->_upload_results_step_2_upload_images(sub { $callback_invoked = [@_]; }); Mojo::IOLoop->one_tick; } - qr|All 5 upload attempts have failed for bar.*Error uploading bar: 500 response: Foo|s, - 'errors logged during final upload'; - is $job->{_result_upload_error}, 'Unable to upload images: Error uploading bar: 500 response: Foo', - 'upload failure tracked'; + qr|All 5 upload attempts have failed for bar.*Error uploading bar: 500 response: Foo|s, 'errors logged during final upload'; + is $job->{_result_upload_error}, 'Unable to upload images: Error uploading bar: 500 response: Foo', 'upload failure tracked'; is_deeply $callback_invoked, [], 'callback invoked'; }; diff --git a/t/24-worker-overall.t b/t/24-worker-overall.t index 587b9f448955..6edd64ab3fc2 100644 --- a/t/24-worker-overall.t +++ b/t/24-worker-overall.t @@ -91,8 +91,7 @@ ok(my $settings = $worker->settings, 'settings instantiated'); my $global_settings = $settings->global_settings; delete $global_settings->{LOG_DIR}; combined_like { $worker->init } -qr/Ignoring host.*Working directory does not exist/, - 'hosts with non-existent working directory ignored and error logged'; +qr/Ignoring host.*Working directory does not exist/, 'hosts with non-existent working directory ignored and error logged'; is($worker->app->level, 'debug', 'log level set to debug with verbose switch'); my @webui_hosts = sort keys %{$worker->clients_by_webui_host}; is_deeply(\@webui_hosts, [qw(http://localhost:9527 https://remotehost)], 'client for each web UI host') @@ -104,8 +103,7 @@ qr/.*http:\/\/localhost:9527,https:\/\/remotehost.*qemu_i386,qemu_x86_64.*/s, 's push(@{$worker->settings->parse_errors}, 'foo', 'bar'); combined_like { $worker->log_setup_info } -qr/.*http:\/\/localhost:9527,https:\/\/remotehost.*qemu_i386,qemu_x86_64.*Errors occurred.*foo.*bar.*/s, - 'setup info with parse errors'; +qr/.*http:\/\/localhost:9527,https:\/\/remotehost.*qemu_i386,qemu_x86_64.*Errors occurred.*foo.*bar.*/s, 'setup info with parse errors'; subtest 'delay and exec' => sub { my $worker_mock = Test::MockModule->new('OpenQA::Worker'); @@ -253,8 +251,7 @@ subtest 'accept or skip next job' => sub { combined_like { is $worker->_accept_or_skip_next_job_in_queue, 1, 'jobs accepted' } qr/Accepting job 0 from queue/s, 'acceptance logged'; combined_like { $worker->_handle_job_status_changed($jobs[0], {@stop_args, reason => WORKER_SR_API_FAILURE}) } - qr/Job 0 from fake finished - reason: api-failure.*Skipping job 1.*parent failed with api-failure/s, - 'skipping logged'; + qr/Job 0 from fake finished - reason: api-failure.*Skipping job 1.*parent failed with api-failure/s, 'skipping logged'; is $_->is_accepted, 1, 'job ' . $_->id . ' accepted' for ($jobs[0]); is $_->is_skipped, 0, 'job ' . $_->id . ' not skipped' for ($jobs[0]); is $_->is_accepted, 0, 'job ' . $_->id . ' not accepted' for ($jobs[1], $jobs[2], $jobs[3]); @@ -356,8 +353,7 @@ subtest 'accept or skip next job' => sub { is_deeply($worker->pending_job_ids, [27, 28], 'pending job IDs returned as expected'); is_deeply($worker->current_job_ids, [26, 27, 28], 'worker keeps track of job IDs'); ok($worker->is_busy, 'worker is considered busy'); - is_deeply($worker->find_current_or_pending_job($_)->info, $job_info{data}->{$_}, 'can find all jobs by ID') - for (26, 27, 28); + is_deeply($worker->find_current_or_pending_job($_)->info, $job_info{data}->{$_}, 'can find all jobs by ID') for (26, 27, 28); }; subtest 'mark job to be skipped' => sub { @@ -372,8 +368,7 @@ subtest 'accept or skip next job' => sub { $worker->enqueue_jobs_and_accept_first($client, \%job_info); is_deeply($worker->current_job_ids, [26, 27], 'jobs accepted/enqueued'); $worker->skip_job(27, 'skip for testing'); - combined_like { $worker->_accept_or_skip_next_job_in_queue } qr/Skipping job 27 from queue/, - 'job 27 is skipped'; + combined_like { $worker->_accept_or_skip_next_job_in_queue } qr/Skipping job 27 from queue/, 'job 27 is skipped'; is_deeply( $client->api_calls, [post => 'jobs/27/set_done', {reason => 'skip for testing', result => 'skipped', worker_id => 42}], @@ -524,20 +519,16 @@ subtest 'checking worker address' => sub { subtest 'handle client status changes' => sub { my $fake_client = OpenQA::Worker::WebUIConnection->new('some-host', {apikey => 'foo', apisecret => 'bar'}); - my $fake_client_2 - = OpenQA::Worker::WebUIConnection->new('yet-another-host', {apikey => 'foo2', apisecret => 'bar2'}); - my $worker - = OpenQA::Worker->new({instance => 1, apikey => 'foo', apisecret => 'bar', verbose => 1, 'no-cleanup' => 1}); + my $fake_client_2 = OpenQA::Worker::WebUIConnection->new('yet-another-host', {apikey => 'foo2', apisecret => 'bar2'}); + my $worker = OpenQA::Worker->new({instance => 1, apikey => 'foo', apisecret => 'bar', verbose => 1, 'no-cleanup' => 1}); $worker->settings->webui_hosts([qw(some-host yet-another-host)]); $worker->clients_by_webui_host({'some-host' => $fake_client, 'yet-another-host' => $fake_client_2}); combined_like { $worker->_handle_client_status_changed($fake_client, {status => 'registering', reason => 'test'}); - $worker->_handle_client_status_changed($fake_client, - {status => 'establishing_ws', reason => 'test', url => 'foo-bar'}); + $worker->_handle_client_status_changed($fake_client, {status => 'establishing_ws', reason => 'test', url => 'foo-bar'}); } - qr/Registering with openQA some-host.*Establishing ws connection via foo-bar/s, - 'registration and ws connection logged'; + qr/Registering with openQA some-host.*Establishing ws connection via foo-bar/s, 'registration and ws connection logged'; my $job = OpenQA::Worker::Job->new($worker, $fake_client, {id => 43, some => 'info'}); $job->{_accept_attempts} = 2; @@ -555,8 +546,7 @@ subtest 'handle client status changes' => sub { $fake_client->status('disabled'); my $output = combined_from { - $worker->_handle_client_status_changed($fake_client, - {status => 'disabled', reason => 'test', error_message => 'Test disabling'}); + $worker->_handle_client_status_changed($fake_client, {status => 'disabled', reason => 'test', error_message => 'Test disabling'}); }; like($output, qr/Test disabling - ignoring server/s, 'client disabled'); unlike($output, qr/Stopping.*because registration/s, 'worker not stopped; there are still other clients'); @@ -564,8 +554,7 @@ subtest 'handle client status changes' => sub { # see if the expected number of retries is performed $ENV{OPENQA_WORKER_CONNECT_INTERVAL} = 7; combined_like { - $worker->_handle_client_status_changed($fake_client, - {status => 'failed', reason => 'test', error_message => '500 response: unavailable'}) + $worker->_handle_client_status_changed($fake_client, {status => 'failed', reason => 'test', error_message => '500 response: unavailable'}) } qr/trying again in 7 seconds/s, 'worker will attempt to retry later'; @@ -573,26 +562,21 @@ subtest 'handle client status changes' => sub { $fake_client_2->status('disabled'); combined_like { - $worker->_handle_client_status_changed($fake_client_2, - {status => 'disabled', reason => 'test', error_message => 'Test disabling'}) + $worker->_handle_client_status_changed($fake_client_2, {status => 'disabled', reason => 'test', error_message => 'Test disabling'}) } - qr/Test disabling - ignoring server.*Stopping because registration/s, - 'worker stopped instantly when last client disabled and there is no job'; + qr/Test disabling - ignoring server.*Stopping because registration/s, 'worker stopped instantly when last client disabled and there is no job'; ok(!$worker->is_stopping, 'not planning to stop yet'); combined_like { $worker->current_job($job); - $worker->_handle_client_status_changed($fake_client_2, - {status => 'disabled', reason => 'test', error_message => 'Test disabling'}); + $worker->_handle_client_status_changed($fake_client_2, {status => 'disabled', reason => 'test', error_message => 'Test disabling'}); } - qr/Test disabling - ignoring server.*Stopping after the current job because registration/s, - 'worker stopped after current job when last client disabled'; + qr/Test disabling - ignoring server.*Stopping after the current job because registration/s, 'worker stopped after current job when last client disabled'; ok($worker->is_stopping, 'worker is stopping'); is $worker->current_job->status, 'accepting', 'current job considered accepting'; combined_like { - $worker->_handle_client_status_changed($fake_client_2, - {status => 'failed', reason => 'test', error_message => 'Test failure'}); + $worker->_handle_client_status_changed($fake_client_2, {status => 'failed', reason => 'test', error_message => 'Test failure'}); } qr/Test failure - trying again/s, 'registration tried again on client failure'; is $worker->current_job->status, 'stopped', 'current job stopped after registration failure on last accept attempt'; @@ -661,8 +645,7 @@ subtest 'handle job status changes' => sub { # stop job with error message and without cleanup enabled combined_like { - $worker->_handle_job_status_changed($fake_job, - {status => 'stopped', reason => 'test', error_message => 'some error message'}); + $worker->_handle_job_status_changed($fake_job, {status => 'stopped', reason => 'test', error_message => 'some error message'}); } qr/Job 42 from some-host finished - reason: test.*some error message/s, 'status logged'; is($cleanup_called, 0, 'pool directory not cleaned up'); @@ -713,8 +696,7 @@ subtest 'handle job status changes' => sub { } qr/Job 42 from some-host finished - reason: quit/, 'first job being stopped is logged'; is $next_job->{_status}, 'skipped: ' . WORKER_COMMAND_QUIT, 'next job skipped with WORKER_COMMAND_QUIT'; - is $inform_webuis_called, 0, - 'web UIs not informed so far; we still need to wait until the next job is processed'; + is $inform_webuis_called, 0, 'web UIs not informed so far; we still need to wait until the next job is processed'; # test how the next job being skipped is handled further $stop_called = 0; @@ -734,8 +716,7 @@ subtest 'handle job status changes' => sub { $worker->_init_queue([$next_job]); # assume there's another job in the queue combined_like { $worker->handle_signal('HUP') } qr/Received signal HUP/, 'signal logged'; is $worker->{_shall_terminate}, 1, 'worker is supposed to terminate'; - ok !$worker->{_finishing_off}, - 'worker is still NOT supposed to finish off the current jobs due to previous SIGTERM'; + ok !$worker->{_finishing_off}, 'worker is still NOT supposed to finish off the current jobs due to previous SIGTERM'; $worker->{_finishing_off} = undef; # simulate we haven't already got SIGTERM $fake_job->{_status} = 0; combined_like { $worker->handle_signal('HUP') } qr/Received signal HUP/, 'signal logged (2)'; @@ -758,8 +739,7 @@ subtest 'handle job status changes' => sub { # test how the next job being skipped is handled further $stop_called = 0; - is $inform_webuis_called, 0, - 'web UIs not informed so far; we still need to wait until the next job is processed'; + is $inform_webuis_called, 0, 'web UIs not informed so far; we still need to wait until the next job is processed'; combined_like { $worker->_handle_job_status_changed($next_job, {status => 'stopped', reason => WORKER_SR_DONE}); } @@ -786,13 +766,8 @@ subtest 'handle job status changes' => sub { combined_like { $worker->_handle_job_status_changed($fake_job, {status => 'stopped', reason => 'done'}); } -qr/Job 42 from some-host finished - reason: done.*A QEMU instance using.*Skipping job 769 from queue because worker is broken/s, - 'status logged'; - is( - $worker->current_error, - 'A QEMU instance using the current pool directory is still running (PID: 17377)', - 'error status recomputed' - ); + qr/Job 42 from some-host finished - reason: done.*A QEMU instance using.*Skipping job 769 from queue because worker is broken/s, 'status logged'; + is($worker->current_error, 'A QEMU instance using the current pool directory is still running (PID: 17377)', 'error status recomputed'); is $pending_job->status, 'skipped: ?', 'pending job is supposed to be skipped due to the error'; combined_like { $worker->_handle_job_status_changed($pending_job, {status => 'stopped', reason => 'skipped'}); @@ -840,8 +815,7 @@ subtest 'handle critical error' => sub { combined_like { like warning { Mojo::IOLoop->start }, qr/$msg_1/, 'expected msg' } - qr/$expected_logs.*$msg_2.*Trying to kill ourself forcefully now/s, - 'log for initial critical error and forcefull kill after second error'; + qr/$expected_logs.*$msg_2.*Trying to kill ourself forcefully now/s, 'log for initial critical error and forcefull kill after second error'; is $stop_called, 1, 'worker tried to stop the job'; is $kill_called, 1, 'worker tried to kill itself in the end'; }; diff --git a/t/24-worker-settings.t b/t/24-worker-settings.t index 6646ba5c0d2d..b4861b5b1700 100644 --- a/t/24-worker-settings.t +++ b/t/24-worker-settings.t @@ -120,8 +120,7 @@ subtest 'settings file not found' => sub { $ENV{OPENQA_CONFIG} = "$FindBin::Bin/data/24-worker-setting"; my $settings = OpenQA::Worker::Settings->new(1); is($settings->file_path, undef, 'no file path present'); - is_deeply($settings->parse_errors, ["Config file not found at '$FindBin::Bin/data/24-worker-setting/workers.ini'."], - 'error logged') + is_deeply($settings->parse_errors, ["Config file not found at '$FindBin::Bin/data/24-worker-setting/workers.ini'."], 'error logged') or diag explain $settings->parse_errors; }; diff --git a/t/24-worker-webui-connection.t b/t/24-worker-webui-connection.t index af725b6053a3..7ad13c530dc3 100644 --- a/t/24-worker-webui-connection.t +++ b/t/24-worker-webui-connection.t @@ -126,8 +126,7 @@ subtest 'attempt to register and send a command' => sub { } qr/Connection error: Can't connect:.*(remaining tries: 0)/s, 'error logged'; is($callback_invoked, 1, 'callback has been invoked'); - is($client->worker->stop_current_job_called, - 0, 'not attempted to stop current job because it is from different web UI'); + is($client->worker->stop_current_job_called, 0, 'not attempted to stop current job because it is from different web UI'); $client->worker->current_webui_host('http://test-host'); $callback_invoked = 0; combined_like { @@ -146,21 +145,12 @@ subtest 'attempt to register and send a command' => sub { qr/Connection error:.*(remaining tries: 0)/s, 'error logged'; is($callback_invoked, 1, 'callback has been invoked'); - is($client->worker->stop_current_job_called, - WORKER_SR_API_FAILURE, 'attempted to stop current job with reason "api-failure"'); + is($client->worker->stop_current_job_called, WORKER_SR_API_FAILURE, 'attempted to stop current job with reason "api-failure"'); my $error_message = ref($happened_events[1]) eq 'HASH' ? delete $happened_events[1]->{error_message} : undef; - ( - is_deeply( - \@happened_events, - [{status => 'registering', error_message => undef}, {status => 'failed'}], - 'events emitted', - ) - and like( - $error_message, - qr{Failed to register at http://test-host - connection error: Can't connect:.*}, - 'error message', - )) or diag explain \@happened_events; + ( is_deeply(\@happened_events, [{status => 'registering', error_message => undef}, {status => 'failed'}], 'events emitted',) + and like($error_message, qr{Failed to register at http://test-host - connection error: Can't connect:.*}, 'error message',)) + or diag explain \@happened_events; }; @@ -262,9 +252,7 @@ qr/$code response: some timeout \(remaining tries: 2\).*$code response: some tim $fake_error->{message} = 'some error'; $fake_error->{code} = 500; $web_ui_supposed_to_be_considered_busy = undef; - send_once(\@send_args, - qr/500 response: some error \(remaining tries: 1\).*500 response: some error \(remaining tries: 0\)/s, - undef, tries => 2); + send_once(\@send_args, qr/500 response: some error \(remaining tries: 1\).*500 response: some error \(remaining tries: 0\)/s, undef, tries => 2); is($fake_ua->start_count, 2, 'tried 2 times'); is($callback_invoked, 1, 'callback invoked exactly one time'); is($retry_delay_invoked, 1, 'retry delay queried'); @@ -286,11 +274,7 @@ qr/$code response: some timeout \(remaining tries: 2\).*$code response: some tim for (sort keys %codes_4xx) { $fake_error->{code} = $_; $fake_error->{message} = $codes_4xx{$_}; - send_once( - \@send_args, - qr/$fake_error->{code} response: $fake_error->{message} \(remaining tries: 0\)/, - "$fake_error->{code} logged" - ); + send_once(\@send_args, qr/$fake_error->{code} response: $fake_error->{message} \(remaining tries: 0\)/, "$fake_error->{code} logged"); is($fake_ua->start_count, $start_count++, "tried 1 time for $fake_error->{code}"); is($callback_invoked, $callback_count++, "callback invoked exactly one time for $fake_error->{code}"); is($retry_delay_invoked, 0, "retry delay not queried $fake_error->{code}"); @@ -369,11 +353,8 @@ subtest 'rejecting jobs' => sub { $client->websocket_connection($ws); $client->emit('connected'); Mojo::IOLoop->one_tick; - is_deeply( - $ws->sent_messages, - [{json => {type => 'rejected', job_ids => [1, 2, 3], reason => 'just a test'}}], - 'rejected sent when connected again' - ) or diag explain $ws->sent_messages; + is_deeply($ws->sent_messages, [{json => {type => 'rejected', job_ids => [1, 2, 3], reason => 'just a test'}}], 'rejected sent when connected again') + or diag explain $ws->sent_messages; ok($callback_called, 'callback invoked'); }; }; @@ -388,7 +369,7 @@ subtest 'command handler' => sub { combined_like { $command_handler->handle_command(undef, {}) } qr/Ignoring WS message without type from http:\/\/test-host.*/, 'ignoring non-result message without type'; combined_like { $command_handler->handle_command(undef, {type => WORKER_COMMAND_LIVELOG_STOP, jobid => 1}) } -qr/Ignoring WS message from http:\/\/test-host with type livelog_stop and job ID 1 \(currently not executing a job\).*/, + qr/Ignoring WS message from http:\/\/test-host with type livelog_stop and job ID 1 \(currently not executing a job\).*/, 'ignoring job-specific message when no job running'; $worker->current_error('some error'); $app->log->level('debug'); @@ -418,21 +399,17 @@ qr/Ignoring WS message from http:\/\/test-host with type livelog_stop and job ID combined_like { $command_handler->handle_command(undef, {type => WORKER_COMMAND_GRAB_JOBS, job_info => {sequence => ['foo']}}) } - qr/Refusing to grab jobs.*: the provided job info lacks job data or execution sequence.*/, - 'ignoring grab multiple jobs if job data'; + qr/Refusing to grab jobs.*: the provided job info lacks job data or execution sequence.*/, 'ignoring grab multiple jobs if job data'; combined_like { - $command_handler->handle_command(undef, - {type => WORKER_COMMAND_GRAB_JOBS, job_info => {sequence => 'not an array', data => {42 => 'foo'}}}) + $command_handler->handle_command(undef, {type => WORKER_COMMAND_GRAB_JOBS, job_info => {sequence => 'not an array', data => {42 => 'foo'}}}) } - qr/Refusing to grab jobs.*: the provided job info lacks execution sequence.*/, - 'ignoring grab multiple jobs if execution sequence missing'; + qr/Refusing to grab jobs.*: the provided job info lacks execution sequence.*/, 'ignoring grab multiple jobs if execution sequence missing'; $worker->current_webui_host('foo'); $worker->is_busy(1); combined_like { $command_handler->handle_command(undef, {type => WORKER_COMMAND_GRAB_JOB, job => {id => 42, settings => {}}}) } - qr/Refusing to grab job from .* already busy with a job from foo/, - 'ignoring job grab when busy with another web UI'; + qr/Refusing to grab job from .* already busy with a job from foo/, 'ignoring job grab when busy with another web UI'; $worker->current_webui_host('http://test-host'); $worker->current_job(OpenQA::Worker::Job->new($worker, $client, {id => 43})); $worker->current_job_ids([43]); @@ -470,8 +447,7 @@ qr/Ignoring WS message from http:\/\/test-host with type livelog_stop and job ID # test accepting a job is($worker->current_job, undef, 'no job accepted so far'); - $command_handler->handle_command(undef, - {type => WORKER_COMMAND_GRAB_JOB, job => {id => 25, settings => {FOO => 'bar'}}}); + $command_handler->handle_command(undef, {type => WORKER_COMMAND_GRAB_JOB, job => {id => 25, settings => {FOO => 'bar'}}}); my $accepted_job = $worker->current_job; is_deeply($accepted_job->info, {id => 25, settings => {FOO => 'bar'}}, 'job accepted'); @@ -486,12 +462,10 @@ qr/Ignoring WS message from http:\/\/test-host with type livelog_stop and job ID is($accepted_job->livelog_viewers, 0, 'livelog stopped'); combined_like { $command_handler->handle_command(undef, {type => WORKER_COMMAND_QUIT, jobid => 27}) } - qr/Ignoring job cancel from http:\/\/test-host because there's no job with ID 27/, - 'ignoring commands for different job'; + qr/Ignoring job cancel from http:\/\/test-host because there's no job with ID 27/, 'ignoring commands for different job'; # stopping job - is($accepted_job->status, 'new', - 'since our fake worker does not start the job is is still supposed to be in state "new" so far'); + is($accepted_job->status, 'new', 'since our fake worker does not start the job is is still supposed to be in state "new" so far'); $command_handler->handle_command(undef, {type => WORKER_COMMAND_QUIT, jobid => 25}); is($accepted_job->status, 'stopped', 'job has been stopped'); @@ -506,8 +480,7 @@ qr/Ignoring WS message from http:\/\/test-host with type livelog_stop and job ID }, ); $command_handler->handle_command(undef, {type => WORKER_COMMAND_GRAB_JOBS, job_info => \%job_info}); - is_deeply($worker->enqueued_job_info, - \%job_info, 'job info successfully validated and passed to enqueue_jobs_and_accept_first') + is_deeply($worker->enqueued_job_info, \%job_info, 'job info successfully validated and passed to enqueue_jobs_and_accept_first') or diag explain $worker->enqueued_job_info; # test refusing multiple jobs due because job data is missing diff --git a/t/25-cache-client.t b/t/25-cache-client.t index 49f34a1fa159..34c34bdb53b3 100644 --- a/t/25-cache-client.t +++ b/t/25-cache-client.t @@ -55,8 +55,7 @@ sub _refuse_connection { } subtest 'Enqueue' => sub { - my $request - = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); + my $request = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); ok !$client->enqueue($request), 'no error'; ok $request->minion_id, 'has Minion id'; ok my $job = $app->minion->job($request->minion_id), 'is Minion job'; @@ -72,8 +71,7 @@ subtest 'Enqueue' => sub { }; subtest 'Enqueue error' => sub { - my $request - = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); + my $request = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); $request->task(undef); like $client->enqueue($request), qr/Cache service enqueue error from API: No task defined/, 'error'; ok !$request->minion_id, 'no Minion id'; @@ -85,34 +83,29 @@ subtest 'Enqueue error' => sub { my $mock = Test::MockModule->new('OpenQA::CacheService::Request::Asset'); $mock->redefine(to_array => sub { undef }); - $request - = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); + $request = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); like $client->enqueue($request), qr/Cache service enqueue error from API: No arguments defined/, 'error'; ok !$request->minion_id, 'no Minion id'; $mock->redefine(to_array => sub { 'test' }); - $request - = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); + $request = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); like $client->enqueue($request), qr/Cache service enqueue error from API: Arguments need to be an array/, 'error'; ok !$request->minion_id, 'no Minion id'; $mock->unmock('to_array'); $mock->redefine(lock => sub { undef }); - $request - = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); + $request = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); like $client->enqueue($request), qr/Cache service enqueue error from API: No lock defined/, 'error'; ok !$request->minion_id, 'no Minion id'; $mock->unmock('lock'); $app->plugins->once(before_dispatch => sub { shift->render(text => 'Howdy!', status => 500) }); - $request - = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); + $request = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); like $client->enqueue($request), qr/Cache service enqueue error 500: Internal Server Error/, 'error'; ok !$request->minion_id, 'no Minion id'; $app->plugins->once(before_dispatch => sub { shift->render(text => 'Howdy!') }); - $request - = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); + $request = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); like $client->enqueue($request), qr/Cache service enqueue error: 200 non-JSON response/, 'error'; ok !$request->minion_id, 'no Minion id'; }; @@ -122,8 +115,7 @@ subtest 'Enqueue error (with retry)' => sub { is $client->attempts, 60, 'correct attempts by default'; my $cb = $client->ua->on(start => \&_refuse_connection); - my $request - = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); + my $request = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); like $client->enqueue($request), qr/Cache service enqueue error: Connection refused/, 'error'; $client->ua->unsubscribe(start => $cb); is $sleep_count, $client->attempts - 1, 'sleep called multiple times'; @@ -131,8 +123,7 @@ subtest 'Enqueue error (with retry)' => sub { $sleep_count = 0; $cb = $client->ua->once(start => \&_refuse_connection); - $request - = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); + $request = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); ok !$client->enqueue($request), 'no error'; is $sleep_count, 1, 'sleep called once'; ok $request->minion_id, 'has Minion id'; @@ -196,8 +187,7 @@ subtest 'Info error (with retry)' => sub { }; subtest 'Status' => sub { - my $request - = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); + my $request = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); ok !$client->enqueue($request), 'no error'; ok $request->minion_id, 'has Minion id'; my $status = $client->status($request); @@ -207,8 +197,7 @@ subtest 'Status' => sub { is $status->result, undef, 'no result'; is $status->output, undef, 'no output'; - my $request2 - = $client->asset_request(id => 9998, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); + my $request2 = $client->asset_request(id => 9998, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); ok !$client->enqueue($request2), 'no error'; ok $request2->minion_id, 'has Minion id'; $status = $client->status($request2); @@ -253,8 +242,7 @@ subtest 'Status' => sub { ok $status->is_processed, 'processed'; is $status->result, undef, 'no result'; is $status->output, "it\nworks\n!", 'output'; - is $job2->info->{notes}{output}, - 'Asset "asset_name.qcow2" was downloaded by #4, details are therefore unavailable here', 'different output'; + is $job2->info->{notes}{output}, 'Asset "asset_name.qcow2" was downloaded by #4, details are therefore unavailable here', 'different output'; # Remove the job that actually performed the download ok $app->minion->job($request->minion_id)->remove, 'removed'; @@ -263,14 +251,12 @@ subtest 'Status' => sub { ok !$status->is_downloading, 'not downloading'; ok $status->is_processed, 'processed'; is $status->result, undef, 'no result'; - is $status->output, 'Asset "asset_name.qcow2" was downloaded by #4, details are therefore unavailable here', - 'output'; + is $status->output, 'Asset "asset_name.qcow2" was downloaded by #4, details are therefore unavailable here', 'output'; $worker->unregister; }; subtest 'Status error' => sub { - my $request - = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); + my $request = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); ok !$client->enqueue($request), 'no error'; ok $request->minion_id, 'has Minion id'; $app->plugins->once(before_dispatch => sub { shift->render(text => 'Howdy!', status => 500) }); @@ -320,8 +306,7 @@ subtest 'Status error' => sub { $request = $client->asset_request(id => 9995, asset => 'asset.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); ok !$client->enqueue($request), 'no error'; ok $request->minion_id, 'has Minion id'; - my $request2 - = $client->asset_request(id => 9994, asset => 'asset.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); + my $request2 = $client->asset_request(id => 9994, asset => 'asset.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); ok !$client->enqueue($request2), 'no error'; ok $request2->minion_id, 'has Minion id'; $job = $worker->dequeue(0, {id => $request->minion_id}); @@ -348,8 +333,7 @@ subtest 'Status error' => sub { subtest 'Status error (with retry)' => sub { $sleep_count = 0; - my $request - = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); + my $request = $client->asset_request(id => 9999, asset => 'asset_name.qcow2', type => 'hdd', host => 'openqa.opensuse.org'); ok !$client->enqueue($request), 'no error'; ok $request->minion_id, 'has Minion id'; my $cb = $client->ua->on(start => \&_refuse_connection); diff --git a/t/25-cache-service.t b/t/25-cache-service.t index 6f5007f654f8..c80542e92868 100644 --- a/t/25-cache-service.t +++ b/t/25-cache-service.t @@ -42,8 +42,7 @@ use Mojo::IOLoop::Server; use POSIX '_exit'; use Mojo::IOLoop::ReadWriteProcess qw(queue process); use Mojo::IOLoop::ReadWriteProcess::Session 'session'; -use OpenQA::Test::Utils - qw(fake_asset_server cache_minion_worker cache_worker_service wait_for_or_bail_out perform_minion_jobs); +use OpenQA::Test::Utils qw(fake_asset_server cache_minion_worker cache_worker_service wait_for_or_bail_out perform_minion_jobs); use OpenQA::Test::TimeLimit '90'; use Mojo::Util qw(md5_sum); use OpenQA::CacheService; @@ -189,11 +188,9 @@ subtest 'Availability check and worker status' => sub { }; subtest 'Configurable minion workers' => sub { - is_deeply([OpenQA::CacheService::setup_workers(qw(minion test))], - [qw(minion test)], 'minion worker setup with test'); + is_deeply([OpenQA::CacheService::setup_workers(qw(minion test))], [qw(minion test)], 'minion worker setup with test'); is_deeply([OpenQA::CacheService::setup_workers(qw(run))], [qw(run -j 10)], 'minion worker setup with worker'); - is_deeply([OpenQA::CacheService::setup_workers(qw(minion daemon))], - [qw(minion daemon)], 'minion worker setup with daemon'); + is_deeply([OpenQA::CacheService::setup_workers(qw(minion daemon))], [qw(minion daemon)], 'minion worker setup with daemon'); path($ENV{OPENQA_CONFIG})->child("workers.ini")->spew(" [global] @@ -218,8 +215,7 @@ subtest 'Cache Requests' => sub { eval { $base->lock }; like $@, qr/lock\(\) not implemented in OpenQA::CacheService::Request/, 'lock() not implemented in base request'; eval { $base->to_array }; - like $@, qr/to_array\(\) not implemented in OpenQA::CacheService::Request/, - 'to_array() not implemented in base request'; + like $@, qr/to_array\(\) not implemented in OpenQA::CacheService::Request/, 'to_array() not implemented in base request'; }; start_servers; @@ -412,8 +408,7 @@ subtest 'Multiple minion workers (parallel downloads, almost simulating real sce my @assets = map { "sle-12-SP3-x86_64-0368-200_$_\@64bit.qcow2" } 1 .. $tot_proc; unlink path($cachedir)->child($_) for @assets; - my %requests - = map { $_ => $cache_client->asset_request(id => 922756, asset => $_, type => 'hdd', host => $host) } @assets; + my %requests = map { $_ => $cache_client->asset_request(id => 922756, asset => $_, type => 'hdd', host => $host) } @assets; ok(!$cache_client->enqueue($requests{$_}), "Download enqueued for $_") for @assets; wait_for_or_bail_out { @@ -425,8 +420,7 @@ subtest 'Multiple minion workers (parallel downloads, almost simulating real sce @assets = map { "sle-12-SP3-x86_64-0368-200_88888\@64bit.qcow2" } 1 .. $tot_proc; unlink path($cachedir)->child($_) for @assets; - %requests - = map { $_ => $cache_client->asset_request(id => 922756, asset => $_, type => 'hdd', host => $host) } @assets; + %requests = map { $_ => $cache_client->asset_request(id => 922756, asset => $_, type => 'hdd', host => $host) } @assets; ok(!$cache_client->enqueue($requests{$_}), "Download enqueued for $_") for @assets; wait_for_or_bail_out { @@ -434,9 +428,7 @@ subtest 'Multiple minion workers (parallel downloads, almost simulating real sce } 'assets'; - ok($cache_client->asset_exists('localhost', "sle-12-SP3-x86_64-0368-200_88888\@64bit.qcow2"), - "Asset $_ downloaded correctly") - for @assets; + ok($cache_client->asset_exists('localhost', "sle-12-SP3-x86_64-0368-200_88888\@64bit.qcow2"), "Asset $_ downloaded correctly") for @assets; $_->stop for ($worker_2, $worker_3, $worker_4); }; @@ -586,8 +578,7 @@ subtest 'Concurrent downloads of the same file' => sub { ok $status2->is_processed, 'is processed'; my $info2 = $app->minion->job($req2->minion_id)->info; ok $info2->{notes}{downloading_job}, 'downloading job is linked'; - like $info2->{notes}{output}, qr/Asset "sle.+" was downloaded by #\d+, details are therefore unavailable here/, - 'right output'; + like $info2->{notes}{output}, qr/Asset "sle.+" was downloaded by #\d+, details are therefore unavailable here/, 'right output'; like $status2->output, qr/Downloading "sle\-12\-SP3\-x86_64\-0368\-200_133333\@64bit.qcow2"/, 'right output'; ok $cache_client->asset_exists('localhost', $asset), 'cached file still exists'; @@ -595,8 +586,7 @@ subtest 'Concurrent downloads of the same file' => sub { $app->minion->job($req->minion_id)->remove; my $status3 = $cache_client->status($req2); ok $status3->is_processed, 'is processed'; - like $status3->output, qr/Asset "sle.+" was downloaded by #\d+, details are therefore unavailable here/, - 'right output'; + like $status3->output, qr/Asset "sle.+" was downloaded by #\d+, details are therefore unavailable here/, 'right output'; }; subtest 'Concurrent rsync' => sub { @@ -642,8 +632,7 @@ subtest 'Concurrent rsync' => sub { is $status2->result, undef, 'expected result'; my $info2 = $app->minion->job($req2->minion_id)->info; ok $info2->{notes}{downloading_job}, 'downloading job is linked'; - like $info2->{notes}{output}, qr/Sync ".+" to ".+" was performed by #\d+, details are therefore unavailable here/, - 'right output'; + like $info2->{notes}{output}, qr/Sync ".+" to ".+" was performed by #\d+, details are therefore unavailable here/, 'right output'; like $status2->output, qr/sending incremental file list/, 'right output'; ok -e $expected, 'target file exists'; is $expected->slurp, 'foobar', 'expected content'; @@ -653,8 +642,7 @@ subtest 'Concurrent rsync' => sub { my $status3 = $cache_client->status($req2); ok $status3->is_processed, 'is processed'; is $status3->result, undef, 'expected result'; - like $status3->output, qr/Sync ".+" to ".+" was performed by #\d+, details are therefore unavailable here/, - 'right output'; + like $status3->output, qr/Sync ".+" to ".+" was performed by #\d+, details are therefore unavailable here/, 'right output'; }; subtest 'OpenQA::CacheService::Task::Sync' => sub { diff --git a/t/25-cache.t b/t/25-cache.t index 38cb4b5b618c..1371027c48c8 100644 --- a/t/25-cache.t +++ b/t/25-cache.t @@ -108,8 +108,7 @@ $cache->downloader->sleep_time(0.01); $cache->init; $cache->limit(100); is $cache->sqlite->migrations->active, 5, 'Current version is still the active version'; -like $cache_log, qr/Cache size of "$cachedir" is 168 Byte, with limit 50 GiB/, - 'Cache limit/size match the expected 100GB/168)'; +like $cache_log, qr/Cache size of "$cachedir" is 168 Byte, with limit 50 GiB/, 'Cache limit/size match the expected 100GB/168)'; unlike $cache_log, qr/Purging ".*[13].qcow2"/, 'Registered assets 1 and 3 were kept'; like $cache_log, qr/Purging ".*2.qcow2" because the asset is not registered/, 'Unregistered asset 2 was removed'; like $cache_log, qr/Purging ".*4.qcow2" because it appears pending/, 'Pending asset 4 was removed'; @@ -133,12 +132,9 @@ $cache->sqlite->db->query('UPDATE assets set pending = 0 where filename = ?', $p # run the cleanup again without preserving the oldest asset $cache->refresh; -like $cache_log, qr/Cache size of "$cachedir" is 84 Byte, with limit 100 Byte/, - 'Cache limit/size match the expected 100/84)'; -like $cache_log, qr/Cache size 168 Byte \+ needed 0 Byte exceeds limit of 100 Byte, purging least used assets/, - 'Requested size is logged'; -like $cache_log, qr/Purging ".*1.qcow2" because we need space for new assets, reclaiming 84/, - 'Oldest asset (1.qcow2) removal was logged'; +like $cache_log, qr/Cache size of "$cachedir" is 84 Byte, with limit 100 Byte/, 'Cache limit/size match the expected 100/84)'; +like $cache_log, qr/Cache size 168 Byte \+ needed 0 Byte exceeds limit of 100 Byte, purging least used assets/, 'Requested size is logged'; +like $cache_log, qr/Purging ".*1.qcow2" because we need space for new assets, reclaiming 84/, 'Oldest asset (1.qcow2) removal was logged'; ok !-e $oldest_asset, 'Oldest asset (1.qcow2) was successfully removed'; ok -e $pending_asset, 'Not so old asset (3.qcow2) was preserved (despite not being pending anymore)'; $cache_log = ''; @@ -170,8 +166,7 @@ $cache_log = ''; # Retry server error (500) $cache->get_asset($host, {id => 922756}, 'hdd', 'sle-12-SP3-x86_64-0368-200_server_error@64bit.qcow2'); like $cache_log, qr/Downloading "sle-12-SP3-x86_64-0368-200_server_error\@64bit.qcow2" from/, 'Asset download attempt'; -like $cache_log, qr/Download of ".*0368-200_server_error\@64bit.qcow2" failed: 500 Internal Server Error/, - 'Real error is logged'; +like $cache_log, qr/Download of ".*0368-200_server_error\@64bit.qcow2" failed: 500 Internal Server Error/, 'Real error is logged'; like $cache_log, qr/Download error 500, waiting 0.01 seconds for next try \(4 remaining\)/, '4 tries remaining'; like $cache_log, qr/Download error 500, waiting 0.01 seconds for next try \(3 remaining\)/, '3 tries remaining'; like $cache_log, qr/Download error 500, waiting 0.01 seconds for next try \(2 remaining\)/, '2 tries remaining'; @@ -206,37 +201,31 @@ $cache_log = ''; # Retry connection error (closed early) $cache->get_asset($host, {id => 922756}, 'hdd', 'sle-12-SP3-x86_64-0368-200_close@64bit.qcow2'); like $cache_log, qr/Downloading "sle-12-SP3-x86_64-0368-200_close\@64bit.qcow2" from/, 'Asset download attempt'; -like $cache_log, qr/Download of ".*200_close\@64bit.qcow2" failed: 521 Premature connection close/, - 'Real error is logged'; +like $cache_log, qr/Download of ".*200_close\@64bit.qcow2" failed: 521 Premature connection close/, 'Real error is logged'; like $cache_log, qr/Download error 521, waiting 0.01 seconds for next try \(4 remaining\)/, '4 tries remaining'; like $cache_log, qr/Download error 521, waiting 0.01 seconds for next try \(3 remaining\)/, '3 tries remaining'; like $cache_log, qr/Download error 521, waiting 0.01 seconds for next try \(2 remaining\)/, '2 tries remaining'; like $cache_log, qr/Download error 521, waiting 0.01 seconds for next try \(1 remaining\)/, '1 tries remaining'; -like $cache_log, qr/Purging ".*200_close\@64bit.qcow2" because of too many download errors/, - 'Bailing out after too many retries'; +like $cache_log, qr/Purging ".*200_close\@64bit.qcow2" because of too many download errors/, 'Bailing out after too many retries'; like $cache_log, qr/Purging ".*200_close\@64bit.qcow2" failed because the asset did not exist/, 'Asset was missing'; ok !-e $cachedir->child($host, 'sle-12-SP3-x86_64-0368-200_close@64bit.qcow2'), 'Asset does not exist in cache'; $cache_log = ''; $cache->get_asset($host, {id => 922756}, 'hdd', 'sle-12-SP3-x86_64-0368-503@64bit.qcow2'); like $cache_log, qr/Downloading "sle-12-SP3-x86_64-0368-503\@64bit.qcow2" from/, 'Asset download attempt'; -like $cache_log, qr/Download of ".*0368-503\@64bit.qcow2" failed: 503 Service Unavailable/, - 'Asset download fails with 503 - Server not available'; +like $cache_log, qr/Download of ".*0368-503\@64bit.qcow2" failed: 503 Service Unavailable/, 'Asset download fails with 503 - Server not available'; like $cache_log, qr/Download error 503, waiting 0.01 seconds for next try \(4 remaining\)/, '4 tries remaining'; -like $cache_log, qr/Purging ".*-503@64bit.qcow2" because of too many download errors/, - 'Bailing out after too many retries'; +like $cache_log, qr/Purging ".*-503@64bit.qcow2" because of too many download errors/, 'Bailing out after too many retries'; ok !-e $cachedir->child($host, 'sle-12-SP3-x86_64-0368-503@64bit.qcow2'), 'Asset does not exist in cache'; $cache_log = ''; # Successful download $cache->get_asset($host, {id => 922756}, 'hdd', 'sle-12-SP3-x86_64-0368-200@64bit.qcow2'); like $cache_log, qr/Downloading "sle-12-SP3-x86_64-0368-200\@64bit.qcow2" from/, 'Asset download attempt'; -like $cache_log, qr/Download of ".*sle-12-SP3-x86_64-0368-200.*" successful \([\d\.]+ \w+\/s\), new cache size is 1024/, - 'Full download logged'; +like $cache_log, qr/Download of ".*sle-12-SP3-x86_64-0368-200.*" successful \([\d\.]+ \w+\/s\), new cache size is 1024/, 'Full download logged'; like $cache_log, qr/Size of .* is 1024 Byte, with ETag "andi \$a3, \$t1, 41399"/, 'Etag and size are logged'; ok -e $cachedir->child($host, 'sle-12-SP3-x86_64-0368-200@64bit.qcow2'), 'Asset exist in cache'; -is $cache->asset($cachedir->child($host, 'sle-12-SP3-x86_64-0368-200@64bit.qcow2')->to_string)->{pending}, 0, - 'Pending flag unset after download'; +is $cache->asset($cachedir->child($host, 'sle-12-SP3-x86_64-0368-200@64bit.qcow2')->to_string)->{pending}, 0, 'Pending flag unset after download'; $cache_log = ''; $cache->get_asset($host, {id => 922756}, 'hdd', 'sle-12-SP3-x86_64-0368-200@64bit.qcow2'); @@ -261,11 +250,9 @@ subtest 'cache purging after successful download' => sub { }); $cache->get_asset($host, {id => 922756}, 'hdd', $asset); like $cache_log, qr/Downloading "$asset" from/, 'Asset download attempt'; - like $cache_log, qr/Download of ".*$asset.*" successful \([\d\.]+ \w+\/s\), new cache size is 256/, - 'Full download logged'; + like $cache_log, qr/Download of ".*$asset.*" successful \([\d\.]+ \w+\/s\), new cache size is 256/, 'Full download logged'; like $cache_log, qr/is 256 Byte, with ETag "andi \$a3, \$t1, 41399"/, 'Etag and size are logged'; - like $cache_log, qr/Cache size 1024 Byte \+ needed 256 Byte exceeds limit of 1024 Byte, purging least used assets/, - 'Requested size is logged'; + like $cache_log, qr/Cache size 1024 Byte \+ needed 256 Byte exceeds limit of 1024 Byte, purging least used assets/, 'Requested size is logged'; like $cache_log, qr/Purging ".*sle-12-SP3-x86_64-0368-200\@64bit.qcow2" because we need space for new assets, reclaiming 1024/, 'Reclaimed space for new smaller asset'; @@ -274,24 +261,21 @@ subtest 'cache purging after successful download' => sub { }; $res = $cache->get_asset($host, {id => 922756}, 'hdd', 'sle-12-SP3-x86_64-0368-200_#:@64bit.qcow2'); -like $cache_log, qr/Download of ".*sle-12-SP3-x86_64-0368-200_#:.*" successful \([\d\.]+ \w+\/s\)/, - 'Asset with special characters was downloaded successfully'; +like $cache_log, qr/Download of ".*sle-12-SP3-x86_64-0368-200_#:.*" successful \([\d\.]+ \w+\/s\)/, 'Asset with special characters was downloaded successfully'; like $cache_log, qr/Size of .* is 20 Byte, with ETag "123456789"/, 'Etag and size are logged'; $cache_log = ''; is $res, undef, 'no error returned for successful download' or diag explain $res; $cache->get_asset("http://$host", {id => 922756}, 'hdd', 'sle-12-SP3-x86_64-0368-200@64bit.qcow2'); like $cache_log, qr/Downloading "sle-12-SP3-x86_64-0368-200\@64bit.qcow2" from/, 'Asset download attempt'; -like $cache_log, qr/Download of ".*sle-12-SP3-x86_64-0368-200.*" successful \([\d\.]+ \w+\/s\), new cache size is 1024/, - 'Full download logged'; +like $cache_log, qr/Download of ".*sle-12-SP3-x86_64-0368-200.*" successful \([\d\.]+ \w+\/s\), new cache size is 1024/, 'Full download logged'; like $cache_log, qr/Size of .* is 1024 Byte, with ETag "andi \$a3, \$t1, 41399"/, 'Etag and size are logged'; $cache_log = ''; $cache->get_asset("http://$host", {id => 922756}, 'hdd', 'sle-12-SP3-x86_64-0368-200@64bit.qcow2'); like $cache_log, qr/Downloading "sle-12-SP3-x86_64-0368-200\@64bit.qcow2" from/, 'Asset download attempt'; like $cache_log, qr/Content of ".*0368-200@64bit.qcow2" has not changed, updating last use/, 'Content has not changed'; -is $cache->asset($cachedir->child(base_host("http://$host"), 'sle-12-SP3-x86_64-0368-200@64bit.qcow2'))->{pending}, 0, - 'Pending flag unset if asset unchanged'; +is $cache->asset($cachedir->child(base_host("http://$host"), 'sle-12-SP3-x86_64-0368-200@64bit.qcow2'))->{pending}, 0, 'Pending flag unset if asset unchanged'; $cache_log = ''; subtest 'track assets' => sub { @@ -332,26 +316,21 @@ subtest 'cache directory is symlink' => sub { $cache->get_asset($host, {id => 922756}, 'hdd', 'sle-12-SP3-x86_64-0368-200@64bit.qcow2'); like $cache_log, qr/Downloading "sle-12-SP3-x86_64-0368-200\@64bit.qcow2" from/, 'Asset download attempt'; - like $cache_log, - qr/Download of ".*sle-12-SP3-x86_64-0368-200.*" successful \([\d\.]+ \w+\/s\), new cache size is 1024/, - 'Full download logged'; + like $cache_log, qr/Download of ".*sle-12-SP3-x86_64-0368-200.*" successful \([\d\.]+ \w+\/s\), new cache size is 1024/, 'Full download logged'; like $cache_log, qr/Size of .* is 1024 Byte, with ETag "andi \$a3, \$t1, 41399"/, 'Etag and size are logged'; $cache_log = ''; $cache->get_asset($host, {id => 922756}, 'hdd', 'sle-12-SP3-x86_64-0368-200@64bit.qcow2'); like $cache_log, qr/Downloading "sle-12-SP3-x86_64-0368-200\@64bit.qcow2" from/, 'Asset download attempt'; - like $cache_log, qr/Content of ".*0368-200@64bit.qcow2" has not changed, updating last use/, - 'Content has not changed'; + like $cache_log, qr/Content of ".*0368-200@64bit.qcow2" has not changed, updating last use/, 'Content has not changed'; $cache_log = ''; $cache->refresh; - like $cache_log, qr/Cache size of "$cachedir" is 1024 Byte, with limit 1024 Byte/, - 'Cache limit/size match the expected 1024/1024)'; + like $cache_log, qr/Cache size of "$cachedir" is 1024 Byte, with limit 1024 Byte/, 'Cache limit/size match the expected 1024/1024)'; $cache_log = ''; $cache->limit(512)->refresh; - like $cache_log, qr/Purging ".*200@64bit.qcow2" because we need space for new assets, reclaiming 1024 Byte/, - 'Reclaimed 1024 Byte'; + like $cache_log, qr/Purging ".*200@64bit.qcow2" because we need space for new assets, reclaiming 1024 Byte/, 'Reclaimed 1024 Byte'; like $cache_log, qr/Cache size of "$cachedir" is 0 Byte, with limit 512 Byte/, 'Cache limit is 512 Byte'; $cache_log = ''; }; @@ -463,8 +442,7 @@ subtest 'checking limits' => sub { $df_mock->redefine(df => {}); $cache_log = ''; is $cache->_exceeds_limit(21), 0, 'limit ignored when free disk space cannot be determined'; - like $cache_log, qr/.*Unable to determine disk usage of.*/, - 'warning shown when free disk space cannot be determined'; + like $cache_log, qr/.*Unable to determine disk usage of.*/, 'warning shown when free disk space cannot be determined'; $cache_log = ''; }; diff --git a/t/25-downloader.t b/t/25-downloader.t index bf4b7f9b2652..a2bd3c0d3ffe 100644 --- a/t/25-downloader.t +++ b/t/25-downloader.t @@ -193,8 +193,7 @@ subtest 'Error when decompressing archive' => sub { ok !-e $to, 'Target not created'; like $cache_log, qr/Downloading "fake-archive" from "$from"/, 'Download attempt'; like $cache_log, qr/Extracting ".*fake-archive\.tar\.xz" to ".*fake-archive"/, 'Extracting download'; - like $cache_log, qr/Extracting ".*fake-archive\.tar\.xz" failed:.*Unrecognized archive format.*/, - 'Extracting failed'; + like $cache_log, qr/Extracting ".*fake-archive\.tar\.xz" failed:.*Unrecognized archive format.*/, 'Extracting failed'; $cache_log = ''; }; diff --git a/t/25-serverstartup.t b/t/25-serverstartup.t index 2c36159bff9d..509db4df239d 100644 --- a/t/25-serverstartup.t +++ b/t/25-serverstartup.t @@ -129,18 +129,12 @@ subtest 'Update configuration from Plugin requirements' => sub { $config->{ini_config}->newval("foofoo", "is_there", "wohoo"); # Check if Config::IniFiles object returns the right values - is $config->{ini_config}->val("auth", "method"), "foobar", - "Ini parser contains the right data for OpenQA::FakePlugin::Foo"; - is $config->{ini_config}->val("bar", "foo"), "test", - "Ini parser contains the right data for OpenQA::FakePlugin::FooBar"; - is $config->{ini_config}->val("baz", "foo"), "test2", - "Ini parser contains the right data for OpenQA::FakePlugin::FooBaz"; - is $config->{ini_config}->val("baz", "test"), "bartest", - "Ini parser contains the right data for OpenQA::FakePlugin::Fuzz"; - is $config->{ini_config}->val("bazzer", "realfoo"), "win", - "Ini parser contains the right data for OpenQA::FakePlugin::Fuzzer"; - is $config->{ini_config}->val("foofoo", "is_there"), "wohoo", - "Ini parser contains the right data for OpenQA::FakePlugin::FooFoo"; + is $config->{ini_config}->val("auth", "method"), "foobar", "Ini parser contains the right data for OpenQA::FakePlugin::Foo"; + is $config->{ini_config}->val("bar", "foo"), "test", "Ini parser contains the right data for OpenQA::FakePlugin::FooBar"; + is $config->{ini_config}->val("baz", "foo"), "test2", "Ini parser contains the right data for OpenQA::FakePlugin::FooBaz"; + is $config->{ini_config}->val("baz", "test"), "bartest", "Ini parser contains the right data for OpenQA::FakePlugin::Fuzz"; + is $config->{ini_config}->val("bazzer", "realfoo"), "win", "Ini parser contains the right data for OpenQA::FakePlugin::Fuzzer"; + is $config->{ini_config}->val("foofoo", "is_there"), "wohoo", "Ini parser contains the right data for OpenQA::FakePlugin::FooFoo"; # inline packages declaration needs to appear as "loaded" $INC{"OpenQA/FakePlugin/Fuzz.pm"} = undef; diff --git a/t/26-controllerrunning.t b/t/26-controllerrunning.t index c177d75b9fb6..debe9ae97e00 100644 --- a/t/26-controllerrunning.t +++ b/t/26-controllerrunning.t @@ -93,8 +93,7 @@ subtest streaming => sub { $faketx = Mojo::Transaction::Fake->new(fakestream => $id); $controller->tx($faketx); monkey_patch 'FakeSchema::Find', find => sub { Job->new }; - combined_like { $controller->streaming } qr/Asking the worker 43 to start providing livestream for job 42/, - 'reached code for enabling livestream'; + combined_like { $controller->streaming } qr/Asking the worker 43 to start providing livestream for job 42/, 'reached code for enabling livestream'; is $controller->res->code, 200, 'tempdir not found'; is_deeply \@messages, [[43, 'livelog_start', 42]], 'livelog started' or diag explain \@messages; Mojo::IOLoop->one_tick; @@ -106,13 +105,11 @@ subtest streaming => sub { $fake_png->spew('not actually a PNG'); symlink $fake_png->basename, $last_png or die "Unable to symlink: $!"; combined_is { Mojo::IOLoop->one_tick } '', 'timer/callback does not clutter log (1)'; - is $controller->res->content->{body_buffer}, "data: data:image/png;base64,bm90IGFjdHVhbGx5IGEgUE5H\n\n", - 'base64-encoded fake PNG sent'; + is $controller->res->content->{body_buffer}, "data: data:image/png;base64,bm90IGFjdHVhbGx5IGEgUE5H\n\n", 'base64-encoded fake PNG sent'; $last_png->remove; symlink '02-fake.png', $last_png or die "Unable to symlink: $!"; combined_is { Mojo::IOLoop->one_tick } '', 'timer/callback does not clutter log (2)'; - like $controller->res->content->{body_buffer}, qr/data: Unable to read image: Can't open file.*\n\n/, - 'error sent if PNG does not exist'; + like $controller->res->content->{body_buffer}, qr/data: Unable to read image: Can't open file.*\n\n/, 'error sent if PNG does not exist'; } or diag explain $log_messages; @@ -123,8 +120,7 @@ subtest init => sub { my $render_specific_not_found; my $render; monkey_patch 'OpenQA::WebAPI::Controller::Running', not_found => sub { $not_found = 1 }; - monkey_patch 'OpenQA::WebAPI::Controller::Running', - render_specific_not_found => sub { $render_specific_not_found = 1 }; + monkey_patch 'OpenQA::WebAPI::Controller::Running', render_specific_not_found => sub { $render_specific_not_found = 1 }; monkey_patch 'OpenQA::WebAPI::Controller::Running', reply => sub { shift }; monkey_patch 'OpenQA::WebAPI::Controller::Running', render => sub { shift; $render = [@_] }; @@ -173,8 +169,7 @@ subtest edit => sub { monkey_patch 'OpenQA::WebAPI::Controller::Running', init => sub { 1 }; monkey_patch 'FakeSchema::Find', find => sub { undef }; monkey_patch 'OpenQA::WebAPI::Controller::Running', not_found => sub { $not_found = 1 }; - monkey_patch 'OpenQA::WebAPI::Controller::Running', - render_specific_not_found => sub { $render_specific_not_found = 1 }; + monkey_patch 'OpenQA::WebAPI::Controller::Running', render_specific_not_found => sub { $render_specific_not_found = 1 }; monkey_patch 'OpenQA::WebAPI::Controller::Running', reply => sub { shift }; # No results diff --git a/t/27-errorpages.t b/t/27-errorpages.t index 59538d63a687..6c45ea1674b7 100644 --- a/t/27-errorpages.t +++ b/t/27-errorpages.t @@ -26,19 +26,15 @@ subtest '404 error page' => sub { subtest 'error pages shown for OpenQA::WebAPI::Controller::Step' => sub { my $existing_job = 99946; $t->get_ok("/tests/$existing_job/modules/installer_timezone/steps/1")->status_is(302, 'redirection'); - $t->get_ok("/tests/$existing_job/modules/installer_timezone/steps/1", {'X-Requested-With' => 'XMLHttpRequest'}) - ->status_is(200); - $t->get_ok("/tests/$existing_job/modules/installer_timezone/steps/1/src")->status_is(200) - ->content_type_is('text/html;charset=UTF-8'); - $t->get_ok("/tests/$existing_job/modules/installer_timezone/steps/1/src.txt")->status_is(200) - ->content_type_is('text/plain;charset=UTF-8'); + $t->get_ok("/tests/$existing_job/modules/installer_timezone/steps/1", {'X-Requested-With' => 'XMLHttpRequest'})->status_is(200); + $t->get_ok("/tests/$existing_job/modules/installer_timezone/steps/1/src")->status_is(200)->content_type_is('text/html;charset=UTF-8'); + $t->get_ok("/tests/$existing_job/modules/installer_timezone/steps/1/src.txt")->status_is(200)->content_type_is('text/plain;charset=UTF-8'); $t->get_ok("/tests/$existing_job/modules/installer_timezone/steps/1/edit")->status_is(200); subtest 'get error 404 if job not found (instead of 500 and Perl warnings)' => sub { my $non_existing_job = 99999; $t->get_ok("/tests/$non_existing_job/modules/installer_timezone/steps/1")->status_is(302, 'redirection'); - $t->get_ok("/tests/$non_existing_job/modules/installer_timezone/steps/1", - {'X-Requested-With' => 'XMLHttpRequest'})->status_is(404); + $t->get_ok("/tests/$non_existing_job/modules/installer_timezone/steps/1", {'X-Requested-With' => 'XMLHttpRequest'})->status_is(404); $t->get_ok("/tests/$non_existing_job/modules/installer_timezone/steps/1/src")->status_is(404); $t->get_ok("/tests/$non_existing_job/modules/installer_timezone/steps/1/src.txt")->status_is(404); $t->get_ok("/tests/$non_existing_job/modules/installer_timezone/steps/1/edit")->status_is(404); diff --git a/t/27-websockets.t b/t/27-websockets.t index d77efdd0e814..72eae2ed57ae 100644 --- a/t/27-websockets.t +++ b/t/27-websockets.t @@ -146,8 +146,7 @@ subtest 'web socket message handling' => sub { $t->send_ok('{"type":"rejected","job_ids":[42,43],"reason":"foo"}'); $t->finish_ok(1000, 'finished ws connection'); } - qr/Worker 1 rejected job\(s\) 42, 43: foo.*Job 42 reset to state scheduled/s, - 'info logged when worker rejects job'; + qr/Worker 1 rejected job\(s\) 42, 43: foo.*Job 42 reset to state scheduled/s, 'info logged when worker rejects job'; is($jobs->find(42)->state, SCHEDULED, 'job is again in scheduled state'); is($jobs->find(43)->state, DONE, 'completed job not affected'); is($workers->find(1)->job_id, undef, 'job not considered the current job of the worker anymore'); @@ -166,9 +165,8 @@ subtest 'web socket message handling' => sub { $t->finish_ok(1000, 'finished ws connection'); } qr/Job 42 reset to state scheduled/s, 'info logged when worker rejects job'; - is($jobs->find(42)->state, SCHEDULED, - 'job is immediately set back to scheduled if assigned worker goes offline ' - . 'gracefully before starting to work on the job'); + is($jobs->find(42)->state, + SCHEDULED, 'job is immediately set back to scheduled if assigned worker goes offline ' . 'gracefully before starting to work on the job'); $worker->discard_changes; ok($worker->dead, 'worker considered immediately dead when it goes offline gracefully'); like($worker->error, qr/graceful disconnect at .*/, 'graceful disconnect logged'); @@ -186,8 +184,8 @@ subtest 'web socket message handling' => sub { $expected_message, 'status update not yet too frequent'; combined_unlike { - $t->finish_ok->websocket_ok('/ws/1', 're-establish ws connection') - ->send_ok({json => {type => 'worker_status', status => 'idle'}})->message_ok('message received'); + $t->finish_ok->websocket_ok('/ws/1', 're-establish ws connection')->send_ok({json => {type => 'worker_status', status => 'idle'}}) + ->message_ok('message received'); } $expected_message, 'status update not yet too frequent due to reconnect'; @@ -197,8 +195,8 @@ subtest 'web socket message handling' => sub { $expected_message, 'status update too frequent'; combined_unlike { - $t->finish_ok->websocket_ok('/ws/1', 're-establish ws connection') - ->send_ok({json => {type => 'worker_status', status => 'idle'}})->message_ok('message received'); + $t->finish_ok->websocket_ok('/ws/1', 're-establish ws connection')->send_ok({json => {type => 'worker_status', status => 'idle'}}) + ->message_ok('message received'); } $expected_message, 'status update not yet too frequent due to another reconnect'; @@ -226,8 +224,7 @@ subtest 'web socket message handling' => sub { $t->message_ok('message received'); } qr/Received.*worker_status message.*Updating seen of worker 1 from worker_status/s, 'update logged'; - ok(!$status->{$worker_id}->{idle_despite_job_assignment}, - 'the idle message has not been remarked because there is no job assignment'); + ok(!$status->{$worker_id}->{idle_despite_job_assignment}, 'the idle message has not been remarked because there is no job assignment'); # assign now a job to the worker my $assigned_job_id = 99963; diff --git a/t/28-logging.t b/t/28-logging.t index 696d9b8d9480..9f220665ae1e 100644 --- a/t/28-logging.t +++ b/t/28-logging.t @@ -248,10 +248,7 @@ subtest 'Logging to right place' => sub { log_debug('debug message'); log_error('error message'); log_info('info message'); - ok( - -f catfile($ENV{OPENQA_WORKER_LOGDIR}, $ENV{OPENQA_LOGFILE}), - 'Log file created defined in logdir and environment' - ); + ok(-f catfile($ENV{OPENQA_WORKER_LOGDIR}, $ENV{OPENQA_LOGFILE}), 'Log file created defined in logdir and environment'); local $ENV{OPENQA_LOGFILE} = catfile($ENV{OPENQA_WORKER_LOGDIR}, 'another_test_log_file.log'); @@ -568,8 +565,7 @@ subtest 'Formatting' => sub { $hires_mock->redefine(gettimeofday => sub() { $time }); my @loglevels = qw(debug info warn error fatal); for my $level (@loglevels) { - like log_format_callback(undef, $level, ("test $level")), qr/\[.+\] \[$level\] test $level\n$/, - "Formatting for $level works"; + like log_format_callback(undef, $level, ("test $level")), qr/\[.+\] \[$level\] test $level\n$/, "Formatting for $level works"; } }; diff --git a/t/30-test_parser.t b/t/30-test_parser.t index 3a1a34053599..ced5aff96f83 100644 --- a/t/30-test_parser.t +++ b/t/30-test_parser.t @@ -191,11 +191,8 @@ subtest 'Parser base class object' => sub { 'serialization support warns'; like warning { - is_deeply $good_parser->_build_tree->{generated_tests_results}->[0]->{OpenQA::Parser::DATA_FIELD()}, - [qw(1 2 3)]; - }, - qr/Serialization is officially supported only if object can be turned into an array with \-\>to_array\(\)/, - 'serialization support warns'; + is_deeply $good_parser->_build_tree->{generated_tests_results}->[0]->{OpenQA::Parser::DATA_FIELD()}, [qw(1 2 3)]; + }, qr/Serialization is officially supported only if object can be turned into an array with \-\>to_array\(\)/, 'serialization support warns'; $good_parser->results->add({test => 'bar'}); @@ -207,11 +204,8 @@ subtest 'Parser base class object' => sub { is $good_parser->results->size, 2, '2 results'; like warning { - is_deeply $good_parser->_build_tree->{generated_tests_results}->[1]->{OpenQA::Parser::DATA_FIELD()}, - {test => 'bar'} - }, - qr/Serialization is officially supported only if object can be turned into an array with \-\>to_array\(\)/, - 'serialization support warns'; + is_deeply $good_parser->_build_tree->{generated_tests_results}->[1]->{OpenQA::Parser::DATA_FIELD()}, {test => 'bar'} + }, qr/Serialization is officially supported only if object can be turned into an array with \-\>to_array\(\)/, 'serialization support warns'; my $copy; like warning { $copy = parser("Base")->_load_tree($good_parser->_build_tree) }, @@ -220,15 +214,11 @@ subtest 'Parser base class object' => sub { like warning { is_deeply $copy->_build_tree->{generated_tests_results}->[0]->{OpenQA::Parser::DATA_FIELD()}, [qw(1 2 3)] or diag explain $copy->_build_tree->{generated_tests_results} - }, - qr/Serialization is officially supported only if object can be turned into an array with \-\>to_array\(\)/, - 'serialization support warns'; + }, qr/Serialization is officially supported only if object can be turned into an array with \-\>to_array\(\)/, 'serialization support warns'; like warning { is_deeply $copy->_build_tree->{generated_tests_results}->[1]->{OpenQA::Parser::DATA_FIELD()}, {test => 'bar'} or die diag explain $good_parser->_build_tree - }, - qr/Serialization is officially supported only if object can be turned into an array with \-\>to_array\(\)/, - 'serialization support warns'; + }, qr/Serialization is officially supported only if object can be turned into an array with \-\>to_array\(\)/, 'serialization support warns'; $good_parser->results->remove(1); $good_parser->results->remove(0); @@ -297,10 +287,9 @@ subtest 'Nested results' => sub { result1 => NestedResult->new(val => 'result_2_result_1'), result2 => NestedResult->new(val => 'result_2_result_2')))); is $deep_p->_build_tree->{generated_tests_results}->[0]->{OpenQA::Parser::TYPE_FIELD()}, 'NestedResult'; - is $deep_p->_build_tree->{generated_tests_results}->[0]->{OpenQA::Parser::DATA_FIELD()}->{result1} - ->{OpenQA::Parser::TYPE_FIELD()}, 'NestedResult'; - is $deep_p->_build_tree->{generated_tests_results}->[0]->{OpenQA::Parser::DATA_FIELD()}->{result1} - ->{OpenQA::Parser::DATA_FIELD()}->{result1}->{OpenQA::Parser::TYPE_FIELD()}, 'NestedResult' + is $deep_p->_build_tree->{generated_tests_results}->[0]->{OpenQA::Parser::DATA_FIELD()}->{result1}->{OpenQA::Parser::TYPE_FIELD()}, 'NestedResult'; + is $deep_p->_build_tree->{generated_tests_results}->[0]->{OpenQA::Parser::DATA_FIELD()}->{result1}->{OpenQA::Parser::DATA_FIELD()}->{result1} + ->{OpenQA::Parser::TYPE_FIELD()}, 'NestedResult' or diag explain $deep_p->_build_tree->{generated_tests_results}->[0]; my $parser_nested = parser('Base'); @@ -329,9 +318,7 @@ subtest 'Nested results' => sub { NestedResult->new(val => '2_0_1_val')) ), NestedResult->new( - result1 => NestedResults->new( - NestedResult->new(val => 'result_1_result_1'), - NestedResult->new(val => 'result_1_result_2')) + result1 => NestedResults->new(NestedResult->new(val => 'result_1_result_1'), NestedResult->new(val => 'result_1_result_2')) ), )); @@ -367,12 +354,10 @@ sub test_junit_file { is $parser->tests->search("name", qr/1_running_upstream_tests/)->first()->name, '1_running_upstream_tests'; is $parser->tests->search("name", qr/1_running_upstream_tests/)->size, 1; - is $parser->tests->size, 9, - 'Generated 9 openQA tests results'; # 9 testsuites with all cumulative results for openQA + is $parser->tests->size, 9, 'Generated 9 openQA tests results'; # 9 testsuites with all cumulative results for openQA is $parser->generated_tests_results->size, 9, 'Object contains 9 testsuites'; - is $parser->results->search_in_details("text", qr/tests-systemd/)->size, 166, - 'Overall 9 testsuites, 166 tests are for systemd'; + is $parser->results->search_in_details("text", qr/tests-systemd/)->size, 166, 'Overall 9 testsuites, 166 tests are for systemd'; is $parser->generated_tests_output->size, 166, "Outputs of systemd tests details matches"; my $resultsdir = tempdir; @@ -430,8 +415,7 @@ sub test_junit_file { $testdir->remove_tree; - is_deeply $parser->results->last->TO_JSON(), $expected_test_result, - 'Expected test result match - with no include_results' + is_deeply $parser->results->last->TO_JSON(), $expected_test_result, 'Expected test result match - with no include_results' or diag explain $parser->results->last->TO_JSON(); return $expected_test_result; } @@ -459,14 +443,11 @@ sub test_xunit_file { ok $parser->generated_tests_results->first()->failures; ok $parser->generated_tests_results->first()->tests; - is $parser->tests->size, 11, - 'Generated 11 openQA tests results'; # 9 testsuites with all cumulative results for openQA + is $parser->tests->size, 11, 'Generated 11 openQA tests results'; # 9 testsuites with all cumulative results for openQA is $parser->generated_tests_results->size, 11, 'Object contains 11 testsuites'; - is $parser->results->search_in_details("title", qr/bacon/)->size, 13, - 'Overall 11 testsuites, 2 tests does not have title containing bacon'; - is $parser->results->search_in_details("text", qr/bacon/)->size, 15, - 'Overall 11 testsuites, 15 tests are for bacon'; + is $parser->results->search_in_details("title", qr/bacon/)->size, 13, 'Overall 11 testsuites, 2 tests does not have title containing bacon'; + is $parser->results->search_in_details("text", qr/bacon/)->size, 15, 'Overall 11 testsuites, 15 tests are for bacon'; is $parser->generated_tests_output->size, 23, "23 Outputs"; my $resultsdir = tempdir; @@ -512,8 +493,7 @@ sub test_xunit_file { $testdir->remove_tree; - is_deeply $parser->results->last->TO_JSON(), $expected_test_result, - 'Expected test result match - with no include_results' + is_deeply $parser->results->last->TO_JSON(), $expected_test_result, 'Expected test result match - with no include_results' or diag explain $parser->results->last->TO_JSON(); return $expected_test_result; } @@ -526,13 +506,11 @@ subtest junit_parse => sub { $parser->load($junit_test_file); my $expected_test_result = test_junit_file($parser); $expected_test_result->{test} = undef; - is_deeply $parser->results->last->TO_JSON(1), $expected_test_result, - 'Expected test result match - with no include_results - forcing to output the test'; + is_deeply $parser->results->last->TO_JSON(1), $expected_test_result, 'Expected test result match - with no include_results - forcing to output the test'; $expected_test_result->{name} = '9_post-tests_audits'; delete $expected_test_result->{test}; - is_deeply $parser->results->last->to_hash(), $expected_test_result, - 'Expected test result match - with no include_results - forcing to output the test'; + is_deeply $parser->results->last->to_hash(), $expected_test_result, 'Expected test result match - with no include_results - forcing to output the test'; delete $expected_test_result->{name}; $parser = OpenQA::Parser::Format::JUnit->new; @@ -540,8 +518,7 @@ subtest junit_parse => sub { $parser->include_results(1); $parser->load($junit_test_file); - is $parser->results->size, 9, - 'Generated 9 openQA tests results'; # 9 testsuites with all cumulative results for openQA + is $parser->results->size, 9, 'Generated 9 openQA tests results'; # 9 testsuites with all cumulative results for openQA is_deeply $parser->results->last->TO_JSON(0), $expected_test_result, 'Test is hidden'; @@ -641,14 +618,12 @@ sub test_ltp_file { is $_->result, 'ok', 'Tests passed' or diag explain $_; ok !!$_->environment, 'Environment is present'; ok !!$_->test, 'Test information is present'; - is $_->environment->gcc, 'gcc (SUSE Linux) 7.2.1 20170927 [gcc-7-branch revision 253227]', - 'Environment information matches'; + is $_->environment->gcc, 'gcc (SUSE Linux) 7.2.1 20170927 [gcc-7-branch revision 253227]', 'Environment information matches'; is $_->test->result, 'TPASS', 'subtest result is TPASS' or diag explain $_; is $_->test_fqn, "LTP:cpuhotplug:cpuhotplug0$i", "test_fqn matches and are different"; $i++; }); - is $p->results->get(0)->environment->gcc, 'gcc (SUSE Linux) 7.2.1 20170927 [gcc-7-branch revision 253227]', - 'Environment information matches'; + is $p->results->get(0)->environment->gcc, 'gcc (SUSE Linux) 7.2.1 20170927 [gcc-7-branch revision 253227]', 'Environment information matches'; } sub test_ipa_file { @@ -662,8 +637,7 @@ sub test_ipa_file { ok !exists($names{$_->name}), 'Test name ' . $_->name; $names{$_->name} = 1; is $_->details->[0]->{_source}, 'parser'; - if ($_->name =~ /^test_sles_repos|test_sles_guestregister|test_sles_smt_reg|EC2_test_sles_ec2_network_01$/) - { + if ($_->name =~ /^test_sles_repos|test_sles_guestregister|test_sles_smt_reg|EC2_test_sles_ec2_network_01$/) { is $_->result, 'fail' or die; } elsif ($_->name =~ /^EC2_test_sles_ec2_network$/) { @@ -867,8 +841,7 @@ subtest 'Unstructured data' => sub { }); ok $deserialized->results->size == 5, 'There are some results'; - is $deserialized->results->first->get('init-param')->val->{'configGlossary:installationAt'}, 'Philadelphia, PA', - 'Nested serialization works!'; + is $deserialized->results->first->get('init-param')->val->{'configGlossary:installationAt'}, 'Philadelphia, PA', 'Nested serialization works!'; my $init_params = $deserialized->results->get(1)->get('init-param'); diff --git a/t/31-client.t b/t/31-client.t index 7656979516ff..ed51c1f3c4ff 100644 --- a/t/31-client.t +++ b/t/31-client.t @@ -60,8 +60,8 @@ my $code = 200; my $content_type = 'application/json'; my $headers_mock = Test::MockObject->new()->set_bound(content_type => \$content_type); my $json = {my => 'json'}; -my $code_mock = Test::MockObject->new()->set_bound(code => \$code)->mock(headers => sub { $headers_mock }) - ->set_always(json => $json)->set_always(body => 'my: yaml'); +my $code_mock + = Test::MockObject->new()->set_bound(code => \$code)->mock(headers => sub { $headers_mock })->set_always(json => $json)->set_always(body => 'my: yaml'); my $res = Test::MockObject->new()->mock(res => sub { $code_mock }); $client_mock->redefine( new => sub { diff --git a/t/31-client_archive.t b/t/31-client_archive.t index 494606fbf22a..6b6096100898 100644 --- a/t/31-client_archive.t +++ b/t/31-client_archive.t @@ -19,8 +19,7 @@ my $destination = tempdir; subtest 'OpenQA::Client:Archive tests' => sub { my $jobid = 99938; my $limit = 1024 * 1024; - my $limittest_path = path($ENV{OPENQA_BASEDIR}, 'openqa', 'testresults', '00099', - '00099938-opensuse-Factory-DVD-x86_64-Build0048-doc', 'ulogs'); + my $limittest_path = path($ENV{OPENQA_BASEDIR}, 'openqa', 'testresults', '00099', '00099938-opensuse-Factory-DVD-x86_64-Build0048-doc', 'ulogs'); my $dd_output = `dd if=/dev/zero of=$limittest_path/limittest.tar.bz2 bs=1M count=2 2>&1`; diff --git a/t/31-client_file.t b/t/31-client_file.t index 7589574f876a..03b7b6b3fcb1 100644 --- a/t/31-client_file.t +++ b/t/31-client_file.t @@ -44,15 +44,13 @@ subtest 'split/join' => sub { is $pieces->join(), path($FindBin::Bin, "data", "ltp_test_result_format.json")->slurp, 'Content match' or die diag explain $pieces; - is $pieces->generate_sum(), sha1_base64(path($FindBin::Bin, "data", "ltp_test_result_format.json")->slurp), - 'SHA-1 match' + is $pieces->generate_sum(), sha1_base64(path($FindBin::Bin, "data", "ltp_test_result_format.json")->slurp), 'SHA-1 match' or die diag explain $pieces; my $t_file = tempfile(); $pieces->write($t_file); - is $t_file->slurp, path($FindBin::Bin, "data", "ltp_test_result_format.json")->slurp, - 'Composed content is same as original' + is $t_file->slurp, path($FindBin::Bin, "data", "ltp_test_result_format.json")->slurp, 'Composed content is same as original' or die diag explain $pieces; my @serialized = $pieces->serialize(); @@ -66,8 +64,7 @@ subtest 'split/join' => sub { is $des_pieces->join(), path($FindBin::Bin, "data", "ltp_test_result_format.json")->slurp, 'Content match' or die diag explain $des_pieces; - is $des_pieces->generate_sum(), - sha1_base64(path($FindBin::Bin, "data", "ltp_test_result_format.json")->slurp), 'SHA-1 match' + is $des_pieces->generate_sum(), sha1_base64(path($FindBin::Bin, "data", "ltp_test_result_format.json")->slurp), 'SHA-1 match' or die diag explain $des_pieces; ok $des_pieces->is_sum(sha1_base64(path($FindBin::Bin, "data", "ltp_test_result_format.json")->slurp)); @@ -146,11 +143,7 @@ subtest 'verify_chunks' => sub { is(OpenQA::Files->verify_chunks($t_dir => $copied_file), undef, 'Verify chunks passes'); $copied_file->spew(''); - is( - OpenQA::Files->verify_chunks($t_dir => $copied_file)->message(), - 'Can\'t verify written data from chunk', - 'Cannot verify chunks passes' - ); + is(OpenQA::Files->verify_chunks($t_dir => $copied_file)->message(), 'Can\'t verify written data from chunk', 'Cannot verify chunks passes'); is $copied_file->slurp, '', 'File is empty now'; is(OpenQA::Files->write_verify_chunks($t_dir => $copied_file), undef, 'Write and verify passes'); @@ -158,11 +151,7 @@ subtest 'verify_chunks' => sub { is $original->file->slurp, path($copied_file)->slurp, 'Same content'; $pieces->first->content('42')->write_content($copied_file); #Let's simulate a writing error - like( - OpenQA::Files->verify_chunks($t_dir => $copied_file), - qr/^Can't verify written data from chunk/, - 'Verify chunks fail' - ); + like(OpenQA::Files->verify_chunks($t_dir => $copied_file), qr/^Can't verify written data from chunk/, 'Verify chunks fail'); isnt $original->file->slurp, path($copied_file)->slurp, 'Not same content'; }; diff --git a/t/32-openqa_client.t b/t/32-openqa_client.t index d4c5ce86b1d2..dd9853f39ebe 100644 --- a/t/32-openqa_client.t +++ b/t/32-openqa_client.t @@ -57,10 +57,7 @@ subtest 'upload public assets (local)' => sub { my $chunkdir = 't/data/openqa/share/factory/tmp/public/hdd_image5.qcow2.CHUNKS/'; my $rp = "t/data/openqa/share/factory/hdd/hdd_image5.qcow2"; - eval { - $t->ua->upload->asset( - 99963 => {chunk_size => $chunk_size, file => $filename, name => 'hdd_image5.qcow2', local => 1}); - }; + eval { $t->ua->upload->asset(99963 => {chunk_size => $chunk_size, file => $filename, name => 'hdd_image5.qcow2', local => 1}); }; ok !$@, 'No upload errors' or die explain $@; path($chunkdir)->remove_tree; ok !-d $chunkdir, 'Chunk directory should not exist anymore'; @@ -77,10 +74,7 @@ subtest 'upload private assets' => sub { my ($local_prepare, $chunk_prepare); my $local_prepare_cb = $t->ua->upload->on('upload_local.prepare' => sub { $local_prepare++ }); my $chunk_prepare_cb = $t->ua->upload->on('upload_chunk.prepare' => sub { $chunk_prepare++ }); - eval { - $t->ua->upload->asset( - 99963 => {chunk_size => $chunk_size, file => $filename, name => 'hdd_image3.qcow2', asset => 'private'}); - }; + eval { $t->ua->upload->asset(99963 => {chunk_size => $chunk_size, file => $filename, name => 'hdd_image3.qcow2', asset => 'private'}); }; ok !$@, 'No upload errors' or die explain $@; $t->ua->upload->unsubscribe('upload_local.prepare' => $local_prepare_cb); $t->ua->upload->unsubscribe('upload_chunl.prepare' => $chunk_prepare_cb); @@ -101,16 +95,7 @@ subtest 'upload private assets (local)' => sub { my ($local_prepare, $chunk_prepare); my $local_prepare_cb = $t->ua->upload->on('upload_local.prepare' => sub { $local_prepare++ }); my $chunk_prepare_cb = $t->ua->upload->on('upload_chunk.prepare' => sub { $chunk_prepare++ }); - eval { - $t->ua->upload->asset( - 99963 => { - chunk_size => $chunk_size, - file => $filename, - name => 'hdd_image7.qcow2', - asset => 'private', - local => 1 - }); - }; + eval { $t->ua->upload->asset(99963 => {chunk_size => $chunk_size, file => $filename, name => 'hdd_image7.qcow2', asset => 'private', local => 1}); }; ok !$@, 'No upload errors' or die explain $@; $t->ua->upload->unsubscribe('upload_local.prepare' => $local_prepare_cb); $t->ua->upload->unsubscribe('upload_chunl.prepare' => $chunk_prepare_cb); @@ -133,10 +118,7 @@ subtest 'upload other assets' => sub { ok(-d $chunkdir, 'Chunk directory exists'); }); - eval { - $t->ua->upload->asset( - 99963 => {chunk_size => $chunk_size, file => $filename, name => 'hdd_image3.xml', asset => 'other'}); - }; + eval { $t->ua->upload->asset(99963 => {chunk_size => $chunk_size, file => $filename, name => 'hdd_image3.xml', asset => 'other'}); }; ok !$@, 'No upload errors' or die explain $@; ok !-d $chunkdir, 'Chunk directory should not exist anymore'; ok -e $rp, 'Asset exists after upload'; @@ -153,17 +135,12 @@ subtest 'upload retries' => sub { my $fired; my $fail_chunk; my $responses; - $t->ua->upload->once( - 'upload_chunk.response' => sub { my ($self, $response) = @_; delete $response->res->json->{status}; $fired++; } - ); + $t->ua->upload->once('upload_chunk.response' => sub { my ($self, $response) = @_; delete $response->res->json->{status}; $fired++; }); $t->ua->upload->on('upload_chunk.fail' => sub { $fail_chunk++ }); $t->ua->upload->on('upload_chunk.response' => sub { $responses++; }); $t->ua->upload->on('upload_chunk.request_fail' => sub { use Data::Dump 'pp'; diag pp(@_) }); - eval { - $t->ua->upload->asset( - 99963 => {chunk_size => $chunk_size, file => $filename, name => 'hdd_image4.xml', asset => 'other'}); - }; + eval { $t->ua->upload->asset(99963 => {chunk_size => $chunk_size, file => $filename, name => 'hdd_image4.xml', asset => 'other'}); }; ok !$@, 'No upload errors'; is $fail_chunk, 1, 'One chunk failed uploading, but we recovered' or diag explain "\$fail_chunk: $fail_chunk"; is $responses, OpenQA::File::_chunk_size(-s $filename, $chunk_size) + 1, 'responses as expected'; @@ -182,8 +159,7 @@ subtest 'upload failures' => sub { my $fired; my $fail_chunk; my $errored; - $t->ua->upload->on('upload_chunk.response' => - sub { my ($self, $response) = @_; $response->res->json->{status} = 'foobar'; $fired++; }); + $t->ua->upload->on('upload_chunk.response' => sub { my ($self, $response) = @_; $response->res->json->{status} = 'foobar'; $fired++; }); $t->ua->upload->on('upload_chunk.fail' => sub { $fail_chunk++ }); $t->ua->upload->on( 'upload_chunk.error' => sub { @@ -191,10 +167,7 @@ subtest 'upload failures' => sub { is(pop()->res->json->{status}, 'foobar', 'Error message status is correct'); }); - eval { - $t->ua->upload->asset(99963 => - {chunk_size => $chunk_size, file => $filename, name => 'hdd_image5.xml', asset => 'other', retries => 7}); - }; + eval { $t->ua->upload->asset(99963 => {chunk_size => $chunk_size, file => $filename, name => 'hdd_image5.xml', asset => 'other', retries => 7}); }; ok !$@, 'No function errors on upload failures' or die diag $@; is $fail_chunk, 7, 'All attempts failed, no recovery on upload failures'; is $errored, 1, 'Upload errors'; @@ -216,10 +189,7 @@ subtest 'upload internal errors' => sub { $t->ua->upload->on('upload_chunk.response' => sub { die("Subdly") }); $t->ua->upload->on('upload_chunk.request_err' => sub { $fail_chunk++; $e = pop(); }); - eval { - $t->ua->upload->asset( - 99963 => {chunk_size => $chunk_size, file => $filename, name => 'hdd_image6.xml', asset => 'other'}); - }; + eval { $t->ua->upload->asset(99963 => {chunk_size => $chunk_size, file => $filename, name => 'hdd_image6.xml', asset => 'other'}); }; ok !$@, 'No function errors on internal errors' or die diag $@; is $fail_chunk, 10, 'All chunks failed, no recovery on internal errors'; like $e, qr/Subdly/, 'Internal error seen'; diff --git a/t/33-developer_mode.t b/t/33-developer_mode.t index 374cfe754f45..8c7e71e035ed 100644 --- a/t/33-developer_mode.t +++ b/t/33-developer_mode.t @@ -104,8 +104,7 @@ $driver->click_element_ok('Login', 'link_text'); $driver->title_is('openQA', 'back on main page'); # setting TESTING_ASSERT_SCREEN_TIMEOUT is important here (see os-autoinst/t/data/tests/tests/boot.pm) -schedule_one_job_over_api_and_verify($driver, - OpenQA::Test::FullstackUtils::job_setup(TESTING_ASSERT_SCREEN_TIMEOUT => '1')); +schedule_one_job_over_api_and_verify($driver, OpenQA::Test::FullstackUtils::job_setup(TESTING_ASSERT_SCREEN_TIMEOUT => '1')); my $job_name = 'tinycore-1-flavor-i386-Build1-core@coolone'; $driver->find_element_by_link_text('core@coolone')->click(); $driver->title_is("openQA: $job_name test results", 'scheduled test page'); @@ -163,34 +162,18 @@ my $second_tab; subtest 'pause at assert_screen timeout' => sub { # wait until asserting 'on_prompt' - wait_for_developer_console_like( - $driver, - qr/(\"tags\":\[\"on_prompt\"\]|\"mustmatch\":\"on_prompt\")/, - 'asserting on_prompt' - ); + wait_for_developer_console_like($driver, qr/(\"tags\":\[\"on_prompt\"\]|\"mustmatch\":\"on_prompt\")/, 'asserting on_prompt'); # send command to pause on assert_screen timeout enter_developer_console_cmd $driver, '{"cmd":"set_pause_on_screen_mismatch","pause_on":"assert_screen"}'; - wait_for_developer_console_like( - $driver, - qr/\"set_pause_on_screen_mismatch\":\"assert_screen\"/, - 'response to set_pause_on_screen_mismatch' - ); + wait_for_developer_console_like($driver, qr/\"set_pause_on_screen_mismatch\":\"assert_screen\"/, 'response to set_pause_on_screen_mismatch'); # skip timeout enter_developer_console_cmd $driver, '{"cmd":"set_assert_screen_timeout","timeout":0}'; - wait_for_developer_console_like( - $driver, - qr/\"set_assert_screen_timeout\":0/, - 'response to set_assert_screen_timeout' - ); + wait_for_developer_console_like($driver, qr/\"set_assert_screen_timeout\":0/, 'response to set_assert_screen_timeout'); # wait until test paused - wait_for_developer_console_like( - $driver, - qr/\"(reason|test_execution_paused)\":\"match=on_prompt timed out/, - 'paused after assert_screen timeout' - ); + wait_for_developer_console_like($driver, qr/\"(reason|test_execution_paused)\":\"match=on_prompt timed out/, 'paused after assert_screen timeout'); # try to resume enter_developer_console_cmd $driver, '{"cmd":"resume_test_execution"}'; @@ -198,11 +181,7 @@ subtest 'pause at assert_screen timeout' => sub { # skip timeout (again) enter_developer_console_cmd $driver, '{"cmd":"set_assert_screen_timeout","timeout":0}'; - wait_for_developer_console_like( - $driver, - qr/\"set_assert_screen_timeout\":0/, - 'response to set_assert_screen_timeout' - ); + wait_for_developer_console_like($driver, qr/\"set_assert_screen_timeout\":0/, 'response to set_assert_screen_timeout'); wait_for_developer_console_like($driver, qr/match=on_prompt timed out/, 'paused on assert_screen timeout (again)'); wait_for_developer_console_like($driver, qr/\"(outstanding_images)\":[1-9]*/, 'progress of image upload received'); @@ -244,8 +223,7 @@ subtest 'pause at certain test' => sub { wait_for_developer_console_like($driver, qr/\"resume_test_execution\":/, 'resume'); # wait until the shutdown test is started and hence the test execution paused - wait_for_developer_console_like($driver, - qr/\"(reason|test_execution_paused)\":\"reached module shutdown\"/, 'paused'); + wait_for_developer_console_like($driver, qr/\"(reason|test_execution_paused)\":\"reached module shutdown\"/, 'paused'); }; sub assert_initial_ui_state { @@ -324,8 +302,7 @@ subtest 'resume test execution and 2nd tab' => sub { # go back to the live view $driver->get($job_page_url); $driver->find_element_by_link_text('Live View')->click(); - wait_for_session_info(qr/owned by Demo.*2 tabs open/, - '2 browser tabs open (live view and tab from previous subtest)'); + wait_for_session_info(qr/owned by Demo.*2 tabs open/, '2 browser tabs open (live view and tab from previous subtest)'); # open developer console $driver->get($developer_console_url); diff --git a/t/34-developer_mode-unit.t b/t/34-developer_mode-unit.t index a97722b0b377..032e703a4563 100644 --- a/t/34-developer_mode-unit.t +++ b/t/34-developer_mode-unit.t @@ -128,25 +128,18 @@ subtest 'version check' => sub { is($live_view_handler->check_os_autoinst_devel_mode_version(\%status_info), 0, 'no version at all not accepted'); - $status_info{devel_mode_major_version} - = OpenQA::LiveHandler::Controller::LiveViewHandler::OS_AUTOINST_DEVEL_MODE_MAJOR_VERSION + 1; - $status_info{devel_mode_minor_version} - = OpenQA::LiveHandler::Controller::LiveViewHandler::OS_AUTOINST_DEVEL_MODE_MINOR_VERSION; - is($live_view_handler->check_os_autoinst_devel_mode_version(\%status_info), - 0, 'different major version not accepted'); - - $status_info{devel_mode_major_version} - = OpenQA::LiveHandler::Controller::LiveViewHandler::OS_AUTOINST_DEVEL_MODE_MAJOR_VERSION; - $status_info{devel_mode_minor_version} - = OpenQA::LiveHandler::Controller::LiveViewHandler::OS_AUTOINST_DEVEL_MODE_MINOR_VERSION - 1; + $status_info{devel_mode_major_version} = OpenQA::LiveHandler::Controller::LiveViewHandler::OS_AUTOINST_DEVEL_MODE_MAJOR_VERSION + 1; + $status_info{devel_mode_minor_version} = OpenQA::LiveHandler::Controller::LiveViewHandler::OS_AUTOINST_DEVEL_MODE_MINOR_VERSION; + is($live_view_handler->check_os_autoinst_devel_mode_version(\%status_info), 0, 'different major version not accepted'); + + $status_info{devel_mode_major_version} = OpenQA::LiveHandler::Controller::LiveViewHandler::OS_AUTOINST_DEVEL_MODE_MAJOR_VERSION; + $status_info{devel_mode_minor_version} = OpenQA::LiveHandler::Controller::LiveViewHandler::OS_AUTOINST_DEVEL_MODE_MINOR_VERSION - 1; is($live_view_handler->check_os_autoinst_devel_mode_version(\%status_info), 0, 'lower minor version not accepted'); - $status_info{devel_mode_minor_version} - = OpenQA::LiveHandler::Controller::LiveViewHandler::OS_AUTOINST_DEVEL_MODE_MINOR_VERSION; + $status_info{devel_mode_minor_version} = OpenQA::LiveHandler::Controller::LiveViewHandler::OS_AUTOINST_DEVEL_MODE_MINOR_VERSION; is($live_view_handler->check_os_autoinst_devel_mode_version(\%status_info), 1, 'exact version match accepted'); - $status_info{devel_mode_minor_version} - = OpenQA::LiveHandler::Controller::LiveViewHandler::OS_AUTOINST_DEVEL_MODE_MINOR_VERSION + 1; + $status_info{devel_mode_minor_version} = OpenQA::LiveHandler::Controller::LiveViewHandler::OS_AUTOINST_DEVEL_MODE_MINOR_VERSION + 1; is($live_view_handler->check_os_autoinst_devel_mode_version(\%status_info), 1, 'higher minor version accepted'); }; @@ -260,12 +253,10 @@ subtest 'send message to JavaScript clients' => sub { $session->delete(); # finish all clients - is($_->finish_called, 0, 'no transactions finished so far') - for (@fake_java_script_transactions, @fake_java_script_transactions2); + is($_->finish_called, 0, 'no transactions finished so far') for (@fake_java_script_transactions, @fake_java_script_transactions2); $live_view_handler->send_message_to_java_script_clients_and_finish(99961, error => 'test', {some => 'error'}); Mojo::IOLoop->one_tick; - is($_->finish_called, 1, 'all transactions finished') - for (@fake_java_script_transactions, @fake_java_script_transactions2); + is($_->finish_called, 1, 'all transactions finished') for (@fake_java_script_transactions, @fake_java_script_transactions2); # assert the messages we've got is_deeply( @@ -446,8 +437,7 @@ subtest 'handle messages from JavaScript clients' => sub { # send command which is expected to be passed to os-autoinst command server is_deeply($fake_cmd_srv_tx->sent_messages, [], 'nothing passed to os-autoinst so far'); - $live_view_handler->handle_message_from_java_script(99961, - '{"cmd":"set_pause_at_test","name":"installation-welcome"}'); + $live_view_handler->handle_message_from_java_script(99961, '{"cmd":"set_pause_at_test","name":"installation-welcome"}'); is_deeply( $fake_cmd_srv_tx->sent_messages, [ @@ -481,8 +471,7 @@ subtest 'handle messages from JavaScript clients' => sub { ); ok($fake_java_script_tx->finish_called, 'connection to JavaScript client closed'); ok(!$fake_status_only_java_script_tx->finish_called, 'connection to status-only JavaScript client still open'); - ok(!$fake_cmd_srv_tx->finish_called, - 'connection to os-autoinst not closed because status-only client still connected'); + ok(!$fake_cmd_srv_tx->finish_called, 'connection to os-autoinst not closed because status-only client still connected'); # send command to quit the session when status-only connections present set_fake_devel_java_script_transactions(99961, [$fake_java_script_tx]); @@ -518,11 +507,8 @@ subtest 'register developer session' => sub { ok($session2, 'session created'); is($developer_sessions->count, 1, 'existing session returned, no new row'); - is_deeply( - \@ipc_messages_for_websocket_server, - [[1, WORKER_COMMAND_DEVELOPER_SESSION_START, 99963]], - 'worker notified exactly once about developer session' - ) or diag explain \@ipc_messages_for_websocket_server; + is_deeply(\@ipc_messages_for_websocket_server, [[1, WORKER_COMMAND_DEVELOPER_SESSION_START, 99963]], 'worker notified exactly once about developer session') + or diag explain \@ipc_messages_for_websocket_server; @ipc_messages_for_websocket_server = (); ok $client_called, 'mocked send_msg method has been called'; @@ -562,15 +548,10 @@ subtest 'URLs for command server and livehandler' => sub { is($app->determine_os_autoinst_web_socket_url($job), undef, 'no URL for job without JOBTOKEN'); $worker->set_property(JOBTOKEN => 'token99961'); - is($app->determine_os_autoinst_web_socket_url($job), - undef, 'no URL for job when worker has not propagated the URL yet'); + is($app->determine_os_autoinst_web_socket_url($job), undef, 'no URL for job when worker has not propagated the URL yet'); $worker->set_property(CMD_SRV_URL => 'http://remotehost:20013/token99964'); - is( - $app->determine_os_autoinst_web_socket_url($job), - 'ws://remotehost:20013/token99961/ws', - 'URL for job with assigned worker' - ); + is($app->determine_os_autoinst_web_socket_url($job), 'ws://remotehost:20013/token99961/ws', 'URL for job with assigned worker'); $worker->set_property(WORKER_HOSTNAME => 'remotehost.qa'); is( @@ -581,11 +562,7 @@ subtest 'URLs for command server and livehandler' => sub { is(determine_web_ui_web_socket_url(99961), 'liveviewhandler/tests/99961/developer/ws-proxy', 'URL for livehandler'); - is( - get_ws_status_only_url(99961), - 'liveviewhandler/tests/99961/developer/ws-proxy/status', - 'URL for livehandler status route' - ); + is(get_ws_status_only_url(99961), 'liveviewhandler/tests/99961/developer/ws-proxy/status', 'URL for livehandler status route'); }; # save app and user agent to be able to restore @@ -596,13 +573,11 @@ subtest 'post upload progress' => sub { $t_livehandler->post_ok($path)->status_is(403, 'upload_progress route requires API authentification'); # use OpenQA::Client for authentication - $t_livehandler->ua( - OpenQA::Client->new(apikey => 'ARTHURKEY01', apisecret => 'EXCALIBUR')->ioloop(Mojo::IOLoop->singleton)); + $t_livehandler->ua(OpenQA::Client->new(apikey => 'ARTHURKEY01', apisecret => 'EXCALIBUR')->ioloop(Mojo::IOLoop->singleton)); $t_livehandler->app($app); # test error handling - $t_livehandler->post_ok('/liveviewhandler/api/v1/jobs/42/upload_progress', json => {}) - ->status_is(400, 'job does not exist'); + $t_livehandler->post_ok('/liveviewhandler/api/v1/jobs/42/upload_progress', json => {})->status_is(400, 'job does not exist'); # test successful post my %upload_progress = ( @@ -641,10 +616,7 @@ $t_livehandler->app($app); subtest 'websocket proxy (connection from client to live view handler not mocked)' => sub { subtest 'job does not exist' => sub { - $t_livehandler->websocket_ok( - '/liveviewhandler/tests/54754/developer/ws-proxy', - 'establish ws connection from JavaScript to livehandler' - ); + $t_livehandler->websocket_ok('/liveviewhandler/tests/54754/developer/ws-proxy', 'establish ws connection from JavaScript to livehandler'); $t_livehandler->message_ok('message received'); $t_livehandler->json_message_is( { @@ -658,10 +630,7 @@ subtest 'websocket proxy (connection from client to live view handler not mocked }; subtest 'job without assigned worker' => sub { - $t_livehandler->websocket_ok( - '/liveviewhandler/tests/99962/developer/ws-proxy', - 'establish ws connection from JavaScript to livehandler' - ); + $t_livehandler->websocket_ok('/liveviewhandler/tests/99962/developer/ws-proxy', 'establish ws connection from JavaScript to livehandler'); $t_livehandler->message_ok('message received'); $t_livehandler->json_message_is( { @@ -688,10 +657,7 @@ subtest 'websocket proxy (connection from client to live view handler not mocked }); my $worker_id = $worker->id; - $t_livehandler->websocket_ok( - '/liveviewhandler/tests/99962/developer/ws-proxy', - 'establish ws connection from JavaScript to livehandler' - ); + $t_livehandler->websocket_ok('/liveviewhandler/tests/99962/developer/ws-proxy', 'establish ws connection from JavaScript to livehandler'); $t_livehandler->message_ok('message received'); $t_livehandler->json_message_is( { @@ -713,20 +679,14 @@ subtest 'websocket proxy (connection from client to live view handler not mocked is($developer_session->ws_connection_count, 0, 'all ws connections finished'); is($developer_session->job_id, 99962, 'job ID correct'); is($developer_session->user_id, 99901, 'user ID correct'); - is_deeply( - \@ipc_messages_for_websocket_server, - [[$worker_id, WORKER_COMMAND_DEVELOPER_SESSION_START, 99962]], - 'worker about devel session notified' - ) or diag explain \@ipc_messages_for_websocket_server; + is_deeply(\@ipc_messages_for_websocket_server, [[$worker_id, WORKER_COMMAND_DEVELOPER_SESSION_START, 99962]], 'worker about devel session notified') + or diag explain \@ipc_messages_for_websocket_server; }; subtest 'job with assigned worker, but os-autoinst not reachable' => sub { prepare_waiting_for_finished_handled(); - $t_livehandler->websocket_ok( - '/liveviewhandler/tests/99961/developer/ws-proxy', - 'establish ws connection from JavaScript to livehandler' - ); + $t_livehandler->websocket_ok('/liveviewhandler/tests/99961/developer/ws-proxy', 'establish ws connection from JavaScript to livehandler'); $t_livehandler->message_ok('message received'); $t_livehandler->json_message_is( { @@ -768,10 +728,7 @@ subtest 'websocket proxy (connection from client to live view handler not mocked prepare_waiting_for_finished_handled(); # connect to ws proxy again, should use the fake connection now - $t_livehandler->websocket_ok( - '/liveviewhandler/tests/99961/developer/ws-proxy', - 'establish ws connection from JavaScript to livehandler' - ); + $t_livehandler->websocket_ok('/liveviewhandler/tests/99961/developer/ws-proxy', 'establish ws connection from JavaScript to livehandler'); $t_livehandler->message_ok('message received'); $t_livehandler->json_message_is( { @@ -783,8 +740,7 @@ subtest 'websocket proxy (connection from client to live view handler not mocked $t_livehandler->json_message_is( { type => 'info', - what => - 'reusing previous connection to os-autoinst command server at ws://remotehost.qa:20013/token99961/ws', + what => 'reusing previous connection to os-autoinst command server at ws://remotehost.qa:20013/token99961/ws', data => undef, }); @@ -804,18 +760,15 @@ subtest 'websocket proxy (connection from client to live view handler not mocked is($developer_sessions->count, 2, 'no new developer session opened'); is($developer_session->ws_connection_count, 1, 'ws connection finally kept open'); is($developer_session->user_id, 99901, 'user ID correct'); - is(scalar @{$t_livehandler->app->devel_java_script_transactions_by_job->{99961} // []}, - 1, 'devel js transactions populated'); - is(scalar @{$t_livehandler->app->status_java_script_transactions_by_job->{99961} // []}, - 0, 'status only js transactions not affected'); + is(scalar @{$t_livehandler->app->devel_java_script_transactions_by_job->{99961} // []}, 1, 'devel js transactions populated'); + is(scalar @{$t_livehandler->app->status_java_script_transactions_by_job->{99961} // []}, 0, 'status only js transactions not affected'); # closing connection will reset counter and bookkeeping of ongoing transations $t_livehandler->finish_ok(); wait_for_finished_handled(); is($developer_sessions->find(99961)->ws_connection_count, 0, 'ws connection finished'); - is(scalar @{$t_livehandler->app->devel_java_script_transactions_by_job->{99961} // []}, - 0, 'devel js transactions cleaned'); + is(scalar @{$t_livehandler->app->devel_java_script_transactions_by_job->{99961} // []}, 0, 'devel js transactions cleaned'); is($t_livehandler->app->cmd_srv_transactions_by_job->{99961}, $fake_cmd_srv_tx, 'command server transaction not cleaned up after js client disconnects'); }; @@ -823,10 +776,7 @@ subtest 'websocket proxy (connection from client to live view handler not mocked subtest 'disconnect on version mismatch' => sub { # connect again through ws-proxy prepare_waiting_for_finished_handled(); - $t_livehandler->websocket_ok( - '/liveviewhandler/tests/99961/developer/ws-proxy', - 'establish ws connection from JavaScript to livehandler' - ); + $t_livehandler->websocket_ok('/liveviewhandler/tests/99961/developer/ws-proxy', 'establish ws connection from JavaScript to livehandler'); $t_livehandler->message_ok('message received'); $t_livehandler->json_message_is( { @@ -838,16 +788,13 @@ subtest 'websocket proxy (connection from client to live view handler not mocked $t_livehandler->json_message_is( { type => 'info', - what => - 'reusing previous connection to os-autoinst command server at ws://remotehost.qa:20013/token99961/ws', + what => 'reusing previous connection to os-autoinst command server at ws://remotehost.qa:20013/token99961/ws', data => undef, }); # send status info where version is supposed to be accepted - my $required_major_version - = OpenQA::LiveHandler::Controller::LiveViewHandler::OS_AUTOINST_DEVEL_MODE_MAJOR_VERSION; - my $required_minor_version - = OpenQA::LiveHandler::Controller::LiveViewHandler::OS_AUTOINST_DEVEL_MODE_MINOR_VERSION; + my $required_major_version = OpenQA::LiveHandler::Controller::LiveViewHandler::OS_AUTOINST_DEVEL_MODE_MAJOR_VERSION; + my $required_minor_version = OpenQA::LiveHandler::Controller::LiveViewHandler::OS_AUTOINST_DEVEL_MODE_MINOR_VERSION; my %status_info = ( running => 'installation-welcome', foo => 'bar', @@ -885,10 +832,8 @@ subtest 'websocket proxy (connection from client to live view handler not mocked # check whether usual cleanup happened here, too wait_for_finished_handled(); is($developer_sessions->find(99961)->ws_connection_count, 0, 'ws connection finished'); - is(scalar @{$t_livehandler->app->devel_java_script_transactions_by_job->{99961} // []}, - 0, 'devel js transactions cleaned'); - is($t_livehandler->app->cmd_srv_transactions_by_job->{99961}, - undef, 'command server transaction cleaned up after version mismatch'); + is(scalar @{$t_livehandler->app->devel_java_script_transactions_by_job->{99961} // []}, 0, 'devel js transactions cleaned'); + is($t_livehandler->app->cmd_srv_transactions_by_job->{99961}, undef, 'command server transaction cleaned up after version mismatch'); }; # restore fake transaction for job 99961 @@ -896,10 +841,8 @@ subtest 'websocket proxy (connection from client to live view handler not mocked subtest 'status-only route' => sub { # connect like in previous subtest, just use the status-only route this time - $t_livehandler->websocket_ok( - '/liveviewhandler/tests/99961/developer/ws-proxy/status', - 'establish status-only ws connection from JavaScript to livehandler' - ); + $t_livehandler->websocket_ok('/liveviewhandler/tests/99961/developer/ws-proxy/status', + 'establish status-only ws connection from JavaScript to livehandler'); $t_livehandler->message_ok('message received'); $t_livehandler->json_message_is( { @@ -911,22 +854,18 @@ subtest 'websocket proxy (connection from client to live view handler not mocked $t_livehandler->json_message_is( { type => 'info', - what => - 'reusing previous connection to os-autoinst command server at ws://remotehost.qa:20013/token99961/ws', + what => 'reusing previous connection to os-autoinst command server at ws://remotehost.qa:20013/token99961/ws', data => undef, }); my $developer_session = $developer_sessions->find(99961); is($developer_sessions->count, 2, 'no new developer session opened'); is($developer_session->ws_connection_count, 0, 'status-only connection not counted'); - is(scalar @{$t_livehandler->app->status_java_script_transactions_by_job->{99961} // []}, - 1, 'status only js transactions populated'); - is(scalar @{$t_livehandler->app->devel_java_script_transactions_by_job->{99961} // []}, - 0, 'devel js transactions not affected'); + is(scalar @{$t_livehandler->app->status_java_script_transactions_by_job->{99961} // []}, 1, 'status only js transactions populated'); + is(scalar @{$t_livehandler->app->devel_java_script_transactions_by_job->{99961} // []}, 0, 'devel js transactions not affected'); $t_livehandler->finish_ok(); - is(scalar @{$t_livehandler->app->status_java_script_transactions_by_job->{99961} // []}, - 0, 'status only js transactions cleaned'); + is(scalar @{$t_livehandler->app->status_java_script_transactions_by_job->{99961} // []}, 0, 'status only js transactions cleaned'); }; subtest 'error handling' => sub { @@ -941,24 +880,21 @@ subtest 'websocket proxy (connection from client to live view handler not mocked # create and start ws transaction manually because Test::Mojo only provides websocket_ok() but # we want to check the opposite here my $ua = $t_livehandler->ua; - my $ws_tx = $ua->build_websocket_tx('/liveviewhandler/tests/99961/developer/ws-proxy', - 'attempt to use proxy as regular user fails'); + my $ws_tx = $ua->build_websocket_tx('/liveviewhandler/tests/99961/developer/ws-proxy', 'attempt to use proxy as regular user fails'); $ua->start($ws_tx, sub { Mojo::IOLoop->stop; }); Mojo::IOLoop->start; ok(!$ws_tx->is_websocket, 'ws handshake fails for non-operator'); is($ws_tx->res->code, 403, 'instead we get 403'); - $t_livehandler->websocket_ok('/liveviewhandler/tests/99961/developer/ws-proxy/status', - 'status-only route accessible, though'); + $t_livehandler->websocket_ok('/liveviewhandler/tests/99961/developer/ws-proxy/status', 'status-only route accessible, though'); $t_livehandler->message_ok('message received'); $t_livehandler->finish_ok(); }; subtest 'access for operators granted' => sub { login('percival'); - $t_livehandler->websocket_ok('/liveviewhandler/tests/99961/developer/ws-proxy', - 'accessing proxy as operator is ok'); + $t_livehandler->websocket_ok('/liveviewhandler/tests/99961/developer/ws-proxy', 'accessing proxy as operator is ok'); $t_livehandler->message_ok('message received'); $t_livehandler->finish_ok(); }; diff --git a/t/35-script_clone_job.t b/t/35-script_clone_job.t index 1c9b4bd382a3..817d1f7b35d5 100644 --- a/t/35-script_clone_job.t +++ b/t/35-script_clone_job.t @@ -138,8 +138,7 @@ subtest 'asset download' => sub { $fake_ua->mirrored({})->missing(0); combined_like { clone_job_download_assets($job_id, \%job, \%url_handler, \%options) } qr{downloading.*http://.*foo.iso.*to.*foo.iso.*downloading.*http://.*bar.iso.*to.*bar.iso}s, 'download logged'; - is_deeply($fake_ua->mirrored, \%expected_downloads, - 'assets downloadeded except HDDs which are generated by parent job anyways') + is_deeply($fake_ua->mirrored, \%expected_downloads, 'assets downloadeded except HDDs which are generated by parent job anyways') or diag explain $fake_ua->mirrored; ok(-f "$temp_assetdir/iso/foo.iso", 'foo touched'); ok(-f "$temp_assetdir/iso/bar.iso", 'foo touched'); @@ -148,19 +147,15 @@ subtest 'asset download' => sub { $options{'skip-deps'} = 1; $expected_downloads{"http://foo/tests/$job_id/asset/hdd/some.qcow2"} = "$temp_assetdir/hdd/some.qcow2"; $expected_downloads{"http://foo/tests/$job_id/asset/hdd/uefi-vars.qcow2"} = "$temp_assetdir/hdd/uefi-vars.qcow2"; - combined_like { clone_job_download_assets($job_id, \%job, \%url_handler, \%options) } qr/downloading/, - 'downloading logged (1)'; - is_deeply($fake_ua->mirrored, \%expected_downloads, - 'assets downloadeded including HDDs because we skip cloning the parent job') + combined_like { clone_job_download_assets($job_id, \%job, \%url_handler, \%options) } qr/downloading/, 'downloading logged (1)'; + is_deeply($fake_ua->mirrored, \%expected_downloads, 'assets downloadeded including HDDs because we skip cloning the parent job') or diag explain $fake_ua->mirrored; $fake_ua->mirrored({}); $job{parents} = {Chained => [3, 5]}; delete $expected_downloads{"http://foo/tests/$job_id/asset/hdd/uefi-vars.qcow2"}; - combined_like { clone_job_download_assets($job_id, \%job, \%url_handler, \%options) } qr/downloading/, - 'downloading logged (2)'; - is_deeply($fake_ua->mirrored, \%expected_downloads, - 'assets downloadeded except uefi-vars because no parent produces it anyways') + combined_like { clone_job_download_assets($job_id, \%job, \%url_handler, \%options) } qr/downloading/, 'downloading logged (2)'; + is_deeply($fake_ua->mirrored, \%expected_downloads, 'assets downloadeded except uefi-vars because no parent produces it anyways') or diag explain $fake_ua->mirrored; }; @@ -230,8 +225,7 @@ subtest 'error handling' => sub { $tx->res->code(200)->body('{"foo": "bar"}'); throws_ok { $test->() } qr/Failed to create job, server replied: \{ foo => "bar" \}/, 'unexpected JSON handled'; ($tx = Mojo::Transaction->new)->res->code(200)->body('{"ids": {"42": 43}}'); - combined_like { $test->() } qr|1 job has been created:.* - testjob -> https://base-url/tests/43|s, - 'expected response'; + combined_like { $test->() } qr|1 job has been created:.* - testjob -> https://base-url/tests/43|s, 'expected response'; }; subtest 'export command' => sub { @@ -288,14 +282,11 @@ subtest 'overall cloning with parallel and chained dependencies' => sub { ); $clone_mock->redefine(clone_job_get_job => sub ($job_id, @args) { $fake_jobs{$job_id} }); - my %options - = (host => 'foo', from => 'bar', 'clone-children' => 1, 'skip-download' => 1, verbose => 1, args => ['FOO=bar']); - throws_ok { OpenQA::Script::CloneJob::clone_jobs(42, \%options) } qr|API key/secret for 'foo' missing|, - 'dies on missing API credentials'; + my %options = (host => 'foo', from => 'bar', 'clone-children' => 1, 'skip-download' => 1, verbose => 1, args => ['FOO=bar']); + throws_ok { OpenQA::Script::CloneJob::clone_jobs(42, \%options) } qr|API key/secret for 'foo' missing|, 'dies on missing API credentials'; $options{apikey} = $options{apisecret} = 'bar'; - combined_like { OpenQA::Script::CloneJob::clone_jobs(42, \%options) } qr|parent.*main.*child|s, - 'verbose output printed'; + combined_like { OpenQA::Script::CloneJob::clone_jobs(42, \%options) } qr|parent.*main.*child|s, 'verbose output printed'; ok $tx_handled, 'transaction handled'; my $check_common_post_args = sub ($test_suffix = '') { diff --git a/t/35-script_clone_job_suse.t b/t/35-script_clone_job_suse.t index f1c06de6b27f..38bd47e7f2f1 100644 --- a/t/35-script_clone_job_suse.t +++ b/t/35-script_clone_job_suse.t @@ -48,10 +48,8 @@ subtest 'maintenance update detect' => sub { lives_ok { detect_maintenance_update($job_id, \%url_handler, \%job) } 'Maintenance updates are available'; lives_ok { detect_maintenance_update($job_id, \%url_handler, \%incident_job) } 'Maintenance updates are available'; $fake_ua->is_validrepo(0); - throws_ok { detect_maintenance_update($job_id, \%url_handler, \%job) } qr/Current job $job_id will fail/, - 'Maintenance updates have been released'; - throws_ok { detect_maintenance_update($job_id, \%url_handler, \%incident_job) } qr/Current job $job_id will fail/, - 'Maintenance updates have been released'; + throws_ok { detect_maintenance_update($job_id, \%url_handler, \%job) } qr/Current job $job_id will fail/, 'Maintenance updates have been released'; + throws_ok { detect_maintenance_update($job_id, \%url_handler, \%incident_job) } qr/Current job $job_id will fail/, 'Maintenance updates have been released'; lives_ok { detect_maintenance_update($job_id, \%url_handler, \%skip_check) } 'Skip updates check'; }; diff --git a/t/36-job_group_settings.t b/t/36-job_group_settings.t index df8035c932c3..5420376e68db 100644 --- a/t/36-job_group_settings.t +++ b/t/36-job_group_settings.t @@ -35,10 +35,7 @@ subtest 'defaults of parent group' => sub { is($new_parent_group->default_keep_logs_in_days, OpenQA::JobGroupDefaults::KEEP_LOGS_IN_DAYS); is($new_parent_group->default_keep_important_logs_in_days, OpenQA::JobGroupDefaults::KEEP_IMPORTANT_LOGS_IN_DAYS); is($new_parent_group->default_keep_results_in_days, OpenQA::JobGroupDefaults::KEEP_RESULTS_IN_DAYS); - is( - $new_parent_group->default_keep_important_results_in_days, - OpenQA::JobGroupDefaults::KEEP_IMPORTANT_RESULTS_IN_DAYS - ); + is($new_parent_group->default_keep_important_results_in_days, OpenQA::JobGroupDefaults::KEEP_IMPORTANT_RESULTS_IN_DAYS); is($new_parent_group->default_priority, OpenQA::JobGroupDefaults::PRIORITY); }; @@ -53,22 +50,15 @@ subtest 'defaults of group without parent' => sub { subtest 'overrideing defaults in settings affects groups' => sub { my $config = $t->app->config->{default_group_limits}; - my @fields - = qw(asset_size_limit log_storage_duration important_log_storage_duration result_storage_duration important_result_storage_duration); + my @fields = qw(asset_size_limit log_storage_duration important_log_storage_duration result_storage_duration important_result_storage_duration); $config->{$_} += 1000 for (@fields); subtest 'defaults for parent group overridden' => sub { is($new_parent_group->size_limit_gb, undef); is($new_parent_group->default_keep_logs_in_days, OpenQA::JobGroupDefaults::KEEP_LOGS_IN_DAYS + 1000); - is( - $new_parent_group->default_keep_important_logs_in_days, - OpenQA::JobGroupDefaults::KEEP_IMPORTANT_LOGS_IN_DAYS + 1000 - ); + is($new_parent_group->default_keep_important_logs_in_days, OpenQA::JobGroupDefaults::KEEP_IMPORTANT_LOGS_IN_DAYS + 1000); is($new_parent_group->default_keep_results_in_days, OpenQA::JobGroupDefaults::KEEP_RESULTS_IN_DAYS + 1000); - is( - $new_parent_group->default_keep_important_results_in_days, - OpenQA::JobGroupDefaults::KEEP_IMPORTANT_RESULTS_IN_DAYS + 1000 - ); + is($new_parent_group->default_keep_important_results_in_days, OpenQA::JobGroupDefaults::KEEP_IMPORTANT_RESULTS_IN_DAYS + 1000); }; subtest 'defaults for job group overridden' => sub { @@ -76,8 +66,7 @@ subtest 'overrideing defaults in settings affects groups' => sub { is($new_job_group->keep_logs_in_days, OpenQA::JobGroupDefaults::KEEP_LOGS_IN_DAYS + 1000); is($new_job_group->keep_important_logs_in_days, OpenQA::JobGroupDefaults::KEEP_IMPORTANT_LOGS_IN_DAYS + 1000); is($new_job_group->keep_results_in_days, OpenQA::JobGroupDefaults::KEEP_RESULTS_IN_DAYS + 1000); - is($new_job_group->keep_important_results_in_days, - OpenQA::JobGroupDefaults::KEEP_IMPORTANT_RESULTS_IN_DAYS + 1000); + is($new_job_group->keep_important_results_in_days, OpenQA::JobGroupDefaults::KEEP_IMPORTANT_RESULTS_IN_DAYS + 1000); }; }; @@ -90,15 +79,9 @@ subtest 'defaults overridden on parent group level' => sub { is($new_parent_group->size_limit_gb, 1000); is($new_parent_group->default_keep_logs_in_days, OpenQA::JobGroupDefaults::KEEP_LOGS_IN_DAYS + 2000); - is( - $new_parent_group->default_keep_important_logs_in_days, - OpenQA::JobGroupDefaults::KEEP_IMPORTANT_LOGS_IN_DAYS + 2000 - ); + is($new_parent_group->default_keep_important_logs_in_days, OpenQA::JobGroupDefaults::KEEP_IMPORTANT_LOGS_IN_DAYS + 2000); is($new_parent_group->default_keep_results_in_days, OpenQA::JobGroupDefaults::KEEP_RESULTS_IN_DAYS + 2000); - is( - $new_parent_group->default_keep_important_results_in_days, - OpenQA::JobGroupDefaults::KEEP_IMPORTANT_RESULTS_IN_DAYS + 2000 - ); + is($new_parent_group->default_keep_important_results_in_days, OpenQA::JobGroupDefaults::KEEP_IMPORTANT_RESULTS_IN_DAYS + 2000); is($new_parent_group->default_priority, OpenQA::JobGroupDefaults::PRIORITY + 1000); # note: prio is just + 1000 (and not + 2000) because in contrast to the other values the default wasn't changed @@ -117,8 +100,7 @@ subtest 'job group properties inherited from parent group except for size_limit_ }; subtest 'inherited job group properties overridden' => sub { - my @columns - = qw(size_limit_gb keep_logs_in_days keep_important_logs_in_days keep_results_in_days keep_important_results_in_days default_priority); + my @columns = qw(size_limit_gb keep_logs_in_days keep_important_logs_in_days keep_results_in_days keep_important_results_in_days default_priority); for my $column (@columns) { $new_job_group->update({$column => $new_job_group->$column + 1000}); } diff --git a/t/37-limit_assets.t b/t/37-limit_assets.t index 31cac3aa8b50..474e15fef325 100644 --- a/t/37-limit_assets.t +++ b/t/37-limit_assets.t @@ -203,8 +203,7 @@ my @expected_assets_with_max_job = ( picked_into_parent_id => 1, name => 'iso/openSUSE-13.1-DVD-x86_64-Build0091-Media.iso', fixed => 0, - groups => {1001 => 99963, 1002 => 99961} - , # specific job groups still visible when a job group is within a parent group + groups => {1001 => 99963, 1002 => 99961}, # specific job groups still visible when a job group is within a parent group parents => {1 => 1}, type => 'iso', pending => 1, @@ -368,12 +367,10 @@ subtest 'handling assets with invalid name' => sub { my $job = $schema->resultset('Jobs')->first; my $job_settings = $job->{_settings} = {REPO_0 => ''}; stdout_like { $job->register_assets_from_settings() } - qr/not registering asset with empty name or type/, - 'warning on attempt to register asset with empty name/type from settings'; + qr/not registering asset with empty name or type/, 'warning on attempt to register asset with empty name/type from settings'; $job_settings->{REPO_0} = 'in/valid'; stdout_like { $job->register_assets_from_settings() } - qr/not registering asset in\/valid containing \//, - 'warning on attempt to register asset with invalid name from settings'; + qr/not registering asset in\/valid containing \//, 'warning on attempt to register asset with invalid name from settings'; is($schema->resultset('Assets')->count, $asset_count, 'no further assets registered'); # add an asset with empty name nevertheless to test that it is ignored (in subsequent subtest) @@ -463,11 +460,7 @@ subtest 'asset status without pending state, max_job and max_job by group' => su $assets_with_max_job->[5]->{id} = undef; # might vary is_deeply($assets_with_max_job, \@expected_assets_with_max_job, 'assets with max job') or diag explain $assets_with_max_job; - is( - join(' ', sort keys %$assets_without_max_job), - join(' ', sort keys %expected_assets_without_max_job), - 'assets without max job' - ); + is(join(' ', sort keys %$assets_without_max_job), join(' ', sort keys %expected_assets_without_max_job), 'assets without max job'); }; subtest 'size of exclusively kept assets tracked' => sub { diff --git a/t/40-job_settings.t b/t/40-job_settings.t index 88591f735992..30b78db9b0f6 100644 --- a/t/40-job_settings.t +++ b/t/40-job_settings.t @@ -36,8 +36,7 @@ my $settings = { HDDSIZEGB => 50, INSTALLONLY => 1, PATTERNS => 'base,minimal', - PUBLISH_PFLASH_VARS => - 'SLES-%VERSION%-%ARCH%-%BUILD%@%MACHINE%-minimal_with_sdk%BUILD_SDK%_installed-uefi-vars.qcow2', + PUBLISH_PFLASH_VARS => 'SLES-%VERSION%-%ARCH%-%BUILD%@%MACHINE%-minimal_with_sdk%BUILD_SDK%_installed-uefi-vars.qcow2', SEPARATE_HOME => 0, BUILD_HA => '%BUILD%', BUILD_SES => '%BUILD%', diff --git a/t/40-script_openqa-clone-custom-git-refspec.t b/t/40-script_openqa-clone-custom-git-refspec.t index 4f022c1c8106..667d11e37236 100644 --- a/t/40-script_openqa-clone-custom-git-refspec.t +++ b/t/40-script_openqa-clone-custom-git-refspec.t @@ -26,8 +26,7 @@ sub test_once { $ENV{dry_run} = 'echo'; my $ret; -test_once '', qr/Need.*parameter/, 'hint shown for mandatory parameter missing', 1, - 'openqa-clone-custom-git-refspec needs parameters'; +test_once '', qr/Need.*parameter/, 'hint shown for mandatory parameter missing', 1, 'openqa-clone-custom-git-refspec needs parameters'; test_once '--help', qr/Usage:/, 'help text shown', 0, 'help screen is regarded as success'; test_once '--invalid-arg', qr/Usage:/, 'invalid args also yield help', 1, 'help screen but no success recorded'; my $args = 'https://github.com/user/repo/pull/9128 https://openqa.opensuse.org/tests/1234'; @@ -36,18 +35,15 @@ isnt run_once($args), 0, 'without network we fail (without error)'; $ENV{curl_github} = qq{echo -e '{"head": {"label": "user:my/branch"}, "body": "Lorem ipsum"}'; true}; $ENV{curl_openqa} = qq{echo -e '{"TEST": "my_test", "CASEDIR": "/my/case/dir", "PRODUCTDIR": "/my/case/dir/product", "NEEDLES_DIR": "/my/case/dir/product/needles"}'; true}; -my $clone_job - = 'openqa-clone-job --skip-chained-deps --parental-inheritance --within-instance https://openqa.opensuse.org '; -my $dirs - = 'CASEDIR=https://github.com/user/repo.git#my/branch PRODUCTDIR=repo/product NEEDLES_DIR=/my/case/dir/product/needles'; +my $clone_job = 'openqa-clone-job --skip-chained-deps --parental-inheritance --within-instance https://openqa.opensuse.org '; +my $dirs = 'CASEDIR=https://github.com/user/repo.git#my/branch PRODUCTDIR=repo/product NEEDLES_DIR=/my/case/dir/product/needles'; my $expected = $clone_job . '1234 _GROUP=0 TEST\+=\@user/repo#my/branch BUILD=user/repo#9128 ' . $dirs; my $expected_re = qr/${expected}/; test_once $args, $expected_re, 'clone-job command line is correct'; test_once "-v $args", qr/\+ local dry_run/, 'clone-job with -v prints commands'; test_once "-n -v $args", qr/\+ local dry_run/, 'clone-job with -n -v prints commands'; my $args_branch = 'https://github.com/user/repo/tree/my/branch https://openqa.opensuse.org/tests/1234 FOO=bar'; -my $expected_branch_re - = qr{${clone_job}1234 _GROUP=0 TEST\+=\@user/repo#my/branch BUILD=user/repo#my/branch ${dirs} FOO=bar}; +my $expected_branch_re = qr{${clone_job}1234 _GROUP=0 TEST\+=\@user/repo#my/branch BUILD=user/repo#my/branch ${dirs} FOO=bar}; test_once $args_branch, $expected_branch_re, 'alternative mode with branch reference also yields right variables'; my $prefix = 'env repo_name=user/repo pr=9128 host=https://openqa.opensuse.org job=1234'; combined_like { $ret = run_once('', $prefix) } $expected_re, 'environment variables can be used instead'; @@ -69,12 +65,10 @@ my $args_clone = '--clone-job-args="--show-progress" ' . $args; $expected_re = qr/openqa-clone-job --show-progress --skip-chained-deps --parental-inheritance --within-instance https/; test_once $args_clone, $expected_re, 'additional parameters can be passed to clone-job'; -my $args_escape - = q(https://github.com/me/repo/pull/1/ https://openqa.opensuse.org/tests/1 TEST1=$FOO_BAR 'TEST2=$VAR' TEST3=space\\ space 'TEST4=(!?bla)'); +my $args_escape = q(https://github.com/me/repo/pull/1/ https://openqa.opensuse.org/tests/1 TEST1=$FOO_BAR 'TEST2=$VAR' TEST3=space\\ space 'TEST4=(!?bla)'); $ENV{FOO_BAR} = 'BLUB'; $expected_re = qr/TEST1=BLUB\r?\nTEST2=\$VAR\r?\nTEST3=space space\r?\nTEST4=\(!\?bla\)$/m; -combined_like { run_once($args_escape, q(dry_run='printf "%s\n"')) } $expected_re, - 'Custom variables has proper bash escaping'; +combined_like { run_once($args_escape, q(dry_run='printf "%s\n"')) } $expected_re, 'Custom variables has proper bash escaping'; TODO: { local $TODO = 'not implemented'; @@ -104,25 +98,21 @@ test_once $args, $expected_re, 'clone-job command with multiple URLs in PR and j $ENV{curl_github} = qq{echo -e '{"head": {"label": "user:my/branch"}, "body": "Lorem ipsum"}'; true}; my $needles = 'my/distri/products/sle/needles'; -$ENV{curl_openqa} - = qq{echo -e '{"TEST": "my_test", "CASEDIR": "my/distri", "PRODUCTDIR": "distri/products/sle", "NEEDLES_DIR": "$needles"}'; true}; +$ENV{curl_openqa} = qq{echo -e '{"TEST": "my_test", "CASEDIR": "my/distri", "PRODUCTDIR": "distri/products/sle", "NEEDLES_DIR": "$needles"}'; true}; $dirs = "CASEDIR=https://github.com/user/repo.git#my/branch PRODUCTDIR=repo/products/sle NEEDLES_DIR=$needles"; $expected = $clone_job . '1169326 _GROUP=0 TEST\+=\@user/repo#my/branch BUILD=user/repo#9539 '; $expected_re = qr/${expected}${dirs}/; test_once $args, $expected_re, "PRODUCTDIR is correct when the source job's PRODUCTDIR is a relative directory"; $needles = "/$needles"; -$ENV{curl_openqa} - = qq{echo -e '{"TEST": "my_test", "CASEDIR": "/my/distri", "PRODUCTDIR": "products/sle", "NEEDLES_DIR": "$needles"}'; true}; +$ENV{curl_openqa} = qq{echo -e '{"TEST": "my_test", "CASEDIR": "/my/distri", "PRODUCTDIR": "products/sle", "NEEDLES_DIR": "$needles"}'; true}; $dirs = "CASEDIR=https://github.com/user/repo.git#my/branch PRODUCTDIR=repo/products/sle NEEDLES_DIR=$needles"; $expected_re = qr/${expected}${dirs}/; test_once $args, $expected_re, 'Correct PRODUCTDIR for relative non-prefixed dir'; my $casedir = '/openqa/cache/openqa1-opensuse/tests/opensuse'; -$ENV{curl_openqa} - = qq{echo -e '{"TEST": "my_test", "CASEDIR": "$casedir", "PRODUCTDIR": "$casedir/products/opensuse"}'; true}; -$dirs - = "CASEDIR=https://github.com/user/repo.git#my/branch PRODUCTDIR=repo/products/opensuse NEEDLES_DIR=$casedir/products/opensuse/needles"; +$ENV{curl_openqa} = qq{echo -e '{"TEST": "my_test", "CASEDIR": "$casedir", "PRODUCTDIR": "$casedir/products/opensuse"}'; true}; +$dirs = "CASEDIR=https://github.com/user/repo.git#my/branch PRODUCTDIR=repo/products/opensuse NEEDLES_DIR=$casedir/products/opensuse/needles"; $expected_re = qr/${expected}${dirs}/; test_once $args, $expected_re, "PRODUCTDIR is correct when the source job's PRODUCTDIR includes specific word"; diff --git a/t/42-df-based-cleanup.t b/t/42-df-based-cleanup.t index 96fdf74758e5..29fe85fbbbdf 100644 --- a/t/42-df-based-cleanup.t +++ b/t/42-df-based-cleanup.t @@ -52,25 +52,21 @@ subtest 'abort early if there is enough free disk space' => sub { $app->config->{misc_limits}->{result_cleanup_max_free_percentage} = 10; my $job = run_gru_job($app, limit_results_and_logs => []); is $job->{state}, 'finished', 'result cleanup still considered successful'; - like $job->{result}, - qr|Skipping.*/openqa/testresults.*exceeds configured percentage 10 % \(free percentage: 11 %\)|, - 'result cleanup aborted early'; + like $job->{result}, qr|Skipping.*/openqa/testresults.*exceeds configured percentage 10 % \(free percentage: 11 %\)|, 'result cleanup aborted early'; $app->config->{misc_limits}->{asset_cleanup_max_free_percentage} = 9; $job = run_gru_job($app, limit_assets => []); is $job->{state}, 'finished', 'asset cleanup still considered successful'; - like $job->{result}, - qr|Skipping.*/openqa/share/factory.*exceeds configured percentage 9 % \(free percentage: 11 %\)|, - 'asset cleanup aborted early'; + like $job->{result}, qr|Skipping.*/openqa/share/factory.*exceeds configured percentage 9 % \(free percentage: 11 %\)|, 'asset cleanup aborted early'; my @check_args = (job => $app->minion->job($job->{id}), setting => 'result_cleanup_max_free_percentage', dir => ''); $job->{state} = undef; - combined_like { ok !finish_job_if_disk_usage_below_percentage(@check_args, setting => 'foo'), - 'invalid setting ignored' } qr/Specified value.*will be ignored/, 'warning about invalid setting logged'; + combined_like { ok !finish_job_if_disk_usage_below_percentage(@check_args, setting => 'foo'), 'invalid setting ignored' } + qr/Specified value.*will be ignored/, 'warning about invalid setting logged'; $df_mock->redefine(df => sub { die 'df failed' }); - combined_like { ok !finish_job_if_disk_usage_below_percentage(@check_args), 'invalid df ignored' } - qr/df failed.*Proceeding with cleanup/s, 'warning about invalid df logged'; + combined_like { ok !finish_job_if_disk_usage_below_percentage(@check_args), 'invalid df ignored' } qr/df failed.*Proceeding with cleanup/s, + 'warning about invalid df logged'; $df_mock->redefine(df => {bavail => 10, blocks => 100}); ok !finish_job_if_disk_usage_below_percentage(@check_args), 'cleanup done if not enough free disk space available'; diff --git a/t/42-screenshots.t b/t/42-screenshots.t index 893f1108f634..acdffd7dfc56 100644 --- a/t/42-screenshots.t +++ b/t/42-screenshots.t @@ -59,11 +59,8 @@ $jobs->find(99926)->delete; @screenshot_data = map { {filename => $_->filename} } @screenshots; is($jobs->find(99926), undef, 'job deleted'); is(scalar @screenshot_links, 0, 'screenshot links for job 99926 deleted'); -is_deeply( - \@screenshot_data, - [{filename => 'foo'}, {filename => 'bar'}], - 'screenshot not directly cleaned up after deleting job' -) or diag explain \@screenshot_data; +is_deeply(\@screenshot_data, [{filename => 'foo'}, {filename => 'bar'}], 'screenshot not directly cleaned up after deleting job') + or diag explain \@screenshot_data; # limit screenshots my %args = ( @@ -141,10 +138,8 @@ subtest 'limiting screenshots split into multiple Minion jobs' => sub { my $args = $enququed_minion_job_args->[1]->[0]; combined_like { $worker->dequeue(0, {id => $enququed_minion_job_ids->[1]})->perform } qr/Removing screenshot batch 1/, 'screenshots being removed'; - is($screenshots->search({id => {-between => [$args->{min_screenshot_id}, $args->{max_screenshot_id}]}})->count, - 0, 'all screenshots in the range deleted'); - is($screenshots->search({filename => {-like => 'test-%'}})->count, - 101, 'screenshots of other ranges not deleted yet'); + is($screenshots->search({id => {-between => [$args->{min_screenshot_id}, $args->{max_screenshot_id}]}})->count, 0, 'all screenshots in the range deleted'); + is($screenshots->search({filename => {-like => 'test-%'}})->count, 101, 'screenshots of other ranges not deleted yet'); # perform remaining enqueued jobs combined_like { @@ -219,8 +214,7 @@ subtest 'unable to delete screenshot' => sub { $subdir->make_path; $subdir->child($_)->make_path for (qw(screenshot .thumbs/screenshot)); combined_like { $screenshot_deletion->delete_screenshot($screenshot->id, $screenshot->filename) } - qr{Can't remove screenshot .*not-deletable/screenshot.*Can't remove thumbnail .*not-deletable/.thumbs/screenshot}s, - 'errors logged'; + qr{Can't remove screenshot .*not-deletable/screenshot.*Can't remove thumbnail .*not-deletable/.thumbs/screenshot}s, 'errors logged'; is $deleted_size, 100, 'deleted size not incremented'; # cover case when only the screenshot or when only the thumbnail can be deleted diff --git a/t/43-cli-archive.t b/t/43-cli-archive.t index dadd47d5bdf1..4aa5e13a55a4 100644 --- a/t/43-cli-archive.t +++ b/t/43-cli-archive.t @@ -119,8 +119,7 @@ subtest 'Archive job' => sub { like $stdout, qr/Asset serial0.txt successfully downloaded and moved to .+serial0.txt/, 'moved serial0.txt'; like $stdout, qr/Downloading autoinst-log.txt/, 'downloading autoinst-log.txt'; - like $stdout, qr/Asset autoinst-log.txt successfully downloaded and moved to .+autoinst-log.txt/, - 'moved autoinst-log.txt'; + like $stdout, qr/Asset autoinst-log.txt successfully downloaded and moved to .+autoinst-log.txt/, 'moved autoinst-log.txt'; like $stdout, qr/Downloading ulogs/, 'downloading ulogs'; diff --git a/t/43-cli-schedule.t b/t/43-cli-schedule.t index 8a8cec233f8a..e283e0dde150 100644 --- a/t/43-cli-schedule.t +++ b/t/43-cli-schedule.t @@ -57,13 +57,11 @@ my @settings2 = (qw(DISTRI=opensuse VERSION=13.1 FLAVOR=DVD ARCH=i586 BUILD=0091 subtest 'running into error reply' => sub { my $res; - combined_like { $res = $schedule->run(@options) } qr/Error: missing parameters: DISTRI VERSION FLAVOR ARCH/, - '"missing parameters" error'; + combined_like { $res = $schedule->run(@options) } qr/Error: missing parameters: DISTRI VERSION FLAVOR ARCH/, '"missing parameters" error'; is $schedule->host, $host, 'host set'; is $res, 1, 'non-zero return-code if parameters missing'; - combined_like { $res = $schedule->run(@options, @settings1) } qr/no products found for/, - '"no products found" error'; + combined_like { $res = $schedule->run(@options, @settings1) } qr/no products found for/, '"no products found" error'; is $res, 1, 'non-zero return-code if no products could be found'; }; @@ -76,12 +74,10 @@ subtest 'scheduling and monitoring zero-sized set of jobs' => sub { subtest 'scheduling and monitoring set of two jobs' => sub { my $res; combined_like { $res = $schedule->run(@options, @scenarios, @settings2) } - qr|2 jobs have been created.*(http://127.0.0.1.*/tests/\d+.*){2}passed.*softfailed|s, - 'response logged if all jobs are ok'; + qr|2 jobs have been created.*(http://127.0.0.1.*/tests/\d+.*){2}passed.*softfailed|s, 'response logged if all jobs are ok'; is $res, 0, 'zero return-code if all jobs are ok'; - combined_like { $res = $schedule->run(@options, @scenarios, @settings2) } qr/count.*2.*passed.*user_cancelled/s, - 'response logged if one job was cancelled'; + combined_like { $res = $schedule->run(@options, @scenarios, @settings2) } qr/count.*2.*passed.*user_cancelled/s, 'response logged if one job was cancelled'; is $res, 2, 'non-zero return-code if at least one job is not ok'; }; diff --git a/t/43-scheduling-and-worker-scalability.t b/t/43-scheduling-and-worker-scalability.t index 0cb52dcd97a2..e3ab8394776c 100644 --- a/t/43-scheduling-and-worker-scalability.t +++ b/t/43-scheduling-and-worker-scalability.t @@ -73,10 +73,7 @@ my $webui_host = "http://localhost:$webui_port"; my $worker_path = path($FindBin::Bin)->child('../script/worker'); my $isotovideo_path = path($FindBin::Bin)->child('dummy-isotovideo.sh'); $webui_host .= " http://localhost:12345" if $ENV{SCALABILITY_TEST_WITH_OFFLINE_WEBUI_HOST}; -my @worker_args = ( - "--apikey=$api_key", "--apisecret=$api_secret", "--host=$webui_host", "--isotovideo=$isotovideo_path", - '--verbose', '--no-cleanup', -); +my @worker_args = ("--apikey=$api_key", "--apisecret=$api_secret", "--host=$webui_host", "--isotovideo=$isotovideo_path", '--verbose', '--no-cleanup',); note("Tests dir: $testsdir"); note("Result dir: $resultdir"); @@ -100,8 +97,7 @@ sub log_jobs { my @job_info # uncoverable statement count:1 # uncoverable statement count:2 - = map { sprintf("id: %s, state: %s, result: %s, reason: %s", $_->id, $_->state, $_->result, $_->reason // 'none') } - $jobs->search({}, {order_by => 'id'}); + = map { sprintf("id: %s, state: %s, result: %s, reason: %s", $_->id, $_->state, $_->result, $_->reason // 'none') } $jobs->search({}, {order_by => 'id'}); # uncoverable statement diag("All jobs:\n - " . join("\n - ", @job_info)); } diff --git a/t/api/01-workers.t b/t/api/01-workers.t index cce6fbeecd44..7d9a554d65c8 100644 --- a/t/api/01-workers.t +++ b/t/api/01-workers.t @@ -36,8 +36,8 @@ my $app = $t->app; $t->ua(OpenQA::Client->new->ioloop(Mojo::IOLoop->singleton)); $t->app($app); -$t->post_ok('/api/v1/workers', form => {host => 'localhost', instance => 1, backend => 'qemu'}) - ->status_is(403, 'register worker without API key fails (403)')->json_is( +$t->post_ok('/api/v1/workers', form => {host => 'localhost', instance => 1, backend => 'qemu'})->status_is(403, 'register worker without API key fails (403)') + ->json_is( '' => { error => 'no api key', error_status => 403, @@ -76,8 +76,7 @@ my @workers = ( instance => 1 }); -$t->get_ok('/api/v1/workers?live=1') - ->json_is('' => {workers => \@workers}, 'workers present with deprecated live flag'); +$t->get_ok('/api/v1/workers?live=1')->json_is('' => {workers => \@workers}, 'workers present with deprecated live flag'); diag explain $t->tx->res->json unless $t->success; $_->{websocket} = 0 for @workers; $t->get_ok('/api/v1/workers')->json_is('' => {workers => \@workers}, "workers present with deprecated websocket flag"); @@ -102,13 +101,11 @@ $registration_params{worker_class} = 'bar'; $t->post_ok('/api/v1/workers', form => \%registration_params)->status_is(426, 'worker informed to upgrade'); $registration_params{websocket_api_version} = WEBSOCKET_API_VERSION; -$t->post_ok('/api/v1/workers', form => \%registration_params)->status_is(200, 'register existing worker with token') - ->json_is('/id' => 1, 'worker id is 1'); +$t->post_ok('/api/v1/workers', form => \%registration_params)->status_is(200, 'register existing worker with token')->json_is('/id' => 1, 'worker id is 1'); diag explain $t->tx->res->json unless $t->success; $registration_params{instance} = 42; -$t->post_ok('/api/v1/workers', form => \%registration_params)->status_is(200, 'register new worker') - ->json_is('/id' => 3, 'new worker id is 3'); +$t->post_ok('/api/v1/workers', form => \%registration_params)->status_is(200, 'register new worker')->json_is('/id' => 3, 'new worker id is 3'); diag explain $t->tx->res->json unless $t->success; is_deeply( OpenQA::Test::Case::find_most_recent_event($t->app->schema, 'worker_register'), @@ -138,8 +135,7 @@ subtest 'incompleting previous job on worker registration' => sub { is($jobs->find($running_job_id)->state, RUNNING, 'job is running in the first place'); subtest 'previous job not incompleted when still being worked on' => sub { - $t->post_ok('/api/v1/workers', form => \%registration_params) - ->status_is(200, 'register existing worker passing job ID') + $t->post_ok('/api/v1/workers', form => \%registration_params)->status_is(200, 'register existing worker passing job ID') ->json_is('/id' => $worker_id, 'worker ID returned'); return diag explain $t->tx->res->json unless $t->success; is($jobs->find($running_job_id)->state, RUNNING, 'assigned job still running'); @@ -147,14 +143,12 @@ subtest 'incompleting previous job on worker registration' => sub { subtest 'previous job incompleted when worker doing something else' => sub { delete $registration_params{job_id}; - $t->post_ok('/api/v1/workers', form => \%registration_params) - ->status_is(200, 'register existing worker passing no job ID') + $t->post_ok('/api/v1/workers', form => \%registration_params)->status_is(200, 'register existing worker passing no job ID') ->json_is('/id' => $worker_id, 'worker ID returned'); return diag explain $t->tx->res->json unless $t->success; my $incomplete_job = $jobs->find($running_job_id); is($incomplete_job->state, DONE, 'assigned job set to done'); - ok($incomplete_job->result eq INCOMPLETE || $incomplete_job->result eq PARALLEL_RESTARTED, - 'assigned job considered incomplete or parallel restarted') + ok($incomplete_job->result eq INCOMPLETE || $incomplete_job->result eq PARALLEL_RESTARTED, 'assigned job considered incomplete or parallel restarted') or diag explain 'actual job result: ' . $incomplete_job->result; }; }; @@ -169,8 +163,7 @@ subtest 'server-side limit has precedence over user-specified limit' => sub { my $id = 4; for (1 .. 4) { $registration_params{instance} = $id; - $t->post_ok('/api/v1/workers', form => \%registration_params)->status_is(200, 'register new worker') - ->json_is('/id' => $id, "new worker id is $id"); + $t->post_ok('/api/v1/workers', form => \%registration_params)->status_is(200, 'register new worker')->json_is('/id' => $id, "new worker id is $id"); diag explain $t->tx->res->json unless $t->success; $id++; } @@ -190,18 +183,15 @@ subtest 'server-side limit has precedence over user-specified limit' => sub { subtest 'server-side limit with pagination' => sub { subtest 'input validation' => sub { - $t->get_ok('/api/v1/workers?limit=a')->status_is(400) - ->json_is({error_status => 400, error => 'Erroneous parameters (limit invalid)'}); - $t->get_ok('/api/v1/workers?offset=a')->status_is(400) - ->json_is({error_status => 400, error => 'Erroneous parameters (offset invalid)'}); + $t->get_ok('/api/v1/workers?limit=a')->status_is(400)->json_is({error_status => 400, error => 'Erroneous parameters (limit invalid)'}); + $t->get_ok('/api/v1/workers?offset=a')->status_is(400)->json_is({error_status => 400, error => 'Erroneous parameters (offset invalid)'}); }; subtest 'navigation with limit' => sub { my $links; subtest 'first page' => sub { - $t->get_ok('/api/v1/workers?limit=3')->status_is(200)->json_has('/workers/0')->json_has('/workers/2') - ->json_hasnt('/workers/3'); + $t->get_ok('/api/v1/workers?limit=3')->status_is(200)->json_has('/workers/0')->json_has('/workers/2')->json_hasnt('/workers/3'); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok $links->{next}, 'has next page'; @@ -209,8 +199,7 @@ subtest 'server-side limit with pagination' => sub { }; subtest 'second page' => sub { - $t->get_ok($links->{next}{link})->status_is(200)->json_has('/workers/0')->json_has('/workers/2') - ->json_hasnt('/workers/3'); + $t->get_ok($links->{next}{link})->status_is(200)->json_has('/workers/0')->json_has('/workers/2')->json_hasnt('/workers/3'); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok $links->{next}, 'has next page'; @@ -226,8 +215,7 @@ subtest 'server-side limit with pagination' => sub { }; subtest 'second page (prev link)' => sub { - $t->get_ok($links->{prev}{link})->status_is(200)->status_is(200)->json_has('/workers/0') - ->json_has('/workers/2')->json_hasnt('/workers/3'); + $t->get_ok($links->{prev}{link})->status_is(200)->status_is(200)->json_has('/workers/0')->json_has('/workers/2')->json_hasnt('/workers/3'); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok $links->{next}, 'has next page'; @@ -235,8 +223,7 @@ subtest 'server-side limit with pagination' => sub { }; subtest 'first page (first link)' => sub { - $t->get_ok($links->{first}{link})->status_is(200)->status_is(200)->json_has('/workers/0') - ->json_has('/workers/2')->json_hasnt('/workers/3'); + $t->get_ok($links->{first}{link})->status_is(200)->status_is(200)->json_has('/workers/0')->json_has('/workers/2')->json_hasnt('/workers/3'); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok $links->{next}, 'has next page'; diff --git a/t/api/02-assets.t b/t/api/02-assets.t index 15b32d2e3bd1..d540477ee592 100644 --- a/t/api/02-assets.t +++ b/t/api/02-assets.t @@ -113,10 +113,8 @@ subtest 'server-side limit has precedence over user-specified limit' => sub { subtest 'server-side limit with pagination' => sub { subtest 'input validation' => sub { - $t->get_ok('/api/v1/assets?limit=a')->status_is(400) - ->json_is({error_status => 400, error => 'Erroneous parameters (limit invalid)'}); - $t->get_ok('/api/v1/assets?offset=a')->status_is(400) - ->json_is({error_status => 400, error => 'Erroneous parameters (offset invalid)'}); + $t->get_ok('/api/v1/assets?limit=a')->status_is(400)->json_is({error_status => 400, error => 'Erroneous parameters (limit invalid)'}); + $t->get_ok('/api/v1/assets?offset=a')->status_is(400)->json_is({error_status => 400, error => 'Erroneous parameters (offset invalid)'}); }; subtest 'navigation with high limit' => sub { @@ -187,8 +185,8 @@ subtest 'server-side limit with pagination' => sub { }; subtest 'fourth page' => sub { - $t->get_ok($links->{next}{link})->status_is(200)->json_has('/assets/1')->json_hasnt('/assets/2') - ->json_like('/assets/0/name', qr/test-dvd-1\.iso/)->json_like('/assets/1/name', qr/test-dvd-2\.iso/); + $t->get_ok($links->{next}{link})->status_is(200)->json_has('/assets/1')->json_hasnt('/assets/2')->json_like('/assets/0/name', qr/test-dvd-1\.iso/) + ->json_like('/assets/1/name', qr/test-dvd-2\.iso/); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok !$links->{next}, 'no next page'; @@ -212,8 +210,7 @@ la; # test delete operation $t->delete_ok('/api/v1/assets/1a')->status_is(404, 'assert with invalid ID'); $t->delete_ok('/api/v1/assets/99')->status_is(404, 'asset does not exist'); -$t->delete_ok('/api/v1/assets/' . $listing->[0]->{id})->status_is(200, 'asset deleted') - ->json_is('/count' => 1, "one asset deleted"); +$t->delete_ok('/api/v1/assets/' . $listing->[0]->{id})->status_is(200, 'asset deleted')->json_is('/count' => 1, "one asset deleted"); $t->get_ok('/api/v1/assets/' . $listing->[0]->{id})->status_is(404, 'asset was deleted'); ok(!-e iso_path($iso1), 'iso file 1 has been removed'); @@ -231,10 +228,8 @@ $t->get_ok('/api/v1/assets/' . ($listing->[1]->{id} + 1))->status_is(200, 'third la; $t->post_ok('/api/v1/assets', form => {type => 'foo', name => $iso1})->status_is(400, 'invalid type is an error'); -$t->post_ok('/api/v1/assets', form => {type => 'iso', name => ''}) - ->status_is(400, 'posting asset with invalid name fails'); -$t->post_ok('/api/v1/assets', form => {type => 'iso', name => 'foo.iso'}) - ->status_is(400, 'registering non-existing asset fails'); +$t->post_ok('/api/v1/assets', form => {type => 'iso', name => ''})->status_is(400, 'posting asset with invalid name fails'); +$t->post_ok('/api/v1/assets', form => {type => 'iso', name => 'foo.iso'})->status_is(400, 'registering non-existing asset fails'); $t->get_ok('/api/v1/assets/iso')->status_is(404, 'getting asset without name is an error'); $t->delete_ok('/api/v1/assets/iso')->status_is(404, 'deleting without name is an error'); @@ -249,8 +244,7 @@ $t->post_ok('/api/v1/assets/cleanup')->status_is(200)->json_is('/status' => 'ok' is($gru_tasks->count, 1, 'gru task added') and is($gru_tasks->first->taskname, 'limit_assets', 'right gru task added'); is($gru->count_jobs(limit_assets => ['inactive']), 1, 'is_task_active returns 1 after task enqueued'); -$t->post_ok('/api/v1/assets/cleanup')->status_is(200)->json_is('/status' => 'ok', 'status ok') - ->json_is('/gru_id' => undef); +$t->post_ok('/api/v1/assets/cleanup')->status_is(200)->json_is('/status' => 'ok', 'status ok')->json_is('/gru_id' => undef); is($gru_tasks->count, 1, 'no further task if one was already enqueued'); # switch to operator (default client) and try some modifications diff --git a/t/api/02-iso-download.t b/t/api/02-iso-download.t index ec8d57701d3c..dfb60428e1d0 100644 --- a/t/api/02-iso-download.t +++ b/t/api/02-iso-download.t @@ -77,8 +77,7 @@ check_download_asset('existing HDD'); my %params = (DISTRI => 'opensuse', VERSION => '13.1', FLAVOR => 'DVD', ARCH => 'i586'); $rsp = schedule_iso($t, {%params, ISO_URL => 'http://localhost/nonexistent.iso'}); is($rsp->json->{count}, $expected_job_count, 'a regular ISO post creates the expected number of jobs'); -check_download_asset('non-existent ISO', - ['http://localhost/nonexistent.iso', [locate_asset('iso', 'nonexistent.iso', mustexist => 0)], 0]); +check_download_asset('non-existent ISO', ['http://localhost/nonexistent.iso', [locate_asset('iso', 'nonexistent.iso', mustexist => 0)], 0]); check_job_setting($t, $rsp, 'ISO', 'nonexistent.iso', 'parameter ISO is correctly set from ISO_URL'); # Schedule download and uncompression of a non-existing HDD @@ -90,8 +89,7 @@ check_job_setting($t, $rsp, 'HDD_1', 'nonexistent.hda', 'parameter HDD_1 correct # Schedule download of a non-existing ISO with a custom target name $rsp = schedule_iso($t, {%iso, ISO_URL => 'http://localhost/nonexistent2.iso', ISO => 'callitthis.iso'}); -check_download_asset('non-existent ISO (with custom name)', - ['http://localhost/nonexistent2.iso', [locate_asset('iso', 'callitthis.iso', mustexist => 0)], 0]); +check_download_asset('non-existent ISO (with custom name)', ['http://localhost/nonexistent2.iso', [locate_asset('iso', 'callitthis.iso', mustexist => 0)], 0]); check_job_setting($t, $rsp, 'ISO', 'callitthis.iso', 'parameter ISO is not overwritten when ISO_URL is set'); # Schedule download and uncompression of a non-existing kernel with a custom target name @@ -105,8 +103,7 @@ $rsp = schedule_iso( is($rsp->json->{count}, $expected_job_count, 'a regular ISO post creates the expected number of jobs'); check_download_asset('non-existent kernel (with uncompression, custom name', ['http://localhost/nonexistvmlinuz', [locate_asset('other', 'callitvmlinuz', mustexist => 0)], 1]); -check_job_setting($t, $rsp, 'KERNEL', 'callitvmlinuz', - 'parameter KERNEL is not overwritten when KERNEL_DECOMPRESS_URL is set'); +check_job_setting($t, $rsp, 'KERNEL', 'callitvmlinuz', 'parameter KERNEL is not overwritten when KERNEL_DECOMPRESS_URL is set'); # Using non-asset _URL does not create gru job and schedule jobs $rsp = schedule_iso($t, {%params, NO_ASSET_URL => 'http://localhost/nonexistent.iso'}); @@ -136,11 +133,7 @@ check_download_asset('arbitrary URL is ignored for download check'); # schedule an existent ISO against a repo to verify the ISO is registered and the repo is not $rsp = schedule_iso($t, {%iso, REPO_1 => 'http://open.qa/any-repo'}, 200); -is_deeply( - fetch_first_job($t, $rsp)->{assets}, - {iso => ['openSUSE-13.1-DVD-i586-Build0091-Media.iso']}, - 'ISO is scheduled' -); +is_deeply(fetch_first_job($t, $rsp)->{assets}, {iso => ['openSUSE-13.1-DVD-i586-Build0091-Media.iso']}, 'ISO is scheduled'); # Schedule an iso that triggers a gru that fails $rsp = schedule_iso($t, {%params, ISO_URL => 'http://localhost/failure.iso'}); @@ -194,15 +187,12 @@ subtest 'create one download task when there is HDD_1_URL in isos post command' is scalar(keys %$gru_task_ids), 1, 'only one download task was created'; my @value = values %$gru_task_ids; is scalar(@{$value[0]}), $expected_job_count, 'ten job were blocked by the same download task'; - check_download_asset('download asset was created', - ['http://localhost/test.qcow2', [locate_asset('hdd', 'test.qcow2', mustexist => 0)], 0]); + check_download_asset('download asset was created', ['http://localhost/test.qcow2', [locate_asset('hdd', 'test.qcow2', mustexist => 0)], 0]); }; subtest 'create many download tasks when many test suites have different _URL' => sub { - $test_suites->find({name => 'textmode'}) - ->settings->create({key => 'HDD_1_URL', value => 'http://localhost/test_textmode.qcow2'}); - $test_suites->find({name => 'server'}) - ->settings->create({key => 'HDD_1_URL', value => 'http://localhost/test_server.qcow2'}); + $test_suites->find({name => 'textmode'})->settings->create({key => 'HDD_1_URL', value => 'http://localhost/test_textmode.qcow2'}); + $test_suites->find({name => 'server'})->settings->create({key => 'HDD_1_URL', value => 'http://localhost/test_server.qcow2'}); $rsp = schedule_iso($t, {%iso, MACHINE => '64bit'}, 200); is $rsp->json->{count}, 6, 'six jobs have been scheduled'; my $gru_task_ids = get_gru_tasks($rsp->json->{ids}); @@ -246,8 +236,7 @@ subtest 'create one download task when test suites have different destinations' }; subtest 'download task only blocks the related job when test suites have different destinations' => sub { - $test_suites->find({name => $_}) - ->update_or_create_related('settings', {key => 'HDD_1_URL', value => 'http://localhost/test.qcow2'}) + $test_suites->find({name => $_})->update_or_create_related('settings', {key => 'HDD_1_URL', value => 'http://localhost/test.qcow2'}) for qw(textmode kde server); $rsp = schedule_iso($t, {%iso, MACHINE => '64bit'}, 200); is $rsp->json->{count}, 6, 'six jobs have been scheduled'; @@ -263,11 +252,7 @@ subtest 'placeholder expansions work with _URL-derived settings' => sub { $rsp = schedule_iso($t, $new_params, 200); is $rsp->json->{count}, 1, 'one job was scheduled'; my $expanderjob = get_job($rsp->json->{ids}->[0]); - is( - $expanderjob->{settings}->{FOOBAR}, - 'openSUSE-13.1-DVD-i586-Build0091-Media.iso', - '%ISO% in template is expanded by posted ISO_URL' - ); + is($expanderjob->{settings}->{FOOBAR}, 'openSUSE-13.1-DVD-i586-Build0091-Media.iso', '%ISO% in template is expanded by posted ISO_URL'); }; subtest 'test suite sets short asset setting to false value' => sub { diff --git a/t/api/02-iso-yaml.t b/t/api/02-iso-yaml.t index ee9ad2b4519e..3517a1719ee9 100644 --- a/t/api/02-iso-yaml.t +++ b/t/api/02-iso-yaml.t @@ -26,14 +26,12 @@ subtest 'schedule from yaml file: error cases' => sub { my $res = schedule_iso($t, \%args, 400); my $json = $res->json; like $json->{error}, - qr/Unable to load YAML:.*Could not open 'does-not-exist.yaml' for reading: No such file or directory/, - 'error when YAML file does not exist' + qr/Unable to load YAML:.*Could not open 'does-not-exist.yaml' for reading: No such file or directory/, 'error when YAML file does not exist' or diag explain $json; is $json->{count}, 0, 'no jobs are scheduled when loading YAML fails' or diag explain $json; $file = "$FindBin::Bin/../data/09-schedule_from_file_incomplete.yaml"; - my @expected_errors - = ('YAML validation failed:', 'machines: Expected object - got null', 'products: Expected object - got null'); + my @expected_errors = ('YAML validation failed:', 'machines: Expected object - got null', 'products: Expected object - got null'); my $expected_errors = join '.*', @expected_errors; %args = (%iso, GROUP_ID => '0', SCENARIO_DEFINITIONS_YAML_FILE => $file, TEST => 'autoyast_btrfs'); $res = schedule_iso($t, \%args, 400); @@ -65,13 +63,9 @@ subtest 'schedule from yaml file: case with machines/products and job dependenci my $child_job = $jobs->find($job_ids->[1]); is $child_job->TEST, 'autoyast_btrfs', 'correct child job was created'; my $child_job_settings = $child_job->settings_hash; - is $child_job_settings->{HDD_1}, - 'opensuse-13.1-i586-0091@aarch64-minimal_with_sdk0091_installed.qcow2', - 'settings of child job were handled correctly'; - ok !exists $parent_job_settings->{SCENARIO_DEFINITIONS_YAML_FILE}, - 'SCENARIO_DEFINITIONS_YAML_FILE does not end up as job setting (1)'; - ok !exists $child_job_settings->{SCENARIO_DEFINITIONS_YAML_FILE}, - 'SCENARIO_DEFINITIONS_YAML_FILE does not end up as job setting (2)'; + is $child_job_settings->{HDD_1}, 'opensuse-13.1-i586-0091@aarch64-minimal_with_sdk0091_installed.qcow2', 'settings of child job were handled correctly'; + ok !exists $parent_job_settings->{SCENARIO_DEFINITIONS_YAML_FILE}, 'SCENARIO_DEFINITIONS_YAML_FILE does not end up as job setting (1)'; + ok !exists $child_job_settings->{SCENARIO_DEFINITIONS_YAML_FILE}, 'SCENARIO_DEFINITIONS_YAML_FILE does not end up as job setting (2)'; my @settings = ($parent_job_settings, $child_job_settings); subtest 'settings from machine definition present' => sub { for my $job_settings (@settings) { @@ -91,8 +85,7 @@ subtest 'schedule from yaml file: case with machines/products and job dependenci } or diag explain \@settings; subtest 'worker class merged from different places' => sub { is $parent_job_settings->{WORKER_CLASS}, 'merged-with-machine-settings,qemu_aarch64', 'WORKER_CLASS (parent)'; - is $child_job_settings->{WORKER_CLASS}, 'job-specific-class,merged-with-machine-settings,qemu_aarch64', - 'WORKER_CLASS (child)'; + is $child_job_settings->{WORKER_CLASS}, 'job-specific-class,merged-with-machine-settings,qemu_aarch64', 'WORKER_CLASS (child)'; }; is_deeply $child_job->dependencies->{parents}->{Chained}, [$parent_job->id], 'the dependency job was created'; }; diff --git a/t/api/02-iso.t b/t/api/02-iso.t index a5b9f7aa1116..654016894d18 100644 --- a/t/api/02-iso.t +++ b/t/api/02-iso.t @@ -30,7 +30,7 @@ sub lj { return unless $ENV{HARNESS_IS_VERBOSE}; $t->get_ok('/api/v1/jobs')->status_is(200); # uncoverable statement my $jobs = $t->tx->res->json->{jobs}; # uncoverable statement - printf("%d %-10s %s (%s)\n", $_->{id}, $_->{state}, $_->{name}, $_->{priority}) for @$jobs; # uncoverable statement + printf("%d %-10s %s (%s)\n", $_->{id}, $_->{state}, $_->{name}, $_->{priority}) for @$jobs; # uncoverable statement } sub find_job ($jobs, $newids, $name, $machine) { @@ -89,8 +89,7 @@ subtest 'group filter and priority override' => sub { my $res = schedule_iso($t, {%iso, PRECEDENCE => 'original', _GROUP => 'invalid group name'}); is($res->json->{count}, 0, 'no jobs created if group invalid'); - $res = schedule_iso($t, - {%iso, PRECEDENCE => 'original', _GROUP => 'opensuse test', _FOO => 'bar', __FOO_URL => 'bar'}); + $res = schedule_iso($t, {%iso, PRECEDENCE => 'original', _GROUP => 'opensuse test', _FOO => 'bar', __FOO_URL => 'bar'}); is($res->json->{count}, 1, 'only one job created due to group filter'); my $job = $jobs->find($res->json->{ids}->[0]); is($job->priority, 42, 'prio from job template used'); @@ -164,8 +163,7 @@ subtest 'scheduled products added' => sub { ok(my $scheduled_job_id = $non_empty_result->{successful_job_ids}->[0], 'scheduled job ID present'); ok(my $scheduled_job = $jobs->find($scheduled_job_id), 'job actually scheduled'); is($scheduled_job->scheduled_product->id, $product_1_id, 'scheduled product assigned'); - is_deeply([map { $_->id } $product_1->jobs->all], - [$scheduled_job_id], 'relationship works also the other way around'); + is_deeply([map { $_->id } $product_1->jobs->all], [$scheduled_job_id], 'relationship works also the other way around'); subtest 'api for querying scheduled products' => sub { $t->get_ok("/api/v1/isos/$product_1_id?include_job_ids=1")->status_is(200); @@ -226,16 +224,8 @@ my $advanced_kde_32 = find_job(\@jobs, \@newids, 'advanced_kde', '32bit'); my $kde_32 = find_job(\@jobs, \@newids, 'kde', '32bit'); my $textmode_32 = find_job(\@jobs, \@newids, 'textmode', '32bit'); -is_deeply( - $client1_32->{parents}, - {Parallel => [$server_32->{id}], Chained => [], 'Directly chained' => []}, - "server_32 is only parent of client1_32" -); -is_deeply( - $client2_32->{parents}, - {Parallel => [$server_32->{id}], Chained => [], 'Directly chained' => []}, - "server_32 is only parent of client2_32" -); +is_deeply($client1_32->{parents}, {Parallel => [$server_32->{id}], Chained => [], 'Directly chained' => []}, "server_32 is only parent of client1_32"); +is_deeply($client2_32->{parents}, {Parallel => [$server_32->{id}], Chained => [], 'Directly chained' => []}, "server_32 is only parent of client2_32"); is_deeply($server_32->{parents}, {Parallel => [], Chained => [], 'Directly chained' => []}, "server_32 has no parents"); is($kde_32, undef, 'kde is not created for 32bit machine'); is($advanced_kde_32, undef, 'advanced_kde is not created for 32bit machine'); @@ -247,31 +237,18 @@ my $advanced_kde_64 = find_job(\@jobs, \@newids, 'advanced_kde', '64bit'); my $kde_64 = find_job(\@jobs, \@newids, 'kde', '64bit'); my $textmode_64 = find_job(\@jobs, \@newids, 'textmode', '64bit'); -is_deeply( - $client1_64->{parents}, - {Parallel => [$server_64->{id}], Chained => [], 'Directly chained' => []}, - "server_64 is only parent of client1_64" -); -is_deeply( - $client2_64->{parents}, - {Parallel => [$server_64->{id}], Chained => [], 'Directly chained' => []}, - "server_64 is only parent of client2_64" -); +is_deeply($client1_64->{parents}, {Parallel => [$server_64->{id}], Chained => [], 'Directly chained' => []}, "server_64 is only parent of client1_64"); +is_deeply($client2_64->{parents}, {Parallel => [$server_64->{id}], Chained => [], 'Directly chained' => []}, "server_64 is only parent of client2_64"); is_deeply($server_64->{parents}, {Parallel => [], Chained => [], 'Directly chained' => []}, "server_64 has no parents"); eq_set($advanced_kde_64->{parents}->{Parallel}, [], 'advanced_kde_64 has no parallel parents'); -eq_set( - $advanced_kde_64->{parents}->{Chained}, - [$kde_64->{id}, $textmode_64->{id}], - 'advanced_kde_64 has two chained parents' -); +eq_set($advanced_kde_64->{parents}->{Chained}, [$kde_64->{id}, $textmode_64->{id}], 'advanced_kde_64 has two chained parents'); is($server_32->{group_id}, 1001, 'server_32 part of opensuse group'); is($server_32->{priority}, 40, 'server_32 has priority according to job template'); is($server_64->{group_id}, 1001, 'server_64 part of opensuse group'); is($server_64->{priority}, 50, 'server_64 has default priority from job group'); -is($advanced_kde_32->{settings}->{PUBLISH_HDD_1}, - undef, 'variable expansion because kde is not created for 32 bit machine'); +is($advanced_kde_32->{settings}->{PUBLISH_HDD_1}, undef, 'variable expansion because kde is not created for 32 bit machine'); is_deeply( $advanced_kde_64->{settings}, { @@ -288,8 +265,7 @@ is_deeply( MACHINE => '64bit', NAME => '00099990-opensuse-13.1-DVD-i586-Build0091-advanced_kde@64bit', PRECEDENCE => 'original', - PUBLISH_HDD_1 => 'opensuse-13.1-i586-advanced_kde-qemu64.qcow2' - , # variable expansion (using variable from job template level as well) + PUBLISH_HDD_1 => 'opensuse-13.1-i586-advanced_kde-qemu64.qcow2', # variable expansion (using variable from job template level as well) QEMUCPU => 'qemu64', START_AFTER_TEST => 'kde,textmode', TEST => 'advanced_kde', @@ -460,11 +436,7 @@ subtest 'Catch multimachine cycles' => sub { my $res = schedule_iso($t, {%iso, _GROUP => 'opensuse test'}); is($res->json->{count}, 0, 'Cycle found'); - like( - $res->json->{failed}->[0]->{error_messages}->[0], - qr/There is a cycle in the dependencies of Algol-c/, - "Cycle reported" - ); + like($res->json->{failed}->[0]->{error_messages}->[0], qr/There is a cycle in the dependencies of Algol-c/, "Cycle reported"); $schema->txn_rollback; }; @@ -477,11 +449,7 @@ subtest 'Catch cycles in chained dependencies' => sub { my $res = schedule_iso($t, {%iso, _GROUP => 'opensuse test'}); is($res->json->{count}, 0, 'no jobs scheduled if cycle detected'); - like( - $res->json->{failed}->[0]->{error_messages}->[0], - qr/There is a cycle in the dependencies of chained-(a|b|c|d)/, - 'cycle reported' - ); + like($res->json->{failed}->[0]->{error_messages}->[0], qr/There is a cycle in the dependencies of chained-(a|b|c|d)/, 'cycle reported'); $schema->txn_rollback; }; @@ -554,7 +522,7 @@ subtest 'Handling different WORKER_CLASS in directly chained dependency chains' is($res->json->{count}, 0, 'none of the jobs has been scheduled'); like( $_->{error_messages}->[0], -qr/Worker class of chained-(c|d|e) \(bar\) does not match the worker class of its directly chained parent \(foo\)/, + qr/Worker class of chained-(c|d|e) \(bar\) does not match the worker class of its directly chained parent \(foo\)/, 'error reported' ) for @{$res->json->{failed}}; $schema->txn_rollback; @@ -563,10 +531,8 @@ qr/Worker class of chained-(c|d|e) \(bar\) does not match the worker class of it for my $machine_separator (qw(@ :)) { $schema->txn_begin; - subtest "Create dependency for jobs on different machines" - . " - dependency setting are correct (using machine separator '$machine_separator')" => sub { - $t->post_ok('/api/v1/machines', form => {name => '64bit-ipmi', backend => 'ipmi', 'settings[TEST]' => 'ipmi'}) - ->status_is(200); + subtest "Create dependency for jobs on different machines" . " - dependency setting are correct (using machine separator '$machine_separator')" => sub { + $t->post_ok('/api/v1/machines', form => {name => '64bit-ipmi', backend => 'ipmi', 'settings[TEST]' => 'ipmi'})->status_is(200); add_opensuse_test('supportserver1'); add_opensuse_test('supportserver2', MACHINE => ['64bit-ipmi']); add_opensuse_test( @@ -611,14 +577,13 @@ for my $machine_separator (qw(@ :)) { "test1_64 and test2_ipmi are the parents of test3" ) or diag explain $test4_64->{parents}; - }; + }; $schema->txn_rollback; } subtest 'Create dependency for jobs on different machines - best match and log error dependency' => sub { $schema->txn_begin; - $t->post_ok('/api/v1/machines', form => {name => 'powerpc', backend => 'qemu', 'settings[TEST]' => 'power'}) - ->status_is(200); + $t->post_ok('/api/v1/machines', form => {name => 'powerpc', backend => 'qemu', 'settings[TEST]' => 'power'})->status_is(200); add_opensuse_test('install_ltp', MACHINE => ['powerpc']); add_opensuse_test('use_ltp', START_AFTER_TEST => 'install_ltp', MACHINE => ['powerpc', '64bit']); @@ -643,11 +608,7 @@ subtest 'Create dependency for jobs on different machines - best match and log e qr/START_AFTER_TEST=install_ltp\@64bit not found - check for dependency typos and dependency cycles/, "install_ltp@64bit not exist, check for dependency typos" ); - is_deeply( - $use_ltp_power->{parents}, - {Parallel => [], Chained => [$install_ltp->{id}], 'Directly chained' => []}, - "install_ltp is parent of use_ltp_power" - ); + is_deeply($use_ltp_power->{parents}, {Parallel => [], Chained => [$install_ltp->{id}], 'Directly chained' => []}, "install_ltp is parent of use_ltp_power"); my $install_kde_64 = find_job(\@jobs, \@newids, 'install_kde', '64bit'); my $install_kde_power = find_job(\@jobs, \@newids, 'install_kde', 'powerpc'); @@ -671,8 +632,7 @@ subtest 'Create dependency for jobs on different machines - log error parents' = $schema->txn_begin; my @machines = qw(ppc ppc-6G ppc-1G ppc-2G s390x); for my $m (@machines) { - $t->post_ok('/api/v1/machines', form => {name => $m, backend => 'qemu', 'settings[TEST]' => 'test'}) - ->status_is(200); + $t->post_ok('/api/v1/machines', form => {name => $m, backend => 'qemu', 'settings[TEST]' => 'test'})->status_is(200); } add_opensuse_test('supportserver', MACHINE => ['ppc', '64bit', 's390x']); add_opensuse_test('server1', PARALLEL_WITH => 'supportserver@ppc', MACHINE => ['ppc-6G']); @@ -815,8 +775,7 @@ subtest 'circular reference' => sub { }, 400 ); - like($res->json->{error}, qr/The key (\w+) contains a circular reference, its value is %\w+%/, - 'circular reference'); + like($res->json->{error}, qr/The key (\w+) contains a circular reference, its value is %\w+%/, 'circular reference'); }; subtest '_SKIP_CHAINED_DEPS prevents scheduling parent tests' => sub { @@ -852,8 +811,7 @@ subtest '_SKIP_CHAINED_DEPS prevents scheduling parent tests' => sub { # schedule with _INCLULDE_CHILDREN as well; now also all nested chained children should be included my %expected_jobs = map { ("child_test_$_" => 1) } 1 .. 7; - $res = schedule_iso($t, - {%iso, _GROUP => 'opensuse test', TEST => 'child_test_1', _SKIP_CHAINED_DEPS => 1, _INCLUDE_CHILDREN => 1}); + $res = schedule_iso($t, {%iso, _GROUP => 'opensuse test', TEST => 'child_test_1', _SKIP_CHAINED_DEPS => 1, _INCLUDE_CHILDREN => 1}); is $res->json->{count}, 7, '7 jobs scheduled'; %created_jobs = map { $jobs->find($_)->settings_hash->{'TEST'} => 1 } @{$res->json->{ids}}; is_deeply \%created_jobs, \%expected_jobs, 'only parallel parent and (nested) children scheduled' @@ -964,11 +922,7 @@ subtest 'Expand specified variables when scheduling iso' => sub { $res = schedule_iso($t, {%iso, _GROUP_ID => '1002', BUILD => '176.6', MACHINE => '64bit'}, 200); is($res->json->{count}, 1, 'only the job template which machine is 64bit was scheduled'); my $result = $jobs->find($res->json->{ids}->[0])->settings_hash; - is( - $result->{HDD_1}, - 'opensuse-13.1-i586-176.6@64bit-minimal_with_sdk176.6_installed.qcow2', - 'the specified variables were expanded correctly' - ); + is($result->{HDD_1}, 'opensuse-13.1-i586-176.6@64bit-minimal_with_sdk176.6_installed.qcow2', 'the specified variables were expanded correctly'); is($result->{BACKEND}, 'qemu', 'the BACKEND was added to settings correctly'); is($result->{YAML_SCHEDULE}, 'foo@64bit-staging.yaml', 'the TEST was replaced correctly'); is($result->{TEST_SUITE_NAME}, 'foo', 'the TEST_SUITE_NAME was right'); diff --git a/t/api/03-auth.t b/t/api/03-auth.t index a0df67eea1fc..822a62ec0ded 100644 --- a/t/api/03-auth.t +++ b/t/api/03-auth.t @@ -182,28 +182,23 @@ subtest 'personal access token' => sub { $t->$userinfo('artie:ARTHURKEY01:EXCALIBUR')->delete_ok('/api/v1/assets/1')->status_is(404); # Valid access token (OpenID user) - $t->$userinfo('lance:LANCELOTKEY01:MANYPEOPLEKNOW')->post_ok('/api/v1/feature' => form => {version => 100}) - ->status_is(200); + $t->$userinfo('lance:LANCELOTKEY01:MANYPEOPLEKNOW')->post_ok('/api/v1/feature' => form => {version => 100})->status_is(200); # Invalid access token - $t->$userinfo('invalid:invalid')->delete_ok('/api/v1/assets/1')->status_is(403) - ->json_is({error => 'invalid personal access token'}); + $t->$userinfo('invalid:invalid')->delete_ok('/api/v1/assets/1')->status_is(403)->json_is({error => 'invalid personal access token'}); # Invalid username - $t->$userinfo('invalid:ARTHURKEY01:EXCALIBUR')->delete_ok('/api/v1/assets/1')->status_is(403) - ->json_is({error => 'invalid personal access token'}); + $t->$userinfo('invalid:ARTHURKEY01:EXCALIBUR')->delete_ok('/api/v1/assets/1')->status_is(403)->json_is({error => 'invalid personal access token'}); # Invalid key - $t->$userinfo('artie:INVALID:EXCALIBUR')->delete_ok('/api/v1/assets/1')->status_is(403) - ->json_is({error => 'invalid personal access token'}); + $t->$userinfo('artie:INVALID:EXCALIBUR')->delete_ok('/api/v1/assets/1')->status_is(403)->json_is({error => 'invalid personal access token'}); # Invalid secret - $t->$userinfo('artie:ARTHURKEY01:INVALID')->delete_ok('/api/v1/assets/1')->status_is(403) - ->json_is({error => 'invalid personal access token'}); + $t->$userinfo('artie:ARTHURKEY01:INVALID')->delete_ok('/api/v1/assets/1')->status_is(403)->json_is({error => 'invalid personal access token'}); # Invalid secret (OpenID user) - $t->$userinfo('lance:LANCELOTKEY01:INVALIDTOO')->post_ok('/api/v1/feature' => form => {version => 100}) - ->status_is(403)->json_is({error => 'invalid personal access token'}); + $t->$userinfo('lance:LANCELOTKEY01:INVALIDTOO')->post_ok('/api/v1/feature' => form => {version => 100})->status_is(403) + ->json_is({error => 'invalid personal access token'}); # Valid access token (again) $t->$userinfo('artie:ARTHURKEY01:EXCALIBUR')->delete_ok('/api/v1/assets/1')->status_is(404); @@ -227,8 +222,7 @@ subtest 'personal access token (with reverse proxy)' => sub { ->json_is({error => 'personal access token can only be used via HTTPS or from localhost'}); # HTTPS - $t->$forwarded('artie:ARTHURKEY01:EXCALIBUR', '192.168.2.1', 'https')->delete_ok('/api/v1/assets/1') - ->status_is(404); + $t->$forwarded('artie:ARTHURKEY01:EXCALIBUR', '192.168.2.1', 'https')->delete_ok('/api/v1/assets/1')->status_is(404); # localhost $t->$forwarded('artie:ARTHURKEY01:EXCALIBUR', '127.0.0.1', 'http')->delete_ok('/api/v1/assets/1')->status_is(404); diff --git a/t/api/04-jobs.t b/t/api/04-jobs.t index 732116d959d2..5f0f01ff2cff 100644 --- a/t/api/04-jobs.t +++ b/t/api/04-jobs.t @@ -147,18 +147,15 @@ subtest 'argument combinations' => sub { subtest 'server-side limit with pagination' => sub { subtest 'input validation' => sub { - $t->get_ok('/api/v1/jobs?limit=a')->status_is(400) - ->json_is({error_status => 400, error => 'Erroneous parameters (limit invalid)'}); - $t->get_ok('/api/v1/jobs?offset=a')->status_is(400) - ->json_is({error_status => 400, error => 'Erroneous parameters (offset invalid)'}); + $t->get_ok('/api/v1/jobs?limit=a')->status_is(400)->json_is({error_status => 400, error => 'Erroneous parameters (limit invalid)'}); + $t->get_ok('/api/v1/jobs?offset=a')->status_is(400)->json_is({error_status => 400, error => 'Erroneous parameters (offset invalid)'}); }; subtest 'navigation with limit' => sub { $t->get_ok('/api/v1/jobs?limit=5')->json_has('/jobs/4')->json_hasnt('/jobs/5'); $t->get_ok('/api/v1/jobs?limit=1')->json_has('/jobs/0')->json_hasnt('/jobs/1')->json_is('/jobs/0/id' => 99981); - $t->get_ok('/api/v1/jobs?limit=1&offset=1')->json_has('/jobs/0')->json_hasnt('/jobs/1') - ->json_is('/jobs/0/id' => 99963); + $t->get_ok('/api/v1/jobs?limit=1&offset=1')->json_has('/jobs/0')->json_hasnt('/jobs/1')->json_is('/jobs/0/id' => 99963); $t->get_ok('/api/v1/jobs?before=99928')->json_has('/jobs/3')->json_hasnt('/jobs/5'); $t->get_ok('/api/v1/jobs?after=99945')->json_has('/jobs/5')->json_hasnt('/jobs/6'); @@ -167,8 +164,8 @@ subtest 'server-side limit with pagination' => sub { my $links; subtest 'first page' => sub { - $t->get_ok('/api/v1/jobs?limit=5')->status_is(200)->json_is('/jobs/0/id' => 99947) - ->json_is('/jobs/3/id' => 99963)->json_is('/jobs/4/id' => 99981)->json_hasnt('/jobs/5'); + $t->get_ok('/api/v1/jobs?limit=5')->status_is(200)->json_is('/jobs/0/id' => 99947)->json_is('/jobs/3/id' => 99963)->json_is('/jobs/4/id' => 99981) + ->json_hasnt('/jobs/5'); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok $links->{next}, 'has next page'; @@ -176,8 +173,8 @@ subtest 'server-side limit with pagination' => sub { }; subtest 'second page' => sub { - $t->get_ok($links->{next}{link})->status_is(200)->json_is('/jobs/0/id' => 99939) - ->json_is('/jobs/3/id' => 99945)->json_is('/jobs/4/id' => 99946)->json_hasnt('/jobs/5'); + $t->get_ok($links->{next}{link})->status_is(200)->json_is('/jobs/0/id' => 99939)->json_is('/jobs/3/id' => 99945)->json_is('/jobs/4/id' => 99946) + ->json_hasnt('/jobs/5'); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok $links->{next}, 'has next page'; @@ -185,8 +182,8 @@ subtest 'server-side limit with pagination' => sub { }; subtest 'third page' => sub { - $t->get_ok($links->{next}{link})->status_is(200)->json_is('/jobs/0/id' => 99927) - ->json_is('/jobs/3/id' => 99937)->json_is('/jobs/4/id' => 99938)->json_hasnt('/jobs/5'); + $t->get_ok($links->{next}{link})->status_is(200)->json_is('/jobs/0/id' => 99927)->json_is('/jobs/3/id' => 99937)->json_is('/jobs/4/id' => 99938) + ->json_hasnt('/jobs/5'); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok $links->{next}, 'has next page'; @@ -194,8 +191,8 @@ subtest 'server-side limit with pagination' => sub { }; subtest 'first page (first link)' => sub { - $t->get_ok($links->{first}{link})->status_is(200)->json_is('/jobs/0/id' => 99947) - ->json_is('/jobs/3/id' => 99963)->json_is('/jobs/4/id' => 99981)->json_hasnt('/jobs/5'); + $t->get_ok($links->{first}{link})->status_is(200)->json_is('/jobs/0/id' => 99947)->json_is('/jobs/3/id' => 99963)->json_is('/jobs/4/id' => 99981) + ->json_hasnt('/jobs/5'); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok $links->{next}, 'has next page link'; @@ -273,44 +270,29 @@ subtest 'job overview' => sub { }; subtest 'jobs for job settings' => sub { - $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26102})->status_is(200) - ->json_is({jobs => []}); - $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '_TEST_ISSUES', list_value => 26103})->status_is(200) - ->json_is({jobs => []}); - $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_', list_value => 26103})->status_is(200) - ->json_is({jobs => []}); + $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26102})->status_is(200)->json_is({jobs => []}); + $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '_TEST_ISSUES', list_value => 26103})->status_is(200)->json_is({jobs => []}); + $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_', list_value => 26103})->status_is(200)->json_is({jobs => []}); $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '%test%', list_value => '%test%'})->status_is(400) ->json_is({error_status => 400, error => 'Erroneous parameters (key invalid, list_value invalid)'}); - $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26103})->status_is(200) - ->json_is({jobs => [99926]}); - $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26104})->status_is(200) - ->json_is({jobs => [99927]}); - $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26105})->status_is(200) - ->json_is({jobs => [99928, 99927]}); - $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26106})->status_is(200) - ->json_is({jobs => [99928, 99927]}); - $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26110})->status_is(200) - ->json_is({jobs => [99981]}); - - $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 261042})->status_is(200) - ->json_is({jobs => []}); - $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 2610})->status_is(200) - ->json_is({jobs => []}); - $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 2})->status_is(200) - ->json_is({jobs => []}); + $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26103})->status_is(200)->json_is({jobs => [99926]}); + $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26104})->status_is(200)->json_is({jobs => [99927]}); + $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26105})->status_is(200)->json_is({jobs => [99928, 99927]}); + $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26106})->status_is(200)->json_is({jobs => [99928, 99927]}); + $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26110})->status_is(200)->json_is({jobs => [99981]}); + + $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 261042})->status_is(200)->json_is({jobs => []}); + $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 2610})->status_is(200)->json_is({jobs => []}); + $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 2})->status_is(200)->json_is({jobs => []}); local $t->app->config->{misc_limits}{job_settings_max_recent_jobs} = 5; - $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26110})->status_is(200) - ->json_is({jobs => [99981]}); - $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26103})->status_is(200) - ->json_is({jobs => []}); + $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26110})->status_is(200)->json_is({jobs => [99981]}); + $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26103})->status_is(200)->json_is({jobs => []}); local $t->app->config->{misc_limits}{job_settings_max_recent_jobs} = 1000000000; - $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26110})->status_is(200) - ->json_is({jobs => [99981]}); - $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26103})->status_is(200) - ->json_is({jobs => [99926]}); + $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26110})->status_is(200)->json_is({jobs => [99981]}); + $t->get_ok('/api/v1/job_settings/jobs' => form => {key => '*_TEST_ISSUES', list_value => 26103})->status_is(200)->json_is({jobs => [99926]}); }; $schema->txn_begin; @@ -318,8 +300,7 @@ $schema->txn_begin; subtest 'restart jobs, error handling' => sub { $t->post_ok('/api/v1/jobs/restart', form => {jobs => [99981, 99963, 99946, 99945, 99927, 99939]})->status_is(200); $t->json_is( - '/errors/0' => - "Job 99939 misses the following mandatory assets: iso/openSUSE-Factory-DVD-x86_64-Build0048-Media.iso\n" + '/errors/0' => "Job 99939 misses the following mandatory assets: iso/openSUSE-Factory-DVD-x86_64-Build0048-Media.iso\n" . 'Ensure to provide mandatory assets and/or force retriggering if necessary.', 'error for missing asset of 99939' ); @@ -349,8 +330,7 @@ subtest 'prevent restarting parents' => sub { }); # restart the two jobs 99963 and 99938; one has a parallel parent (99961) and one a directly chained parent (99937) $t->post_ok('/api/v1/jobs/restart?force=1&skip_parents=1', form => {jobs => [99963, 99938]})->status_is(200); - $t->json_is('/result' => [{99938 => 99985}, {99963 => 99986}], 'response') - ->or(sub (@) { diag explain $t->tx->res->json }); + $t->json_is('/result' => [{99938 => 99985}, {99963 => 99986}], 'response')->or(sub (@) { diag explain $t->tx->res->json }); # check whether jobs have been restarted but not their parents isnt($jobs->find(99963)->clone_id, undef, 'job with parallel parent has been cloned'); isnt($jobs->find(99938)->clone_id, undef, 'job with directly chained parent has been cloned'); @@ -361,11 +341,9 @@ subtest 'prevent restarting parents' => sub { $schema->txn_rollback; subtest 'restart jobs (forced)' => sub { - $t->post_ok('/api/v1/jobs/restart?force=1', form => {jobs => [99981, 99963, 99946, 99945, 99927, 99939]}) - ->status_is(200); + $t->post_ok('/api/v1/jobs/restart?force=1', form => {jobs => [99981, 99963, 99946, 99945, 99927, 99939]})->status_is(200); $t->json_is( - '/warnings/0' => - "Job 99939 misses the following mandatory assets: iso/openSUSE-Factory-DVD-x86_64-Build0048-Media.iso\n" + '/warnings/0' => "Job 99939 misses the following mandatory assets: iso/openSUSE-Factory-DVD-x86_64-Build0048-Media.iso\n" . 'Ensure to provide mandatory assets and/or force retriggering if necessary.', 'warning for missing asset' ); @@ -440,8 +418,7 @@ close($fh); subtest 'upload video' => sub { $rp = "$tempdir/openqa/testresults/00099/00099963-opensuse-13.1-DVD-x86_64-Build0091-kde/video.ogv"; - $t->post_ok('/api/v1/jobs/99963/artefact' => form => {file => {file => $filename, filename => 'video.ogv'}}) - ->status_is(200); + $t->post_ok('/api/v1/jobs/99963/artefact' => form => {file => {file => $filename, filename => 'video.ogv'}})->status_is(200); ok(-e $rp, 'video exist after') and is($jobs->find(99963)->result_size, $expected_result_size += -s $rp, 'video size taken into account'); @@ -450,9 +427,7 @@ subtest 'upload video' => sub { subtest 'upload "ulog" file' => sub { $rp = "$tempdir/openqa/testresults/00099/00099963-opensuse-13.1-DVD-x86_64-Build0091-kde/ulogs/y2logs.tar.bz2"; - $t->post_ok( - '/api/v1/jobs/99963/artefact' => form => {file => {file => $filename, filename => 'y2logs.tar.bz2'}, ulog => 1}) - ->status_is(200); + $t->post_ok('/api/v1/jobs/99963/artefact' => form => {file => {file => $filename, filename => 'y2logs.tar.bz2'}, ulog => 1})->status_is(200); $t->content_is('OK'); ok(-e $rp, 'logs exist after') and is($jobs->find(99963)->result_size, $expected_result_size += -s $rp, 'log size taken into account'); @@ -475,8 +450,7 @@ subtest 'upload screenshot' => sub { subtest 'upload asset: fails without chunks' => sub { $rp = "$tempdir/openqa/share/factory/hdd/hdd_image.qcow2"; - $t->post_ok('/api/v1/jobs/99963/artefact' => form => - {file => {file => $filename, filename => 'hdd_image.qcow2'}, asset => 'public'})->status_is(500); + $t->post_ok('/api/v1/jobs/99963/artefact' => form => {file => {file => $filename, filename => 'hdd_image.qcow2'}, asset => 'public'})->status_is(500); $t->json_like('/error' => qr/Failed receiving asset/); }; @@ -490,8 +464,8 @@ subtest 'upload asset: successful chunk upload' => sub { sub { $_->prepare; my $chunk_asset = Mojo::Asset::Memory->new->add_chunk($_->serialize); - $t->post_ok('/api/v1/jobs/99963/artefact' => form => - {file => {file => $chunk_asset, filename => 'hdd_image.qcow2'}, asset => 'public'})->status_is(200); + $t->post_ok('/api/v1/jobs/99963/artefact' => form => {file => {file => $chunk_asset, filename => 'hdd_image.qcow2'}, asset => 'public'}) + ->status_is(200); $t->json_is({status => 'ok'}); ok(-d $chunkdir, 'Chunk directory exists') unless $_->is_last; $_->content(\undef); @@ -511,8 +485,7 @@ subtest 'Test failure - if chunks are broken' => sub { $_->prepare; $_->content(int(rand(99999))); my $chunk_asset = Mojo::Asset::Memory->new->add_chunk($_->serialize); - $t->post_ok('/api/v1/jobs/99963/artefact' => form => - {file => {file => $chunk_asset, filename => 'hdd_image.qcow2'}, asset => 'public'}); + $t->post_ok('/api/v1/jobs/99963/artefact' => form => {file => {file => $chunk_asset, filename => 'hdd_image.qcow2'}, asset => 'public'}); $t->json_like('/error' => qr/Can't verify written data from chunk/) unless $_->is_last(); ok(!-d $chunkdir, 'Chunk directory does not exists') if $_->is_last; ok((-e path($chunkdir, 'hdd_image.qcow2')), 'Chunk is there') unless $_->is_last; @@ -532,8 +505,7 @@ subtest 'last chunk is broken' => sub { $_->content(int(rand(99999))) if $_->is_last; $_->prepare; my $chunk_asset = Mojo::Asset::Memory->new->add_chunk($_->serialize); - $t->post_ok('/api/v1/jobs/99963/artefact' => form => - {file => {file => $chunk_asset, filename => 'hdd_image.qcow2'}, asset => 'public'}); + $t->post_ok('/api/v1/jobs/99963/artefact' => form => {file => {file => $chunk_asset, filename => 'hdd_image.qcow2'}, asset => 'public'}); $t->json_is('/error' => undef) unless $_->is_last(); $t->json_like('/error', qr/Checksum mismatch expected/) if $_->is_last; ok(!-d $chunkdir, 'Chunk directory does not exist') if $_->is_last; @@ -550,13 +522,11 @@ subtest 'Failed upload, public assets' => sub { $first_chunk->prepare; my $chunk_asset = Mojo::Asset::Memory->new->add_chunk($first_chunk->serialize); - $t->post_ok('/api/v1/jobs/99963/artefact' => form => - {file => {file => $chunk_asset, filename => 'hdd_image.qcow2'}, asset => 'public'}); + $t->post_ok('/api/v1/jobs/99963/artefact' => form => {file => {file => $chunk_asset, filename => 'hdd_image.qcow2'}, asset => 'public'}); $t->json_is('/status' => 'ok'); ok(-d $chunkdir, 'Chunk directory exists'); - $t->post_ok('/api/v1/jobs/99963/upload_state' => form => - {filename => 'hdd_image.qcow2', scope => 'public', state => 'fail'}); + $t->post_ok('/api/v1/jobs/99963/upload_state' => form => {filename => 'hdd_image.qcow2', scope => 'public', state => 'fail'}); ok(!-d $chunkdir, 'Chunk directory was removed'); ok((!-e path($chunkdir, $first_chunk->index)), 'Chunk was removed'); }; @@ -570,8 +540,7 @@ subtest 'Failed upload, private assets' => sub { $first_chunk->prepare; my $chunk_asset = Mojo::Asset::Memory->new->add_chunk($first_chunk->serialize); - $t->post_ok('/api/v1/jobs/99963/artefact' => form => - {file => {file => $chunk_asset, filename => 'hdd_image.qcow2'}, asset => 'private'}); + $t->post_ok('/api/v1/jobs/99963/artefact' => form => {file => {file => $chunk_asset, filename => 'hdd_image.qcow2'}, asset => 'private'}); $t->json_is('/status' => 'ok'); ok(-d $chunkdir, 'Chunk directory exists'); @@ -608,8 +577,8 @@ subtest 'Chunks uploaded correctly, private asset registered and associated with sub { $_->prepare; my $chunk_asset = Mojo::Asset::Memory->new->add_chunk($_->serialize); - $t->post_ok('/api/v1/jobs/99963/artefact' => form => - {file => {file => $chunk_asset, filename => 'hdd_image.qcow2'}, asset => 'private'})->status_is(200); + $t->post_ok('/api/v1/jobs/99963/artefact' => form => {file => {file => $chunk_asset, filename => 'hdd_image.qcow2'}, asset => 'private'}) + ->status_is(200); $t->json_is({status => 'ok'}); ok(-d $chunkdir, 'Chunk directory exists') unless $_->is_last; }); @@ -619,8 +588,7 @@ subtest 'Chunks uploaded correctly, private asset registered and associated with # check whether private asset is registered and correctly associated with the parent and child job my @expected_assets = (qw(00099963-hdd_image.qcow2 openSUSE-13.1-DVD-x86_64-Build0091-Media.iso)); - $t->get_ok('/api/v1/assets/hdd/00099963-hdd_image.qcow2')->status_is(200) - ->json_is('/name' => '00099963-hdd_image.qcow2', 'asset is registered'); + $t->get_ok('/api/v1/assets/hdd/00099963-hdd_image.qcow2')->status_is(200)->json_is('/name' => '00099963-hdd_image.qcow2', 'asset is registered'); is_deeply _asset_names($parent_job), \@expected_assets, 'asset associated with job it has been created by'; pop @expected_assets; # child only requires hdd is_deeply _asset_names($child_job), \@expected_assets, 'asset associated with job supposed to use it'; @@ -636,8 +604,7 @@ subtest 'Tiny chunks, private assets' => sub { $first_chunk->prepare; my $chunk_asset = Mojo::Asset::Memory->new->add_chunk($first_chunk->serialize); - $t->post_ok('/api/v1/jobs/99963/artefact' => form => - {file => {file => $chunk_asset, filename => 'new_ltp_result_array.json'}, asset => 'other'}); + $t->post_ok('/api/v1/jobs/99963/artefact' => form => {file => {file => $chunk_asset, filename => 'new_ltp_result_array.json'}, asset => 'other'}); $t->json_is('/status' => 'ok'); ok(!-d $chunkdir, 'Chunk directory does not exist'); @@ -740,8 +707,7 @@ subtest 'update job status' => sub { $job->modules->create({name => 'bar_module', category => 'selftests', script => 'bar_module.pm'}); $t->post_ok(@post_args)->status_is(200, 'result upload for existing module succeeds'); my $response = $t->tx->res->json; - my %expected_response - = (job_result => 'failed', known_files => \@known_files, known_images => \@known_images, result => 1); + my %expected_response = (job_result => 'failed', known_files => \@known_files, known_images => \@known_images, result => 1); is_deeply($response, \%expected_response, 'response as expected; only the known images and files returned') or diag explain $response; # note: The arrays are supposed to be sorted so it is fine to assume a fix order here. @@ -755,8 +721,7 @@ subtest 'update job status' => sub { combined_like { $t->post_ok('/api/v1/jobs/99764/status', json => {})->status_is(400) } - qr/Got status update for job 99764 but does not contain a worker id!/, - 'status update without worker ID rejected'; + qr/Got status update for job 99764 but does not contain a worker id!/, 'status update without worker ID rejected'; combined_like { $t->post_ok('/api/v1/jobs/99963/status', json => {status => {worker_id => 999999}})->status_is(400) } @@ -773,7 +738,7 @@ subtest 'update job status' => sub { combined_like { $t->post_ok('/api/v1/jobs/99963/status', json => {status => {worker_id => 999999}})->status_is(400) } -qr/Got status update for job 99963 with unexpected worker ID 999999 \(expected no updates anymore, job is done with result incomplete\)/, + qr/Got status update for job 99963 with unexpected worker ID 999999 \(expected no updates anymore, job is done with result incomplete\)/, 'status update for job that is already considered done rejected'; }; @@ -781,34 +746,24 @@ qr/Got status update for job 99963 with unexpected worker ID 999999 \(expected n }; subtest 'get job status' => sub { - $t->get_ok('/api/v1/experimental/jobs/80000/status')->status_is(200)->json_is('/id' => 80000, 'id present') - ->json_is('/state' => 'done', 'status done')->json_is('/result' => 'passed', 'result passed') - ->json_is('/blocked_by_id' => undef, 'blocked_by_id undef'); - $t->get_ok('/api/v1/experimental/jobs/999999999/status')->status_is(404) - ->json_is('/error_status' => 404, 'Status code correct')->json_is('/error' => 'Job does not exist'); + $t->get_ok('/api/v1/experimental/jobs/80000/status')->status_is(200)->json_is('/id' => 80000, 'id present')->json_is('/state' => 'done', 'status done') + ->json_is('/result' => 'passed', 'result passed')->json_is('/blocked_by_id' => undef, 'blocked_by_id undef'); + $t->get_ok('/api/v1/experimental/jobs/999999999/status')->status_is(404)->json_is('/error_status' => 404, 'Status code correct') + ->json_is('/error' => 'Job does not exist'); }; subtest 'cancel job' => sub { $t->post_ok('/api/v1/jobs/99963/cancel')->status_is(200); - is_deeply( - OpenQA::Test::Case::find_most_recent_event($schema, 'job_cancel'), - {id => 99963, reason => undef}, - 'Cancellation was logged correctly' - ); + is_deeply(OpenQA::Test::Case::find_most_recent_event($schema, 'job_cancel'), {id => 99963, reason => undef}, 'Cancellation was logged correctly'); $t->post_ok('/api/v1/jobs/99963/cancel?reason=Undecided')->status_is(200); - is_deeply( - OpenQA::Test::Case::find_most_recent_event($schema, 'job_cancel'), - {id => 99963, reason => 'Undecided'}, - 'Cancellation was logged with reason' - ); + is_deeply(OpenQA::Test::Case::find_most_recent_event($schema, 'job_cancel'), {id => 99963, reason => 'Undecided'}, 'Cancellation was logged with reason'); my $form = {TEST => 'spam_eggs'}; $t->post_ok('/api/v1/jobs', form => $form)->status_is(200); $t->post_ok('/api/v1/jobs/cancel', form => $form)->status_is(200); is($t->tx->res->json->{result}, 1, 'number of affected jobs returned') or diag explain $t->tx->res->json; - is_deeply(OpenQA::Test::Case::find_most_recent_event($schema, 'job_cancel_by_settings'), - $form, 'Cancellation was logged with settings'); + is_deeply(OpenQA::Test::Case::find_most_recent_event($schema, 'job_cancel_by_settings'), $form, 'Cancellation was logged with settings'); }; # helper to find a build in the JSON results @@ -906,8 +861,7 @@ subtest 'WORKER_CLASS correctly assigned when posting job' => sub { my $id; $t->post_ok('/api/v1/jobs', form => \%jobs_post_params)->status_is(200); ok $id = $t->tx->res->json->{id}, 'id returned (0)' or diag explain $t->tx->res->json; - is $jobs->find($id)->settings_hash->{WORKER_CLASS}, 'qemu_x86_64', - 'default WORKER_CLASS assigned (with arch fallback)'; + is $jobs->find($id)->settings_hash->{WORKER_CLASS}, 'qemu_x86_64', 'default WORKER_CLASS assigned (with arch fallback)'; $jobs_post_params{ARCH} = 'aarch64'; $t->post_ok('/api/v1/jobs', form => \%jobs_post_params)->status_is(200); @@ -986,8 +940,7 @@ subtest 'posting multiple jobs at once' => sub { ok my $root_job = $jobs->find($root_job_id), 'root job actually exists'; ok my $follow_up_job_1 = $jobs->find($follow_up_job_1_id), 'follow-up job 1 job actually exists'; ok my $follow_up_job_2 = $jobs->find($follow_up_job_2_id), 'follow-up job 2 job actually exists'; - my @d = map { $_ => [] } - qw(chained_children chained_parents directly_chained_children directly_chained_parents parallel_children parallel_parents); + my @d = map { $_ => [] } qw(chained_children chained_parents directly_chained_children directly_chained_parents parallel_children parallel_parents); push @d, ok => 0, state => SCHEDULED; is $root_job->TEST, 'root-job', "name of root job ($root_job_id) correct"; is $follow_up_job_1->TEST, 'follow-up-job-1', "name of follow-up 1 ($follow_up_job_1_id) correct"; @@ -1077,11 +1030,7 @@ subtest 'handle settings when posting job' => sub { subtest 'circular reference settings' => sub { $new_jobs_post_params{BUILD} = '%BUILD_SDK%'; $t->post_ok('/api/v1/jobs', form => \%new_jobs_post_params)->status_is(400); - like( - $t->tx->res->json->{error}, - qr/The key (\w+) contains a circular reference, its value is %\w+%/, - 'circular reference exit successfully' - ); + like($t->tx->res->json->{error}, qr/The key (\w+) contains a circular reference, its value is %\w+%/, 'circular reference exit successfully'); }; }; @@ -1384,8 +1333,7 @@ subtest 'Parse extra tests results - junit' => sub { ok !-e path($basedir, $fname), 'file was not uploaded'; ok $parser->tests->size > 2, 'Tests parsed correctly'; - junit_ok $parser, $jobid, $basedir, - ['details-1_running_upstream_tests.json', 'tests-systemd-9_post-tests_audits-3.txt']; + junit_ok $parser, $jobid, $basedir, ['details-1_running_upstream_tests.json', 'tests-systemd-9_post-tests_audits-3.txt']; }; subtest 'create job failed when PUBLISH_HDD_1 is invalid' => sub { @@ -1405,11 +1353,7 @@ subtest 'show job modules execution time' => sub { my @testresults = sort { $a->{name} cmp $b->{name} } @{$t->tx->res->json->{job}->{testresults}}; my %execution_times = map { $_->{name} => $_->{execution_time} } @testresults; for my $module_name (keys %modules_execution_time) { - is( - $execution_times{$module_name}, - $modules_execution_time{$module_name}, - $module_name . ' execution time showed correctly' - ); + is($execution_times{$module_name}, $modules_execution_time{$module_name}, $module_name . ' execution time showed correctly'); } is(scalar(@{$testresults[0]->{details}}), 2, 'the old format json file parsed correctly'); is($testresults[0]->{execution_time}, undef, 'the old format json file does not include execution_time'); @@ -1500,8 +1444,7 @@ subtest 'marking job as done' => sub { $jobs->find(99961)->update({reason => undef}); $jobs->find(99961)->update({clone_id => undef}); $t->get_ok('/api/v1/jobs/99961')->status_is(200); - $t->post_ok( - Mojo::URL->new('/api/v1/jobs/99961/set_done')->query({result => INCOMPLETE, reason => $incomplete_reason})); + $t->post_ok(Mojo::URL->new('/api/v1/jobs/99961/set_done')->query({result => INCOMPLETE, reason => $incomplete_reason})); perform_minion_jobs($t->app->minion); $t->get_ok('/api/v1/jobs/99961')->status_is(200); $t->json_is('/job/result' => INCOMPLETE, 'the job status is correct'); @@ -1515,10 +1458,7 @@ subtest 'handle FOO_URL' => sub { { name => 'handle_foo_url', description => '', - settings => [ - {key => 'ISO_1_URL', value => 'http://localhost/foo.iso'}, - {key => 'HDD_1', value => 'hdd@%MACHINE%.qcow2'} - ], + settings => [{key => 'ISO_1_URL', value => 'http://localhost/foo.iso'}, {key => 'HDD_1', value => 'hdd@%MACHINE%.qcow2'}], }); my $params = { TEST => 'handle_foo_url', diff --git a/t/api/05-machines.t b/t/api/05-machines.t index bf4f7c20fe23..3f57732363ac 100644 --- a/t/api/05-machines.t +++ b/t/api/05-machines.t @@ -59,35 +59,25 @@ is_deeply( ) || diag explain $t->tx->res->json; -$t->post_ok('/api/v1/machines', form => {name => "testmachine"})->status_is(400) - ->json_is('/error', 'Missing parameter: backend'); -$t->post_ok('/api/v1/machines', form => {backend => "kde/usb"})->status_is(400) - ->json_is('/error', 'Missing parameter: name'); +$t->post_ok('/api/v1/machines', form => {name => "testmachine"})->status_is(400)->json_is('/error', 'Missing parameter: backend'); +$t->post_ok('/api/v1/machines', form => {backend => "kde/usb"})->status_is(400)->json_is('/error', 'Missing parameter: name'); $t->post_ok('/api/v1/machines', form => {})->status_is(400)->json_is('/error', 'Missing parameter: backend, name'); -$t->post_ok('/api/v1/machines', - form => {name => "testmachine", backend => "qemu", "settings[TEST]" => "val1", "settings[TEST2]" => "val1"}) - ->status_is(200); +$t->post_ok('/api/v1/machines', form => {name => "testmachine", backend => "qemu", "settings[TEST]" => "val1", "settings[TEST2]" => "val1"})->status_is(200); my $machine_id = $t->tx->res->json->{id}; my $event = OpenQA::Test::Case::find_most_recent_event($t->app->schema, 'table_create'); -is_deeply( - [sort keys %$event], - ['backend', 'description', 'id', 'name', 'settings', 'table'], - 'machine event was logged correctly' -); +is_deeply([sort keys %$event], ['backend', 'description', 'id', 'name', 'settings', 'table'], 'machine event was logged correctly'); $t->get_ok('/api/v1/machines', form => {name => "testmachine"})->status_is(200); is($t->tx->res->json->{Machines}->[0]->{id}, $machine_id); -$t->post_ok('/api/v1/machines', - form => {name => "testmachineQ", backend => "qemu", "settings[TEST]" => "'v'al1", "settings[TEST2]" => "va'l\'1"}) +$t->post_ok('/api/v1/machines', form => {name => "testmachineQ", backend => "qemu", "settings[TEST]" => "'v'al1", "settings[TEST2]" => "va'l\'1"}) ->status_is(200); $t->get_ok('/api/v1/machines', form => {name => "testmachineQ"})->status_is(200); is($t->tx->res->json->{Machines}->[0]->{settings}->[0]->{value}, "'v'al1"); is($t->tx->res->json->{Machines}->[0]->{settings}->[1]->{value}, "va'l\'1"); -$t->post_ok('/api/v1/machines', form => {name => "testmachineZ", backend => "qemu", "settings[TE'S\'T]" => "'v'al1"}) - ->status_is(200); +$t->post_ok('/api/v1/machines', form => {name => "testmachineZ", backend => "qemu", "settings[TE'S\'T]" => "'v'al1"})->status_is(200); $t->get_ok('/api/v1/machines', form => {name => "testmachineQ"})->status_is(200); is($t->tx->res->json->{Machines}->[0]->{settings}->[0]->{key}, "TEST"); is($t->tx->res->json->{Machines}->[0]->{settings}->[0]->{value}, "'v'al1"); @@ -116,8 +106,7 @@ is_deeply( "Add machine" ) || diag explain $t->tx->res->json; -$t->put_ok("/api/v1/machines/$machine_id", - form => {name => "testmachine", backend => "qemu", "settings[TEST2]" => "val1"})->status_is(200); +$t->put_ok("/api/v1/machines/$machine_id", form => {name => "testmachine", backend => "qemu", "settings[TEST2]" => "val1"})->status_is(200); $t->get_ok("/api/v1/machines/$machine_id")->status_is(200); is_deeply( @@ -203,11 +192,8 @@ subtest 'trim whitespace characters' => sub { # switch to operator (default client) and try some modifications client($t); -$t->post_ok('/api/v1/machines', - form => {name => "testmachine", backend => "qemu", "settings[TEST]" => "val1", "settings[TEST2]" => "val1"}) - ->status_is(403); -$t->put_ok("/api/v1/machines/$machine_id", - form => {name => "testmachine", backend => "qemu", "settings[TEST2]" => "val1"})->status_is(403); +$t->post_ok('/api/v1/machines', form => {name => "testmachine", backend => "qemu", "settings[TEST]" => "val1", "settings[TEST2]" => "val1"})->status_is(403); +$t->put_ok("/api/v1/machines/$machine_id", form => {name => "testmachine", backend => "qemu", "settings[TEST2]" => "val1"})->status_is(403); $t->delete_ok("/api/v1/machines/$machine_id")->status_is(403); subtest 'server-side limit has precedence over user-specified limit' => sub { @@ -233,10 +219,8 @@ subtest 'server-side limit has precedence over user-specified limit' => sub { subtest 'server-side limit with pagination' => sub { subtest 'input validation' => sub { - $t->get_ok('/api/v1/machines?limit=a')->status_is(400) - ->json_is({error_status => 400, error => 'Erroneous parameters (limit invalid)'}); - $t->get_ok('/api/v1/machines?offset=a')->status_is(400) - ->json_is({error_status => 400, error => 'Erroneous parameters (offset invalid)'}); + $t->get_ok('/api/v1/machines?limit=a')->status_is(400)->json_is({error_status => 400, error => 'Erroneous parameters (limit invalid)'}); + $t->get_ok('/api/v1/machines?offset=a')->status_is(400)->json_is({error_status => 400, error => 'Erroneous parameters (offset invalid)'}); }; subtest 'navigation with high limit' => sub { @@ -287,8 +271,8 @@ subtest 'server-side limit with pagination' => sub { }; subtest 'second page' => sub { - $t->get_ok($links->{next}{link})->status_is(200)->json_has('/Machines/1')->json_hasnt('/Machines/2') - ->json_like('/Machines/0/name', qr/Laptop_64/)->json_like('/Machines/1/name', qr/testmachineQ/); + $t->get_ok($links->{next}{link})->status_is(200)->json_has('/Machines/1')->json_hasnt('/Machines/2')->json_like('/Machines/0/name', qr/Laptop_64/) + ->json_like('/Machines/1/name', qr/testmachineQ/); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok $links->{next}, 'has next page'; @@ -304,8 +288,8 @@ subtest 'server-side limit with pagination' => sub { }; subtest 'first page (first link)' => sub { - $t->get_ok($links->{first}{link})->status_is(200)->json_has('/Machines/1')->json_hasnt('/Machines/2') - ->json_like('/Machines/0/name', qr/32bit/)->json_like('/Machines/1/name', qr/64bit/); + $t->get_ok($links->{first}{link})->status_is(200)->json_has('/Machines/1')->json_hasnt('/Machines/2')->json_like('/Machines/0/name', qr/32bit/) + ->json_like('/Machines/1/name', qr/64bit/); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok $links->{next}, 'has next page'; diff --git a/t/api/06-products.t b/t/api/06-products.t index cdc95afa10c5..ed22201da784 100644 --- a/t/api/06-products.t +++ b/t/api/06-products.t @@ -83,14 +83,9 @@ $t->post_ok( })->status_is(200); my $product_id = $t->tx->res->json->{id}; my $event = OpenQA::Test::Case::find_most_recent_event($t->app->schema, 'table_create'); -is_deeply( - [sort keys %$event], - ['arch', 'description', 'distri', 'flavor', 'id', 'name', 'settings', 'table', 'version'], - 'product event was logged correctly' -); +is_deeply([sort keys %$event], ['arch', 'description', 'distri', 'flavor', 'id', 'name', 'settings', 'table', 'version'], 'product event was logged correctly'); -$t->post_ok('/api/v1/products', form => {arch => "x86_64", distri => "opensuse", flavor => "DVD", version => 13.2}) - ->status_is(400); #already exists +$t->post_ok('/api/v1/products', form => {arch => "x86_64", distri => "opensuse", flavor => "DVD", version => 13.2})->status_is(400); #already exists $t->get_ok("/api/v1/products/$product_id")->status_is(200); is_deeply( @@ -118,8 +113,7 @@ is_deeply( "Add product" ) || diag explain $t->tx->res->json; -$t->put_ok("/api/v1/products/$product_id", - form => {arch => "x86_64", distri => "opensuse", flavor => "DVD", version => 13.2, "settings[TEST2]" => "val1"}) +$t->put_ok("/api/v1/products/$product_id", form => {arch => "x86_64", distri => "opensuse", flavor => "DVD", version => 13.2, "settings[TEST2]" => "val1"}) ->status_is(200); $t->get_ok("/api/v1/products/$product_id")->status_is(200); @@ -151,8 +145,7 @@ subtest 'server-side limit has precedence over user-specified limit' => sub { #create test-products for my $i (2 .. 4) { - $t->post_ok('/api/v1/products', - form => {arch => "x86_64", distri => "opensuse-$i", flavor => "DVD", version => 13.2})->status_is(200); + $t->post_ok('/api/v1/products', form => {arch => "x86_64", distri => "opensuse-$i", flavor => "DVD", version => 13.2})->status_is(200); } $t->get_ok('/api/v1/products?limit=10', 'query with exceeding user-specified limit for products')->status_is(200); @@ -173,10 +166,8 @@ subtest 'server-side limit has precedence over user-specified limit' => sub { subtest 'server-side limit with pagination' => sub { subtest 'input validation' => sub { - $t->get_ok('/api/v1/products?limit=a')->status_is(400) - ->json_is({error_status => 400, error => 'Erroneous parameters (limit invalid)'}); - $t->get_ok('/api/v1/products?offset=a')->status_is(400) - ->json_is({error_status => 400, error => 'Erroneous parameters (offset invalid)'}); + $t->get_ok('/api/v1/products?limit=a')->status_is(400)->json_is({error_status => 400, error => 'Erroneous parameters (limit invalid)'}); + $t->get_ok('/api/v1/products?offset=a')->status_is(400)->json_is({error_status => 400, error => 'Erroneous parameters (offset invalid)'}); }; subtest 'navigation with high limit' => sub { @@ -227,8 +218,8 @@ subtest 'server-side limit with pagination' => sub { }; subtest 'second page' => sub { - $t->get_ok($links->{next}{link})->status_is(200)->json_has('/Products/1')->json_hasnt('/Products/2') - ->json_like('/Products/0/version', qr/13\.1/)->json_like('/Products/1/version', qr/13\.2/); + $t->get_ok($links->{next}{link})->status_is(200)->json_has('/Products/1')->json_hasnt('/Products/2')->json_like('/Products/0/version', qr/13\.1/) + ->json_like('/Products/1/version', qr/13\.2/); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok $links->{next}, 'has next page'; @@ -244,8 +235,7 @@ subtest 'server-side limit with pagination' => sub { }; subtest 'fourth page' => sub { - $t->get_ok($links->{next}{link})->status_is(200)->json_has('/Products/0')->json_hasnt('/Products/1') - ->json_like('/Products/0/version', qr/13\.2/); + $t->get_ok($links->{next}{link})->status_is(200)->json_has('/Products/0')->json_hasnt('/Products/1')->json_like('/Products/0/version', qr/13\.2/); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok !$links->{next}, 'no next page'; @@ -253,8 +243,8 @@ subtest 'server-side limit with pagination' => sub { }; subtest 'first page (first link)' => sub { - $t->get_ok($links->{first}{link})->status_is(200)->json_has('/Products/1')->json_hasnt('/Products/2') - ->json_like('/Products/0/version', qr/13\.1/)->json_like('/Products/1/version', qr/12-SP1/); + $t->get_ok($links->{first}{link})->status_is(200)->json_has('/Products/1')->json_hasnt('/Products/2')->json_like('/Products/0/version', qr/13\.1/) + ->json_like('/Products/1/version', qr/12-SP1/); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok $links->{next}, 'has next page'; @@ -278,8 +268,7 @@ $t->post_ok( "settings[TEST]" => "val1", "settings[TEST2]" => "val1" })->status_is(403); -$t->put_ok("/api/v1/products/$product_id", - form => {arch => "x86_64", distri => "opensuse", flavor => "DVD", version => 13.2, "settings[TEST2]" => "val1"}) +$t->put_ok("/api/v1/products/$product_id", form => {arch => "x86_64", distri => "opensuse", flavor => "DVD", version => 13.2, "settings[TEST2]" => "val1"}) ->status_is(403); $t->delete_ok("/api/v1/products/$product_id")->status_is(403); diff --git a/t/api/07-testsuites.t b/t/api/07-testsuites.t index a5a70e6deb84..2c602f21684f 100644 --- a/t/api/07-testsuites.t +++ b/t/api/07-testsuites.t @@ -17,18 +17,15 @@ my $t = client(Test::Mojo->new('OpenQA::WebAPI'), apikey => 'ARTHURKEY01', apise subtest 'server-side limit with pagination' => sub { subtest 'input validation' => sub { - $t->get_ok('/api/v1/test_suites?limit=a')->status_is(400) - ->json_is({error_status => 400, error => 'Erroneous parameters (limit invalid)'}); - $t->get_ok('/api/v1/test_suites?offset=a')->status_is(400) - ->json_is({error_status => 400, error => 'Erroneous parameters (offset invalid)'}); + $t->get_ok('/api/v1/test_suites?limit=a')->status_is(400)->json_is({error_status => 400, error => 'Erroneous parameters (limit invalid)'}); + $t->get_ok('/api/v1/test_suites?offset=a')->status_is(400)->json_is({error_status => 400, error => 'Erroneous parameters (offset invalid)'}); }; subtest 'navigation with high limit' => sub { my $links; subtest 'first page' => sub { - $t->get_ok('/api/v1/test_suites?limit=5')->status_is(200)->json_has('/TestSuites/4') - ->json_hasnt('/TestSuites/5'); + $t->get_ok('/api/v1/test_suites?limit=5')->status_is(200)->json_has('/TestSuites/4')->json_hasnt('/TestSuites/5'); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok $links->{next}, 'has next page'; @@ -64,9 +61,8 @@ subtest 'server-side limit with pagination' => sub { my $links; subtest 'first page' => sub { - $t->get_ok('/api/v1/test_suites?limit=2')->status_is(200)->json_has('/TestSuites/1') - ->json_hasnt('/TestSuites/2')->json_like('/TestSuites/0/name', qr/textmode/) - ->json_like('/TestSuites/1/name', qr/kde/); + $t->get_ok('/api/v1/test_suites?limit=2')->status_is(200)->json_has('/TestSuites/1')->json_hasnt('/TestSuites/2') + ->json_like('/TestSuites/0/name', qr/textmode/)->json_like('/TestSuites/1/name', qr/kde/); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok $links->{next}, 'has next page'; @@ -232,11 +228,7 @@ $t->post_ok( })->status_is(200); my $test_suite_id = $t->tx->res->json->{id}; my $event = OpenQA::Test::Case::find_most_recent_event($t->app->schema, 'table_create'); -is_deeply( - [sort keys %$event], - ['description', 'id', 'name', 'settings', 'table'], - 'testsuite event was logged correctly' -); +is_deeply([sort keys %$event], ['description', 'id', 'name', 'settings', 'table'], 'testsuite event was logged correctly'); $t->post_ok('/api/v1/test_suites', form => {name => "testsuite"})->status_is(400); #already exists @@ -262,8 +254,7 @@ is_deeply( "Add test_suite" ) || diag explain $t->tx->res->json; -$t->put_ok("/api/v1/test_suites/$test_suite_id", form => {name => "testsuite", "settings[TEST2]" => "val1"}) - ->status_is(200); +$t->put_ok("/api/v1/test_suites/$test_suite_id", form => {name => "testsuite", "settings[TEST2]" => "val1"})->status_is(200); $t->get_ok("/api/v1/test_suites/$test_suite_id")->status_is(200); is_deeply( @@ -288,8 +279,7 @@ $t->delete_ok("/api/v1/test_suites/$test_suite_id")->status_is(404); #not fou # switch to operator (default client) and try some modifications client($t); $t->post_ok('/api/v1/test_suites', form => {name => "testsuite"})->status_is(403); -$t->put_ok("/api/v1/test_suites/$test_suite_id", form => {name => "testsuite", "settings[TEST2]" => "val1"}) - ->status_is(403); +$t->put_ok("/api/v1/test_suites/$test_suite_id", form => {name => "testsuite", "settings[TEST2]" => "val1"})->status_is(403); $t->delete_ok("/api/v1/test_suites/$test_suite_id")->status_is(403); done_testing(); diff --git a/t/api/08-jobtemplates.t b/t/api/08-jobtemplates.t index 62b0156b2d6a..5d90a7f4247e 100644 --- a/t/api/08-jobtemplates.t +++ b/t/api/08-jobtemplates.t @@ -449,9 +449,7 @@ subtest 'Changing priority' => sub { test_suite_id => 1002, prio => $prio, prio_only => 1, - } - )->status_is(400) - ->json_is('/error' => 'Erroneous parameters (prio invalid)', "setting prio to '$prio' is an error"); + })->status_is(400)->json_is('/error' => 'Erroneous parameters (prio invalid)', "setting prio to '$prio' is an error"); is($job_templates->search({prio => $prio})->count, 0, 'no rows affected'); } }; @@ -465,25 +463,16 @@ $yaml->{scenarios}{'x86_64'}{$product} = ['spam', 'eggs']; is_deeply($t->app->validate_yaml($yaml, $schema_filename, 1), ["/products: Missing property."], 'No products defined') or diag explain dump_yaml(string => $yaml); $yaml->{products}{$product} = {version => '42.1', flavor => 'DVD'}; -is_deeply( - @{$t->app->validate_yaml($yaml, $schema_filename, 1)}[0], - "/products/$product/distri: Missing property.", - 'No distri specified' -) or diag explain dump_yaml(string => $yaml); +is_deeply(@{$t->app->validate_yaml($yaml, $schema_filename, 1)}[0], "/products/$product/distri: Missing property.", 'No distri specified') + or diag explain dump_yaml(string => $yaml); $yaml->{products}{$product}{distri} = 'sle'; delete $yaml->{products}{$product}{flavor}; -is_deeply( - @{$t->app->validate_yaml($yaml, $schema_filename, 1)}[0], - "/products/$product/flavor: Missing property.", - 'No flavor specified' -) or diag explain dump_yaml(string => $yaml); +is_deeply(@{$t->app->validate_yaml($yaml, $schema_filename, 1)}[0], "/products/$product/flavor: Missing property.", 'No flavor specified') + or diag explain dump_yaml(string => $yaml); $yaml->{products}{$product}{flavor} = 'DVD'; delete $yaml->{products}{$product}{version}; -is_deeply( - $t->app->validate_yaml($yaml, $schema_filename, 1), - ["/products/$product/version: Missing property."], - 'No version specified' -) or diag explain dump_yaml(string => $yaml); +is_deeply($t->app->validate_yaml($yaml, $schema_filename, 1), ["/products/$product/version: Missing property."], 'No version specified') + or diag explain dump_yaml(string => $yaml); $yaml->{products}{$product}{distribution} = 'sle'; is_deeply( @{$t->app->validate_yaml($yaml, $schema_filename, 1)}[0], @@ -526,64 +515,40 @@ my $yaml2 = load_yaml(file => "$FindBin::Bin/../data/08-opensuse-2.yaml"); is_deeply($yaml, $yaml2, 'YAML for opensuse group') || diag explain $t->tx->res->body; subtest 'content-type' => sub { - $t->get_ok('/api/v1/job_templates_scheduling/' . $opensuse->id, $accept_yaml)->status_is(200) - ->content_type_is('text/yaml;charset=UTF-8'); - is_deeply(load_yaml(string => $t->tx->res->body), - $yaml, '[Accept: text/yaml] Test suite with unicode characters encoded correctly') + $t->get_ok('/api/v1/job_templates_scheduling/' . $opensuse->id, $accept_yaml)->status_is(200)->content_type_is('text/yaml;charset=UTF-8'); + is_deeply(load_yaml(string => $t->tx->res->body), $yaml, '[Accept: text/yaml] Test suite with unicode characters encoded correctly') || diag explain $t->tx->res->body; - $t->get_ok('/api/v1/job_templates_scheduling/' . $opensuse->id, {Accept => '*/*'})->status_is(200) - ->content_type_is('text/yaml;charset=UTF-8'); - is_deeply(load_yaml(string => $t->tx->res->body), - $yaml, '[Accept: */*] Test suite with unicode characters encoded correctly') + $t->get_ok('/api/v1/job_templates_scheduling/' . $opensuse->id, {Accept => '*/*'})->status_is(200)->content_type_is('text/yaml;charset=UTF-8'); + is_deeply(load_yaml(string => $t->tx->res->body), $yaml, '[Accept: */*] Test suite with unicode characters encoded correctly') || diag explain $t->tx->res->body; $t->get_ok('/api/v1/job_templates_scheduling/' . $opensuse->id, {Accept => 'application/json'})->status_is(200) ->content_type_is('application/json;charset=UTF-8'); - is_deeply(load_yaml(string => $t->tx->res->json), - $yaml, '[Accept: application/json] Test suite with unicode characters encoded correctly') + is_deeply(load_yaml(string => $t->tx->res->json), $yaml, '[Accept: application/json] Test suite with unicode characters encoded correctly') || diag explain $t->tx->res->body; - $t->get_ok('/api/v1/job_templates_scheduling/' . $opensuse->id)->status_is(200) - ->content_type_is('application/json;charset=UTF-8'); - is_deeply(load_yaml(string => $t->tx->res->json), - $yaml, '[no explicit Accept header] Test suite with unicode characters encoded correctly') + $t->get_ok('/api/v1/job_templates_scheduling/' . $opensuse->id)->status_is(200)->content_type_is('application/json;charset=UTF-8'); + is_deeply(load_yaml(string => $t->tx->res->json), $yaml, '[no explicit Accept header] Test suite with unicode characters encoded correctly') || diag explain $t->tx->res->body; - $t->get_ok('/api/v1/job_templates_scheduling', $accept_yaml)->status_is(200) - ->content_type_is('text/yaml;charset=UTF-8'); + $t->get_ok('/api/v1/job_templates_scheduling', $accept_yaml)->status_is(200)->content_type_is('text/yaml;charset=UTF-8'); my $yaml = load_yaml(string => $t->tx->res->body); - is_deeply( - ['opensuse', 'opensuse test'], - [sort keys %$yaml], - '[Accept: text/yaml] YAML of all groups contains names' - ) || diag explain $t->tx->res->body; + is_deeply(['opensuse', 'opensuse test'], [sort keys %$yaml], '[Accept: text/yaml] YAML of all groups contains names') || diag explain $t->tx->res->body; - $t->get_ok('/api/v1/job_templates_scheduling', {Accept => '*/*'})->status_is(200) - ->content_type_is('text/yaml;charset=UTF-8'); + $t->get_ok('/api/v1/job_templates_scheduling', {Accept => '*/*'})->status_is(200)->content_type_is('text/yaml;charset=UTF-8'); $yaml = load_yaml(string => $t->tx->res->body); - is_deeply( - ['opensuse', 'opensuse test'], - [sort keys %$yaml], - '[Accept: text/yaml] YAML of all groups contains names' - ) || diag explain $t->tx->res->body; + is_deeply(['opensuse', 'opensuse test'], [sort keys %$yaml], '[Accept: text/yaml] YAML of all groups contains names') || diag explain $t->tx->res->body; - $t->get_ok('/api/v1/job_templates_scheduling', {Accept => 'application/json'})->status_is(200) - ->content_type_is('application/json;charset=UTF-8'); + $t->get_ok('/api/v1/job_templates_scheduling', {Accept => 'application/json'})->status_is(200)->content_type_is('application/json;charset=UTF-8'); $yaml = $t->tx->res->json; - is_deeply( - ['opensuse', 'opensuse test'], - [sort keys %$yaml], - '[Accept: application/json] YAML of all groups contains names' - ) || diag explain $t->tx->res->body; + is_deeply(['opensuse', 'opensuse test'], [sort keys %$yaml], '[Accept: application/json] YAML of all groups contains names') + || diag explain $t->tx->res->body; $t->get_ok('/api/v1/job_templates_scheduling')->status_is(200)->content_type_is('application/json;charset=UTF-8'); $yaml = $t->tx->res->json; - is_deeply( - ['opensuse', 'opensuse test'], - [sort keys %$yaml], - '[no explicit Accept header] YAML of all groups contains names' - ) || diag explain $t->tx->res->body; + is_deeply(['opensuse', 'opensuse test'], [sort keys %$yaml], '[no explicit Accept header] YAML of all groups contains names') + || diag explain $t->tx->res->body; }; subtest 'Migration' => sub { @@ -807,11 +772,8 @@ subtest 'Create and modify groups with YAML' => sub { 'Expected result returned in response' ) || diag explain $t->tx->res->body; $t->get_ok("/api/v1/job_templates_scheduling/$job_group_id3"); - is_deeply( - load_yaml(string => $t->tx->res->json), - {scenarios => {}, products => {}}, - 'No job group and templates added to the database' - ) || diag explain $t->tx->res->body; + is_deeply(load_yaml(string => $t->tx->res->json), {scenarios => {}, products => {}}, 'No job group and templates added to the database') + || diag explain $t->tx->res->body; is($audit_events->count, $audit_event_count, 'no audit event emitted in preview mode'); $t->post_ok( @@ -860,9 +822,7 @@ subtest 'Create and modify groups with YAML' => sub { template => dump_yaml(string => $yaml)} )->status_is(400, 'Post rejected because scenarios are ambiguous')->json_is( '' => { - error => [ -'Job template name \'textmode\' with opensuse-13.1-DVD-i586 and 64bit is already used in job group \'opensuse\'' - ], + error => ['Job template name \'textmode\' with opensuse-13.1-DVD-i586 and 64bit is already used in job group \'opensuse\''], error_status => 400, id => $job_group_id3, job_group_id => $job_group_id3, @@ -883,13 +843,8 @@ subtest 'Create and modify groups with YAML' => sub { }, )->status_is(200, 'Posting template with "testsuite: null"'); - my $empty_testsuite - = $test_suites->find({name => OpenQA::Schema::ResultSet::JobTemplates::EMPTY_TESTSUITE_NAME}); - is( - $empty_testsuite->description, - OpenQA::Schema::ResultSet::JobTemplates::EMPTY_TESTSUITE_DESCRIPTION, - 'Empty testsuite description ok' - ); + my $empty_testsuite = $test_suites->find({name => OpenQA::Schema::ResultSet::JobTemplates::EMPTY_TESTSUITE_NAME}); + is($empty_testsuite->description, OpenQA::Schema::ResultSet::JobTemplates::EMPTY_TESTSUITE_DESCRIPTION, 'Empty testsuite description ok'); is($job_templates->search({test_suite_id => $empty_testsuite->id})->count, 1, 'one row has empty testsuite'); is($job_templates->search({prio => 97})->count, 1, 'one row has prio 97'); $schema->txn_rollback; @@ -910,11 +865,8 @@ subtest 'Create and modify groups with YAML' => sub { $t->get_ok("/api/v1/job_templates_scheduling/" . $opensuse->id); # Prepare expected result - is_deeply( - load_yaml(string => $t->tx->res->json), - load_yaml(string => $exp_yaml), - 'YAML with merge keys equals YAML with resolved merge keys' - ) || diag explain $t->tx->res->body; + is_deeply(load_yaml(string => $t->tx->res->json), load_yaml(string => $exp_yaml), 'YAML with merge keys equals YAML with resolved merge keys') + || diag explain $t->tx->res->body; $schema->txn_rollback; }; @@ -965,11 +917,7 @@ subtest 'Create and modify groups with YAML' => sub { return diag explain $t->tx->res->body unless $t->success; my $jobs = $schema->resultset('Jobs'); my %tests = map { $_ => $jobs->find($_)->settings_hash->{'NAME'} } @{$t->tx->res->json->{ids}}; - is_deeply( - [sort values %tests], - ['00099982-opensuse-13.1-DVD-i586-foobar@64bit', '00099983-opensuse-13.1-DVD-i586-foobar_eggs@64bit',], - 'Jobs created' - ); + is_deeply([sort values %tests], ['00099982-opensuse-13.1-DVD-i586-foobar@64bit', '00099983-opensuse-13.1-DVD-i586-foobar_eggs@64bit',], 'Jobs created'); }; subtest 'Post unmodified job template' => sub { @@ -994,9 +942,8 @@ subtest 'Create and modify groups with YAML' => sub { subtest 'Single scenario with multiple machines' => sub { $test_suites->create({name => 'baz'}); $yaml->{defaults}{i586}{'machine'} = ['Laptop_64', '64bit']; - $yaml->{scenarios}{i586}{'opensuse-13.1-DVD-i586'} = [ - {baz => {machine => ['32bit', '64bit'], priority => 7}}, - {baz_defaults => {priority => 7, testsuite => 'baz'}}]; + $yaml->{scenarios}{i586}{'opensuse-13.1-DVD-i586'} + = [{baz => {machine => ['32bit', '64bit'], priority => 7}}, {baz_defaults => {priority => 7, testsuite => 'baz'}}]; $t->post_ok( "/api/v1/job_templates_scheduling/$job_group_id3", form => { @@ -1092,8 +1039,7 @@ subtest 'References' => sub { $t->get_ok("/api/v1/job_templates_scheduling/$job_group_id4"); # Prepare expected result @{$yaml->{scenarios}{ppc64}{'opensuse-13.1-DVD-ppc64'}} = qw(spam eggs); - is_deeply(load_yaml(string => $t->tx->res->json), - $yaml, 'Added group with references should be reflected in the database') + is_deeply(load_yaml(string => $t->tx->res->json), $yaml, 'Added group with references should be reflected in the database') || diag explain $t->tx->res->body; # Event reflects changes to the YAML @@ -1143,8 +1089,7 @@ subtest 'Hidden keys' => sub { = [{kde_usb => {priority => 70, machine => '64bit', settings => {USB => '1'}}}]; delete $yaml->{defaults}; delete $yaml->{'.kde_template'}; - is_deeply(load_yaml(string => load_yaml(string => $t->tx->res->body)->{result}), - $yaml, 'Added group with hidden keys should be reflected in the database') + is_deeply(load_yaml(string => load_yaml(string => $t->tx->res->body)->{result}), $yaml, 'Added group with hidden keys should be reflected in the database') || diag explain $t->tx->res->body; # Clean up to avoid affecting other subtests $job_group->delete; @@ -1212,12 +1157,11 @@ subtest 'Staging' => sub { subtest 'Modifying tables used in YAML not allowed' => sub { my $job_templates = $job_templates->search({id => $job_template_id1}); while (my $job_template = $job_templates->next) { - $t->post_ok('/api/v1/products/' . $job_template->product_id, - form => {arch => 'x86_64', distri => 'opensuse', flavor => 'DVD', version => 13.2})->json_is( - '' => - {error_status => 400, error => 'Groups foo, opensuse, test must be updated through the YAML template'}, + $t->post_ok('/api/v1/products/' . $job_template->product_id, form => {arch => 'x86_64', distri => 'opensuse', flavor => 'DVD', version => 13.2}) + ->json_is( + '' => {error_status => 400, error => 'Groups foo, opensuse, test must be updated through the YAML template'}, 'Attempt to rename product used in group was blocked' - ); + ); $t->post_ok( '/api/v1/products/' . $job_template->product_id, form => { @@ -1229,31 +1173,25 @@ subtest 'Modifying tables used in YAML not allowed' => sub { })->status_is(200, 'Product settings are not locked'); diag explain $t->tx->res->body if !$t->success; $t->delete_ok('/api/v1/products/' . $job_template->product_id)->json_is( - '' => - {error_status => 400, error => 'Groups foo, opensuse, test must be updated through the YAML template'}, + '' => {error_status => 400, error => 'Groups foo, opensuse, test must be updated through the YAML template'}, 'Attempt to delete product used in group was blocked' ); - $t->post_ok('/api/v1/machines/' . $job_template->machine_id, form => {name => 'deadbeef', backend => 'kde/usb'}) - ->json_is( - '' => - {error_status => 400, error => 'Groups foo, opensuse, test must be updated through the YAML template'}, + $t->post_ok('/api/v1/machines/' . $job_template->machine_id, form => {name => 'deadbeef', backend => 'kde/usb'})->json_is( + '' => {error_status => 400, error => 'Groups foo, opensuse, test must be updated through the YAML template'}, 'Attempt to rename machine used in group was blocked' - ); + ); $t->post_ok('/api/v1/machines/' . $job_template->machine_id, - form => {name => $job_template->machine->name, backend => 'kde/usb', 'settings[TEST]' => '1'}) - ->status_is(200, 'Machine settings are not locked'); + form => {name => $job_template->machine->name, backend => 'kde/usb', 'settings[TEST]' => '1'})->status_is(200, 'Machine settings are not locked'); diag explain $t->tx->res->body if !$t->success; $t->delete_ok('/api/v1/machines/' . $job_template->machine_id)->json_is( - '' => - {error_status => 400, error => 'Groups foo, opensuse, test must be updated through the YAML template'}, + '' => {error_status => 400, error => 'Groups foo, opensuse, test must be updated through the YAML template'}, 'Attempt to delete machine used in group was blocked' ); $t->post_ok('/api/v1/test_suites/' . $job_template->test_suite_id, form => {name => 'deadbeef'})->json_is( '' => {error_status => 400, error => 'Group opensuse must be updated through the YAML template'}, 'Attempt to rename test suite used in group was blocked' ); - $t->post_ok('/api/v1/test_suites/' . $job_template->test_suite_id, - form => {name => $job_template->test_suite->name, description => 'Lorem ipsum'}) + $t->post_ok('/api/v1/test_suites/' . $job_template->test_suite_id, form => {name => $job_template->test_suite->name, description => 'Lorem ipsum'}) ->status_is(200, 'Description is not locked'); diag explain $t->tx->res->body if !$t->success; $t->post_ok('/api/v1/test_suites/' . $job_template->test_suite_id, @@ -1287,11 +1225,7 @@ $t->delete_ok("/api/v1/job_templates/$job_template_id1")->status_is(404); $t->delete_ok("/api/v1/job_templates/$job_template_id2")->status_is(200); $t->delete_ok("/api/v1/job_templates/$job_template_id2")->status_is(404); -is_deeply( - OpenQA::Test::Case::find_most_recent_event($t->app->schema, 'jobtemplate_delete'), - {id => "$job_template_id2"}, - 'Delete was logged correctly' -); +is_deeply(OpenQA::Test::Case::find_most_recent_event($t->app->schema, 'jobtemplate_delete'), {id => "$job_template_id2"}, 'Delete was logged correctly'); # switch to operator (default client) and try some modifications client($t); diff --git a/t/api/09-comments.t b/t/api/09-comments.t index 06fbc7aabf77..7889efeb20b8 100644 --- a/t/api/09-comments.t +++ b/t/api/09-comments.t @@ -44,11 +44,7 @@ sub test_get_comment_groups_json ($id, $supposed_text) { sub test_get_comment_invalid_job_or_group ($in, $id, $comment_id) { local $Test::Builder::Level = $Test::Builder::Level + 1; $t->get_ok("/api/v1/$in/$id/comments/$comment_id")->status_is(404, 'comment not found'); - like( - $t->tx->res->json->{error}, - qr/$id does not exist/, - $in eq 'jobs' ? "Job $id does not exist" : "Job group $id does not exist" - ); + like($t->tx->res->json->{error}, qr/$id does not exist/, $in eq 'jobs' ? "Job $id does not exist" : "Job group $id does not exist"); } sub test_get_comment_invalid_comment ($in, $id, $comment_id) { @@ -85,31 +81,26 @@ sub test_comments ($in, $id) { }; subtest 'create comment without text' => sub { - $t->post_ok("/api/v1/$in/$id/comments" => form => {}) - ->status_is(400, 'comment can not be created without text') + $t->post_ok("/api/v1/$in/$id/comments" => form => {})->status_is(400, 'comment can not be created without text') ->json_is('/error' => 'Erroneous parameters (text missing)'); - $t->post_ok("/api/v1/$in/$id/comments" => form => {text => ''}) - ->status_is(400, 'comment can not be created with empty text') + $t->post_ok("/api/v1/$in/$id/comments" => form => {text => ''})->status_is(400, 'comment can not be created with empty text') ->json_is('/error' => 'Erroneous parameters (text invalid)'); }; subtest 'create comment with invalid job or group' => sub { - $t->post_ok("/api/v1/$in/1234/comments" => form => {text => $test_message}) - ->status_is(404, 'comment can not be created for invalid job/group') + $t->post_ok("/api/v1/$in/1234/comments" => form => {text => $test_message})->status_is(404, 'comment can not be created for invalid job/group') ->json_is('/error' => $expected_name . ' 1234 does not exist'); test_get_comment_invalid_job_or_group($in, 1234, 35); }; subtest 'update comment' => sub { - $t->put_ok("/api/v1/$in/$id/comments/$new_comment_id" => form => {text => $edited_test_message}) - ->status_is(200, 'comment can be updated'); + $t->put_ok("/api/v1/$in/$id/comments/$new_comment_id" => form => {text => $edited_test_message})->status_is(200, 'comment can be updated'); test_get_comment($in, $id, $new_comment_id, $edited_test_message); }; subtest 'update comment with invalid job or group' => sub { $t->put_ok("/api/v1/$in/1234/comments/$new_comment_id" => form => {text => $edited_test_message}) - ->status_is(404, 'comment can not be updated for invalid job/group') - ->json_is('/error' => $expected_name . ' 1234 does not exist'); + ->status_is(404, 'comment can not be updated for invalid job/group')->json_is('/error' => $expected_name . ' 1234 does not exist'); test_get_comment_invalid_job_or_group('jobs', 1234, 35); }; @@ -120,27 +111,23 @@ sub test_comments ($in, $id) { }; subtest 'list multiple comments' => sub { - $t->get_ok("/api/v1/$in/$id/comments")->status_is(200) - ->json_is('/0/text' => $edited_test_message, 'text correct')->json_is( + $t->get_ok("/api/v1/$in/$id/comments")->status_is(200)->json_is('/0/text' => $edited_test_message, 'text correct')->json_is( '/0/renderedMarkdown' => "

    This is a cool test \x{2620} - http://open.qa - this message will be\\nappended if editing works \x{2620}

    \n", 'markdown correct' - ); + ); is(scalar @{$t->tx->res->json}, 1, 'one comment present'); }; subtest 'update comment without text' => sub { - $t->put_ok("/api/v1/$in/$id/comments/$new_comment_id" => form => {}) - ->status_is(400, 'comment can not be updated without text') + $t->put_ok("/api/v1/$in/$id/comments/$new_comment_id" => form => {})->status_is(400, 'comment can not be updated without text') ->json_is('/error' => 'Erroneous parameters (text missing)'); - $t->put_ok("/api/v1/$in/$id/comments/$new_comment_id" => form => {text => ''}) - ->status_is(400, 'comment can not be updated with empty text') + $t->put_ok("/api/v1/$in/$id/comments/$new_comment_id" => form => {text => ''})->status_is(400, 'comment can not be updated with empty text') ->json_is('/error' => 'Erroneous parameters (text invalid)'); }; test_get_comment($in, $id, $new_comment_id, $edited_test_message); - $t->delete_ok("/api/v1/$in/$id/comments/$new_comment_id") - ->status_is(403, 'comment can not be deleted by unauthorized user'); + $t->delete_ok("/api/v1/$in/$id/comments/$new_comment_id")->status_is(403, 'comment can not be deleted by unauthorized user'); } subtest 'job comments' => sub { @@ -166,14 +153,12 @@ subtest 'server-side limit has precedence over user-specified limit' => sub { $limits->{generic_max_limit} = 5; $limits->{generic_default_limit} = 2; - $t->get_ok('/api/v1/jobs/99981/comments?limit=10', 'query with exceeding user-specified limit for comments') - ->status_is(200); + $t->get_ok('/api/v1/jobs/99981/comments?limit=10', 'query with exceeding user-specified limit for comments')->status_is(200); my $jobs = $t->tx->res->json; diag explain $jobs; is ref $jobs, 'ARRAY', 'data returned (1)' and is scalar @$jobs, 5, 'maximum limit for comments is effective'; - $t->get_ok('/api/v1/jobs/99981/comments?limit=3', 'query with exceeding user-specified limit for comments') - ->status_is(200); + $t->get_ok('/api/v1/jobs/99981/comments?limit=3', 'query with exceeding user-specified limit for comments')->status_is(200); $jobs = $t->tx->res->json; is ref $jobs, 'ARRAY', 'data returned (2)' and is scalar @$jobs, 3, 'user limit for comments is effective'; @@ -192,8 +177,7 @@ subtest 'admin can delete comments' => sub { test_get_comment_invalid_comment(jobs => 99981, $new_comment_id); subtest 'delete comment with invalid job or group' => sub { - $t->delete_ok("/api/v1/jobs/1234/comments/$new_comment_id") - ->status_is(404, 'comment can be deleted for invalid job/group') + $t->delete_ok("/api/v1/jobs/1234/comments/$new_comment_id")->status_is(404, 'comment can be deleted for invalid job/group') ->json_is('/error' => 'Job 1234 does not exist'); test_get_comment_invalid_job_or_group('jobs', 1234, 35); }; @@ -226,22 +210,19 @@ subtest 'can update job result with special label comment' => sub { my $comments = $schema->resultset('Comments'); my $nr_comments = $comments->all; $t->post_ok($route => form => {text => 'label:force_result:invalid_result'}) - ->status_is(400, 'comment can not be created with invalid result for force_result') - ->json_like('/error' => qr/Invalid result/); + ->status_is(400, 'comment can not be created with invalid result for force_result')->json_like('/error' => qr/Invalid result/); is $jobs->find($job_id)->result, 'softfailed', 'job is not updated with invalid result'; is $comments->all, $nr_comments, 'no new comment created with invalid result'; my $global_cfg = $t->app->config->{global}; $global_cfg->{force_result_regex} = '[A-Z0-9-]+'; - $t->post_ok($route => form => {text => 'label:force_result:passed'}) - ->status_is(400, 'comment can not be created when description pattern does not match') + $t->post_ok($route => form => {text => 'label:force_result:passed'})->status_is(400, 'comment can not be created when description pattern does not match') ->json_like('/error' => qr/description.*does not match/); is $jobs->find($job_id)->result, 'softfailed', 'job is not updated when description pattern does not match'; is $comments->all, $nr_comments, 'no new comment created for wrong description'; test_create_comment('jobs', $job_id, 'label:force_result:passed:boo42'); is $jobs->find($job_id)->result, 'passed', 'job is updated when description pattern matches'; my $id = $t->get_ok("/api/v1/jobs/$job_id/comments")->tx->res->json->[0]->{id}; - $t->put_ok("$route/$id" => form => {text => 'label:force_result:passed'}) - ->status_is(400, 'can not update comment with invalid description') + $t->put_ok("$route/$id" => form => {text => 'label:force_result:passed'})->status_is(400, 'can not update comment with invalid description') ->json_like('/error' => qr/description.*does not match/); $t->delete_ok("$route/$id")->status_is(403, 'can not delete comment with label:force_result'); $t->put_ok("$route/$id" => form => {text => 'no label'})->status_is(200, 'can update comment with special label'); @@ -250,15 +231,13 @@ subtest 'can update job result with special label comment' => sub { $job_id = 99927; $route = "/api/v1/jobs/$job_id/comments"; is $jobs->find($job_id)->state, 'scheduled', 'job initially is unfinished'; - $t->post_ok($route => form => {text => 'label:force_result:passed'}) - ->status_is(400, 'comment can not be created when job is unfinished') + $t->post_ok($route => form => {text => 'label:force_result:passed'})->status_is(400, 'comment can not be created when job is unfinished') ->json_like('/error' => qr/only allowed on finished/); is $jobs->find($job_id)->result, 'none', 'unfinished job will not be updated'; $job_id = 99981; $route = "/api/v1/jobs/$job_id/comments"; is $jobs->find($job_id)->state, CANCELLED, 'job initially is cancelled'; - $t->post_ok($route => form => {text => 'label:force_result:passed:foo'}) - ->status_is(200, 'comment can be created when job is cancelled'); + $t->post_ok($route => form => {text => 'label:force_result:passed:foo'})->status_is(200, 'comment can be created when job is cancelled'); my $job = $jobs->find($job_id); is $job->state, DONE, 'cancelled job is now considered done'; is $job->result, PASSED, 'result of cancelled job has been updated'; diff --git a/t/api/10-jobgroups.t b/t/api/10-jobgroups.t index a13ca40ce61b..ab497d9532b3 100644 --- a/t/api/10-jobgroups.t +++ b/t/api/10-jobgroups.t @@ -74,11 +74,10 @@ subtest 'create parent group' => sub() { for my $form (@forms) { my $parameter = (keys %$form)[0]; $form->{name} = 'Cool parent group'; - $t->post_ok('/api/v1/parent_groups', form => $form)->status_is(400, "Create group with invalid $parameter") - ->json_is( + $t->post_ok('/api/v1/parent_groups', form => $form)->status_is(400, "Create group with invalid $parameter")->json_is( '/error' => "Erroneous parameters ($parameter invalid)", 'Invalid parameter types caught' - ); + ); return diag explain $t->tx->res->json unless $t->success; } @@ -134,11 +133,10 @@ subtest 'create job group' => sub() { for my $form (@forms) { my $parameter = (keys %$form)[0]; $form->{name} = 'Cold group'; - $t->post_ok('/api/v1/job_groups', form => $form)->status_is(400, "Create group with invalid $parameter") - ->json_is( + $t->post_ok('/api/v1/job_groups', form => $form)->status_is(400, "Create group with invalid $parameter")->json_is( '/error' => "Erroneous parameters ($parameter invalid)", 'Invalid parameter types caught' - ); + ); return diag explain $t->tx->res->json unless $t->success; } @@ -151,8 +149,7 @@ subtest 'create job group' => sub() { {name => 'Cool group', size_limit_gb => 200, description => 'Test2', keep_important_logs_in_days => 45}, ); for my $form (@forms) { - $t->post_ok('/api/v1/job_groups', form => $form) - ->status_is(200, "Create group $form->{name} with different properties"); + $t->post_ok('/api/v1/job_groups', form => $form)->status_is(200, "Create group $form->{name} with different properties"); return diag explain $t->tx->res->json unless $t->success; } @@ -216,11 +213,10 @@ subtest 'update job group' => sub() { for my $form (@forms) { my $parameter = (keys %$form)[0]; $form->{name} = 'Cold group'; - $t->put_ok("/api/v1/job_groups/$opensuse_group", form => $form) - ->status_is(400, "Update group with invalid $parameter")->json_is( + $t->put_ok("/api/v1/job_groups/$opensuse_group", form => $form)->status_is(400, "Update group with invalid $parameter")->json_is( '/error' => "Erroneous parameters ($parameter invalid)", 'Invalid parameter types caught' - ); + ); return diag explain $t->tx->res->json unless $t->success; } @@ -281,11 +277,7 @@ subtest 'delete job/parent group and error when listing non-existing group' => s my $event = OpenQA::Test::Case::find_most_recent_event($schema, 'jobgroup_delete'); is($event->{id}, $new_id, 'event contains id'); $t->get_ok("/api/v1/$variant/$new_id")->status_is(404); - is_deeply( - $t->tx->res->json, - {error => "Group $new_id does not exist", error_status => 404}, - 'error about non-existing group' - ); + is_deeply($t->tx->res->json, {error => "Group $new_id does not exist", error_status => 404}, 'error about non-existing group'); } }; @@ -399,11 +391,7 @@ subtest 'prevent create/update duplicate job group on same parent group' => sub( name => 'group1', parent_id => $parent_group_id })->status_is(400); - like( - $t->tx->res->json->{error}, - qr/duplicate key/, - 'Unable to create group due to not allow duplicated job group on the same parent job group' - ); + like($t->tx->res->json->{error}, qr/duplicate key/, 'Unable to create group due to not allow duplicated job group on the same parent job group'); my $group2_id = $t->post_ok( '/api/v1/job_groups', form => { @@ -415,11 +403,7 @@ subtest 'prevent create/update duplicate job group on same parent group' => sub( form => { name => 'group1', })->status_is(400); - like( - $t->tx->res->json->{error}, - qr/duplicate key/, - 'Unable to update group due to not allow duplicated job group on the same parent job group' - ); + like($t->tx->res->json->{error}, qr/duplicate key/, 'Unable to update group due to not allow duplicated job group on the same parent job group'); }; done_testing(); diff --git a/t/api/11-bugs.t b/t/api/11-bugs.t index 1474bf956b69..989619d3fc2e 100644 --- a/t/api/11-bugs.t +++ b/t/api/11-bugs.t @@ -35,8 +35,7 @@ subtest 'Properties' => sub { subtest 'Refreshable' => sub { $t->get_ok('/api/v1/bugs?refreshable=1')->json_is('/bugs', {}, 'All bugs are refreshed'); - $t->post_ok('/api/v1/bugs', form => {title => "foobar2", bugid => 'poo#201', existing => 1, refreshed => 1}) - ->json_is('/id' => 2, 'Bug #2 created'); + $t->post_ok('/api/v1/bugs', form => {title => "foobar2", bugid => 'poo#201', existing => 1, refreshed => 1})->json_is('/id' => 2, 'Bug #2 created'); return diag explain $t->tx->res->body unless $t->success; $t->get_ok('/api/v1/bugs/2')->json_is('/title' => 'foobar2', 'Bug #2 has correct title'); @@ -90,19 +89,16 @@ subtest 'server-side limit has precedence over user-specified limit' => sub { subtest 'server-side limit with pagination' => sub { subtest 'input validation' => sub { - $t->get_ok('/api/v1/bugs?limit=a')->status_is(400) - ->json_is({error_status => 400, error => 'Erroneous parameters (limit invalid)'}); - $t->get_ok('/api/v1/bugs?offset=a')->status_is(400) - ->json_is({error_status => 400, error => 'Erroneous parameters (offset invalid)'}); + $t->get_ok('/api/v1/bugs?limit=a')->status_is(400)->json_is({error_status => 400, error => 'Erroneous parameters (limit invalid)'}); + $t->get_ok('/api/v1/bugs?offset=a')->status_is(400)->json_is({error_status => 400, error => 'Erroneous parameters (offset invalid)'}); }; subtest 'navigation with limit' => sub { my $links; subtest 'first page' => sub { - $t->get_ok('/api/v1/bugs?limit=5')->status_is(200)->json_has('/bugs/1')->json_has('/bugs/3') - ->json_has('/bugs/4')->json_has('/bugs/5')->json_has('/bugs/6')->json_hasnt('/bugs/10') - ->json_hasnt('/bugs/12'); + $t->get_ok('/api/v1/bugs?limit=5')->status_is(200)->json_has('/bugs/1')->json_has('/bugs/3')->json_has('/bugs/4')->json_has('/bugs/5') + ->json_has('/bugs/6')->json_hasnt('/bugs/10')->json_hasnt('/bugs/12'); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok $links->{next}, 'has next page'; @@ -110,9 +106,8 @@ subtest 'server-side limit with pagination' => sub { }; subtest 'second page' => sub { - $t->get_ok($links->{next}{link})->status_is(200)->json_has('/bugs/10')->json_has('/bugs/11') - ->json_has('/bugs/7')->json_has('/bugs/8')->json_has('/bugs/9')->json_hasnt('/bugs/1') - ->json_hasnt('/bugs/12'); + $t->get_ok($links->{next}{link})->status_is(200)->json_has('/bugs/10')->json_has('/bugs/11')->json_has('/bugs/7')->json_has('/bugs/8') + ->json_has('/bugs/9')->json_hasnt('/bugs/1')->json_hasnt('/bugs/12'); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok $links->{next}, 'has next page'; @@ -120,8 +115,7 @@ subtest 'server-side limit with pagination' => sub { }; subtest 'third page' => sub { - $t->get_ok($links->{next}{link})->status_is(200)->json_has('/bugs/12')->json_has('/bugs/13') - ->json_hasnt('/bugs/1')->json_hasnt('/bugs/10'); + $t->get_ok($links->{next}{link})->status_is(200)->json_has('/bugs/12')->json_has('/bugs/13')->json_hasnt('/bugs/1')->json_hasnt('/bugs/10'); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok !$links->{next}, 'no next page'; @@ -129,9 +123,8 @@ subtest 'server-side limit with pagination' => sub { }; subtest 'second page (prev link)' => sub { - $t->get_ok($links->{prev}{link})->status_is(200)->json_has('/bugs/10')->json_has('/bugs/11') - ->json_has('/bugs/7')->json_has('/bugs/8')->json_has('/bugs/9')->json_hasnt('/bugs/1') - ->json_hasnt('/bugs/12'); + $t->get_ok($links->{prev}{link})->status_is(200)->json_has('/bugs/10')->json_has('/bugs/11')->json_has('/bugs/7')->json_has('/bugs/8') + ->json_has('/bugs/9')->json_hasnt('/bugs/1')->json_hasnt('/bugs/12'); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok $links->{next}, 'has next page'; @@ -139,9 +132,8 @@ subtest 'server-side limit with pagination' => sub { }; subtest 'first page (first link)' => sub { - $t->get_ok($links->{first}{link})->status_is(200)->json_has('/bugs/1')->json_has('/bugs/3') - ->json_has('/bugs/4')->json_has('/bugs/5')->json_has('/bugs/6')->json_hasnt('/bugs/10') - ->json_hasnt('/bugs/12'); + $t->get_ok($links->{first}{link})->status_is(200)->json_has('/bugs/1')->json_has('/bugs/3')->json_has('/bugs/4')->json_has('/bugs/5') + ->json_has('/bugs/6')->json_hasnt('/bugs/10')->json_hasnt('/bugs/12'); $links = $t->tx->res->headers->links; ok $links->{first}, 'has first page'; ok $links->{next}, 'has next page'; diff --git a/t/api/13-influxdb.t b/t/api/13-influxdb.t index 59cd608e8bb3..930e04f67dc3 100644 --- a/t/api/13-influxdb.t +++ b/t/api/13-influxdb.t @@ -31,8 +31,7 @@ openqa_jobs_by_arch,url=http://example.com,arch=x86_64 running=2i " ); -$t->get_ok('/admin/influxdb/minion')->status_is(200) - ->content_like(qr!openqa_minion_jobs,url=http://example.com active=0i,delayed=0i,failed=0i,inactive=0i!) +$t->get_ok('/admin/influxdb/minion')->status_is(200)->content_like(qr!openqa_minion_jobs,url=http://example.com active=0i,delayed=0i,failed=0i,inactive=0i!) ->content_like(qr!openqa_minion_jobs_hook_rc_failed,url=http://example.com rc_failed_per_10min=0i \d+!) ->content_like(qr!openqa_minion_workers,url=http://example.com active=0i,inactive=0i,registered=0i!); $t->app->minion->add_task(test => sub { }); @@ -40,20 +39,17 @@ my $job_id = $t->app->minion->enqueue('test'); my $job_id2 = $t->app->minion->enqueue('test'); my $worker = $t->app->minion->worker->register; my $job = $worker->dequeue(0); -$t->get_ok('/admin/influxdb/minion')->status_is(200) - ->content_like(qr!openqa_minion_jobs,url=http://example.com active=1i,delayed=0i,failed=0i,inactive=1i!) +$t->get_ok('/admin/influxdb/minion')->status_is(200)->content_like(qr!openqa_minion_jobs,url=http://example.com active=1i,delayed=0i,failed=0i,inactive=1i!) ->content_like(qr!openqa_minion_jobs_hook_rc_failed,url=http://example.com rc_failed_per_10min=0i \d+!) ->content_like(qr!openqa_minion_workers,url=http://example.com active=1i,inactive=0i,registered=1i!); $job->fail('test'); -$t->get_ok('/admin/influxdb/minion')->status_is(200) - ->content_like(qr!openqa_minion_jobs,url=http://example.com active=0i,delayed=0i,failed=1i,inactive=1i!) +$t->get_ok('/admin/influxdb/minion')->status_is(200)->content_like(qr!openqa_minion_jobs,url=http://example.com active=0i,delayed=0i,failed=1i,inactive=1i!) ->content_like(qr!openqa_minion_jobs_hook_rc_failed,url=http://example.com rc_failed_per_10min=0i \d+!) ->content_like(qr!openqa_minion_workers,url=http://example.com active=0i,inactive=1i,registered=1i!); $t->get_ok('/admin/influxdb/minion?rc_fail_timespan_minutes=23')->status_is(200) ->content_like(qr!openqa_minion_jobs_hook_rc_failed,url=http://example.com rc_failed_per_23min=0i \d+!); $job->retry({delay => ONE_HOUR}); -$t->get_ok('/admin/influxdb/minion')->status_is(200) - ->content_like(qr!openqa_minion_jobs,url=http://example.com active=0i,delayed=1i,failed=0i,inactive=2i!) +$t->get_ok('/admin/influxdb/minion')->status_is(200)->content_like(qr!openqa_minion_jobs,url=http://example.com active=0i,delayed=1i,failed=0i,inactive=2i!) ->content_like(qr!openqa_minion_jobs_hook_rc_failed,url=http://example.com rc_failed_per_10min=0i \d+!) ->content_like(qr!openqa_minion_workers,url=http://example.com active=0i,inactive=1i,registered=1i!); diff --git a/t/api/14-plugin_obs_rsync.t b/t/api/14-plugin_obs_rsync.t index 5fb825881b17..64ece1f9e657 100644 --- a/t/api/14-plugin_obs_rsync.t +++ b/t/api/14-plugin_obs_rsync.t @@ -17,8 +17,8 @@ $t->ua(OpenQA::Client->new(apikey => 'ARTHURKEY01', apisecret => 'EXCALIBUR')->i $t->app($app); # just check that all projects are mentioned -$t->get_ok('/api/v1/obs_rsync')->status_is(200, 'project list')->content_like(qr/Proj1/)->content_like(qr/Proj2/) - ->content_like(qr/Proj3/)->content_unlike(qr/Proj3::standard/)->content_like(qr/BatchedProj/); +$t->get_ok('/api/v1/obs_rsync')->status_is(200, 'project list')->content_like(qr/Proj1/)->content_like(qr/Proj2/)->content_like(qr/Proj3/) + ->content_unlike(qr/Proj3::standard/)->content_like(qr/BatchedProj/); subtest 'smoke' => sub { $t->put_ok('/api/v1/obs_rsync/Proj1/runs')->status_is(201, "trigger rsync"); @@ -31,27 +31,21 @@ perform_minion_jobs($t->app->minion); subtest 'appliances' => sub { $t->put_ok('/api/v1/obs_rsync/Proj2/runs?repository=images')->status_is(201, "trigger with repository parameter"); - $t->put_ok('/api/v1/obs_rsync/Proj2/runs?repository=images') - ->status_is(208, "trigger with repository parameter again"); - $t->put_ok('/api/v1/obs_rsync/Proj2/runs?repository=appliances') - ->status_is(201, "trigger with different repository"); + $t->put_ok('/api/v1/obs_rsync/Proj2/runs?repository=images')->status_is(208, "trigger with repository parameter again"); + $t->put_ok('/api/v1/obs_rsync/Proj2/runs?repository=appliances')->status_is(201, "trigger with different repository"); }; perform_minion_jobs($t->app->minion); sub test_queue { my $t = shift; - $t->put_ok('/api/v1/obs_rsync/Proj2/runs?repository=wrong') - ->status_is(204, "Proj2 with different repository ignored"); - $t->put_ok('/api/v1/obs_rsync/Proj2/runs?repository=images') - ->status_is(201, "Proj2 first time - should just start as queue is empty"); - $t->put_ok('/api/v1/obs_rsync/Proj2/runs') - ->status_is(208, "Proj2 second time - should report IN_QUEUE, because another Proj2 wasn't started by worker"); + $t->put_ok('/api/v1/obs_rsync/Proj2/runs?repository=wrong')->status_is(204, "Proj2 with different repository ignored"); + $t->put_ok('/api/v1/obs_rsync/Proj2/runs?repository=images')->status_is(201, "Proj2 first time - should just start as queue is empty"); + $t->put_ok('/api/v1/obs_rsync/Proj2/runs')->status_is(208, "Proj2 second time - should report IN_QUEUE, because another Proj2 wasn't started by worker"); $t->put_ok('/api/v1/obs_rsync/Proj3::standard/runs')->status_is(201, "Proj3 first time - should just start"); $t->put_ok('/api/v1/obs_rsync/Proj2/runs')->status_is(208, "Proj2 still gets queued"); $t->put_ok('/api/v1/obs_rsync/Proj3::standard/runs')->status_is(208, "Proj3 now reports that already queued"); - $t->put_ok('/api/v1/obs_rsync/Proj1/runs?repository=standard') - ->status_is(507, "Proj1 cannot be handled because queue is full 2=(Proj2, Proj3 running)"); + $t->put_ok('/api/v1/obs_rsync/Proj1/runs?repository=standard')->status_is(507, "Proj1 cannot be handled because queue is full 2=(Proj2, Proj3 running)"); $t->put_ok('/api/v1/obs_rsync/Proj3/runs?repository=standard')->status_is(208, "Proj3 is still in queue"); $t->put_ok('/api/v1/obs_rsync/WRONGPROJECT/runs')->status_is(404, "wrong project still returns error"); @@ -75,29 +69,25 @@ my $helper = $t->app->obs_rsync; subtest 'latest_test' => sub { is($helper->get_last_test_id('Proj1'), 99937); - $t->get_ok('/api/v1/obs_rsync/Proj1/latest_test')->status_is(200, 'status')->content_like(qr/99937/, 'correct id') - ->content_unlike(qr/passed/)->json_like('/id' => qr/^99937$/)->json_hasnt('/result'); - $t->get_ok('/api/v1/obs_rsync/Proj1/latest_test?full=1')->status_is(200, 'status') - ->content_like(qr/99937/, 'correct id')->content_like(qr/passed/)->json_like('/id' => qr/^99937$/) - ->json_has('/result')->json_like('/result' => qr/^passed$/); + $t->get_ok('/api/v1/obs_rsync/Proj1/latest_test')->status_is(200, 'status')->content_like(qr/99937/, 'correct id')->content_unlike(qr/passed/) + ->json_like('/id' => qr/^99937$/)->json_hasnt('/result'); + $t->get_ok('/api/v1/obs_rsync/Proj1/latest_test?full=1')->status_is(200, 'status')->content_like(qr/99937/, 'correct id')->content_like(qr/passed/) + ->json_like('/id' => qr/^99937$/)->json_has('/result')->json_like('/result' => qr/^passed$/); }; subtest 'test_result' => sub { is($helper->get_version_test_id('Proj1', '468.2'), 99926); is($helper->get_version_test_id('Proj1', '469.1'), 99937); - $t->get_ok('/api/v1/obs_rsync/Proj1/test_result?version=468.2')->status_is(200, 'status') - ->content_like(qr/99926/, 'correct id')->content_unlike(qr/passed/)->content_unlike(qr/incomplete/) - ->json_like('/id' => qr/^99926$/)->json_hasnt('/result'); - $t->get_ok('/api/v1/obs_rsync/Proj1/test_result?version=468.2&full=1')->status_is(200, 'status') - ->content_like(qr/99926/, 'correct id')->content_unlike(qr/passed/)->content_like(qr/incomplete/) - ->json_like('/id' => qr/^99926$/)->json_has('/result')->json_like('/result' => qr/^incomplete$/); - $t->get_ok('/api/v1/obs_rsync/Proj1/test_result?version=469.1')->status_is(200, 'status') - ->content_like(qr/99937/, 'correct id')->content_unlike(qr/passed/)->content_unlike(qr/incomplete/) - ->json_like('/id' => qr/^99937$/)->json_hasnt('/result'); - $t->get_ok('/api/v1/obs_rsync/Proj1/test_result?version=469.1&full=1')->status_is(200, 'status') - ->content_like(qr/99937/, 'correct id')->content_like(qr/passed/)->content_unlike(qr/incomplete/) - ->json_like('/id' => qr/^99937$/)->json_has('/result')->json_like('/result' => qr/^passed$/); + $t->get_ok('/api/v1/obs_rsync/Proj1/test_result?version=468.2')->status_is(200, 'status')->content_like(qr/99926/, 'correct id') + ->content_unlike(qr/passed/)->content_unlike(qr/incomplete/)->json_like('/id' => qr/^99926$/)->json_hasnt('/result'); + $t->get_ok('/api/v1/obs_rsync/Proj1/test_result?version=468.2&full=1')->status_is(200, 'status')->content_like(qr/99926/, 'correct id') + ->content_unlike(qr/passed/)->content_like(qr/incomplete/)->json_like('/id' => qr/^99926$/)->json_has('/result') + ->json_like('/result' => qr/^incomplete$/); + $t->get_ok('/api/v1/obs_rsync/Proj1/test_result?version=469.1')->status_is(200, 'status')->content_like(qr/99937/, 'correct id') + ->content_unlike(qr/passed/)->content_unlike(qr/incomplete/)->json_like('/id' => qr/^99937$/)->json_hasnt('/result'); + $t->get_ok('/api/v1/obs_rsync/Proj1/test_result?version=469.1&full=1')->status_is(200, 'status')->content_like(qr/99937/, 'correct id') + ->content_like(qr/passed/)->content_unlike(qr/incomplete/)->json_like('/id' => qr/^99937$/)->json_has('/result')->json_like('/result' => qr/^passed$/); }; sub lock_test { diff --git a/t/api/14-plugin_obs_rsync_async.t b/t/api/14-plugin_obs_rsync_async.t index 796e1aac99bb..44366511bf59 100644 --- a/t/api/14-plugin_obs_rsync_async.t +++ b/t/api/14-plugin_obs_rsync_async.t @@ -96,31 +96,22 @@ sub test_async { unlink_signal_rsync_ready('MockProjectLongProcessing', 'MockProjectLongProcessing1'); # MockProjectLongProcessing causes job to sleep some sec, so we can reach job limit - $t->put_ok('/api/v1/obs_rsync/MockProjectLongProcessing/runs') - ->status_is(201, 'first request to MockProjectLongProcessing should start'); + $t->put_ok('/api/v1/obs_rsync/MockProjectLongProcessing/runs')->status_is(201, 'first request to MockProjectLongProcessing should start'); sleep_until_job_start($t, 'MockProjectLongProcessing'); - $t->put_ok('/api/v1/obs_rsync/MockProjectLongProcessing/runs') - ->status_is(200, 'second request to MockProjectLongProcessing should be queued'); - $t->put_ok('/api/v1/obs_rsync/MockProjectLongProcessing/runs') - ->status_is(208, 'third request to MockProjectLongProcessing should report already in queue'); - $t->put_ok('/api/v1/obs_rsync/MockProjectLongProcessing1/runs') - ->status_is(201, 'first request to MockProjectLongProcessing1 should start'); - $t->put_ok('/api/v1/obs_rsync/MockProjectLongProcessing/runs') - ->status_is(208, 'request for MockProjectLongProcessing still reports in queue'); + $t->put_ok('/api/v1/obs_rsync/MockProjectLongProcessing/runs')->status_is(200, 'second request to MockProjectLongProcessing should be queued'); + $t->put_ok('/api/v1/obs_rsync/MockProjectLongProcessing/runs')->status_is(208, 'third request to MockProjectLongProcessing should report already in queue'); + $t->put_ok('/api/v1/obs_rsync/MockProjectLongProcessing1/runs')->status_is(201, 'first request to MockProjectLongProcessing1 should start'); + $t->put_ok('/api/v1/obs_rsync/MockProjectLongProcessing/runs')->status_is(208, 'request for MockProjectLongProcessing still reports in queue'); sleep_until_job_start($t, 'MockProjectLongProcessing1'); - $t->put_ok('/api/v1/obs_rsync/MockProjectLongProcessing1/runs') - ->status_is(200, 'second request to MockProjectLongProcessing1 is queued'); - $t->put_ok('/api/v1/obs_rsync/MockProjectLongProcessing1/runs') - ->status_is(208, 'now MockProjectLongProcessing1 should report already in queue'); + $t->put_ok('/api/v1/obs_rsync/MockProjectLongProcessing1/runs')->status_is(200, 'second request to MockProjectLongProcessing1 is queued'); + $t->put_ok('/api/v1/obs_rsync/MockProjectLongProcessing1/runs')->status_is(208, 'now MockProjectLongProcessing1 should report already in queue'); $t->put_ok('/api/v1/obs_rsync/Proj1/runs')->status_is(507, 'Queue limit is reached 4=(2 running + 2 scheduled)'); - $t->put_ok('/api/v1/obs_rsync/MockProjectLongProcessing1/runs') - ->status_is(208, 'MockProjectLongProcessing1 still in queue'); - $t->put_ok('/api/v1/obs_rsync/WRONGPROJECT/runs') - ->status_is(404, 'trigger rsync wrong project still returns error'); + $t->put_ok('/api/v1/obs_rsync/MockProjectLongProcessing1/runs')->status_is(208, 'MockProjectLongProcessing1 still in queue'); + $t->put_ok('/api/v1/obs_rsync/WRONGPROJECT/runs')->status_is(404, 'trigger rsync wrong project still returns error'); signal_rsync_ready('MockProjectLongProcessing', 'MockProjectLongProcessing1'); sleep_until_all_jobs_finished($t); @@ -174,11 +165,8 @@ subtest 'test max retry count' => sub { is($cnt, 11, 'Job should retry succeed'); is($jobs->[0]->{retries}, $config{retry_max_count}, 'Job retris is correct'); is(ref $jobs->[0]->{result}, 'HASH', 'Job retry result is hash'); - is( - $jobs->[0]->{result}->{message}, - "Exceeded retry count $config{retry_max_count}. Consider job will be re-triggered later", - 'Job retry message' - ) if ref $jobs->[0]->{result} eq 'HASH'; + is($jobs->[0]->{result}->{message}, "Exceeded retry count $config{retry_max_count}. Consider job will be re-triggered later", 'Job retry message') + if ref $jobs->[0]->{result} eq 'HASH'; # unlock guards @guards = undef; }; diff --git a/t/api/15-search.t b/t/api/15-search.t index 582cee69deb0..a3f0159aedd5 100644 --- a/t/api/15-search.t +++ b/t/api/15-search.t @@ -21,8 +21,7 @@ subtest 'Perl modules' => sub { $t->json_is( '/data/1' => { occurrence => 'opensuse/tests/installation/installer_timezone.pm', - contents => qq{ 3 # Summary: Verify timezone settings page\n} - . qq{ 10 assert_screen "inst-timezone", 125 || die 'no timezone';} + contents => qq{ 3 # Summary: Verify timezone settings page\n} . qq{ 10 assert_screen "inst-timezone", 125 || die 'no timezone';} }, 'contents found' ); @@ -35,8 +34,7 @@ subtest 'Python modules' => sub { $t->json_is( '/data/1' => { occurrence => 'opensuse/tests/openQA/search.py', - contents => qq{ 6 assert_and_click('openqa-search')\n} - . qq{ 9 assert_screen('openqa-search-results')} + contents => qq{ 6 assert_and_click('openqa-search')\n} . qq{ 9 assert_screen('openqa-search-results')} }, 'contents found' ); @@ -79,8 +77,7 @@ subtest 'Job modules' => sub { subtest 'Job templates' => sub { my $schema = $t->app->schema; my $group = $schema->resultset('JobGroups')->create({name => 'Cool Group'}); - my $product = $schema->resultset('Products') - ->create({name => 'Awesome Product', arch => 'arm64', distri => 'AwesomeOS', flavor => 'cherry'}); + my $product = $schema->resultset('Products')->create({name => 'Awesome Product', arch => 'arm64', distri => 'AwesomeOS', flavor => 'cherry'}); my $test_suites = $schema->resultset('TestSuites'); my $test_suite_banana = $test_suites->create({name => 'banana'}); my $machine = $schema->resultset('Machines')->create({name => 'arm64', backend => 'qemu'}); diff --git a/t/api/15-users.t b/t/api/15-users.t index 1f633cf947e3..f52e152f8434 100644 --- a/t/api/15-users.t +++ b/t/api/15-users.t @@ -19,11 +19,7 @@ $t->ua(OpenQA::Client->new(apikey => 'ARTHURKEY01', apisecret => 'EXCALIBUR')->i $t->app($app); $t->delete_ok('/api/v1/user/99904')->status_is(200, 'admins can delete users'); -is_deeply( - OpenQA::Test::Case::find_most_recent_event($t->app->schema, 'user_deleted'), - {username => 'Demo'}, - 'Delete was logged correctly' -); +is_deeply(OpenQA::Test::Case::find_most_recent_event($t->app->schema, 'user_deleted'), {username => 'Demo'}, 'Delete was logged correctly'); $t->delete_ok('/api/v1/user/99999')->status_is(404, 'a non-existent user cannot be deleted'); diff --git a/t/api/16-webhooks.t b/t/api/16-webhooks.t index fe361a7b2334..c9100284d03c 100644 --- a/t/api/16-webhooks.t +++ b/t/api/16-webhooks.t @@ -82,8 +82,7 @@ subtest 'error cases' => sub { }; subtest 'failure when reporting status to GitHub' => sub { - $t->post_ok($url, \%headers, json => $test_payload) - ->status_is(500, 'error returned when GitHub status cannot be created'); + $t->post_ok($url, \%headers, json => $test_payload)->status_is(500, 'error returned when GitHub status cannot be created'); is $minion->jobs->total, 0, 'no Minion job created'; is $scheduled_products->count, 0, 'no scheduled product created'; }; @@ -99,8 +98,7 @@ my $expected_statuses_url = "https://127.0.0.1/repos/os-autoinst/openQA/statuses my $expected_ci_check_state = 'pending'; my $expected_ci_check_desc = undef; $vcs_mock->redefine( - report_status_to_github => - sub ($self, $statuses_url, $params, $scheduled_product_id, $base_url_from_req, $callback) { + report_status_to_github => sub ($self, $statuses_url, $params, $scheduled_product_id, $base_url_from_req, $callback) { my $tx = $ua->build_tx(POST => 'http://dummy'); is $statuses_url, $expected_statuses_url, 'URL from webhook payload used for reporting back'; is $params->{state}, $expected_ci_check_state, "check reported to be $expected_ci_check_state"; diff --git a/t/config.t b/t/config.t index 15d3f9dab6c9..5aa215bf64a0 100644 --- a/t/config.t +++ b/t/config.t @@ -231,10 +231,8 @@ subtest 'Test configuration override from file' => sub { 'referers parsed correctly' ); - is_deeply($app->config->{minion_task_triggers}->{on_job_done}, - [qw(spam eggs)], 'parse minion task triggers correctly'); - is_deeply($app->config->{influxdb}->{ignored_failed_minion_jobs}, - [qw(foo boo)], 'parse ignored_failed_minion_jobs correctly'); + is_deeply($app->config->{minion_task_triggers}->{on_job_done}, [qw(spam eggs)], 'parse minion task triggers correctly'); + is_deeply($app->config->{influxdb}->{ignored_failed_minion_jobs}, [qw(foo boo)], 'parse ignored_failed_minion_jobs correctly'); }; subtest 'trim whitespace characters from both ends of openqa.ini value' => sub { @@ -251,11 +249,7 @@ subtest 'trim whitespace characters from both ends of openqa.ini value' => sub { OpenQA::Setup::read_config($app); ok($app->config->{global}->{appname} eq 'openQA', 'appname'); ok($app->config->{global}->{hide_asset_types} eq 'repo iso', 'hide_asset_types'); - is_deeply( - $app->config->{global}->{recognized_referers}, - [qw(bugzilla.suse.com progress.opensuse.org github.com)], - 'recognized_referers' - ); + is_deeply($app->config->{global}->{recognized_referers}, [qw(bugzilla.suse.com progress.opensuse.org github.com)], 'recognized_referers'); }; subtest 'Validation of worker timeout' => sub { diff --git a/t/data/40-templates-more.pl b/t/data/40-templates-more.pl index 18883ee0c885..253257fef7b8 100644 --- a/t/data/40-templates-more.pl +++ b/t/data/40-templates-more.pl @@ -30,8 +30,7 @@ TestSuites => [ { name => "uefi", - settings => - [{key => "DESKTOP", value => "kde"}, {key => "INSTALLONLY", value => 1}, {key => "UEFI", value => 1},], + settings => [{key => "DESKTOP", value => "kde"}, {key => "INSTALLONLY", value => 1}, {key => "UEFI", value => 1},], }, ], } diff --git a/t/data/40-templates.pl b/t/data/40-templates.pl index e6824639ee4e..31f7c1384a37 100644 --- a/t/data/40-templates.pl +++ b/t/data/40-templates.pl @@ -25,8 +25,7 @@ TestSuites => [ { name => "uefi", - settings => - [{key => "DESKTOP", value => "kde"}, {key => "INSTALLONLY", value => 1}, {key => "UEFI", value => 1},], + settings => [{key => "DESKTOP", value => "kde"}, {key => "INSTALLONLY", value => 1}, {key => "UEFI", value => 1},], }, ], } diff --git a/t/fixtures/04-products.pl b/t/fixtures/04-products.pl index e722a815be86..7cc754a26558 100644 --- a/t/fixtures/04-products.pl +++ b/t/fixtures/04-products.pl @@ -37,18 +37,13 @@ TestSuites => { id => 1013, name => "RAID0", - settings => - [{key => "RAIDLEVEL", value => 0}, {key => "INSTALLONLY", value => 1}, {key => "DESKTOP", value => "kde"},], + settings => [{key => "RAIDLEVEL", value => 0}, {key => "INSTALLONLY", value => 1}, {key => "DESKTOP", value => "kde"},], }, TestSuites => { id => 1014, name => "client1", - settings => [ - {key => "DESKTOP", value => "kde"}, - {key => "PARALLEL_WITH", value => "server"}, - {key => "PRECEDENCE", value => "wontoverride"} - ], + settings => [{key => "DESKTOP", value => "kde"}, {key => "PARALLEL_WITH", value => "server"}, {key => "PRECEDENCE", value => "wontoverride"}], }, TestSuites => { diff --git a/t/full-stack.t b/t/full-stack.t index 869bf8e552f7..050945c15065 100644 --- a/t/full-stack.t +++ b/t/full-stack.t @@ -244,8 +244,7 @@ subtest 'clone job that crashes' => sub { 'Job 1 produced the wrong results'; subtest 'cancel a scheduled job' => sub { - client_call( - '-X POST jobs ' . OpenQA::Test::FullstackUtils::job_setup(MACHINE => 'noassets', HDD_1 => 'nihilist_disk.hda')); + client_call('-X POST jobs ' . OpenQA::Test::FullstackUtils::job_setup(MACHINE => 'noassets', HDD_1 => 'nihilist_disk.hda')); $driver->click_element_ok('All Tests', 'link_text', 'Clicked All Tests'); wait_for_ajax(msg => 'wait for All Tests displayed before looking for 3'); @@ -433,8 +432,7 @@ subtest 'Cache tests' => sub { like $log_content, qr/\+\+\+\ worker notes \+\+\+/, 'worker notes present'; like((split(/\n/, $log_content))[0], qr/\+\+\+ setup notes \+\+\+/, 'setup notes present'); like((split(/\n/, $log_content))[-1], qr/uploading autoinst-log.txt/i, 'autoinst-log uploaded'); - like $log_content, qr/(Failed to download.*non-existent.qcow2|Download of.*non-existent.qcow2.*failed)/, - 'failure message found in log'; + like $log_content, qr/(Failed to download.*non-existent.qcow2|Download of.*non-existent.qcow2.*failed)/, 'failure message found in log'; like $log_content, qr/Result: setup failure/, 'job result result'; } or print_log 8; diff --git a/t/lib/OpenQA/SeleniumTest.pm b/t/lib/OpenQA/SeleniumTest.pm index cad768a5227a..b3768bbdc7d8 100644 --- a/t/lib/OpenQA/SeleniumTest.pm +++ b/t/lib/OpenQA/SeleniumTest.pm @@ -74,7 +74,7 @@ sub start_driver ($mojoport) { # context but bail out to not have repeated entries for the # same problem exceeded console scrollback buffers easily my ($driver, $exception, $args) = @_; # uncoverable statement - my $err = (split /\n/, $exception)[0] =~ s/Error while executing command: //r; # uncoverable statement + my $err = (split /\n/, $exception)[0] =~ s/Error while executing command: //r; # uncoverable statement $err .= ' at ' . __FILE__ . ':' . __LINE__; # uncoverable statement # prevent aborting the complete test when interactively debugging @@ -86,8 +86,7 @@ sub start_driver ($mojoport) { $ENV{PATH} = join(':', $ENV{PATH}, qw(/usr/lib64/chromium)); $opts{custom_args} = "--log-path=t/log_chromedriver"; unless ($ENV{NOT_HEADLESS}) { - push(@{$opts{extra_capabilities}{$_}{args}}, qw(--headless --disable-gpu --no-sandbox)) - for @chrome_option_keys; + push(@{$opts{extra_capabilities}{$_}{args}}, qw(--headless --disable-gpu --no-sandbox)) for @chrome_option_keys; } my $startup_timeout = $ENV{OPENQA_SELENIUM_TEST_STARTUP_TIMEOUT} // 10; $_driver = Test::Selenium::Chrome->new(%opts, startup_timeout => $startup_timeout); diff --git a/t/lib/OpenQA/Test/FullstackUtils.pm b/t/lib/OpenQA/Test/FullstackUtils.pm index ad35f9edd02b..220d33e50f8c 100644 --- a/t/lib/OpenQA/Test/FullstackUtils.pm +++ b/t/lib/OpenQA/Test/FullstackUtils.pm @@ -76,8 +76,7 @@ sub _fail_with_result_panel_contents ($result_panel_contents, $msg) { fail "Expected result not found"; # uncoverable statement } -sub wait_for_result_panel ($driver, $result_panel, $context = undef, $fail_on_incomplete = undef, $check_interval = 0.5) -{ +sub wait_for_result_panel ($driver, $result_panel, $context = undef, $fail_on_incomplete = undef, $check_interval = 0.5) { my $looking_for_result = $result_panel =~ qr/Result: /; $context //= 'current job'; my $msg = "Expected result for $context not found"; diff --git a/t/lib/OpenQA/Test/Utils.pm b/t/lib/OpenQA/Test/Utils.pm index ecc885060607..08c55f6318ca 100644 --- a/t/lib/OpenQA/Test/Utils.pm +++ b/t/lib/OpenQA/Test/Utils.pm @@ -82,8 +82,7 @@ sub mock_service_ports { } sub setup_mojo_app_with_default_worker_timeout { - OpenQA::App->set_singleton( - Mojolicious->new(config => {global => {worker_timeout => DEFAULT_WORKER_TIMEOUT}}, log => undef)); + OpenQA::App->set_singleton(Mojolicious->new(config => {global => {worker_timeout => DEFAULT_WORKER_TIMEOUT}}, log => undef)); } sub cache_minion_worker { @@ -254,8 +253,7 @@ sub _setup_sigchld_handler { # adds the PIDs from the specified $ipc_run_harness to the PIDs considered by $SIGCHLD_HANDLER and # ensures $SIGCHLD_HANDLER is called my ($child_name, $ipc_run_harness) = @_; - $RELEVANT_CHILD_PIDS{$_} = $child_name - for @{_pids_from_ipc_run_harness($ipc_run_harness, "IPC harness for $child_name contains no PIDs")}; + $RELEVANT_CHILD_PIDS{$_} = $child_name for @{_pids_from_ipc_run_harness($ipc_run_harness, "IPC harness for $child_name contains no PIDs")}; $SIG{CHLD} = $SIGCHLD_HANDLER; return $ipc_run_harness; } diff --git a/t/ui/01-list.t b/t/ui/01-list.t index 767c73f45302..ed8e3dd0e695 100644 --- a/t/ui/01-list.t +++ b/t/ui/01-list.t @@ -100,8 +100,7 @@ sub prepare_database { id => 99991, state => OpenQA::Jobs::Constants::SCHEDULED, TEST => 'kde_variant', - settings => - [{key => 'JOB_TEMPLATE_NAME', value => 'kde_variant'}, {key => 'TEST_SUITE_NAME', value => 'kde'}]}); + settings => [{key => 'JOB_TEMPLATE_NAME', value => 'kde_variant'}, {key => 'TEST_SUITE_NAME', value => 'kde'}]}); assume_all_assets_exist; } @@ -128,10 +127,8 @@ $time->attribute_like('title', qr/.*Z/, 'finish time title of 99946'); $time->text_like(qr/about 3 hours ago/, 'finish time of 99946'); subtest 'running jobs, progress bars' => sub { - is($driver->find_element('#job_99961 .progress-bar-striped')->get_text(), - 'running', 'striped progress bar if not modules present yet'); - is($driver->find_element('#job_99970 .progress-bar')->get_text(), - '67 %', 'progress is 67 % if 2 modules finished, 1 is running and 1 is queued'); + is($driver->find_element('#job_99961 .progress-bar-striped')->get_text(), 'running', 'striped progress bar if not modules present yet'); + is($driver->find_element('#job_99970 .progress-bar')->get_text(), '67 %', 'progress is 67 % if 2 modules finished, 1 is running and 1 is queued'); # note: For simplicity the running module is ignored. That means 2 of only 3 modules # have been finished and hence we get 67 %. I suppose that's not worse than counting # the currently running module always as zero progress. @@ -193,17 +190,14 @@ subtest 'scheduled jobs server-side limit has precedence over user-specified lim id => 99991 + $i, state => OpenQA::Jobs::Constants::SCHEDULED, TEST => 'kde_variant', - settings => - [{key => 'JOB_TEMPLATE_NAME', value => 'kde_variant'}, {key => 'TEST_SUITE_NAME', value => 'kde'}]}); + settings => [{key => 'JOB_TEMPLATE_NAME', value => 'kde_variant'}, {key => 'TEST_SUITE_NAME', value => 'kde'}]}); } - $t->get_ok('/tests/list_scheduled_ajax?limit=10', 'query with exceeding user-specified limit for list scheduled') - ->status_is(200); + $t->get_ok('/tests/list_scheduled_ajax?limit=10', 'query with exceeding user-specified limit for list scheduled')->status_is(200); my $jobs = $t->tx->res->json->{data}; is ref $jobs, 'ARRAY', 'data returned (1)' and is scalar @$jobs, 5, 'maximum limit for list scheduled is effective'; - $t->get_ok('/tests/list_scheduled_ajax?limit=3', 'query with exceeding user-specified limit for previous') - ->status_is(200); + $t->get_ok('/tests/list_scheduled_ajax?limit=3', 'query with exceeding user-specified limit for previous')->status_is(200); $jobs = $t->tx->res->json->{data}; is ref $jobs, 'ARRAY', 'data returned (2)' and is scalar @$jobs, 3, 'user limit for list scheduled is effective'; @@ -219,56 +213,27 @@ subtest 'available comments shown' => sub { $driver->get('/tests'); wait_for_ajax(msg => 'DataTables on "All tests" page for comments'); - is( - $driver->find_element('#job_99946 .fa-comment')->get_attribute('title'), - '2 comments available', - 'available comments shown for finished jobs' - ); - is(@{$driver->find_elements('#job_99962 .fa-comment')}, - 0, 'available comments only shown if at least one comment available'); + is($driver->find_element('#job_99946 .fa-comment')->get_attribute('title'), '2 comments available', 'available comments shown for finished jobs'); + is(@{$driver->find_elements('#job_99962 .fa-comment')}, 0, 'available comments only shown if at least one comment available'); is( $driver->find_element('#job_99936 .fa-bolt')->get_attribute('title'), "Bug referenced: poo#1\nopen poo bug", 'available bugref (poo#1) shown for finished jobs' ); - is( - $driver->find_element('#job_99936 .fa-bug')->get_attribute('title'), - "Bug referenced: bsc#3", - 'available bugref (bsc#3) shown for finished jobs' - ); + is($driver->find_element('#job_99936 .fa-bug')->get_attribute('title'), "Bug referenced: bsc#3", 'available bugref (bsc#3) shown for finished jobs'); my @closed = $driver->find_elements('#job_99936 .bug_closed'); - is( - $closed[1]->get_attribute('title'), - "Bug referenced: poo#2\nclosed poo bug", - 'available bugref (poo#2) shown for finished jobs' - ); - is( - $closed[0]->get_attribute('title'), - "Bug referenced: bsc#4\nclosed bugzilla bug", - 'available bugref (bsc#4) shown for finished jobs' - ); + is($closed[1]->get_attribute('title'), "Bug referenced: poo#2\nclosed poo bug", 'available bugref (poo#2) shown for finished jobs'); + is($closed[0]->get_attribute('title'), "Bug referenced: bsc#4\nclosed bugzilla bug", 'available bugref (bsc#4) shown for finished jobs'); SKIP: { skip 'comment icon for running and scheduled jobs skipped to imporove performance', 2; - is( - $driver->find_element('#job_99963 .fa-comment')->get_attribute('title'), - '2 comments available', - 'available comments shown for running jobs' - ); - is( - $driver->find_element('#job_99928 .fa-comment')->get_attribute('title'), - '1 comment available', - 'available comments shown for scheduled jobs' - ); + is($driver->find_element('#job_99963 .fa-comment')->get_attribute('title'), '2 comments available', 'available comments shown for running jobs'); + is($driver->find_element('#job_99928 .fa-comment')->get_attribute('title'), '1 comment available', 'available comments shown for scheduled jobs'); } }; $driver->find_element_by_link_text('Build0091')->click(); -like( - $driver->find_element_by_id('summary')->get_text(), - qr/Overall Summary of opensuse build 0091/, - 'we are on build 91' -); +like($driver->find_element_by_id('summary')->get_text(), qr/Overall Summary of opensuse build 0091/, 'we are on build 91'); # return is($driver->get("/tests"), 1, "/tests gets"); @@ -364,21 +329,13 @@ no_highlighting; # first check the relevant jobs my @jobs = map { $_->get_attribute('id') } @{$driver->find_elements('#results tbody tr', 'css')}; -is_deeply( - \@jobs, - [qw(job_99940 job_99939 job_99938 job_99926 job_99936 job_99947 job_99962 job_99946 job_80000 job_99937)], - '99945 is not displayed' -); +is_deeply(\@jobs, [qw(job_99940 job_99939 job_99938 job_99926 job_99936 job_99947 job_99962 job_99946 job_80000 job_99937)], '99945 is not displayed'); $driver->find_element_by_id('relevantfilter')->click(); wait_for_ajax(); # Test 99945 is not longer relevant (replaced by 99946) - but displayed for all @jobs = map { $_->get_attribute('id') } @{$driver->find_elements('#results tbody tr', 'css')}; -is_deeply( - \@jobs, - [qw(job_99940 job_99939 job_99938 job_99926 job_99936 job_99947 job_99962 job_99946 job_99945 job_99944)], - 'all rows displayed' -); +is_deeply(\@jobs, [qw(job_99940 job_99939 job_99938 job_99926 job_99936 job_99947 job_99962 job_99946 job_99945 job_99944)], 'all rows displayed'); subtest 'filter-finished' => sub { # test filtering finished jobs by result @@ -396,11 +353,7 @@ subtest 'filter-finished' => sub { $driver->find_element_by_id('relevantfilter')->click(); wait_for_ajax_and_animations(); @jobs = map { $_->get_attribute('id') } @{$driver->find_elements('#results tbody tr', 'css')}; - is_deeply( - \@jobs, - [qw(job_99940 job_99939 job_99938 job_99936 job_99962 job_99944)], - 'only softfailed and failed jobs displayed' - ); + is_deeply(\@jobs, [qw(job_99940 job_99939 job_99938 job_99936 job_99962 job_99944)], 'only softfailed and failed jobs displayed'); $driver->find_element('#finished_jobs_result_filter_chosen .search-choice-close', 'css')->click(); $driver->find_element('#finished_jobs_result_filter_chosen .search-choice-close', 'css')->click(); @@ -409,11 +362,7 @@ subtest 'filter-finished' => sub { wait_for_ajax(); @jobs = map { $_->get_attribute('id') } @{$driver->find_elements('#results tbody tr', 'css')}; - is_deeply( - \@jobs, - [qw(job_99940 job_99939 job_99938 job_99926 job_99936 job_99947 job_99962 job_99946 job_80000 job_99937)], - '99945 again hidden' - ); + is_deeply(\@jobs, [qw(job_99940 job_99939 job_99938 job_99926 job_99936 job_99947 job_99962 job_99946 job_80000 job_99937)], '99945 again hidden'); ok $driver->get('/tests?todo=1'), 'get TODO-tests'; wait_for_ajax(msg => 'tables loaded after reloading page with TODO-parameter'); @@ -471,16 +420,11 @@ subtest 'check test results of job99940' => sub { subtest 'test name and description still show up correctly using JOB_TEMPLATE_NAME' => sub { $driver->get('/tests'); wait_for_ajax(msg => 'wait for all tests displayed before looking for 99991'); - is($driver->find_element('#job_99991 td.test')->get_text(), - 'kde_variant@64bit', 'job 99991 displays TEST correctly'); + is($driver->find_element('#job_99991 td.test')->get_text(), 'kde_variant@64bit', 'job 99991 displays TEST correctly'); $driver->get('/tests/99991#settings'); wait_for_ajax; - is( - $driver->find_element('#scenario-description')->get_text(), - 'Simple kde test, before advanced_kde', - 'job 99991 description displays correctly' - ); + is($driver->find_element('#scenario-description')->get_text(), 'Simple kde test, before advanced_kde', 'job 99991 description displays correctly'); }; kill_driver(); diff --git a/t/ui/04-api_keys.t b/t/ui/04-api_keys.t index d4438ac61688..6cdfb8b7cfc4 100644 --- a/t/ui/04-api_keys.t +++ b/t/ui/04-api_keys.t @@ -29,20 +29,17 @@ $test_case->login($t, 'percival'); # And perform some 'legitimate' actions # Percival can see all his keys, but not the Lancelot's one -$t->get_ok('/api_keys')->status_is(200)->element_exists('#api_key_3', 'keys are there') - ->element_exists('#api_key_4', 'keys are there')->element_exists('#api_key_5', 'keys are there') - ->element_exists_not('#api_key_99901', "no other users's keys")->text_isnt('#api_key_3 .expiration' => 'never') - ->text_is('#api_key_5 .expiration' => 'never'); +$t->get_ok('/api_keys')->status_is(200)->element_exists('#api_key_3', 'keys are there')->element_exists('#api_key_4', 'keys are there') + ->element_exists('#api_key_5', 'keys are there')->element_exists_not('#api_key_99901', "no other users's keys") + ->text_isnt('#api_key_3 .expiration' => 'never')->text_is('#api_key_5 .expiration' => 'never'); # When clicking in 'create' a new API key is displayed in the listing $t->post_ok('/api_keys', {'X-CSRF-Token' => $token} => form => {})->status_is(302); -$t->get_ok('/api_keys')->status_is(200)->element_exists('#api_key_3', 'keys are there') - ->element_exists('#api_key_6', 'keys are there'); +$t->get_ok('/api_keys')->status_is(200)->element_exists('#api_key_3', 'keys are there')->element_exists('#api_key_6', 'keys are there'); # It's also possible to specify an expiration date $t->post_ok('/api_keys', {'X-CSRF-Token' => $token} => form => {t_expiration => '2016-01-05'})->status_is(302); -$t->get_ok('/api_keys')->status_is(200)->text_is('#api_key_6 .expiration' => 'never') - ->text_like('#api_key_7 .expiration' => qr/2016-01-05/); +$t->get_ok('/api_keys')->status_is(200)->text_is('#api_key_6 .expiration' => 'never')->text_like('#api_key_7 .expiration' => qr/2016-01-05/); # check invalid expiration date $t->post_ok('/api_keys', {'X-CSRF-Token' => $token} => form => {t_expiration => 'asdlfj'})->status_is(302); @@ -51,8 +48,7 @@ $t->get_ok('/api_keys')->status_is(200)->element_exists_not('#api_key_8', "No in # And to delete keys $t->delete_ok('/api_keys/6', {'X-CSRF-Token' => $token})->status_is(302); -$t->get_ok('/api_keys')->status_is(200)->element_exists_not('#api_key_6', 'API key 6 is gone') - ->content_like(qr/API key deleted/, 'deletion is reported'); +$t->get_ok('/api_keys')->status_is(200)->element_exists_not('#api_key_6', 'API key 6 is gone')->content_like(qr/API key deleted/, 'deletion is reported'); # # Now let's try to cheat the system diff --git a/t/ui/04-appearance.t b/t/ui/04-appearance.t index b9f6faffa001..212f61870a00 100644 --- a/t/ui/04-appearance.t +++ b/t/ui/04-appearance.t @@ -33,8 +33,7 @@ subtest 'We can switch to dark theme' => sub { $t->ua->max_redirects(5); $t->get_ok('/appearance')->status_is(200)->element_exists('select option[selected][value="light"]') ->element_exists_not('select option[selected][value="dark"]'); - $t->post_ok('/appearance' => form => {theme => 'dark'})->status_is(200) - ->element_exists('select option[selected][value="dark"]') + $t->post_ok('/appearance' => form => {theme => 'dark'})->status_is(200)->element_exists('select option[selected][value="dark"]') ->element_exists_not('select option[selected][value="light"]'); $t->get_ok('/appearance')->status_is(200)->element_exists('select option[selected][value="dark"]') ->element_exists_not('select option[selected][value="light"]'); @@ -43,8 +42,7 @@ subtest 'We can switch to dark theme' => sub { subtest 'We can switch to theme detection' => sub { $t->get_ok('/appearance')->status_is(200)->element_exists('select option[selected][value="dark"]') ->element_exists_not('select option[selected][value="detect"]'); - $t->post_ok('/appearance' => form => {theme => 'detect'})->status_is(200) - ->element_exists('select option[selected][value="detect"]') + $t->post_ok('/appearance' => form => {theme => 'detect'})->status_is(200)->element_exists('select option[selected][value="detect"]') ->element_exists_not('select option[selected][value="dark"]'); $t->get_ok('/appearance')->status_is(200)->element_exists('select option[selected][value="detect"]') ->element_exists_not('select option[selected][value="dark"]'); @@ -53,8 +51,7 @@ subtest 'We can switch to theme detection' => sub { subtest 'We can switch back to light theme' => sub { $t->get_ok('/appearance')->status_is(200)->element_exists('select option[selected][value="detect"]') ->element_exists_not('select option[selected][value="light"]'); - $t->post_ok('/appearance' => form => {theme => 'light'})->status_is(200) - ->element_exists('select option[selected][value="light"]') + $t->post_ok('/appearance' => form => {theme => 'light'})->status_is(200)->element_exists('select option[selected][value="light"]') ->element_exists_not('select option[selected][value="detect"]'); $t->get_ok('/appearance')->status_is(200)->element_exists('select option[selected][value="light"]') ->element_exists_not('select option[selected][value="detect"]'); diff --git a/t/ui/05-auth.t b/t/ui/05-auth.t index f3aa112b834b..d16694b39124 100644 --- a/t/ui/05-auth.t +++ b/t/ui/05-auth.t @@ -26,8 +26,7 @@ subtest 'authentication routes for plugins' => sub { # # No login, no user-info and no api_keys -my $res = OpenQA::Test::Case::trim_whitespace( - $t->get_ok('/tests')->status_is(200)->tx->res->dom->at('#user-action')->all_text); +my $res = OpenQA::Test::Case::trim_whitespace($t->get_ok('/tests')->status_is(200)->tx->res->dom->at('#user-action')->all_text); is($res, 'Login', 'no-one logged in'); $t->get_ok('/api_keys')->status_is(302); @@ -35,8 +34,7 @@ $t->get_ok('/api_keys')->status_is(302); # So let's log in as an unpriviledged user $test_case->login($t, 'https://openid.camelot.uk/lancelot'); # ...who should see a logout option but no link to API keys -$res = OpenQA::Test::Case::trim_whitespace( - $t->get_ok('/tests')->status_is(200)->tx->res->dom->at('#user-action')->all_text); +$res = OpenQA::Test::Case::trim_whitespace($t->get_ok('/tests')->status_is(200)->tx->res->dom->at('#user-action')->all_text); like($res, qr/Logged in as lance Operators Menu.*Logout/, 'lance is logged in'); $t->get_ok('/api_keys')->status_is(403); @@ -48,36 +46,28 @@ $t->get_ok('/admin/operator_plugin')->status_is(403); # # Then logout $t->delete_ok('/logout')->status_is(302); -$res = OpenQA::Test::Case::trim_whitespace( - $t->get_ok('/tests')->status_is(200)->tx->res->dom->at('#user-action')->all_text); +$res = OpenQA::Test::Case::trim_whitespace($t->get_ok('/tests')->status_is(200)->tx->res->dom->at('#user-action')->all_text); is($res, 'Login', 'no-one logged in'); # # Try creating new user by logging in $test_case->login($t, 'morgana'); # ...who should see a logout option but no link to API keys -$res = OpenQA::Test::Case::trim_whitespace( - $t->get_ok('/tests')->status_is(200)->tx->res->dom->at('#user-action')->all_text); +$res = OpenQA::Test::Case::trim_whitespace($t->get_ok('/tests')->status_is(200)->tx->res->dom->at('#user-action')->all_text); like($res, qr/Logged in as morgana Operators Menu.*API help Changelog Logout/, 'morgana as no api keys'); $t->get_ok('/api_keys')->status_is(403); # # Then logout $t->delete_ok('/logout')->status_is(302); -$res = OpenQA::Test::Case::trim_whitespace( - $t->get_ok('/tests')->status_is(200)->tx->res->dom->at('#user-action')->all_text); +$res = OpenQA::Test::Case::trim_whitespace($t->get_ok('/tests')->status_is(200)->tx->res->dom->at('#user-action')->all_text); is($res, 'Login', 'no-one logged in'); # # And log in as operator $test_case->login($t, 'percival'); -my $actions = OpenQA::Test::Case::trim_whitespace( - $t->get_ok('/tests')->status_is(200)->tx->res->dom->at('#user-action')->all_text); -like( - $actions, - qr/Logged in as perci Operators Menu.*Manage API keys Appearance API help Changelog Logout/, - 'perci has operator links' -); +my $actions = OpenQA::Test::Case::trim_whitespace($t->get_ok('/tests')->status_is(200)->tx->res->dom->at('#user-action')->all_text); +like($actions, qr/Logged in as perci Operators Menu.*Manage API keys Appearance API help Changelog Logout/, 'perci has operator links'); unlike($actions, qr/Administrators Menu/, 'perci has no admin links'); $t->get_ok('/api_keys')->status_is(200); diff --git a/t/ui/06-operator_links.t b/t/ui/06-operator_links.t index d319dc0594d9..3d50cf4af874 100644 --- a/t/ui/06-operator_links.t +++ b/t/ui/06-operator_links.t @@ -43,8 +43,7 @@ note 'now hack ourselves to be just operator - this is stupid procedure, but we $driver->find_element('#user-action a')->click(); $driver->find_element_by_link_text('Users')->click; $driver->execute_script('$("#users").off("change")'); -$driver->execute_script( - '$("#users").on("change", "input[name=\"role\"]:radio", function() {$(this).parent("form").submit();})'); +$driver->execute_script('$("#users").on("change", "input[name=\"role\"]:radio", function() {$(this).parent("form").submit();})'); $driver->find_element_by_xpath('//tr[./td[@class="nick" and text()="Demo"]]/td[@class="role"]//label[2]')->click; note 'refresh and return to admin pages'; $driver->refresh; diff --git a/t/ui/07-file.t b/t/ui/07-file.t index 8161e2c7f135..ab7ecc1bc632 100644 --- a/t/ui/07-file.t +++ b/t/ui/07-file.t @@ -18,13 +18,11 @@ $schema->resultset('Assets')->search({size => undef})->update({size => 0}); my $t = Test::Mojo->new('OpenQA::WebAPI'); # Exact size of logpackages-1.png -$t->get_ok('/tests/99938/images/logpackages-1.png')->status_is(200)->content_type_is('image/png') - ->header_is('Content-Length' => '48019'); +$t->get_ok('/tests/99938/images/logpackages-1.png')->status_is(200)->content_type_is('image/png')->header_is('Content-Length' => '48019'); $t->get_ok('/tests/99937/../99938/images/logpackages-1.png')->status_is(404); -$t->get_ok('/tests/99938/images/thumb/logpackages-1.png')->status_is(200)->content_type_is('image/png') - ->header_is('Content-Length' => '6769'); +$t->get_ok('/tests/99938/images/thumb/logpackages-1.png')->status_is(200)->content_type_is('image/png')->header_is('Content-Length' => '6769'); # Not the same logpackages-1.png $t->get_ok('/tests/99946/images/logpackages-1.png')->header_is('Content-Length' => '211'); @@ -67,8 +65,7 @@ subtest 'needle download' => sub { path("$needle_subdir/inst-subdirectory.png")->spew("png\n"); path("$needle_subdir/inst-subdirectory.json")->spew($json2); - $t->get_ok('/needles/opensuse/inst-timezone-text.png')->status_is(200)->content_type_is('image/png') - ->content_is("png\n"); + $t->get_ok('/needles/opensuse/inst-timezone-text.png')->status_is(200)->content_type_is('image/png')->content_is("png\n"); $t->get_ok('/needles/1/image')->status_is(200)->content_type_is('image/png')->content_is("png\n"); $t->get_ok('/needles/1/json')->status_is(200)->content_type_is('application/json;charset=UTF-8')->content_is($json); @@ -80,16 +77,16 @@ subtest 'needle download' => sub { # currently you can only find a needle in a subdirectory by passing the # jsonfile query parameter like this: - $t->get_ok("/needles/opensuse/inst-subdirectory.png?jsonfile=$needle_path/subdirectory/inst-subdirectory.json") - ->status_is(200)->content_type_is('image/png')->content_is("png\n"); + $t->get_ok("/needles/opensuse/inst-subdirectory.png?jsonfile=$needle_path/subdirectory/inst-subdirectory.json")->status_is(200) + ->content_type_is('image/png')->content_is("png\n"); # also test with jsonfile as absolute path (as usual in production) - $t->get_ok("/needles/opensuse/inst-subdirectory.png?jsonfile=$abs_needle_path/subdirectory/inst-subdirectory.json") - ->status_is(200)->content_type_is('image/png')->content_is("png\n"); + $t->get_ok("/needles/opensuse/inst-subdirectory.png?jsonfile=$abs_needle_path/subdirectory/inst-subdirectory.json")->status_is(200) + ->content_type_is('image/png')->content_is("png\n"); # getting needle image and json by ID also does not work for needles # in subdirectories, but arguably should do and should be tested: #$t->get_ok('/needles/2/image')->status_is(200)->content_type_is('image/png')->content_is("png\n"); - #$t->get_ok('/needles/2/json')->status_is(200)->content_type_is('application/json;charset=UTF-8')->content_is($json2); + #$t->get_ok('/needles/2/json')->status_is(200)->content_type_is('application/json;charset=UTF-8')->content_is($json2); }; @@ -110,21 +107,17 @@ $t->get_ok('/tests/99946/asset/1')->status_is(302) $t->get_ok('/tests/99946/asset/iso/openSUSE-13.1-DVD-i586-Build0091-Media.iso')->status_is(302) ->header_like(Location => qr/(?:http:\/\/localhost:\d+)?\/assets\/iso\/openSUSE-13.1-DVD-i586-Build0091-Media.iso/); -$t->get_ok('/tests/99946/asset/5')->status_is(302) - ->header_like(Location => qr/(?:http:\/\/localhost:\d+)?\/assets\/hdd\/fixed\/openSUSE-13.1-x86_64.hda/); +$t->get_ok('/tests/99946/asset/5')->status_is(302)->header_like(Location => qr/(?:http:\/\/localhost:\d+)?\/assets\/hdd\/fixed\/openSUSE-13.1-x86_64.hda/); # verify error on invalid downloads $t->get_ok('/tests/99946/asset/iso/foobar.iso')->status_is(404); -$t->get_ok('/tests/99961/asset/repo/testrepo/README')->status_is(302) - ->header_like(Location => qr/(?:http:\/\/localhost:\d+)?\/assets\/repo\/testrepo\/README/); -$t->get_ok('/tests/99961/asset/repo/testrepo/README/../README')->status_is(400) - ->content_is('invalid character in path'); +$t->get_ok('/tests/99961/asset/repo/testrepo/README')->status_is(302)->header_like(Location => qr/(?:http:\/\/localhost:\d+)?\/assets\/repo\/testrepo\/README/); +$t->get_ok('/tests/99961/asset/repo/testrepo/README/../README')->status_is(400)->content_is('invalid character in path'); # download_asset is handled by apache normally, but make sure it works - important for fullstack test $t->get_ok('/assets/repo/testrepo/README')->status_is(200); -$t->get_ok('/assets/iso/openSUSE-13.1-DVD-i586-Build0091-Media.iso')->status_is(200) - ->content_type_is('application/octet-stream'); +$t->get_ok('/assets/iso/openSUSE-13.1-DVD-i586-Build0091-Media.iso')->status_is(200)->content_type_is('application/octet-stream'); $t->get_ok('/assets/iso/../iso/openSUSE-13.1-DVD-i586-Build0091-Media.iso')->status_is(404); # created with `qemu-img create -f qcow2 t/data/openqa/share/factory/hdd/foo.qcow2 0` $t->get_ok('/assets/hdd/foo.qcow2')->status_is(200)->content_type_is('application/octet-stream'); diff --git a/t/ui/09-users-list.t b/t/ui/09-users-list.t index f763bd7d1b1f..4a76bf21ffea 100644 --- a/t/ui/09-users-list.t +++ b/t/ui/09-users-list.t @@ -40,21 +40,18 @@ is($t->tx->res->dom->at('#user_99903 .role')->attr('data-order'), '01'); # Click on "+ admin" for Lancelot $t->post_ok('/admin/users/99902', {'X-CSRF-Token' => $token} => form => {role => 'admin'})->status_is(302); -$t->get_ok('/admin/users')->status_is(200)->content_like(qr/User lance updated/) - ->text_is('#user_99902 .username' => 'https://openid.camelot.uk/lancelot'); +$t->get_ok('/admin/users')->status_is(200)->content_like(qr/User lance updated/)->text_is('#user_99902 .username' => 'https://openid.camelot.uk/lancelot'); is($t->tx->res->dom->at('#user_99902 .role')->attr('data-order'), '11'); # We can even update both fields in one request $t->post_ok('/admin/users/99902', {'X-CSRF-Token' => $token} => form => {role => 'operator'})->status_is(302); -$t->get_ok('/admin/users')->status_is(200)->content_like(qr/User lance updated/) - ->text_is('#user_99902 .username' => 'https://openid.camelot.uk/lancelot'); +$t->get_ok('/admin/users')->status_is(200)->content_like(qr/User lance updated/)->text_is('#user_99902 .username' => 'https://openid.camelot.uk/lancelot'); is($t->tx->res->dom->at('#user_99902 .role')->attr('data-order'), '01'); # not giving a role, makes it a user $t->post_ok('/admin/users/99902', {'X-CSRF-Token' => $token} => form => {})->status_is(302); -$t->get_ok('/admin/users')->status_is(200)->content_like(qr/User lance updated/) - ->text_is('#user_99902 .username' => 'https://openid.camelot.uk/lancelot'); +$t->get_ok('/admin/users')->status_is(200)->content_like(qr/User lance updated/)->text_is('#user_99902 .username' => 'https://openid.camelot.uk/lancelot'); is($t->tx->res->dom->at('#user_99902 .role')->attr('data-order'), '00'); done_testing(); diff --git a/t/ui/10-tests_overview.t b/t/ui/10-tests_overview.t index 70a9d9731aae..e60bfa219a0e 100644 --- a/t/ui/10-tests_overview.t +++ b/t/ui/10-tests_overview.t @@ -138,8 +138,7 @@ is(scalar @filtered_out, 0, 'result filter correctly applied'); # Test whether all URL parameter are passed correctly my $url_with_escaped_parameters - = $baseurl - . 'tests/overview?arch=&flavor=&machine=&test=&modules=&module_re=&distri=opensuse&build=0091&version=Staging%3AI&groupid=1001'; + = $baseurl . 'tests/overview?arch=&flavor=&machine=&test=&modules=&module_re=&distri=opensuse&build=0091&version=Staging%3AI&groupid=1001'; $driver->get($url_with_escaped_parameters); $driver->find_element('#filter-panel .card-header')->click(); $driver->find_element('#filter-form button')->click(); @@ -150,8 +149,7 @@ $driver->get($baseurl . 'tests/overview?distri=opensuse&version=13.1&build=0091& my $fmod = $driver->find_elements('.failedmodule', 'css')->[1]; $driver->mouse_move_to_location(element => $fmod, xoffset => 8, yoffset => 8); wait_for_ajax; -like($driver->find_elements('.failedmodule', 'css')->[1]->get_attribute('href'), - qr/\/kate\/1$/, 'ajax update failed module step'); +like($driver->find_elements('.failedmodule', 'css')->[1]->get_attribute('href'), qr/\/kate\/1$/, 'ajax update failed module step'); my @descriptions = $driver->find_elements('td.name a', 'css'); is(scalar @descriptions, 2, 'only test suites with description content are shown as links'); @@ -350,13 +348,11 @@ subtest 'filtering does not reveal old jobs' => sub { is(scalar @{$driver->find_elements('#res-99920')}, 0, 'and old kde job not revealed'); $driver->get('/tests/overview?arch=&failed_modules=zypper_up&distri=opensuse&version=13.1&build=0091&groupid=1001'); - is($driver->find_element('#summary .badge-danger')->get_text(), - '1', 'filtering for failed modules works for latest job'); + is($driver->find_element('#summary .badge-danger')->get_text(), '1', 'filtering for failed modules works for latest job'); is(scalar @{$driver->find_elements('#res-99946')}, 1, 'textmode job matches failed modules filter'); $driver->get('/tests/overview?arch=&failed_modules=bar&distri=opensuse&version=13.1&build=0091&groupid=1001'); - is scalar @{$driver->find_elements('#summary .badge-danger')}, 0, - 'filtering for failed modules does not reveal old job'; + is scalar @{$driver->find_elements('#summary .badge-danger')}, 0, 'filtering for failed modules does not reveal old job'; }; subtest 'filtering by module' => sub { @@ -388,8 +384,7 @@ subtest 'filtering by module' => sub { $driver->get("/tests/overview?arch=&distri=opensuse&modules_result=$result"); my @jobs = $driver->find_elements($JOB_ICON_SELECTOR); # Assert that all the jobs with the specified result are shown in the results - is(scalar @jobs, $number_of_found_jobs, - "$number_of_found_jobs jobs where modules with \"$result\" result found"); + is(scalar @jobs, $number_of_found_jobs, "$number_of_found_jobs jobs where modules with \"$result\" result found"); element_visible('#res_DVD_i586_kde'); element_visible('#res_DVD_x86_64_kde'); element_visible('#res_DVD_i586_textmode'); @@ -473,8 +468,7 @@ subtest "filtering by machine" => sub { subtest "job template names displayed on 'Test result overview' page" => sub { $driver->get('/group_overview/1002'); is($driver->find_element('.progress-bar-failed')->get_text(), '1 failed', 'The number of failed jobs is right'); - is($driver->find_element('.progress-bar-unfinished')->get_text(), - '1 unfinished', 'The number of unfinished jobs is right'); + is($driver->find_element('.progress-bar-unfinished')->get_text(), '1 unfinished', 'The number of unfinished jobs is right'); $driver->get('/tests/overview?distri=opensuse&version=13.1&build=0091&groupid=1002'); my @tds = $driver->find_elements('#results_DVD tbody tr .name'); @@ -500,14 +494,12 @@ subtest "job dependencies displayed on 'Test result overview' page" => sub { $driver->move_to(element => $parent_ele); my @child_deps = $driver->find_elements('tr.highlight_child'); is scalar @child_deps, 1, 'child job was highlighted'; - is $driver->find_child_element($child_deps[0], '#res_DVD_x86_64_doc')->get_attribute('name'), 'jobid_td_99938', - 'child job was highlighted correctly'; + is $driver->find_child_element($child_deps[0], '#res_DVD_x86_64_doc')->get_attribute('name'), 'jobid_td_99938', 'child job was highlighted correctly'; my $child_ele = $driver->find_element('td#res_DVD_x86_64_doc .parents_children'); $driver->move_to(element => $child_ele); my @parent_deps = $driver->find_elements('tr.highlight_parent'); is scalar @parent_deps, 1, 'parent job was highlighted'; - is $driver->find_child_element($parent_deps[0], '#res_DVD_i586_kde')->get_attribute('name'), 'jobid_td_99937', - 'parent job was highlighted correctly'; + is $driver->find_child_element($parent_deps[0], '#res_DVD_i586_kde')->get_attribute('name'), 'jobid_td_99937', 'parent job was highlighted correctly'; }; kill_driver(); diff --git a/t/ui/12-needle-edit.t b/t/ui/12-needle-edit.t index b690f2708533..f3a7798293e5 100644 --- a/t/ui/12-needle-edit.t +++ b/t/ui/12-needle-edit.t @@ -103,11 +103,7 @@ my $decode_textarea; sub goto_editor_for_installer_timezone { $driver->get('/tests/99946'); - is( - $driver->get_title(), - 'openQA: opensuse-13.1-DVD-i586-Build0091-textmode@32bit test results', - 'tests/99946 followed' - ); + is($driver->get_title(), 'openQA: opensuse-13.1-DVD-i586-Build0091-textmode@32bit test results', 'tests/99946 followed'); # init the preview wait_for_ajax(with_minion => $minion); @@ -124,8 +120,7 @@ sub add_needle_tag { $elem->send_keys($tagname); $driver->find_element_by_id('tag_add_button')->click(); wait_for_ajax(with_minion => $minion); - is($driver->find_element_by_xpath("//input[\@value=\"$tagname\"]")->is_selected(), - 1, "new tag found and was checked"); + is($driver->find_element_by_xpath("//input[\@value=\"$tagname\"]")->is_selected(), 1, "new tag found and was checked"); } sub add_workaround_property () { @@ -183,8 +178,7 @@ sub change_needle_value { is($decode_new_textarea->{area}[0]->{type}, "ocr", "type is ocr"); $driver->double_click; # the match type change back to match - unlike($driver->find_element_by_id('change-match')->get_attribute('class'), - qr/disabled/, "match level now enabled"); + unlike($driver->find_element_by_id('change-match')->get_attribute('class'), qr/disabled/, "match level now enabled"); # test match level $driver->find_element_by_id('change-match')->click(); @@ -234,30 +228,18 @@ sub overwrite_needle { my $diag; $diag = $driver->find_element_by_id('modal-overwrite'); is($driver->find_child_element($diag, '.modal-title', 'css')->is_displayed(), 1, "overwrite dialog shown"); - is( - $driver->find_child_element($diag, '.modal-title', 'css')->get_text(), - "Sure to overwrite test-newneedle?", - "Needle part of the title" - ); + is($driver->find_child_element($diag, '.modal-title', 'css')->get_text(), "Sure to overwrite test-newneedle?", "Needle part of the title"); $driver->find_element_by_id('modal-overwrite-confirm')->click(); wait_for_ajax(with_minion => $minion); - is( - $driver->find_element('#flash-messages span')->get_text(), - 'Needle test-newneedle created/updated - restart job', - 'highlight appears correct' - ); + is($driver->find_element('#flash-messages span')->get_text(), 'Needle test-newneedle created/updated - restart job', 'highlight appears correct'); ok(-f "$dir/$needlename.json", "$needlename.json overwritten"); $driver->find_element('#flash-messages span a')->click(); # restart is an ajax call, for some reason the check/sleep interval must be at least 1 sec for this call wait_for_ajax(interval => 1, minion => $minion); - is( - $driver->get_title(), - 'openQA: opensuse-13.1-DVD-i586-Build0091-textmode@32bit test results', - "no longer on needle editor" - ); + is($driver->get_title(), 'openQA: opensuse-13.1-DVD-i586-Build0091-textmode@32bit test results', "no longer on needle editor"); } sub check_flash_for_saving_logpackages { @@ -366,11 +348,7 @@ subtest 'Create new needle' => sub { wait_for_ajax(with_minion => $minion); # check state highlight appears with valid content - is( - $driver->find_element('#flash-messages span')->get_text(), - 'Needle test-newneedle created/updated - restart job', - 'highlight appears correct' - ); + is($driver->find_element('#flash-messages span')->get_text(), 'Needle test-newneedle created/updated - restart job', 'highlight appears correct'); # check files are exists ok(-f "$dir/$needlename.json", "$needlename.json created"); ok(-f "$dir/$needlename.png", "$needlename.png created"); @@ -419,11 +397,7 @@ subtest 'Saving needle with only OCR areas' => sub { $driver->double_click; # the match tpye change to ocr $driver->find_element_by_id('save')->click(); wait_for_ajax(msg => 'wait for needle with only OCR areas created', with_minion => $minion); - like( - $driver->find_element('#flash-messages span')->get_text(), - qr/Cannot create a needle with only OCR areas/, - 'error displayed for OCR-only needle' - ); + like($driver->find_element('#flash-messages span')->get_text(), qr/Cannot create a needle with only OCR areas/, 'error displayed for OCR-only needle'); $driver->find_element('#flash-messages .close')->click(); }; @@ -439,16 +413,8 @@ subtest 'Verify new needle\'s JSON' => sub { $match = 1 if ($tag eq 'test-overwritetag'); } is($match, 1, "found new tag in new needle"); - is( - $decoded_json->{area}[0]->{xpos}, - $decode_textarea->{area}[0]->{xpos} + $xoffset, - "new xpos stored to new needle" - ); - is( - $decoded_json->{area}[0]->{ypos}, - $decode_textarea->{area}[0]->{ypos} + $yoffset, - "new ypos stored to new needle" - ); + is($decoded_json->{area}[0]->{xpos}, $decode_textarea->{area}[0]->{xpos} + $xoffset, "new xpos stored to new needle"); + is($decoded_json->{area}[0]->{ypos}, $decode_textarea->{area}[0]->{ypos} + $yoffset, "new ypos stored to new needle"); }; sub assert_needle_appears_in_selection { @@ -457,11 +423,7 @@ sub assert_needle_appears_in_selection { my $selection = $driver->find_element_by_id($selection_id); my $new_needle_options = $driver->find_child_elements($selection, "./option[\@value='$needlename']", 'xpath'); is(scalar @$new_needle_options, 1, "needle appears in $selection_id selection"); - is( - OpenQA::Test::Case::trim_whitespace($new_needle_options->[0]->get_text()), - 'new: ' . $needlename, - "needle title in $selection_id selection correct" - ); + is(OpenQA::Test::Case::trim_whitespace($new_needle_options->[0]->get_text()), 'new: ' . $needlename, "needle title in $selection_id selection correct"); return $new_needle_options; } @@ -514,8 +476,8 @@ subtest 'Showing new needles limited to the 5 most recent ones' => sub { $needle_name_input->clear(); $needle_name_input->send_keys($new_needle_name); # ensure there are areas selected (by taking over areas from previously created needle) - $driver->execute_script('$("#area_select option").eq(1).prop("selected", true);' - . 'if ($("#take_matches").prop("checked")) { $("#take_matches").click(); }'); + $driver->execute_script( + '$("#area_select option").eq(1).prop("selected", true);' . 'if ($("#take_matches").prop("checked")) { $("#take_matches").click(); }'); $driver->find_element_by_id('save')->click(); wait_for_ajax(with_minion => $minion); # add expected warnings and needle names for needle @@ -550,11 +512,8 @@ subtest 'Broken needle is handled gracefully' => sub { $driver->refresh; $driver->title_is('openQA: Needle Editor', 'needle editor still shows up'); my @warnings = (split /\n/, $driver->find_element('#editor_warnings span')->get_text()); - like( - $warnings[0], - qr/Could not parse needle inst-timezone-text for opensuse 13\.1: .+ at character offset/, - 'warning about broken needle displayed' - ) or diag explain \@warnings; + like($warnings[0], qr/Could not parse needle inst-timezone-text for opensuse 13\.1: .+ at character offset/, 'warning about broken needle displayed') + or diag explain \@warnings; }; subtest 'Deletion of needle is handled gracefully' => sub { @@ -562,11 +521,8 @@ subtest 'Deletion of needle is handled gracefully' => sub { $driver->refresh; $driver->title_is('openQA: Needle Editor', 'needle editor still shows up'); my @warnings = (split /\n/, $driver->find_element('#editor_warnings span')->get_text()); - is( - $warnings[0], - 'Could not parse needle inst-timezone-text for opensuse 13.1: File not found', - 'warning about missing needle displayed' - ) or diag explain \@warnings; + is($warnings[0], 'Could not parse needle inst-timezone-text for opensuse 13.1: File not found', 'warning about missing needle displayed') + or diag explain \@warnings; }; subtest 'areas/tags verified via JavaScript' => sub { @@ -587,23 +543,17 @@ subtest 'show needle editor for screenshot (without any tags)' => sub { wait_for_ajax(with_minion => $minion); $driver->find_element('.step_actions .create_new_needle')->click(); wait_for_ajax(with_minion => $minion); - is(OpenQA::Test::Case::trim_whitespace($driver->find_element_by_id('image_select')->get_text()), - 'Screenshot', 'images taken from screenshot'); + is(OpenQA::Test::Case::trim_whitespace($driver->find_element_by_id('image_select')->get_text()), 'Screenshot', 'images taken from screenshot'); }; subtest 'open needle editor for running test' => sub { my $t = Test::Mojo->new('OpenQA::WebAPI'); $t->ua->max_redirects(1); warnings { $t->get_ok('/tests/99980/edit') }; - note( 'ignoring warning "DateTime objects passed to search() are not supported properly"' - . ' at lib/OpenQA/WebAPI/Controller/Step.pm line 211'); + note('ignoring warning "DateTime objects passed to search() are not supported properly"' . ' at lib/OpenQA/WebAPI/Controller/Step.pm line 211'); $t->status_is(200); $t->text_is(title => 'openQA: Needle Editor', 'needle editor shown for running test'); - is( - $t->tx->req->url->path->to_string, - '/tests/99980/modules/installation_mode/steps/2/edit', - 'redirected to correct module/step' - ); + is($t->tx->req->url->path->to_string, '/tests/99980/modules/installation_mode/steps/2/edit', 'redirected to correct module/step'); }; subtest 'error handling when opening needle editor for running test' => sub { @@ -614,7 +564,7 @@ subtest 'error handling when opening needle editor for running test' => sub { $t->text_is(title => 'openQA: Needle Editor', 'title still the same'); $t->text_like( '#content p', -qr/The test opensuse-13\.1-DVD-i586-Build0091-textmode\@32bit has no worker assigned so the page \"Needle Editor\" is not available\./, + qr/The test opensuse-13\.1-DVD-i586-Build0091-textmode\@32bit has no worker assigned so the page \"Needle Editor\" is not available\./, 'error message' ); @@ -623,7 +573,7 @@ qr/The test opensuse-13\.1-DVD-i586-Build0091-textmode\@32bit has no worker assi $t->text_is(title => 'openQA: Page not found', 'generic title present'); $t->text_like( '#content p', -qr/The test opensuse-13\.1-DVD-i586-Build0091-textmode\@32bit has no worker assigned so this route is not available\./, + qr/The test opensuse-13\.1-DVD-i586-Build0091-textmode\@32bit has no worker assigned so this route is not available\./, 'error message' ); }; @@ -646,8 +596,7 @@ subtest '(created) needles can be accessed over API' => sub { my @warnings = warnings { $t->get_ok('/needles/opensuse/doesntexist.png')->status_is(404) }; map { like($_, qr/No such file or directory/, 'expected warning') } @warnings; - $t->get_ok( - '/needles/opensuse/test-newneedle.png?jsonfile=t/data/openqa/share/tests/opensuse/needles/test-newneedle.json') + $t->get_ok('/needles/opensuse/test-newneedle.png?jsonfile=t/data/openqa/share/tests/opensuse/needles/test-newneedle.json') ->status_is(200, 'needle accessible')->content_type_is('image/png'); @warnings = warnings { $t->get_ok('/needles/opensuse/test-newneedle.png?jsonfile=/try/to/break_out.json') @@ -655,9 +604,8 @@ subtest '(created) needles can be accessed over API' => sub { }; map { like($_, qr/is not in a subdir of/, 'expected warning') } @warnings; @warnings = warnings { - $t->get_ok( -'/needles/opensuse/test-newneedle.png?jsonfile=t/data/openqa/share/tests/opensuse/needles/../../../../try/to/break_out.json' - )->status_is(403, 'access to files outside the test directory not granted (relative)'); + $t->get_ok('/needles/opensuse/test-newneedle.png?jsonfile=t/data/openqa/share/tests/opensuse/needles/../../../../try/to/break_out.json') + ->status_is(403, 'access to files outside the test directory not granted (relative)'); }; map { like($_, qr/cannot contain ../, 'expected warning') } @warnings; @@ -665,8 +613,7 @@ subtest '(created) needles can be accessed over API' => sub { File::Path::rmtree($tmp_dir); File::Copy::move($dir, $tmp_dir) || die 'failed to move'; symlink(abs_path($tmp_dir), $dir); - $t->get_ok( - '/needles/opensuse/test-newneedle.png?jsonfile=t/data/openqa/share/tests/opensuse/needles/test-newneedle.json') + $t->get_ok('/needles/opensuse/test-newneedle.png?jsonfile=t/data/openqa/share/tests/opensuse/needles/test-newneedle.json') ->status_is(200, 'needle also accessible when containing directory is a symlink')->content_type_is('image/png'); unlink($dir); File::Copy::move($tmp_dir, $dir); diff --git a/t/ui/13-admin.t b/t/ui/13-admin.t index 15a4820a5613..0cf4af42bdc5 100644 --- a/t/ui/13-admin.t +++ b/t/ui/13-admin.t @@ -203,15 +203,10 @@ subtest 'add test suite' => sub() { @cells = $driver->find_child_elements($elem, 'td'); is(scalar @cells, 1 * $column_count, 'everything filtered out but one row'); is($cells[0 * $column_count + 0]->get_text(), 'RAID0', 'remaining row has correct name'); - is( - $cells[0 * $column_count + 1]->get_text(), - "DESKTOP=kde\nINSTALLONLY=1\nRAIDLEVEL=0", - 'remaining row has correct settings' - ); + is($cells[0 * $column_count + 1]->get_text(), "DESKTOP=kde\nINSTALLONLY=1\nRAIDLEVEL=0", 'remaining row has correct settings'); is($driver->find_element_by_xpath('//input[@value="New test suite"]')->click(), 1, 'new test suite'); - is(element_prop_by_selector('.dataTables_filter input'), '((DESKTOP=kdeINSTALLONLY=1)|(new row))', - 'search cleared'); + is(element_prop_by_selector('.dataTables_filter input'), '((DESKTOP=kdeINSTALLONLY=1)|(new row))', 'search cleared'); @cells = $driver->find_child_elements($elem, 'td'); is(scalar @cells, 2 * $column_count, 'filtered row and empty row present'); is($cells[0 * $column_count + 0]->get_text(), 'RAID0', 'filtered row has correct name'); @@ -243,17 +238,15 @@ subtest 'add test suite' => sub() { is($driver->find_element_by_xpath('//button[@title="Add"]')->click(), 1, 'added'); # leave the ajax some time wait_for_ajax; -# now read data back and compare to original, name and value shall be the same, key sanitized by removing all special chars - $elem = $driver->find_element('.admintable tbody tr:nth-child(7)') - ; # sorting by name so `t"e\st'Suite\'` is supposed to be the 7th element + # now read data back and compare to original, name and value shall be the same, key sanitized by removing all special chars + $elem = $driver->find_element('.admintable tbody tr:nth-child(7)'); # sorting by name so `t"e\st'Suite\'` is supposed to be the 7th element is($elem->get_text(), "$suiteName testKey=$suiteValue", 'stored text is the same except key'); # try to edit and save ok($driver->find_child_element($elem, './td/button[@title="Edit"]', 'xpath')->click(), 'editing enabled'); wait_for_ajax; $elem = $driver->find_element('.admintable tbody tr:nth-child(7) td textarea'); - is(element_prop_by_selector('.admintable tbody tr:nth-child(7) td input[type="text"]'), - $suiteName, 'suite name edit box match'); + is(element_prop_by_selector('.admintable tbody tr:nth-child(7) td input[type="text"]'), $suiteName, 'suite name edit box match'); is($elem->get_text, "testKey=$suiteValue", 'textarea matches sanitized key and value'); ok($driver->find_child_element($elem, '//button[@title="Update"]', 'xpath')->click(), 'editing saved'); @@ -286,18 +279,12 @@ subtest 'add job group' => sub() { # add new parentless group, leave name empty (which should lead to error) $driver->find_element_by_xpath('//a[@title="Add new job group on top-level"]')->click(); - is($driver->find_element('#create_group_button')->get_attribute('disabled'), - 'true', 'create group submit button is disabled if leave name is empty'); + is($driver->find_element('#create_group_button')->get_attribute('disabled'), 'true', 'create group submit button is disabled if leave name is empty'); # now leave group name with blank which also lead to error my $groupname = $driver->find_element_by_id('new_group_name'); $groupname->send_keys(' '); - is($driver->find_element('#create_group_button')->get_attribute('disabled'), - 'true', 'create group submit button is disabled if leave name as blank'); - is( - $driver->find_element('#new_group_name')->get_attribute('class'), - 'form-control is-invalid', - 'group name input marked as invalid' - ); + is($driver->find_element('#create_group_button')->get_attribute('disabled'), 'true', 'create group submit button is disabled if leave name as blank'); + is($driver->find_element('#new_group_name')->get_attribute('class'), 'form-control is-invalid', 'group name input marked as invalid'); $groupname->clear(); $driver->find_element_by_id('create_group_button')->click(); wait_for_ajax; @@ -329,8 +316,7 @@ subtest 'add job group' => sub() { # check whether parent is present $list_element = $driver->find_element_by_id('job_group_list'); @parent_group_entries = $driver->find_child_elements($list_element, 'li'); - is(@parent_group_entries, 4, - 'now 4 top-level groups present (one is new parent, remaining are parentless job groups)'); + is(@parent_group_entries, 4, 'now 4 top-level groups present (one is new parent, remaining are parentless job groups)'); my $new_groups_entry = shift @parent_group_entries; is($new_groups_entry->get_text(), 'New parent group', 'new group present'); @@ -342,8 +328,7 @@ subtest 'add job group' => sub() { $list_element = $driver->find_element_by_id('job_group_list'); @parent_group_entries = $driver->find_child_elements($list_element, 'li'); - is(@parent_group_entries, 4, - 'now 4 top-level groups present (one is new parent, remaining are parentless job groups)'); + is(@parent_group_entries, 4, 'now 4 top-level groups present (one is new parent, remaining are parentless job groups)'); is((shift @parent_group_entries)->get_text(), 'opensuse', 'first parentless group from fixtures present'); is((shift @parent_group_entries)->get_text(), 'opensuse test', 'second parentless group from fixtures present'); is((shift @parent_group_entries)->get_text(), 'Cool Group', 'new parentless group present'); @@ -377,11 +362,7 @@ subtest 'job property editor' => sub() { $groupname->send_keys(Selenium::Remote::WDKeys->KEYS->{backspace}); is($driver->find_element('#properties p.buttons button.btn-primary')->get_attribute('disabled'), 'true', 'group properties save button is disabled if name is left empty'); - is( - $driver->find_element('#editor-name')->get_attribute('class'), - 'form-control is-invalid', - 'editor name input marked as invalid' - ); + is($driver->find_element('#editor-name')->get_attribute('class'), 'form-control is-invalid', 'editor name input marked as invalid'); $driver->refresh(); $driver->find_element_by_id('toggle-group-properties')->click(); @@ -391,11 +372,7 @@ subtest 'job property editor' => sub() { $groupname->send_keys(' '); is($driver->find_element('#properties p.buttons button.btn-primary')->get_attribute('disabled'), 'true', 'group properties save button is disabled if name is blank'); - is( - $driver->find_element('#editor-name')->get_attribute('class'), - 'form-control is-invalid', - 'editor name input marked as invalid' - ); + is($driver->find_element('#editor-name')->get_attribute('class'), 'form-control is-invalid', 'editor name input marked as invalid'); $driver->refresh(); $driver->find_element_by_id('toggle-group-properties')->click(); }; @@ -409,8 +386,7 @@ subtest 'job property editor' => sub() { $ele = $driver->find_element_by_id('editor-keep-important-results-in-days'); $ele->send_keys(Selenium::Remote::WDKeys->KEYS->{control}, 'a'); $ele->send_keys('500'); - is($driver->find_element('#properties p.buttons button.btn-primary')->get_attribute('disabled'), - undef, 'group properties save button is enabled'); + is($driver->find_element('#properties p.buttons button.btn-primary')->get_attribute('disabled'), undef, 'group properties save button is enabled'); $driver->find_element_by_id('editor-carry-over-bugrefs')->click(); $driver->find_element('#properties p.buttons button.btn-primary')->click(); wait_for_ajax(msg => 'ensure there is no race condition, even though the page is reloaded'); @@ -444,8 +420,7 @@ subtest 'edit job templates' => sub() { my $form = $driver->find_element_by_id('editor-form'); ok($form->is_displayed(), 'editor form is shown by default'); ok($form->child('.progress-indication')->is_hidden(), 'spinner is hidden'); - is(scalar @{$driver->find_elements('Test new medium as part of this group', 'link_text')}, - 0, 'link to add a new medium (via legacy editor) not shown'); + is(scalar @{$driver->find_elements('Test new medium as part of this group', 'link_text')}, 0, 'link to add a new medium (via legacy editor) not shown'); my $yaml = $driver->execute_script('return editor.doc.getValue();'); like($yaml, qr/products:\s*{}.*scenarios:\s*{}/s, 'default YAML was fetched') or diag explain $yaml; }; @@ -603,11 +578,8 @@ subtest 'asset list' => sub { ['iso/openSUSE-13.1-DVD-i586-Build0091-Media.iso', '99947', '4 byte', '1001'], 'asset with unknown last use and size' ); - is_deeply( - get_cell_contents('tr:nth-child(2)'), - ['iso/openSUSE-13.1-DVD-x86_64-Build0091-Media.iso', '99963', '4 byte', '1001 1002'], - 'asset with last use' - ); + is_deeply(get_cell_contents('tr:nth-child(2)'), ['iso/openSUSE-13.1-DVD-x86_64-Build0091-Media.iso', '99963', '4 byte', '1001 1002'], + 'asset with last use'); # assets by group my @assets_by_group = map { $_->get_text() } $driver->find_elements('#assets-by-group > li'); @@ -615,11 +587,7 @@ subtest 'asset list' => sub { note('ignoring untracked assets in your checkout (likely created by previous tests)'); splice(@assets_by_group, 0, 1); } - is_deeply( - \@assets_by_group, - ["opensuse test\n16 byte / 100 GiB", "opensuse\n16 byte / 100 GiB"], - 'groups of "assets by group"' - ); + is_deeply(\@assets_by_group, ["opensuse test\n16 byte / 100 GiB", "opensuse\n16 byte / 100 GiB"], 'groups of "assets by group"'); $driver->click_element_ok('#group-1001-checkbox + label', 'css'); is_deeply( [map { $_->get_text() } $driver->find_elements('#group-1001-checkbox ~ ul li')], @@ -639,11 +607,7 @@ subtest 'asset list' => sub { and $asset4_a->click(); wait_for_ajax; - like( - $driver->find_element("div#flash-messages .alert span")->get_text, - qr/The asset was deleted successfully/, - 'delete asset successfully' - ); + like($driver->find_element("div#flash-messages .alert span")->get_text, qr/The asset was deleted successfully/, 'delete asset successfully'); $asset4_a->click(); wait_for_ajax; is( diff --git a/t/ui/14-dashboard.t b/t/ui/14-dashboard.t index 4fbda889c1fc..c40f8e551c0b 100644 --- a/t/ui/14-dashboard.t +++ b/t/ui/14-dashboard.t @@ -31,8 +31,7 @@ my @build_headings = $driver->find_elements('.h4', 'css'); is(scalar @build_headings, 4, '4 builds shown'); subtest 'Back to top button' => sub { - my $check_visibility - = sub { $driver->execute_script('return getComputedStyle(document.getElementById("back-to-top")).display') }; + my $check_visibility = sub { $driver->execute_script('return getComputedStyle(document.getElementById("back-to-top")).display') }; is $check_visibility->(), 'none', 'button is not visible'; # scroll down resizing the jumbotron to ensure there's enough content for scrolling down $driver->execute_script( @@ -48,11 +47,7 @@ subtest 'Back to top button' => sub { # click on last build which should be Build0091 $driver->find_child_element($build_headings[-1], 'a', 'css')->click(); -like( - $driver->find_element_by_id('summary')->get_text(), - qr/Overall Summary of opensuse test build 0091/, - 'we are on build 91' -); +like($driver->find_element_by_id('summary')->get_text(), qr/Overall Summary of opensuse test build 0091/, 'we are on build 91'); is($driver->get('/?limit_builds=1'), 1, 'index page accepts limit_builds parameter'); wait_for_ajax; @@ -70,27 +65,18 @@ my $build_url = $driver->get_current_url(); $build_url =~ s/\?.*//; log_debug('build_url: ' . $build_url); is(scalar @{$driver->find_elements('.h4', 'css')}, 5, 'number of builds for opensuse'); -is( - $driver->find_element_by_id('group_description')->get_text(), - "Test description\nwith bugref bsc#1234", - 'description shown' -); +is($driver->find_element_by_id('group_description')->get_text(), "Test description\nwith bugref bsc#1234", 'description shown'); is( $driver->find_element('#group_description a')->get_attribute('href'), 'https://bugzilla.suse.com/show_bug.cgi?id=1234', 'bugref in description rendered as link' ); $driver->get('/group_overview/1002'); -is(scalar @{$driver->find_elements('#group_description', 'css')}, - 0, 'no well for group description shown if none present'); +is(scalar @{$driver->find_elements('#group_description', 'css')}, 0, 'no well for group description shown if none present'); is($driver->get($build_url . '?limit_builds=2'), 1, 'group overview page accepts query parameter, too'); $driver->get($build_url . '?limit_builds=0'); is(scalar @{$driver->find_elements('div.build-row .h4', 'css')}, 0, 'all builds filtered out'); -is( - $driver->find_element('h2')->get_text(), - 'Last Builds for opensuse', - 'group name shown correctly when all builds filtered out' -); +is($driver->find_element('h2')->get_text(), 'Last Builds for opensuse', 'group name shown correctly when all builds filtered out'); $driver->find_element_by_link_text('400')->click(); is($driver->find_element('#more_builds b')->get_text(), 400, 'limited to the selected number'); @@ -121,8 +107,7 @@ is(scalar @{$driver->find_elements('h2', 'css')}, 2, 'a single, empty group para subtest 'filter form' => sub { $driver->get('/'); - like($driver->find_element('#filter-panel .help_popover')->get_attribute('data-title'), - qr/Help/, 'help popover is shown'); + like($driver->find_element('#filter-panel .help_popover')->get_attribute('data-title'), qr/Help/, 'help popover is shown'); wait_for_ajax_and_animations; my $url = $driver->get_current_url; $driver->find_element('#filter-panel .card-header')->click(); diff --git a/t/ui/15-admin-workers.t b/t/ui/15-admin-workers.t index 511a6d5a451a..0f52c7b1a759 100644 --- a/t/ui/15-admin-workers.t +++ b/t/ui/15-admin-workers.t @@ -22,8 +22,7 @@ my $offline_worker_id = 8; my $test_case = OpenQA::Test::Case->new; my $schema_name = OpenQA::Test::Database->generate_schema_name; -my $schema - = $test_case->init_data(schema_name => $schema_name, fixtures_glob => '01-jobs.pl 02-workers.pl 03-users.pl'); +my $schema = $test_case->init_data(schema_name => $schema_name, fixtures_glob => '01-jobs.pl 02-workers.pl 03-users.pl'); assume_all_assets_exist; embed_server_for_testing( @@ -56,11 +55,7 @@ $driver->title_is("openQA", "on main page"); subtest 'offline status' => sub { $driver->get("/admin/workers/$offline_worker_id"); - like( - $driver->find_element_by_class('status-info')->get_text, - qr/Seen: .*ago.*Status: Offline$/s, - 'worker just shown as offline' - ); + like($driver->find_element_by_class('status-info')->get_text, qr/Seen: .*ago.*Status: Offline$/s, 'worker just shown as offline'); $workers->find($offline_worker_id)->update({error => 'graceful disconnect at foo', t_seen => $online_timestamp}); $driver->get("/admin/workers/$offline_worker_id"); @@ -72,11 +67,7 @@ subtest 'offline status' => sub { $workers->find($offline_worker_id)->update({t_seen => undef, error => undef}); $driver->get("/admin/workers/$offline_worker_id"); - like( - $driver->find_element_by_class('status-info')->get_text, - qr/Seen: never.*Status: Offline$/s, - 'worker with t_seen not set yet shown as "never"' - ); + like($driver->find_element_by_class('status-info')->get_text, qr/Seen: never.*Status: Offline$/s, 'worker with t_seen not set yet shown as "never"'); }; # without loggin we hide properties of worker @@ -106,10 +97,8 @@ subtest 'worker overview' => sub { is($driver->find_element('tr#worker_1 .action')->get_text(), '', 'localhost:1 do not show delete button'); is($driver->find_element('tr#worker_2 .action')->get_text(), '', 'remotehost:1 do not show delete button'); is($driver->find_element("tr#worker_$broken_worker_id .action")->get_text(), '', 'foo do not show delete button'); - is($driver->find_element("tr#worker_$online_worker_id .action")->get_text(), - '', 'online_test do not show delete button'); - is($driver->find_element("tr#worker_$offline_worker_id .action .btn")->is_displayed(), - 1, 'offline worker show delete button'); + is($driver->find_element("tr#worker_$online_worker_id .action")->get_text(), '', 'online_test do not show delete button'); + is($driver->find_element("tr#worker_$offline_worker_id .action .btn")->is_displayed(), 1, 'offline worker show delete button'); # check worker 1 is($driver->find_element('tr#worker_1 .worker')->get_text(), 'localhost:1', 'localhost:1 shown'); @@ -134,10 +123,7 @@ subtest 'worker overview' => sub { # check worker 3 (broken one added in schema hook) is($driver->find_element("tr#worker_$broken_worker_id .worker")->get_text(), 'foo:42', 'foo shown'); $driver->find_element("tr#worker_$broken_worker_id .help_popover")->click(); - is( - $driver->find_element("tr#worker_$broken_worker_id .status")->get_text(), - 'Broken', "worker $broken_worker_id is broken", - ); + is($driver->find_element("tr#worker_$broken_worker_id .status")->get_text(), 'Broken', "worker $broken_worker_id is broken",); like($driver->find_element('.popover')->get_text(), qr/Error\nout of order/, 'reason for brokenness shown'); }; @@ -162,11 +148,7 @@ my @entries = map { $_->get_text() } $driver->find_child_elements($table, 'tbody is(scalar @entries, 6, 'two previous jobs shown (3 cols per row)'); is_deeply( \@entries, - [ - 'opensuse-13.1-NET-x86_64-Build0091-kde@64bit', - '', 'not yet', 'opensuse-Factory-staging_e-x86_64-Build87.5011-minimalx@32bit', - '0', 'about an hour ago', - ], + ['opensuse-13.1-NET-x86_64-Build0091-kde@64bit', '', 'not yet', 'opensuse-Factory-staging_e-x86_64-Build87.5011-minimalx@32bit', '0', 'about an hour ago',], 'correct entries shown' ); diff --git a/t/ui/15-comments.t b/t/ui/15-comments.t index a5407aeeda49..fc0cd1b4f1c9 100644 --- a/t/ui/15-comments.t +++ b/t/ui/15-comments.t @@ -16,8 +16,7 @@ use OpenQA::SeleniumTest; my $test_case = OpenQA::Test::Case->new; my $schema_name = OpenQA::Test::Database->generate_schema_name; -my $schema - = $test_case->init_data(schema_name => $schema_name, fixtures_glob => '01-jobs.pl 03-users.pl 04-products.pl'); +my $schema = $test_case->init_data(schema_name => $schema_name, fixtures_glob => '01-jobs.pl 03-users.pl 04-products.pl'); my $t = Test::Mojo->new('OpenQA::WebAPI'); @@ -46,8 +45,7 @@ $driver->title_is("openQA", "back on main page"); # check 'reviewed' labels -$t->get_ok('/dashboard_build_results?limit_builds=10')->status_is(200) - ->element_count_is('.review', 2, 'exactly two builds marked as \'reviewed\'') +$t->get_ok('/dashboard_build_results?limit_builds=10')->status_is(200)->element_count_is('.review', 2, 'exactly two builds marked as \'reviewed\'') ->element_exists('.badge-all-passed', 'one build is marked as \'reviewed-all-passed\' because all tests passed'); $driver->find_element_by_link_text('opensuse')->click(); @@ -75,7 +73,7 @@ sub write_comment ($text, $desc) { wait_for_ajax msg => $desc; }; return undef unless my $error = $@; - die $error if ($error !~ qr/unexpected alert/i) || ($attempts >= $max_write_attempts); # uncoverable statement + die $error if ($error !~ qr/unexpected alert/i) || ($attempts >= $max_write_attempts); # uncoverable statement # try to dismiss the alert "The comment text mustn't be empty." that is for some reason possibly shown # note: Even waiting until document.forms.commentForm.text.value is not empty anymore before submitting @@ -107,8 +105,7 @@ sub check_comment { # check heading my $first_heading_text = $comment_headings[0]->get_text(); if ($edited) { - is($first_heading_text, "$user_name wrote less than a minute ago (last edited less than a minute ago)", - 'heading text'); + is($first_heading_text, "$user_name wrote less than a minute ago (last edited less than a minute ago)", 'heading text'); } else { is($first_heading_text, "$user_name wrote less than a minute ago", 'heading text'); @@ -166,8 +163,7 @@ sub test_comment_editing { wait_for_ajax(msg => 'comment removal dismissed within ' . $context); # the comment mustn't be deleted yet - is($driver->find_element('div.media-comment')->get_text(), - $edited_test_message, "comment is still there after dismissing removal"); + is($driver->find_element('div.media-comment')->get_text(), $edited_test_message, "comment is still there after dismissing removal"); # try to remove the first displayed comment again (and accept this time); $driver->find_element('button.remove-edit-button')->click(); @@ -279,11 +275,7 @@ subtest 'commenting in test results including labels' => sub { $driver->find_element_by_link_text('Job Groups')->click(); $driver->find_element_by_link_text('Build0048')->click(); $driver->find_element('.status')->click(); - is( - $driver->get_title(), - 'openQA: opensuse-Factory-DVD-x86_64-Build0048-doc@64bit test results', - "on test result page" - ); + is($driver->get_title(), 'openQA: opensuse-Factory-DVD-x86_64-Build0048-doc@64bit test results', "on test result page"); switch_to_comments_tab(0); subtest 'help popover' => sub { @@ -329,19 +321,11 @@ EOM subtest 'check comment availability sign on test result overview' => sub { $driver->find_element_by_link_text('Job Groups')->click(); - like( - $driver->find_element_by_id('current-build-overview')->get_text(), - qr/\QBuild 0048\E/, - 'on the right build' - ); + like($driver->find_element_by_id('current-build-overview')->get_text(), qr/\QBuild 0048\E/, 'on the right build'); $driver->find_element('#current-build-overview a')->click(); $driver->title_is("openQA: Test summary", "back on test group overview"); - is( - $driver->find_element('#res_DVD_x86_64_doc .fa-comment')->get_attribute('title'), - '3 comments available', - "test results show available comment(s)" - ); + is($driver->find_element('#res_DVD_x86_64_doc .fa-comment')->get_attribute('title'), '3 comments available', "test results show available comment(s)"); }; subtest 'add label and bug and check availability sign' => sub { @@ -349,11 +333,7 @@ EOM write_comment 'label:true_positive', 'comment added to job 99938'; $driver->find_element_by_link_text('Job Groups')->click(); $driver->find_element('#current-build-overview a')->click(); - is( - $driver->find_element('#res_DVD_x86_64_doc .fa-bookmark')->get_attribute('title'), - 'Label: true_positive', - 'label icon shown' - ); + is($driver->find_element('#res_DVD_x86_64_doc .fa-bookmark')->get_attribute('title'), 'Label: true_positive', 'label icon shown'); $driver->get('/tests/99939#comments'); write_comment 'label:force_result:passed:forceresult_for_testing_purposes', 'comment added to job 99939'; $driver->find_element_by_link_text('Job Groups')->click(); @@ -372,29 +352,19 @@ EOM "Bug referenced: bsc#1234\nsome title with \"quotes\" and elements", 'bug icon shown for bsc#1234, title rendered with new-line, HTML code is rendered as text' ); - is( - $driver->find_element('#res_DVD_x86_64_doc .fa-bolt')->get_attribute('title'), - 'Bug referenced: poo#4321', - 'bug icon shown for poo#4321' - ); + is($driver->find_element('#res_DVD_x86_64_doc .fa-bolt')->get_attribute('title'), 'Bug referenced: poo#4321', 'bug icon shown for poo#4321'); my @labels = $driver->find_elements('#res_DVD_x86_64_doc .test-label', 'css'); is(scalar @labels, 3, '3 bugrefs shown'); $t->get_ok($driver->get_current_url())->status_is(200); - is($t->tx->res->dom->at('#res_DVD_x86_64_doc .fa-bug')->parent->{href}, - 'https://bugzilla.suse.com/show_bug.cgi?id=1234'); + is($t->tx->res->dom->at('#res_DVD_x86_64_doc .fa-bug')->parent->{href}, 'https://bugzilla.suse.com/show_bug.cgi?id=1234'); $driver->find_element_by_link_text('opensuse')->click(); - is($driver->find_element('.badge-all-passed')->get_attribute('title'), - 'All passed', 'build should be marked because all tests passed'); + is($driver->find_element('.badge-all-passed')->get_attribute('title'), 'All passed', 'build should be marked because all tests passed'); subtest 'progress items work, too' => sub { $driver->get('/tests/99926#comments'); write_comment 'poo#9876', 'comment added to job 99926'; $driver->find_element_by_link_text('Job Groups')->click(); - like( - $driver->find_element_by_id('current-build-overview')->get_text(), - qr/\QBuild 87.5011\E/, - 'on the right build' - ); + like($driver->find_element_by_id('current-build-overview')->get_text(), qr/\QBuild 87.5011\E/, 'on the right build'); $driver->find_element('#current-build-overview a')->click(); is( $driver->find_element('#res_staging_e_x86_64_minimalx .fa-bolt')->get_attribute('title'), @@ -407,11 +377,7 @@ EOM $driver->get('/tests/99926#comments'); write_comment 'poo#9875 poo#9874', 'comment added to job 99926 (2)'; $driver->find_element_by_link_text('Job Groups')->click(); - like( - $driver->find_element_by_id('current-build-overview')->get_text(), - qr/\QBuild 87.5011\E/, - 'on the right build' - ); + like($driver->find_element_by_id('current-build-overview')->get_text(), qr/\QBuild 87.5011\E/, 'on the right build'); $driver->find_element('#current-build-overview a')->click(); my @bugrefs = $driver->find_elements('#res_staging_e_x86_64_minimalx .fa-bolt', 'css'); is($bugrefs[0]->get_attribute('title'), 'Bug referenced: poo#9876', 'first bugref shown'); @@ -419,8 +385,7 @@ EOM is($bugrefs[2]->get_attribute('title'), 'Bug referenced: poo#9874', 'third bugref shown'); is($bugrefs[3], undef, 'correct number of bugrefs shown'); $t->get_ok($driver->get_current_url())->status_is(200); - is($t->tx->res->dom->at('#res_staging_e_x86_64_minimalx .fa-bolt')->parent->{href}, - 'https://progress.opensuse.org/issues/9876'); + is($t->tx->res->dom->at('#res_staging_e_x86_64_minimalx .fa-bolt')->parent->{href}, 'https://progress.opensuse.org/issues/9876'); }; $driver->find_element_by_link_text('opensuse')->click(); @@ -441,14 +406,12 @@ subtest 'editing when logged in as regular user' => sub { my @group_overview_urls = ('/group_overview/1001', '/parent_group_overview/1'); sub no_edit_no_remove_on_other_comments_expected { - is(@{$driver->find_elements('button.trigger-edit-button', 'css')}, - 0, "edit not displayed for other users comments"); + is(@{$driver->find_elements('button.trigger-edit-button', 'css')}, 0, "edit not displayed for other users comments"); is(@{$driver->find_elements('button.remove-edit-button', 'css')}, 0, "removal not displayed for regular user"); } sub only_edit_for_own_comments_expected { is(@{$driver->find_elements('button.trigger-edit-button', 'css')}, 1, "own comments can be edited"); - is(@{$driver->find_elements('button.remove-edit-button', 'css')}, 0, - "no comments can be removed, even not own"); + is(@{$driver->find_elements('button.remove-edit-button', 'css')}, 0, "no comments can be removed, even not own"); } subtest 'test pinned comments: ' . $_ => sub { @@ -456,8 +419,7 @@ subtest 'editing when logged in as regular user' => sub { $driver->get($group_url); write_comment $description_test_message, 'pinned comment added to job group'; $driver->get($group_url); - is($driver->find_element('#group_descriptions .media-comment')->get_text(), - $description_test_message, 'comment is pinned'); + is($driver->find_element('#group_descriptions .media-comment')->get_text(), $description_test_message, 'comment is pinned'); } for (@group_overview_urls); diff --git a/t/ui/15-search.t b/t/ui/15-search.t index f943777d7546..fde329f1ef44 100644 --- a/t/ui/15-search.t +++ b/t/ui/15-search.t @@ -40,15 +40,12 @@ subtest 'Perl modules' => sub { is scalar @entries, 2, '2 elements' or return; my $first = $entries[0]; - is $first->child('.occurrence')->get_text(), 'opensuse/tests/installation/installer_timezone.pm', - 'expected occurrence'; + is $first->child('.occurrence')->get_text(), 'opensuse/tests/installation/installer_timezone.pm', 'expected occurrence'; my $second = $entries[1]; - is $second->child('.occurrence')->get_text(), 'opensuse/tests/installation/installer_timezone.pm', - 'expected occurrence'; + is $second->child('.occurrence')->get_text(), 'opensuse/tests/installation/installer_timezone.pm', 'expected occurrence'; is $second->child('.contents')->get_text(), - qq{ 3 # Summary: Verify timezone settings page\n} - . qq{ 10 assert_screen "inst-timezone", 125 || die 'no timezone';}, + qq{ 3 # Summary: Verify timezone settings page\n} . qq{ 10 assert_screen "inst-timezone", 125 || die 'no timezone';}, 'expected contents'; }; diff --git a/t/ui/16-activity-view.t b/t/ui/16-activity-view.t index d567adc3aa30..028f8903aeb0 100644 --- a/t/ui/16-activity-view.t +++ b/t/ui/16-activity-view.t @@ -75,10 +75,7 @@ subtest 'Current jobs' => sub { 99927 => 'job_update_result', 99936 => 'job_create', 99937 => 'job_done', - ( - map { $_ => 'job_create' } 99981, - 99928, 99963, 99938, 80001, 80002, 80003, 80004, 80005, 80006, 80007, 80008, 80009, 80010 - )); + (map { $_ => 'job_create' } 99981, 99928, 99963, 99938, 80001, 80002, 80003, 80004, 80005, 80006, 80007, 80008, 80009, 80010)); my $user = $schema->resultset('Users')->find({is_admin => 1}); my $jobs = $schema->resultset('Jobs'); diff --git a/t/ui/16-tests_dependencies.t b/t/ui/16-tests_dependencies.t index 96c6cbea21d1..3628ab6c78d9 100644 --- a/t/ui/16-tests_dependencies.t +++ b/t/ui/16-tests_dependencies.t @@ -170,21 +170,9 @@ subtest 'graph rendering' => sub { $check_element_quandity->('.edgePath', 3, 'three edges present'); $check_element_quandity->('.node', 5, 'five nodes present'); - like( - get_tooltip(99938), - qr/.*opensuse-Factory-DVD-x86_64-Build0048-doc\@64bit.*START_AFTER_TEST=kde.*/, - 'tooltip for doc job' - ); - like( - get_tooltip(99963), - qr/.*opensuse-13.1-DVD-x86_64-Build0091-kde\@64bit.*START_AFTER_TEST=doc.*PARALLEL_WITH=kde.*/, - 'tooltip for kde job 99963' - ); - like( - get_tooltip(99927), - qr/.*opensuse-13.1-DVD-i586-Build0091-RAID0\@32bit.*START_DIRECTLY_AFTER_TEST=kde.*/, - 'tooltip for RAID0 job 99927' - ); + like(get_tooltip(99938), qr/.*opensuse-Factory-DVD-x86_64-Build0048-doc\@64bit.*START_AFTER_TEST=kde.*/, 'tooltip for doc job'); + like(get_tooltip(99963), qr/.*opensuse-13.1-DVD-x86_64-Build0091-kde\@64bit.*START_AFTER_TEST=doc.*PARALLEL_WITH=kde.*/, 'tooltip for kde job 99963'); + like(get_tooltip(99927), qr/.*opensuse-13.1-DVD-i586-Build0091-RAID0\@32bit.*START_DIRECTLY_AFTER_TEST=kde.*/, 'tooltip for RAID0 job 99927'); like(get_tooltip(99961), qr/.*opensuse-13.1-NET-x86_64-Build0091-kde\@64bit.*<\/p>/, 'tooltip for kde job 99963'); subtest 'cloned job' => sub { diff --git a/t/ui/16-tests_job_next_previous.t b/t/ui/16-tests_job_next_previous.t index aa794a9a96ca..d977b80a86f8 100644 --- a/t/ui/16-tests_job_next_previous.t +++ b/t/ui/16-tests_job_next_previous.t @@ -84,17 +84,11 @@ sub goto_next_previous_tab { } # check job next and previous not loaded when open tests/x -$t->get_ok('/tests/99946')->status_is(200)->element_exists_not( - '#job_next_previous_table_wrapper .dataTables_wrapper', - 'datatable of job next and previous not loaded when open tests/x' -); +$t->get_ok('/tests/99946')->status_is(200) + ->element_exists_not('#job_next_previous_table_wrapper .dataTables_wrapper', 'datatable of job next and previous not loaded when open tests/x'); my $job_header = $t->tx->res->dom->at('#next_previous #scenario .h5'); -like( - OpenQA::Test::Case::trim_whitespace($job_header->all_text), - qr/Next & previous results for opensuse-13\.1-DVD-i586-textmode/, - 'header for job scenario' -); +like(OpenQA::Test::Case::trim_whitespace($job_header->all_text), qr/Next & previous results for opensuse-13\.1-DVD-i586-textmode/, 'header for job scenario'); # trigger job next and previous for current job $driver->title_is('openQA', 'on main page'); @@ -119,13 +113,11 @@ is((shift @tds)->get_text(), 'L', '99947 is the latest job'); my $state = $driver->find_child_element(shift @tds, '.status', 'css'); is($state->get_attribute('title'), 'Done: passed', 'the latest job 99947 was passed'); is((shift @tds)->get_text(), '0092', 'build of 99947 is 0092'); -is(scalar @{$driver->find_elements('#job_next_previous_table #job_result_99945')}, - 1, 'found nearest previous job 99945'); +is(scalar @{$driver->find_elements('#job_next_previous_table #job_result_99945')}, 1, 'found nearest previous job 99945'); is(scalar @{$driver->find_elements("//*[\@title='Done: incomplete']", 'xpath')}, 6, 'include 6 incomletes in page 1'); $driver->find_element_by_link_text('Next')->click(); is(scalar @{$driver->find_elements("//*[\@title='Done: incomplete']", 'xpath')}, 2, 'include 2 incomletes in page 2'); -is(scalar @{$driver->find_elements('#job_next_previous_table #job_result_99901')}, - 1, 'found farmost previous job 99901'); +is(scalar @{$driver->find_elements('#job_next_previous_table #job_result_99901')}, 1, 'found farmost previous job 99901'); # select the most previous job in the table and check its job next and previous results $driver->find_element('[href="/tests/99901"]')->click(); @@ -145,8 +137,7 @@ is((shift @tds)->get_text(), 'about 4 hours ago ( 01:00 hours )', 'finished and is(scalar @{$driver->find_elements('#job_next_previous_table #job_result_99902')}, 1, 'found nearest next job 99902'); $driver->find_element_by_link_text('Previous')->click(); is(scalar @{$driver->find_elements('#job_next_previous_table #job_result_99946')}, 1, 'found farmost next job 99946'); -is(scalar @{$driver->find_elements('#job_next_previous_table #job_result_99947')}, 1, - 'found next and latest job 99947'); +is(scalar @{$driver->find_elements('#job_next_previous_table #job_result_99947')}, 1, 'found next and latest job 99947'); # select the latest job in the table and check its job next and previous results $driver->find_element('[href="/tests/99947"]')->click(); @@ -161,19 +152,13 @@ $state = $driver->find_child_element(shift @tds, '.status', 'css'); is($state->get_attribute('title'), 'Done: passed', 'the latest job 99947 was passed'); is((shift @tds)->get_text(), '0092', 'build of 99947 is 0092'); is((shift @tds)->get_text(), 'about 2 hours ago ( 01:58 hours )', 'finished and duration of 99947'); -is(scalar @{$driver->find_elements('#job_next_previous_table #job_result_99946')}, - 1, 'found nearest previous job 99946'); +is(scalar @{$driver->find_elements('#job_next_previous_table #job_result_99946')}, 1, 'found nearest previous job 99946'); $driver->find_element_by_link_text('Next')->click(); -is(scalar @{$driver->find_elements('#job_next_previous_table #job_result_99901')}, - 1, 'found farmost previous job 99901'); +is(scalar @{$driver->find_elements('#job_next_previous_table #job_result_99901')}, 1, 'found farmost previous job 99901'); #check build links to overview page $driver->find_element_by_link_text('0091')->click(); -like( - $driver->find_element('#summary .card-header')->get_text(), - qr/Overall Summary of opensuse 13\.1 build 0091/, - 'build links to overview page' -); +like($driver->find_element('#summary .card-header')->get_text(), qr/Overall Summary of opensuse 13\.1 build 0091/, 'build links to overview page'); # check job next and previous of current running/scheduled job $driver->find_element_by_link_text('All Tests')->click(); @@ -263,8 +248,7 @@ is(scalar @{$driver->find_elements('#job_next_previous_table #job_result_99947') $driver->get('/tests/latest?previous_limit=1&next_limit=1#next_previous'); wait_for_ajax(); -is(scalar @{$driver->find_elements('#job_next_previous_table tbody tr', 'css')}, - 1, 'job next and previous of the latest job - 99981'); +is(scalar @{$driver->find_elements('#job_next_previous_table tbody tr', 'css')}, 1, 'job next and previous of the latest job - 99981'); subtest 'bug reference shown' => sub { my @bug_labels = $driver->find_elements('#bug-99981 .label_bug'); @@ -284,23 +268,19 @@ subtest 'server-side limit has precedence over user-specified limit' => sub { $limits->{previous_jobs_default_limit} = 2; # expected amount is the defined limit plus current and latest job - $t->get_ok('/tests/99910/ajax?previous_limit=0&next_limit=6', 'query with exceeding user-specified limit for next') - ->status_is(200); + $t->get_ok('/tests/99910/ajax?previous_limit=0&next_limit=6', 'query with exceeding user-specified limit for next')->status_is(200); my $jobs = $t->tx->res->json->{data}; is ref $jobs, 'ARRAY', 'data returned (1)' and is scalar @$jobs, 7, 'maximum limit for next is effective'; - $t->get_ok('/tests/99910/ajax?previous_limit=6&next_limit=0', - 'query with exceeding user-specified limit for previous')->status_is(200); + $t->get_ok('/tests/99910/ajax?previous_limit=6&next_limit=0', 'query with exceeding user-specified limit for previous')->status_is(200); $jobs = $t->tx->res->json->{data}; is ref $jobs, 'ARRAY', 'data returned (2)' and is scalar @$jobs, 7, 'maximum limit for previous is effective'; - $t->get_ok('/tests/99910/ajax?previous_limit=3&next_limit=0', 'query with low user-specified limit for next') - ->status_is(200); + $t->get_ok('/tests/99910/ajax?previous_limit=3&next_limit=0', 'query with low user-specified limit for next')->status_is(200); $jobs = $t->tx->res->json->{data}; is ref $jobs, 'ARRAY', 'data returned (3)' and is scalar @$jobs, 5, 'user-specified limit for next is effective'; - $t->get_ok('/tests/99910/ajax?previous_limit=0&next_limit=3', 'query with low user-specified limit for previous') - ->status_is(200); + $t->get_ok('/tests/99910/ajax?previous_limit=0&next_limit=3', 'query with low user-specified limit for previous')->status_is(200); $jobs = $t->tx->res->json->{data}; is ref $jobs, 'ARRAY', 'data returned (4)' and is scalar @$jobs, 5, 'user-specified limit for previous is effective'; diff --git a/t/ui/17-product-log.t b/t/ui/17-product-log.t index 0b9063f69057..6f3da4917612 100644 --- a/t/ui/17-product-log.t +++ b/t/ui/17-product-log.t @@ -21,8 +21,7 @@ my $fixtures = '01-jobs.pl 03-users.pl 04-products.pl'; my $schema = $test_case->init_data(schema_name => $schema_name, fixtures_glob => $fixtures); # simulate typo in START_AFTER_TEST to check for error message in this case -$schema->resultset('TestSuites')->find(1017)->settings->find({key => 'START_AFTER_TEST'}) - ->update({value => 'kda,textmode'}); +$schema->resultset('TestSuites')->find(1017)->settings->find({key => 'START_AFTER_TEST'})->update({value => 'kda,textmode'}); driver_missing unless my $driver = call_driver; @@ -75,11 +74,7 @@ subtest 'scheduled product displayed' => sub { my @cell_contents = map { $_->get_text } @cells; ok(shift @cell_contents, 'ID present'); ok(shift @cell_contents, 'time present'); - is_deeply( - \@cell_contents, - [qw(perci scheduled opensuse 13.1 DVD i586 0091 whatever.iso), ''], - 'row contents match specified scheduling parameter' - ); + is_deeply(\@cell_contents, [qw(perci scheduled opensuse 13.1 DVD i586 0091 whatever.iso), ''], 'row contents match specified scheduling parameter'); }; subtest 'trigger actions' => sub { @@ -108,20 +103,12 @@ subtest 'trigger actions' => sub { ['START_AFTER_TEST=kda@64bit not found - check for dependency typos and dependency cycles'], 'error message' ); - is_deeply( - $failed_job_info->[1]->{error_messages}, - ['textmode@32bit has no child, check its machine placed or dependency setting typos'], - 'error message' - ); + is_deeply($failed_job_info->[1]->{error_messages}, ['textmode@32bit has no child, check its machine placed or dependency setting typos'], 'error message'); $driver->find_element('.modal-footer button')->click(); # trigger rescheduling $action_links[2]->click(); - is( - $driver->get_alert_text, - 'Do you really want to reschedule all jobs for the product 1?', - 'confirmation prompt shown' - ); + is($driver->get_alert_text, 'Do you really want to reschedule all jobs for the product 1?', 'confirmation prompt shown'); $driver->accept_alert; wait_for_ajax msg => 'info message for rescheduling'; $driver->element_text_is('#flash-messages span', 'The product has been re-triggered as 2.', 'info message shown'),; @@ -136,11 +123,7 @@ subtest 'rescheduled ISO shown after refreshing page' => sub { ok($table, 'products tables found'); @rows = $driver->find_child_elements($table, './tbody/tr[./td[text() = "whatever.iso"]]', 'xpath'); is(scalar @rows, 2, 'rescheduled ISO shown'); - like( - $driver->find_element_by_id('product_log_table_info')->get_text(), - qr/Showing 1 to 2 of 2 entries/, - 'Info line shows number of entries' - ); + like($driver->find_element_by_id('product_log_table_info')->get_text(), qr/Showing 1 to 2 of 2 entries/, 'Info line shows number of entries'); $driver->find_element('#product_log_table_filter input')->send_keys('whatever.iso'); wait_for_ajax(msg => 'search applied'); @rows = $driver->find_child_elements($table, './tbody/tr[./td[text() = "whatever.iso"]]', 'xpath'); @@ -162,8 +145,7 @@ subtest 'showing a particular scheduled product' => sub { is(scalar @rows, 1, 'only one row shown'); like($rows[0]->get_text, qr/perci.*whatever\.iso/, 'row data'); like($driver->find_element('#scheduled-products h3 + table')->get_text, qr/FOO.*bar/, 'settings'); - like($driver->find_element('#scheduled-products h3 + pre')->get_text, - qr/check for dependency typos and dependency cycles/, 'results'); + like($driver->find_element('#scheduled-products h3 + pre')->get_text, qr/check for dependency typos and dependency cycles/, 'results'); }; kill_driver(); diff --git a/t/ui/18-tests-details.t b/t/ui/18-tests-details.t index c83b2f0394f0..4eb856c8ef7d 100644 --- a/t/ui/18-tests-details.t +++ b/t/ui/18-tests-details.t @@ -25,8 +25,7 @@ my $test_case = OpenQA::Test::Case->new; my $schema_name = OpenQA::Test::Database->generate_schema_name; my $schema = $test_case->init_data( schema_name => $schema_name, - fixtures_glob => - '01-jobs.pl 02-workers.pl 03-users.pl 04-products.pl ui-18-tests-details/01-job_modules.pl 07-needles.pl' + fixtures_glob => '01-jobs.pl 02-workers.pl 03-users.pl 04-products.pl ui-18-tests-details/01-job_modules.pl 07-needles.pl' ); my $jobs = $schema->resultset('Jobs'); @@ -99,8 +98,7 @@ sub find_candidate_needles { is(scalar @needle_parts, 3, 'exactly three parts per needle present (percentage, name, diff buttons)'); push(@needles, - OpenQA::Test::Case::trim_whitespace($needle_parts[0]->get_text()) . '%: ' - . OpenQA::Test::Case::trim_whitespace($needle_parts[1]->get_text())); + OpenQA::Test::Case::trim_whitespace($needle_parts[0]->get_text()) . '%: ' . OpenQA::Test::Case::trim_whitespace($needle_parts[1]->get_text())); } OpenQA::Test::Case::trim_whitespace($tag_elements[0]->get_text()) => \@needles; @@ -140,11 +138,8 @@ subtest 'show job modules execution time' => sub { ); for my $td (@$tds) { my $module_name = $td->children('div')->[0]->get_text(); - is( - $td->children('span')->[0]->get_text(), - $modules_execution_time{$module_name}, - $module_name . ' execution time showed correctly' - ) if $modules_execution_time{$module_name}; + is($td->children('span')->[0]->get_text(), $modules_execution_time{$module_name}, $module_name . ' execution time showed correctly') + if $modules_execution_time{$module_name}; } }; @@ -192,11 +187,8 @@ subtest 'filtering' => sub { is($count_headings->(), 0, 'no module headings shown when filter active'); # disable name filter - $driver->find_element('#details-name-filter')->send_keys( - Selenium::Remote::WDKeys->KEYS->{end}, - Selenium::Remote::WDKeys->KEYS->{backspace}, - Selenium::Remote::WDKeys->KEYS->{backspace}, - ); + $driver->find_element('#details-name-filter') + ->send_keys(Selenium::Remote::WDKeys->KEYS->{end}, Selenium::Remote::WDKeys->KEYS->{backspace}, Selenium::Remote::WDKeys->KEYS->{backspace},); is($count_steps->('ok'), 0, 'number of passed steps only with failed filter'); is($count_steps->('failed'), 2, 'number of failed steps only with failed filter'); is($count_headings->(), 0, 'no module headings shown when filter active'); @@ -223,11 +215,7 @@ sub check_report_links { like($url[0], qr{in\+scenario\+opensuse-13\.1-DVD-i586-kde}, 'bugzilla link contains scenario'); like($url[1], qr{progress.*new}, 'progress/redmine link for reporting test issues'); like($url[1], qr{in\+scenario\+opensuse-13\.1-DVD-i586-kde}, 'progress/redmine link contains scenario'); - like( - $url[1], - qr{in.*$failed_module.*$failed_module%2Fsteps%2F$failed_step}, - 'progress/redmine link refers to right module/step' - ); + like($url[1], qr{in.*$failed_module.*$failed_module%2Fsteps%2F$failed_step}, 'progress/redmine link refers to right module/step'); } subtest 'bug reporting' => sub { @@ -244,19 +232,14 @@ subtest 'scheduled product shown' => sub { my $scheduled_product_link = $driver->find_element('#scheduled-product-info > a'); my $expected_scheduled_product_id = $schema->resultset('Jobs')->find(99937)->scheduled_product_id; is($scheduled_product_link->get_text(), 'distri-dvd-1234', 'scheduled product name'); - like( - $scheduled_product_link->get_attribute('href'), - qr/\/admin\/productlog\?id=$expected_scheduled_product_id/, - 'scheduled product href' - ); + like($scheduled_product_link->get_attribute('href'), qr/\/admin\/productlog\?id=$expected_scheduled_product_id/, 'scheduled product href'); my $reschedule_link = $driver->find_element('#scheduled-product-info div > a'); my $expected_params = qr/scheduled_product_clone_id=$expected_scheduled_product_id&TEST=kde/; like $reschedule_link->get_attribute('data-url'), $expected_params, 'reschedule link shown'; $reschedule_link->click; $driver->accept_alert; wait_for_ajax msg => 'message for rescheduling'; - element_visible '#flash-messages .alert > span', qr/Scheduled product to clone settings from misses DISTRI/, undef, - 'error shown'; + element_visible '#flash-messages .alert > span', qr/Scheduled product to clone settings from misses DISTRI/, undef, 'error shown'; $driver->get('/tests/99963'); like( $driver->find_element_by_id('scheduled-product-info')->get_text(), @@ -280,8 +263,7 @@ subtest 'reason and log details on incomplete jobs' => sub { like($log_element->get_attribute('data-src'), qr/autoinst-log.txt/, 'log file embedded'); like($log_element->get_text(), qr/Crashed\?/, 'log contents loaded'); $driver->find_element_by_link_text('Investigation')->click; - $driver->find_element('table#investigation_status_entry') - ->text_like(qr/cannot provide hints/, 'investigation status content shown as table'); + $driver->find_element('table#investigation_status_entry')->text_like(qr/cannot provide hints/, 'investigation status content shown as table'); }; sub update_status { @@ -311,13 +293,8 @@ subtest 'running job' => sub { $driver->execute_script('window.enableStatusUpdates = false'); subtest 'info panel contents' => sub { - like( - $driver->find_element('#assigned-worker')->get_text, - qr/[ \n]*Assigned worker:[ \n]*localhost:1[ \n]*/, - 'worker displayed when job running' - ); - like($driver->find_element('#assigned-worker a')->get_attribute('href'), - qr{.*/admin/workers/1$}, 'link to worker correct'); + like($driver->find_element('#assigned-worker')->get_text, qr/[ \n]*Assigned worker:[ \n]*localhost:1[ \n]*/, 'worker displayed when job running'); + like($driver->find_element('#assigned-worker a')->get_attribute('href'), qr{.*/admin/workers/1$}, 'link to worker correct'); like( $driver->find_element('#scenario-description')->get_text, qr/[ \n]*Simple kde test, before advanced_kde[ \n]*/, @@ -335,8 +312,7 @@ subtest 'running job' => sub { $job_modules->search({job_id => 99961})->update({job_id => 99963}); update_status sub { scalar @{$driver->find_elements('#results .result')} >= 1 }, 'test modules shown'; is $driver->find_element('#module_glibc_i686 .result')->get_text, RUNNING, 'glibc_i686 is running'; - is scalar @{$driver->find_elements('#results .result')}, - $job_module_count, "all $job_module_count job modules rendered"; + is scalar @{$driver->find_elements('#results .result')}, $job_module_count, "all $job_module_count job modules rendered"; }; subtest 'missing text results are attempted to be reloaded' => sub { my $step_detail_element = $driver->find_element('#module_aplay .links'); @@ -358,11 +334,7 @@ subtest 'render bugref links in thumbnail text windows' => sub { wait_for_ajax(msg => 'details tab for job 99946 loaded (2)'); $driver->find_element('[title="Soft Failed"]')->click(); wait_for_ajax(msg => 'preview container for softfailed step loaded'); - is( - $driver->find_element_by_id('preview_container_in')->get_text(), - 'Test bugref bsc#1234 https://fate.suse.com/321208', - 'bugref text correct' - ); + is($driver->find_element_by_id('preview_container_in')->get_text(), 'Test bugref bsc#1234 https://fate.suse.com/321208', 'bugref text correct'); my @a = $driver->find_elements('#preview_container_in pre a', 'css'); is((shift @a)->get_attribute('href'), 'https://bugzilla.suse.com/show_bug.cgi?id=1234', 'bugref href correct'); is((shift @a)->get_attribute('href'), 'https://fate.suse.com/321208', 'regular href correct'); @@ -414,10 +386,8 @@ subtest 'render text results' => sub { is($external_table->is_displayed(), 1, 'external table visible after clicking its tab header'); my @rows = $driver->find_child_elements($external_table, 'tr'); is(scalar @rows, 3, 'external table has 3 rows (heading and 2 results)'); - my $res1 - = 'logpackages Some text result from external parser This is a dummy result to test rendering text results from external parsers.'; - my $res2 - = qr/logpackages Another text result from external parser Another dummy result to test rendering text results from external parsers\..*/; + my $res1 = 'logpackages Some text result from external parser This is a dummy result to test rendering text results from external parsers.'; + my $res2 = qr/logpackages Another text result from external parser Another dummy result to test rendering text results from external parsers\..*/; is($rows[1]->get_text(), $res1, 'first result displayed'); like($rows[2]->get_text(), $res2, 'second result displayed'); @@ -439,34 +409,21 @@ subtest 'render video link if frametime is available' => sub { wait_for_ajax(msg => 'second step of bootloader test module loaded'); my @video_link_elems = $driver->find_elements('.step_actions .fa-file-video-o'); is($video_link_elems[0]->get_attribute('title'), 'Jump to video', 'video link exists'); - like( - $video_link_elems[0]->get_attribute('href'), - qr!/tests/99946/video\?filename=video\.ogv&t=0\.00,1\.00!, - 'video href correct' - ); + like($video_link_elems[0]->get_attribute('href'), qr!/tests/99946/video\?filename=video\.ogv&t=0\.00,1\.00!, 'video href correct'); $video_link_elems[0]->click(); - like( - $driver->find_element('video')->get_attribute('src'), - qr!/tests/99946/file/video\.ogv#t=0!, - 'video src correct and starts on timestamp' - ); + like($driver->find_element('video')->get_attribute('src'), qr!/tests/99946/file/video\.ogv#t=0!, 'video src correct and starts on timestamp'); }; subtest 'misc details: title, favicon, go back, go to source view, go to log view' => sub { $driver->go_back(); # to 99946 $driver->title_is('openQA: opensuse-13.1-DVD-i586-Build0091-textmode@32bit test results', 'tests/99946 followed'); - like($driver->find_element('link[rel=icon]')->get_attribute('href'), - qr/logo-passed/, 'favicon is based on job result'); + like($driver->find_element('link[rel=icon]')->get_attribute('href'), qr/logo-passed/, 'favicon is based on job result'); wait_for_ajax(msg => 'test details tab for job 99946 loaded (1)'); if (ok(my $current_preview = $driver->find_element('.current_preview'), 'state preserved when going back')) { $current_preview->click; } $driver->find_element_by_link_text('installer_timezone')->click(); - like( - $driver->get_current_url(), - qr{.*/tests/99946/modules/installer_timezone/steps/1/src$}, - 'on src page for installer_timezone test' - ); + like($driver->get_current_url(), qr{.*/tests/99946/modules/installer_timezone/steps/1/src$}, 'on src page for installer_timezone test'); is($driver->find_element('.cm-comment')->get_text(), '#!/usr/bin/env perl', 'we have a perl comment'); # load "Logs & Assets" tab contents directly because accessing the tab within the whole page in a straight forward @@ -492,20 +449,18 @@ subtest 'scheduled job' => sub { }; subtest 'svg badge' => sub { - $t->get_ok('/tests/99927/badge')->status_is(200)->content_type_is('image/svg+xml') - ->header_is('Cache-Control' => 'max-age=0, no-cache')->element_exists('svg', 'valid svg badge'); + $t->get_ok('/tests/99927/badge')->status_is(200)->content_type_is('image/svg+xml')->header_is('Cache-Control' => 'max-age=0, no-cache') + ->element_exists('svg', 'valid svg badge'); $t->get_ok('/tests/9992711111/badge')->status_is(404)->content_type_is('image/svg+xml')->element_exists('svg') ->content_like(qr/404/, 'valid 404 svg badge'); - $t->get_ok('/tests/latest/badge?test=kde&machine=32bit')->status_is(200)->content_type_is('image/svg+xml') - ->element_exists('svg', 'valid latest svg badge'); + $t->get_ok('/tests/latest/badge?test=kde&machine=32bit')->status_is(200)->content_type_is('image/svg+xml')->element_exists('svg', 'valid latest svg badge'); $jobs->find(99928)->update({state => SCHEDULED, result => NONE, blocked_by_id => 99927}); $t->get_ok('/tests/99928/badge')->status_is(200)->content_type_is('image/svg+xml')->element_exists('svg') ->content_like(qr/blocked/, 'valid blocked svg badge'); }; subtest 'route to latest' => sub { - $t->get_ok('/tests/latest?distri=opensuse&version=13.1&flavor=DVD&arch=x86_64&test=kde&machine=64bit') - ->status_is(200); + $t->get_ok('/tests/latest?distri=opensuse&version=13.1&flavor=DVD&arch=x86_64&test=kde&machine=64bit')->status_is(200); my $dom = $t->tx->res->dom; my $header = $dom->at('#info_box .card-header a'); is($header->text, '99963', 'link shows correct test'); @@ -562,8 +517,7 @@ sub test_with_error { # modify the fixture test data: parse JSON -> modify -> write JSON if (defined $needle_to_modify || defined $tags) { - my $details_file = path('t/data/openqa/testresults/00099/' - . '00099946-opensuse-13.1-DVD-i586-Build0091-textmode/details-yast2_lan.json'); + my $details_file = path('t/data/openqa/testresults/00099/' . '00099946-opensuse-13.1-DVD-i586-Build0091-textmode/details-yast2_lan.json'); my $details = decode_json($details_file->slurp); my $detail = $details->[0]; $detail->{needles}->[$needle_to_modify]->{error} = $error if defined $needle_to_modify && defined $error; @@ -605,27 +559,20 @@ subtest 'test candidate list' => sub { 'sudo-passwordprompt' => $expected_candidates{'sudo-passwordprompt'}, 'some-other-tag' => $expected_candidates{'sudo-passwordprompt'}, ); - test_with_error(0, 0, ['sudo-passwordprompt', 'some-other-tag'], - \%expected_candidates, 'needles appear twice, each time under different tag'); + test_with_error(0, 0, ['sudo-passwordprompt', 'some-other-tag'], \%expected_candidates, 'needles appear twice, each time under different tag'); $driver->get('/tests/99946#step/installer_timezone/1'); wait_for_ajax_and_animations(msg => 'step preview'); $driver->find_element_by_id('candidatesMenu')->click(); wait_for_element(selector => '#needlediff_selector .show-needle-info', is_displayed => 1)->click(); - like( - $driver->find_element('.needle-info-table')->get_text(), - qr/Last match.*T.*Last seen.*T.*/s, - 'last match and last seen shown', - ); + like($driver->find_element('.needle-info-table')->get_text(), qr/Last match.*T.*Last seen.*T.*/s, 'last match and last seen shown',); $driver->find_element_by_id('candidatesMenu')->click(); wait_until_element_gone('.needle-info-table'); }; # set job 99963 to done via API to tests whether worker is still displayed then my $app = $t->app; -$t->ua( - OpenQA::Client->new(apikey => '1234567890ABCDEF', apisecret => '1234567890ABCDEF')->ioloop(Mojo::IOLoop->singleton) -); +$t->ua(OpenQA::Client->new(apikey => '1234567890ABCDEF', apisecret => '1234567890ABCDEF')->ioloop(Mojo::IOLoop->singleton)); $t->app($app); my $post = $t->post_ok($baseurl . 'api/v1/jobs/99963/set_done', form => {result => FAILED})->status_is(200, 'set job as done'); @@ -635,11 +582,7 @@ $t->get_ok($baseurl . 'tests/99963')->status_is(200); my @worker_text = $t->tx->res->dom->find('#assigned-worker')->map('all_text')->each; like($worker_text[0], qr/[ \n]*Assigned worker:[ \n]*localhost:1[ \n]*/, 'worker still displayed when job set to done'); my @scenario_description = $t->tx->res->dom->find('#scenario-description')->map('all_text')->each; -like( - $scenario_description[0], - qr/[ \n]*Simple kde test, before advanced_kde[ \n]*/, - 'scenario description is displayed' -); +like($scenario_description[0], qr/[ \n]*Simple kde test, before advanced_kde[ \n]*/, 'scenario description is displayed'); # now test the details of a job with nearly no settings which should yield no # warnings @@ -670,19 +613,11 @@ subtest 'test module flags are displayed correctly' => sub { $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' - ); + 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' - ); + is($flag->get_attribute('title'), 'Fatal: testsuite is aborted if this test fails', 'Description of fatal flag is correct'); }; subtest 'number of restarts displayed (zero times)' => sub { @@ -711,8 +646,7 @@ subtest 'additional investigation notes provided on new failed' => sub { wait_for_ajax(msg => 'details tab for job 99947 loaded to test investigation'); $driver->find_element('#clones a')->click; # navigates to 99982 $driver->find_element_by_link_text('Investigation')->click; - $driver->find_element('table#investigation_status_entry') - ->text_like(qr/No result dir/, 'investigation status content shown as table'); + $driver->find_element('table#investigation_status_entry')->text_like(qr/No result dir/, 'investigation status content shown as table'); }; subtest 'number of restarts displayed (one time)' => sub { @@ -723,16 +657,13 @@ subtest 'alert box shown if not already on first bad' => sub { $driver->get('/tests/99940'); wait_for_ajax(msg => 'details tab for job 99940 loaded to test investigation'); $driver->find_element_by_link_text('Investigation')->click; - $driver->find_element("//div[\@class='alert alert-info']", 'xpath') - ->text_like(qr/Investigate the first bad test directly: 99938/); + $driver->find_element("//div[\@class='alert alert-info']", 'xpath')->text_like(qr/Investigate the first bad test directly: 99938/); $driver->find_element_by_xpath("//div[\@class='alert alert-info']/a[\@class='alert-link']")->click; wait_for_ajax(msg => 'details tab for job 99938 loaded to test investigation'); $driver->find_element('table#investigation_status_entry') - ->text_like(qr/error\nNo previous job in this scenario, cannot provide hints/, - 'linked to investigation tab directly'); - $driver->find_element_by_xpath("//div[\@class='tab-content']") - ->text_unlike(qr/Investigate the first bad test/, 'no alert shown for first bad itself'); + ->text_like(qr/error\nNo previous job in this scenario, cannot provide hints/, 'linked to investigation tab directly'); + $driver->find_element_by_xpath("//div[\@class='tab-content']")->text_unlike(qr/Investigate the first bad test/, 'no alert shown for first bad itself'); }; subtest 'archived icon' => sub { diff --git a/t/ui/19-tests-links.t b/t/ui/19-tests-links.t index 15328dd3abed..b76885ba2a9e 100644 --- a/t/ui/19-tests-links.t +++ b/t/ui/19-tests-links.t @@ -41,11 +41,7 @@ $driver->find_element_by_link_text('logpackages')->click(); $driver->title_is('openQA: opensuse-Factory-DVD-x86_64-Build0048-doc@64bit test results', 'on test page'); # expect the failure to be displayed -is( - wait_for_element(selector => '#step_view')->get_attribute('data-image'), - '/tests/99938/images/logpackages-1.png', - 'Failure displayed' -); +is(wait_for_element(selector => '#step_view')->get_attribute('data-image'), '/tests/99938/images/logpackages-1.png', 'Failure displayed'); # now navigate back $driver->find_element('.navbar-brand')->click(); diff --git a/t/ui/21-admin-needles.t b/t/ui/21-admin-needles.t index f91bdef0d3de..e868a8be7c02 100644 --- a/t/ui/21-admin-needles.t +++ b/t/ui/21-admin-needles.t @@ -20,8 +20,7 @@ use DateTime; my $test_case = OpenQA::Test::Case->new; my $schema_name = OpenQA::Test::Database->generate_schema_name; -my $schema - = $test_case->init_data(schema_name => $schema_name, fixtures_glob => '01-jobs.pl 05-job_modules.pl 07-needles.pl'); +my $schema = $test_case->init_data(schema_name => $schema_name, fixtures_glob => '01-jobs.pl 05-job_modules.pl 07-needles.pl'); # ensure needle dir can be listed (might not be the case because previous test run failed) my $needle_dir = 't/data/openqa/share/tests/opensuse/needles/'; @@ -83,20 +82,12 @@ is((shift @tds)->get_text(), 'never-matched.json', "Name is right"); is((shift @tds)->get_text(), 'a day ago', "last use is right"); is((shift @tds)->get_text(), 'never', "last match is right"); $driver->find_child_element($module_link, 'a', 'css')->click(); -like( - $driver->execute_script("return window.location.href"), - qr(\Q/tests/99937#step/partitioning_finish/1\E), - "redirected to right module" -); +like($driver->execute_script("return window.location.href"), qr(\Q/tests/99937#step/partitioning_finish/1\E), "redirected to right module"); goto_admin_needle_table(); $driver->find_element_by_link_text('about 14 hours ago')->click(); -like( - $driver->execute_script("return window.location.href"), - qr(\Q/tests/99937#step/partitioning/1\E), - "redirected to right module too" -); +like($driver->execute_script("return window.location.href"), qr(\Q/tests/99937#step/partitioning/1\E), "redirected to right module too"); subtest 'dereference symlink when displaying needles info' => sub { my $real_needle_dir = getcwd . '/t/data/openqa/share/tests/opensuse'; @@ -199,8 +190,7 @@ subtest 'delete needle' => sub { is($driver->find_element('#confirm_delete .modal-title')->get_text(), 'Needle deletion', 'title matches'); is(scalar @{$driver->find_elements('#outstanding-needles li', 'css')}, 1, 'one needle outstanding for deletion'); is(scalar @{$driver->find_elements('#failed-needles li', 'css')}, 0, 'no failed needles so far'); - is($driver->find_element('#outstanding-needles li')->get_text(), - 'inst-timezone-text.json', 'right needle name displayed'); + is($driver->find_element('#outstanding-needles li')->get_text(), 'inst-timezone-text.json', 'right needle name displayed'); subtest 'error case' => sub { chmod(0444, $needle_dir); @@ -224,8 +214,8 @@ subtest 'delete needle' => sub { is(scalar @outstanding_needles, 2, 'still two needle outstanding for deletion'); is((shift @outstanding_needles)->get_text(), 'inst-timezone-text.json', 'right needle names displayed'); is((shift @outstanding_needles)->get_text(), 'never-matched.json', 'right needle names displayed'); - is(scalar @{$driver->find_elements('#failed-needles li', 'css')}, - 0, 'failed needles from last time shouldn\'t appear again when reopening deletion dialog'); + is(scalar @{$driver->find_elements('#failed-needles li', 'css')}, 0, + 'failed needles from last time shouldn\'t appear again when reopening deletion dialog'); subtest 'successful deletion' => sub { chmod(0755, $needle_dir); @@ -244,20 +234,13 @@ subtest 'delete needle' => sub { subtest 'pass invalid IDs to needle deletion route' => sub { my $func = 'function(error) { window.deleteMsg = JSON.stringify(error); }'; - ok( - !$driver->execute_script( - "jQuery.ajax({url: '/admin/needles/delete?id=42&id=foo', type: 'DELETE', success: $func});"), - 'delete needle with ID 42' - ); + ok(!$driver->execute_script("jQuery.ajax({url: '/admin/needles/delete?id=42&id=foo', type: 'DELETE', success: $func});"), 'delete needle with ID 42'); wait_for_ajax(with_minion => $minion); my $error = decode_json($driver->execute_script('return window.deleteMsg;')); is_deeply( $error, { - errors => [ - {id => 42, message => 'Unable to find needle with ID "42"'}, - {id => 'foo', message => 'Unable to find needle with ID "foo"'}, - ], + errors => [{id => 42, message => 'Unable to find needle with ID "42"'}, {id => 'foo', message => 'Unable to find needle with ID "foo"'},], removed_ids => [] }, 'error returned' diff --git a/t/ui/23-audit-log.t b/t/ui/23-audit-log.t index e0a2eebc9287..b1c95bcc9221 100644 --- a/t/ui/23-audit-log.t +++ b/t/ui/23-audit-log.t @@ -85,8 +85,7 @@ subtest 'audit log entries' => sub { $search->send_keys('older:today'); $entries = check_data_table_entries $table, 1, 'one row for empty table when filtering for only older than today'; - is $driver->find_child_element($entries->[0], 'td')->get_attribute('class'), 'dataTables_empty', - 'but DataTable is empty'; + is $driver->find_child_element($entries->[0], 'td')->get_attribute('class'), 'dataTables_empty', 'but DataTable is empty'; $search->clear; $search->send_keys('user:system event:startup date:today'); @@ -118,8 +117,7 @@ subtest 'clickable events' => sub { ok($entries->[0]->child('.audit_event_details'), 'event detail link present'); $t->post_ok("$url/api/v1/jobs" => $auth => form => {TEST => 'foo'})->status_is(200)->json_is({id => 1}); - $t->post_ok("$url/api/v1/jobs/1/comments" => $auth => form => {text => 'Just a job test'})->status_is(200) - ->json_is({id => 1}); + $t->post_ok("$url/api/v1/jobs/1/comments" => $auth => form => {text => 'Just a job test'})->status_is(200)->json_is({id => 1}); $driver->refresh; wait_for_ajax msg => 'DataTable ready'; diff --git a/t/ui/25-developer_mode.t b/t/ui/25-developer_mode.t index 5a04ea0f1477..e24b3239fb54 100644 --- a/t/ui/25-developer_mode.t +++ b/t/ui/25-developer_mode.t @@ -86,8 +86,7 @@ sub fake_message_from_ws_connection { sub assert_sent_commands { my ($expected, $test_name) = @_; - my $sent_cmds - = $driver->execute_script('var sentCmds = window.sentCmds; window.sentCmds = undefined; return sentCmds;'); + my $sent_cmds = $driver->execute_script('var sentCmds = window.sentCmds; window.sentCmds = undefined; return sentCmds;'); is_deeply $sent_cmds, $expected, $test_name or diag explain $sent_cmds; } @@ -140,7 +139,7 @@ mock_js_functions( updateStatus => '', setupWebsocketConnection => '', startDeveloperSession => -'developerMode.ownSession = true; developerMode.useDeveloperWsRoute = true; handleWebsocketConnectionOpened(developerMode.wsConnection);', + 'developerMode.ownSession = true; developerMode.useDeveloperWsRoute = true; handleWebsocketConnectionOpened(developerMode.wsConnection);', sendWsCommand => 'if (!window.sentCmds) { window.sentCmds = [] } window.sentCmds.push(arg1);', ); @@ -163,10 +162,7 @@ subtest 'devel UI shown when running module known' => sub { element_hidden('#developer-global-session-info'); element_hidden('#developer-vnc-notice'); element_visible('#developer-panel'); - element_visible( - '#developer-panel .card-header', - qr/Developer mode.*\nretrieving status.*\nregular test execution - click to expand/, - ); + element_visible('#developer-panel .card-header', qr/Developer mode.*\nretrieving status.*\nregular test execution - click to expand/,); element_hidden('#developer-panel .card-body'); # expand @@ -188,11 +184,7 @@ subtest 'state shown when connected' => sub { element_hidden('#developer-global-session-info'); element_hidden('#developer-vnc-notice'); element_visible('#developer-panel'); - element_visible( - '#developer-panel .card-header', - qr/Developer mode.*\nrunning.*\nregular test execution - click to expand/, - [qr/paused/, qr/owned by/], - ); + element_visible('#developer-panel .card-header', qr/Developer mode.*\nrunning.*\nregular test execution - click to expand/, [qr/paused/, qr/owned by/],); element_hidden('#developer-panel .card-body'); # running, current module known @@ -200,8 +192,7 @@ subtest 'state shown when connected' => sub { element_hidden('#developer-vnc-notice'); element_visible('#developer-panel .card-header', qr/current module: installation-welcome/, qr/paused/,); - my $options_state = map_elements('#developer-pause-at-module option, #developer-pause-at-module optgroup', - 'e.style.display, e.value || ""'); + my $options_state = map_elements('#developer-pause-at-module option, #developer-pause-at-module optgroup', 'e.style.display, e.value || ""'); subtest 'only modules after the current module displayed' => sub { is $_->[0], ($_->[1] =~ qr/boot|welcome/) ? 'none' : '', "option $_->[1]" for @$options_state; } or diag explain $options_state; @@ -231,11 +222,7 @@ subtest 'state shown when connected' => sub { '#developer-vnc-notice', qr/You might be able to connect to the SUT at remotehost:5991 via VNC with shared mode enabled \(eg\. vncviewer remotehost:5991 -Shared for TigerVNC\)\./, ); - element_visible( - '#developer-panel .card-header', - qr/paused at module: installation-welcome/, - [qr/current module/, qr/uploading/], - ); + element_visible('#developer-panel .card-header', qr/paused at module: installation-welcome/, [qr/current module/, qr/uploading/],); element_visible('#developer-status-appendix', qr/reason: some reason/); # developer session opened @@ -256,11 +243,7 @@ qr/You might be able to connect to the SUT at remotehost:5991 via VNC with share subtest 'configuration issue shown' => sub { fake_state(developerMode => {badConfiguration => 'true'}); - element_visible( - '#developer-panel .card-header', - qr/configuration issue/, - [qr/retrieving/, qr/current module/, qr/uploading/], - ); + element_visible('#developer-panel .card-header', qr/configuration issue/, [qr/retrieving/, qr/current module/, qr/uploading/],); click_header(); element_visible('#developer-config-issue-note', qr/steps to debug developer mode setup/); }; @@ -268,10 +251,7 @@ subtest 'configuration issue shown' => sub { subtest 'stopping shown' => sub { fake_state(developerMode => {stoppingTestExecution => 'true'}); - element_visible( - '#developer-panel .card-header', - qr/stopping/, [qr/retrieving/, qr/current module/, qr/uploading/, qr/configuration issue/], - ); + element_visible('#developer-panel .card-header', qr/stopping/, [qr/retrieving/, qr/current module/, qr/uploading/, qr/configuration issue/],); element_visible('#developer-stopping-note', qr/test is about to stop/); }; @@ -296,11 +276,7 @@ my @expected_text_after_session_created = (qr/the controls below\./); subtest 'expand developer panel' => sub { click_header(); - element_visible( - '#developer-panel .card-body', - \@expected_text_on_initial_session_creation, - [@expected_text_after_session_created, qr/Resume/], - ); + element_visible('#developer-panel .card-body', \@expected_text_on_initial_session_creation, [@expected_text_after_session_created, qr/Resume/],); element_visible('#developer-pause-at-module'); element_hidden('#developer-stopping-note'); element_hidden('#developer-config-issue-note'); @@ -411,11 +387,7 @@ subtest 'start developer session' => sub { outstandingImagesToUpload => '1', outstandingFilesToUpload => '0', }); - element_visible( - '#developer-panel .card-header', - qr/paused at module: installation-welcome, uploading/, - qr/current module/, - ); + element_visible('#developer-panel .card-header', qr/paused at module: installation-welcome, uploading/, qr/current module/,); element_visible('#developer-panel .card-body', qr/Resume/, qr/Open needle editor/); }; @@ -427,8 +399,7 @@ subtest 'start developer session' => sub { subtest 'resume paused test' => sub { $driver->find_element('Resume test execution', 'link_text')->click(); - assert_sent_commands([{cmd => 'resume_test_execution', options => {ignore_failure => undef}}], - 'command for resuming test execution sent'); + assert_sent_commands([{cmd => 'resume_test_execution', options => {ignore_failure => undef}}], 'command for resuming test execution sent'); }; subtest 'select module to pause at' => sub { @@ -444,8 +415,7 @@ subtest 'start developer session' => sub { ok $options[4], 'option #5 present' or return undef; $options[4]->click(); # select installation-bar - assert_sent_commands([{cmd => 'set_pause_at_test', name => 'installation-bar'}], - 'command to set module to pause at sent'); + assert_sent_commands([{cmd => 'set_pause_at_test', name => 'installation-bar'}], 'command to set module to pause at sent'); $options[0]->click(); # select assert_sent_commands([{cmd => 'set_pause_at_test', name => undef}], 'command to clear module to pause at sent'); @@ -468,8 +438,7 @@ subtest 'start developer session' => sub { # turn pausing on assert_screen on $options[1]->click(); - assert_sent_commands([{cmd => 'set_pause_on_screen_mismatch', pause_on => 'assert_screen'}], - 'command to pause on assert_screen failure sent'); + assert_sent_commands([{cmd => 'set_pause_on_screen_mismatch', pause_on => 'assert_screen'}], 'command to pause on assert_screen failure sent'); # fake the feedback from os-autoinst fake_state(developerMode => {pauseOnScreenMismatch => '"assert_screen"'}); @@ -478,8 +447,7 @@ subtest 'start developer session' => sub { # turn pausing on check_screen on $options[2]->click(); - assert_sent_commands([{cmd => 'set_pause_on_screen_mismatch', pause_on => 'check_screen'}], - 'command to pause on check_screen failure sent'); + assert_sent_commands([{cmd => 'set_pause_on_screen_mismatch', pause_on => 'check_screen'}], 'command to pause on check_screen failure sent'); # fake the feedback from os-autoinst fake_state(developerMode => {pauseOnScreenMismatch => '"check_screen"'}); @@ -488,10 +456,7 @@ subtest 'start developer session' => sub { # turn pausing on screen mismatch off $options[0]->click(); - assert_sent_commands( - [{cmd => 'set_pause_on_screen_mismatch', pause_on => undef}], - 'command to turn pausing on screen mismatch off sent' - ); + assert_sent_commands([{cmd => 'set_pause_on_screen_mismatch', pause_on => undef}], 'command to turn pausing on screen mismatch off sent'); }; my $test_boolean_behavior_switch = sub ($deveoper_mode_property, $command, $response_message, $checkbox_id) { @@ -556,22 +521,14 @@ subtest 'process state changes from os-autoinst/worker' => sub { $driver->execute_script( 'handleMessageFromWebsocketConnection("foo", { data: "{\"type\":\"info\",\"what\":\"cmdsrvmsg\",\"data\":{\"current_test_full_name\":\"some test\",\"paused\":true}}" });' ); - element_visible( - '#developer-panel .card-header', - qr/paused at module: installation-welcome/, - qr/current module/, - ); + element_visible('#developer-panel .card-header', qr/paused at module: installation-welcome/, qr/current module/,); }; subtest 'testname and paused state updated' => sub { $driver->execute_script( 'handleMessageFromWebsocketConnection(developerMode.wsConnection, { data: "{\"type\":\"info\",\"what\":\"cmdsrvmsg\",\"data\":{\"resume_test_execution\":\"foo\"}}" });' ); - element_visible( - '#developer-panel .card-header', - qr/current module: installation-welcome/, - qr/paused at module/, - ); + element_visible('#developer-panel .card-header', qr/current module: installation-welcome/, qr/paused at module/,); $driver->execute_script( 'handleMessageFromWebsocketConnection(developerMode.wsConnection, { data: "{\"type\":\"info\",\"what\":\"cmdsrvmsg\",\"data\":{\"current_test_full_name\":\"some test\",\"paused\":true, \"set_pause_on_screen_mismatch\":\"assert_screen\"}}" });' @@ -582,8 +539,7 @@ subtest 'process state changes from os-autoinst/worker' => sub { }; subtest 'upload progress handled' => sub { - is(js_variable('developerMode.detailsForCurrentModuleUploaded'), - 0, 'details for current module initially not considered uploaded'); + is(js_variable('developerMode.detailsForCurrentModuleUploaded'), 0, 'details for current module initially not considered uploaded'); fake_state( developerMode => { @@ -599,28 +555,24 @@ subtest 'process state changes from os-autoinst/worker' => sub { is(js_variable('developerMode.outstandingImagesToUpload'), 5, 'outstanding images updated'); is(js_variable('developerMode.outstandingFilesToUpload'), 7, 'outstanding files updated'); is(js_variable('developerMode.uploadingUpToCurrentModule'), 1, 'uploading up to current module updated'); - is(js_variable('developerMode.detailsForCurrentModuleUploaded'), - 0, 'details for current module still not considered uploaded'); + is(js_variable('developerMode.detailsForCurrentModuleUploaded'), 0, 'details for current module still not considered uploaded'); $driver->execute_script( 'handleMessageFromWebsocketConnection(developerMode.wsConnection, { data: "{\"type\":\"info\",\"what\":\"upload progress\",\"data\":{\"outstanding_files\":0}}" });' ); is(js_variable('developerMode.outstandingImagesToUpload'), 5, 'outstanding images not changed'); is(js_variable('developerMode.outstandingFilesToUpload'), 0, 'outstanding files updated'); - is(js_variable('developerMode.detailsForCurrentModuleUploaded'), - 0, 'details for current module still not considered uploaded'); + is(js_variable('developerMode.detailsForCurrentModuleUploaded'), 0, 'details for current module still not considered uploaded'); $driver->execute_script( 'handleMessageFromWebsocketConnection(developerMode.wsConnection, { data: "{\"type\":\"info\",\"what\":\"upload progress\",\"data\":{\"outstanding_images\":0,\"outstanding_files\":0,\"upload_up_to_current_module\":true}}" });' ); is(js_variable('developerMode.outstandingImagesToUpload'), 0, 'outstanding images updated'); is(js_variable('developerMode.outstandingFilesToUpload'), 0, 'outstanding files has bot changed'); - is(js_variable('developerMode.detailsForCurrentModuleUploaded'), - 1, 'details for current module considered uploaded'); + is(js_variable('developerMode.detailsForCurrentModuleUploaded'), 1, 'details for current module considered uploaded'); }; - my $script_start - = 'handleMessageFromWebsocketConnection(developerMode.wsConnection, { data: "{\"type\":\"info\",\"what\":\"cmdsrvmsg\",\"data\":{\"'; + my $script_start = 'handleMessageFromWebsocketConnection(developerMode.wsConnection, { data: "{\"type\":\"info\",\"what\":\"cmdsrvmsg\",\"data\":{\"'; subtest 'curent API function handled' => sub { is(js_variable('developerMode.currentApiFunction'), undef, 'current API function not set so far'); @@ -629,9 +581,8 @@ subtest 'process state changes from os-autoinst/worker' => sub { is(js_variable('developerMode.currentApiFunction'), 'assert_screen', 'current API function set'); is(js_variable('developerMode.currentApiFunctionArgs'), '', 'current API function set'); - $driver->execute_script($script_start - . 'current_api_function\":\"assert_screen\",\"check_screen\":{\"check\":0,\"mustmatch\":\"generic-desktop\",\"timeout\":30}}}" });' - ); + $driver->execute_script( + $script_start . 'current_api_function\":\"assert_screen\",\"check_screen\":{\"check\":0,\"mustmatch\":\"generic-desktop\",\"timeout\":30}}}" });'); is(js_variable('developerMode.currentApiFunction'), 'assert_screen', 'current API function set'); is(js_variable('developerMode.currentApiFunctionArgs'), 'generic-desktop', 'current API function set'); @@ -639,9 +590,8 @@ subtest 'process state changes from os-autoinst/worker' => sub { is(js_variable('developerMode.currentApiFunction'), 'wait_serial', 'current API function set'); is(js_variable('developerMode.currentApiFunctionArgs'), '', 'current API function set'); - $driver->execute_script($script_start - . 'current_api_function\":\"assert_screen\",\"check_screen\":{\"check\":0,\"mustmatch\":[\"foo\",\"bar\"],\"timeout\":30}}}" });' - ); + $driver->execute_script( + $script_start . 'current_api_function\":\"assert_screen\",\"check_screen\":{\"check\":0,\"mustmatch\":[\"foo\",\"bar\"],\"timeout\":30}}}" });'); is(js_variable('developerMode.currentApiFunction'), 'assert_screen', 'current API function set'); is_deeply(js_variable('developerMode.currentApiFunctionArgs'), ['foo', 'bar'], 'current API function set'); }; @@ -656,8 +606,7 @@ subtest 'process state changes from os-autoinst/worker' => sub { }; subtest 'error handling, flash messages' => sub { - $driver->execute_script( - 'handleMessageFromWebsocketConnection("foo", { data: "{\"type\":\"error\",\"what\":\"some error\"}" });'); + $driver->execute_script('handleMessageFromWebsocketConnection("foo", { data: "{\"type\":\"error\",\"what\":\"some error\"}" });'); assert_flash_messages(any => [], 'messsages not from current connection ignored'); $driver->execute_script('handleMessageFromWebsocketConnection(developerMode.wsConnection, { });'); @@ -667,12 +616,10 @@ subtest 'process state changes from os-autoinst/worker' => sub { my $invalid_message = 'invalid { json'; my $error = '{\"type\":\"error\",\"what\":\"some error\"}'; my $another_error = '{\"type\":\"error\",\"what\":\"another error\"}'; - my $not_ignored_connection_error - = '{\"type\":\"error\",\"what\":\"not ignored error\",\"data\":{\"category\":\"cmdsrv-connection\"}}'; - my $ignored_connection_error - = '{\"type\":\"error\",\"what\":\"ignored error\",\"data\":{\"category\":\"cmdsrv-connection\"}}'; + my $not_ignored_connection_error = '{\"type\":\"error\",\"what\":\"not ignored error\",\"data\":{\"category\":\"cmdsrv-connection\"}}'; + my $ignored_connection_error = '{\"type\":\"error\",\"what\":\"ignored error\",\"data\":{\"category\":\"cmdsrv-connection\"}}'; - # assume there's no running module (so connection issues with os-autoinst are expected and errors regarding it ignored) + # assume there's no running module (so connection issues with os-autoinst are expected and errors regarding it ignored) fake_state(testStatus => {running => 'null'}); # let the JavaScript code process those errors @@ -690,8 +637,7 @@ subtest 'process state changes from os-autoinst/worker' => sub { danger => [qr/Unable to parse/, qr/some error/, qr/another error/, qr/not ignored error/], 'errors shown via flash messages, same error not shown twice' ); - like $driver->find_element('#developer-flash-messages .alert span a')->get_text, qr/documentation/, - 'link to docs present'; + like $driver->find_element('#developer-flash-messages .alert span a')->get_text, qr/documentation/, 'link to docs present'; subtest 'dismissed message appears again' => sub { # click "X" button of 2nd flash message diff --git a/t/ui/26-jobs_restart.t b/t/ui/26-jobs_restart.t index 7ff225524201..f7e64b9b0e0b 100644 --- a/t/ui/26-jobs_restart.t +++ b/t/ui/26-jobs_restart.t @@ -95,8 +95,7 @@ subtest 'restart job from info panel in test results' => sub { my $restart_parent = $driver->find_element('#restart-result-skip-parents'); ok $restart_parent->is_displayed, 'advanced restart entries shown'; $restart_parent->attribute_like('href', qr/skip_parents=1/, 'skip parents API URL correct'); - $driver->find_element('#restart-result-skip-ok-children') - ->attribute_like('href', qr/skip_ok_result_children=1/, 'skip OK children API URL correct'); + $driver->find_element('#restart-result-skip-ok-children')->attribute_like('href', qr/skip_ok_result_children=1/, 'skip OK children API URL correct'); $driver->find_element('#restart-result-skip-children')->click; wait_for_ajax(msg => 'wait for redirection to clone job'); like $driver->get_current_url, qr{/tests/99982}, 'shows cloned job'; @@ -126,8 +125,7 @@ subtest 'restart job from info panel in test results' => sub { }; subtest 'assets missing; there is a parent' => sub { $schema->resultset('JobDependencies') - ->create( - {child_job_id => 99939, parent_job_id => 99947, dependency => OpenQA::JobDependencies::Constants::CHAINED}); + ->create({child_job_id => 99939, parent_job_id => 99947, dependency => OpenQA::JobDependencies::Constants::CHAINED}); is($driver->get('/tests/99939'), 1, 'go to job 99939'); $driver->find_element('#restart-result')->click(); wait_for_ajax(msg => 'fail to start job with missing asset and no parent'); @@ -141,11 +139,7 @@ subtest 'restart job from info panel in test results' => sub { update_last_job_id; $driver->find_element('#flash-messages button.force-restart')->click(); wait_for_ajax(msg => 'forced job restart'); - like( - $driver->find_element_by_link_text('new job')->get_attribute('href'), - expected_job_id_regex(2), - 'warning with link to new job appears' - ); + like($driver->find_element_by_link_text('new job')->get_attribute('href'), expected_job_id_regex(2), 'warning with link to new job appears'); }; subtest 'successful restart' => sub { is($driver->get('/tests/99946'), 1, 'go to job 99946'); @@ -153,8 +147,7 @@ subtest 'restart job from info panel in test results' => sub { $driver->find_element('#restart-result')->click(); wait_for_ajax(msg => 'successful restart from info panel in test results'); like($driver->get_current_url(), expected_job_id_regex, 'auto refresh to restarted job'); - like($driver->find_element('#info_box .card-header')->get_text(), - qr/textmode\@32bit/, 'restarted job is correct'); + like($driver->find_element('#info_box .card-header')->get_text(), qr/textmode\@32bit/, 'restarted job is correct'); }; }; @@ -185,13 +178,11 @@ subtest 'check single job restart in /tests page' => sub { $driver->find_child_element($td, '.restart', 'css')->click(); wait_for_ajax(msg => 'successful job restart'); is($td->get_text(), 'minimalx@32bit (restarted)', 'job is marked as restarted'); - like($driver->find_child_element($td, "./a[\@title='new test']", 'xpath')->get_attribute('href'), - expected_job_id_regex, 'restart link is correct'); + like($driver->find_child_element($td, "./a[\@title='new test']", 'xpath')->get_attribute('href'), expected_job_id_regex, 'restart link is correct'); # open restart link then verify its test name $driver->find_child_element($td, "./a[\@title='new test']", 'xpath')->click(); - like($driver->find_element('#info_box .card-header')->get_text(), - qr/minimalx@32bit/, 'restarted job is correct'); + like($driver->find_element('#info_box .card-header')->get_text(), qr/minimalx@32bit/, 'restarted job is correct'); }; }; @@ -216,24 +207,20 @@ subtest 'check cluster jobs restart in /tests page' => sub { is($chained_child->get_text(), 'doc@64bit (restarted)', 'chained child is marked as restarted'); # Check if restart links are correct - my $parent_restart_link - = $driver->find_child_element($chained_parent, "./a[\@title='new test']", 'xpath')->get_attribute('href'); - my $child_restart_link - = $driver->find_child_element($chained_child, "./a[\@title='new test']", 'xpath')->get_attribute('href'); + my $parent_restart_link = $driver->find_child_element($chained_parent, "./a[\@title='new test']", 'xpath')->get_attribute('href'); + my $child_restart_link = $driver->find_child_element($chained_child, "./a[\@title='new test']", 'xpath')->get_attribute('href'); like($parent_restart_link, expected_job_id_regex(1), 'restart link is correct'); like($child_restart_link, expected_job_id_regex(2), 'restart link is correct'); # Open tab for each restart link then verify its test name my $second_tab = open_new_tab($parent_restart_link); $driver->switch_to_window($second_tab); - like($driver->find_element('#info_box .card-header')->get_text(), - qr/kde\@32bit/, 'restarted chained parent is correct'); + like($driver->find_element('#info_box .card-header')->get_text(), qr/kde\@32bit/, 'restarted chained parent is correct'); $driver->close(); $driver->switch_to_window($first_tab); $second_tab = open_new_tab($child_restart_link); $driver->switch_to_window($second_tab); - like($driver->find_element('#info_box .card-header')->get_text(), - qr/doc\@64bit/, 'restarted chained child is correct'); + like($driver->find_element('#info_box .card-header')->get_text(), qr/doc\@64bit/, 'restarted chained child is correct'); $driver->close(); $driver->switch_to_window($first_tab); is($driver->get_title(), 'openQA: Test results', 'back to /tests page'); @@ -258,19 +245,12 @@ subtest 'check cluster jobs restart in /tests page' => sub { # All parallel jobs and their parent job should be marked as restarted is($master_node->get_text(), 'master_node@32bit (restarted)', 'parallel child master_node is marked as restarted'); is($slave_node->get_text(), 'slave_node@32bit (restarted)', 'parallel child slave_node is marked as restarted'); - is( - $support_server->get_text(), - 'support_server@32bit (restarted)', - 'parallel parent support_server is marked as restarted' - ); + is($support_server->get_text(), 'support_server@32bit (restarted)', 'parallel parent support_server is marked as restarted'); # Check if restart links are correct - my $master_node_link - = $driver->find_child_element($master_node, "./a[\@title='new test']", 'xpath')->get_attribute('href'); - my $slave_node_link - = $driver->find_child_element($slave_node, "./a[\@title='new test']", 'xpath')->get_attribute('href'); - my $support_server_link - = $driver->find_child_element($support_server, "./a[\@title='new test']", 'xpath')->get_attribute('href'); + my $master_node_link = $driver->find_child_element($master_node, "./a[\@title='new test']", 'xpath')->get_attribute('href'); + my $slave_node_link = $driver->find_child_element($slave_node, "./a[\@title='new test']", 'xpath')->get_attribute('href'); + my $support_server_link = $driver->find_child_element($support_server, "./a[\@title='new test']", 'xpath')->get_attribute('href'); like($master_node_link, expected_job_id_regex(2), 'restart link is correct'); like($slave_node_link, expected_job_id_regex(3), 'restart link is correct'); like($support_server_link, expected_job_id_regex(1), 'restart link is correct'); @@ -278,20 +258,17 @@ subtest 'check cluster jobs restart in /tests page' => sub { # Open tab for each restart link then verify its test name $second_tab = open_new_tab($master_node_link); $driver->switch_to_window($second_tab); - like($driver->find_element('#info_box .card-header')->get_text(), - qr/master_node\@32bit/, 'restarted parallel child is correct'); + like($driver->find_element('#info_box .card-header')->get_text(), qr/master_node\@32bit/, 'restarted parallel child is correct'); $driver->close(); $driver->switch_to_window($first_tab); $second_tab = open_new_tab($slave_node_link); $driver->switch_to_window($second_tab); - like($driver->find_element('#info_box .card-header')->get_text(), - qr/slave_node\@32bit/, 'restarted parallel child is correct'); + like($driver->find_element('#info_box .card-header')->get_text(), qr/slave_node\@32bit/, 'restarted parallel child is correct'); $driver->close(); $driver->switch_to_window($first_tab); $second_tab = open_new_tab($support_server_link); $driver->switch_to_window($second_tab); - like($driver->find_element('#info_box .card-header')->get_text(), - qr/support_server\@32bit/, 'restarted parallel parent is correct'); + like($driver->find_element('#info_box .card-header')->get_text(), qr/support_server\@32bit/, 'restarted parallel parent is correct'); $driver->close(); $driver->switch_to_window($first_tab); is($driver->get_title(), 'openQA: Test results', 'back to /tests page'); @@ -305,22 +282,17 @@ subtest 'check cluster jobs restart in test overview page' => sub { $driver->find_child_element($scheduled_tds[$_], '.cancel', 'css')->click for (0 .. 5); # Restart a parent job in test results overview page - is($driver->get('/tests/overview?distri=opensuse&version=13.1&build=0091&groupid=1001'), - 1, 'go to test overview page'); + is($driver->get('/tests/overview?distri=opensuse&version=13.1&build=0091&groupid=1001'), 1, 'go to test overview page'); update_last_job_id; $driver->find_element('#res_DVD_i586_create_hdd .restart')->click(); wait_for_ajax(msg => 'restart parent job in test results overview page'); subtest 'all related cluster jobs marked as restarted' => sub { my @cluster_jobs = qw(create_hdd support_server master_node slave_node); - is($driver->find_element("#res_DVD_i586_$_ .fa-circle")->get_attribute('title'), 'Scheduled', "$_ is restarted") - for @cluster_jobs; + is($driver->find_element("#res_DVD_i586_$_ .fa-circle")->get_attribute('title'), 'Scheduled', "$_ is restarted") for @cluster_jobs; my $i = 0; - like( - $driver->find_element("#res_DVD_i586_$_ .restarted")->get_attribute('href'), - expected_job_id_regex(++$i), - "restarted link for $_ is correct" - ) for @cluster_jobs; + like($driver->find_element("#res_DVD_i586_$_ .restarted")->get_attribute('href'), expected_job_id_regex(++$i), "restarted link for $_ is correct") + for @cluster_jobs; }; }; diff --git a/t/ui/27-plugin_obs_rsync.t b/t/ui/27-plugin_obs_rsync.t index ce03e884f085..f9d535a93ba9 100644 --- a/t/ui/27-plugin_obs_rsync.t +++ b/t/ui/27-plugin_obs_rsync.t @@ -25,36 +25,29 @@ sub _el1 { sub test_project { my ($t, $project, $batch, $dt, $build) = @_; - $t->get_ok('/admin/obs_rsync')->status_is(200, 'index status')->element_exists(_el($project)) - ->content_unlike(qr/script\<\/a\>/); + $t->get_ok('/admin/obs_rsync')->status_is(200, 'index status')->element_exists(_el($project))->content_unlike(qr/script\<\/a\>/); my $alias = $project; my $alias1 = $project; if ($batch) { $alias = "$project|$batch"; $alias1 = $project . '%7C' . $batch; - $t->get_ok("/admin/obs_rsync/$project")->status_is(200, 'parent project status') - ->element_exists_not(_el1($project, 'rsync_iso.cmd'))->element_exists_not(_el1($project, 'rsync_repo.cmd')) - ->element_exists_not(_el1($project, 'openqa.cmd'))->element_exists(_el($alias1)); + $t->get_ok("/admin/obs_rsync/$project")->status_is(200, 'parent project status')->element_exists_not(_el1($project, 'rsync_iso.cmd')) + ->element_exists_not(_el1($project, 'rsync_repo.cmd'))->element_exists_not(_el1($project, 'openqa.cmd'))->element_exists(_el($alias1)); } - $t->get_ok("/admin/obs_rsync/$alias")->status_is(200, 'project status') - ->element_exists(_el1($alias1, 'rsync_iso.cmd'))->element_exists(_el1($alias1, 'rsync_repo.cmd')) - ->element_exists(_el1($alias1, 'openqa.cmd')); + $t->get_ok("/admin/obs_rsync/$alias")->status_is(200, 'project status')->element_exists(_el1($alias1, 'rsync_iso.cmd')) + ->element_exists(_el1($alias1, 'rsync_repo.cmd'))->element_exists(_el1($alias1, 'openqa.cmd')); - $t->get_ok("/admin/obs_rsync/$alias/runs")->status_is(200, 'project logs status') - ->element_exists(_el($alias1, ".run_$dt")); + $t->get_ok("/admin/obs_rsync/$alias/runs")->status_is(200, 'project logs status')->element_exists(_el($alias1, ".run_$dt")); $t->get_ok("/admin/obs_rsync/$alias/runs/.run_$dt")->status_is(200, 'project log subfolder status') ->element_exists(_el($alias1, ".run_$dt", 'files_iso.lst')); - $t->get_ok("/admin/obs_rsync/$alias/runs/.run_$dt/download/files_iso.lst") - ->status_is(200, 'project log file download status') - ->content_like(qr/openSUSE-Leap-15.1-DVD-x86_64-Build470.$build-Media.iso/) - ->content_like(qr/openSUSE-Leap-15.1-NET-x86_64-Build470.$build-Media.iso/); + $t->get_ok("/admin/obs_rsync/$alias/runs/.run_$dt/download/files_iso.lst")->status_is(200, 'project log file download status') + ->content_like(qr/openSUSE-Leap-15.1-DVD-x86_64-Build470.$build-Media.iso/)->content_like(qr/openSUSE-Leap-15.1-NET-x86_64-Build470.$build-Media.iso/); - $t->get_ok("/admin/obs_rsync/$alias/run_last")->status_is(200, 'get project last run') - ->json_is('/message', $dt, 'run_last is $dt'); + $t->get_ok("/admin/obs_rsync/$alias/run_last")->status_is(200, 'get project last run')->json_is('/message', $dt, 'run_last is $dt'); $t->post_ok("/admin/obs_rsync/$alias/run_last" => $params)->status_is(200, 'forget project last run') ->json_is('/message', 'success', 'forgetting run_last succeeded'); diff --git a/t/ui/27-plugin_obs_rsync_gru.t b/t/ui/27-plugin_obs_rsync_gru.t index 6f1832e3cbf0..9f2814b9594f 100644 --- a/t/ui/27-plugin_obs_rsync_gru.t +++ b/t/ui/27-plugin_obs_rsync_gru.t @@ -27,14 +27,11 @@ $t->post_ok('/admin/obs_rsync/Proj1/runs' => $params)->status_is(201, 'trigger r $t->get_ok('/admin/obs_rsync/queue')->status_is(200, 'jobs list')->content_like(qr/Proj1/, 'get project queue'); $t->get_ok('/admin/obs_rsync/Proj1/dirty_status')->status_is(200, 'get dirty status')->content_like(qr/dirty on/); -$t->post_ok('/admin/obs_rsync/Proj1/dirty_status' => $params)->status_is(200, 'dirty status update enqueued') - ->content_like(qr/started/); -is $minion->jobs({tasks => [qw(obs_rsync_update_dirty_status)]})->total, 1, - 'obs_rsync_update_dirty_status job enqueued'; +$t->post_ok('/admin/obs_rsync/Proj1/dirty_status' => $params)->status_is(200, 'dirty status update enqueued')->content_like(qr/started/); +is $minion->jobs({tasks => [qw(obs_rsync_update_dirty_status)]})->total, 1, 'obs_rsync_update_dirty_status job enqueued'; $t->get_ok('/admin/obs_rsync/Proj1/obs_builds_text')->status_is(200, 'get builds text')->content_like(qr/No data/); -$t->post_ok('/admin/obs_rsync/Proj1/obs_builds_text' => $params)->status_is(200, 'builds text update enqueued') - ->content_like(qr/started/); +$t->post_ok('/admin/obs_rsync/Proj1/obs_builds_text' => $params)->status_is(200, 'builds text update enqueued')->content_like(qr/started/); is $minion->jobs({tasks => [qw(obs_rsync_update_builds_text)]})->total, 1, 'obs_rsync_update_builds_text job enqueued'; subtest 'process minion jobs' => sub { @@ -45,8 +42,7 @@ subtest 'process minion jobs' => sub { $minion->job($info->{id})->remove; is $job->{state}, 'finished', "$task has been finished"; } - is $home->child('Proj1/files_iso.lst')->slurp, "openSUSE-Leap-15.1-DVD-x86_64-Build470.1-Media.iso\n", - 'files_iso.lst has been created'; + is $home->child('Proj1/files_iso.lst')->slurp, "openSUSE-Leap-15.1-DVD-x86_64-Build470.1-Media.iso\n", 'files_iso.lst has been created'; }; done_testing(); diff --git a/t/ui/27-plugin_obs_rsync_obs_status.t b/t/ui/27-plugin_obs_rsync_obs_status.t index d9e47c076b1b..ddaf700ad528 100644 --- a/t/ui/27-plugin_obs_rsync_obs_status.t +++ b/t/ui/27-plugin_obs_rsync_obs_status.t @@ -141,17 +141,16 @@ $t->post_ok('/admin/obs_rsync/Proj3/runs?repository=standard' => $params)->statu $t->get_ok('/admin/obs_rsync/')->status_is(200, 'project list')->content_like(qr/inactive/); # at start job is added as inactive -$t->get_ok('/admin/obs_rsync/queue')->status_is(200, 'jobs list')->content_like(qr/inactive/) - ->content_unlike(qr/\bactive\b/)->content_like(qr/Proj1/)->content_like(qr/Proj2/)->content_like(qr/Proj3/); +$t->get_ok('/admin/obs_rsync/queue')->status_is(200, 'jobs list')->content_like(qr/inactive/)->content_unlike(qr/\bactive\b/)->content_like(qr/Proj1/) + ->content_like(qr/Proj2/)->content_like(qr/Proj3/); perform_minion_jobs($t->app->minion); # Proj1 and Proj2 must be still in queue, but Proj3 must gone now -$t->get_ok('/admin/obs_rsync/queue')->status_is(200, 'jobs list')->content_like(qr/inactive/) - ->content_unlike(qr/\bactive\b/)->content_like(qr/Proj1/)->content_like(qr/Proj2/)->content_unlike(qr/Proj3/); +$t->get_ok('/admin/obs_rsync/queue')->status_is(200, 'jobs list')->content_like(qr/inactive/)->content_unlike(qr/\bactive\b/)->content_like(qr/Proj1/) + ->content_like(qr/Proj2/)->content_unlike(qr/Proj3/); -$t->get_ok('/admin/obs_rsync/')->status_is(200, 'project list')->content_like(qr/published/)->content_like(qr/dirty/) - ->content_like(qr/publishing/); +$t->get_ok('/admin/obs_rsync/')->status_is(200, 'project list')->content_like(qr/published/)->content_like(qr/dirty/)->content_like(qr/publishing/); $server_instance->stop; done_testing(); diff --git a/t/ui/27-plugin_obs_rsync_status_details.t b/t/ui/27-plugin_obs_rsync_status_details.t index 89efcb4e2b18..872b0394608c 100644 --- a/t/ui/27-plugin_obs_rsync_status_details.t +++ b/t/ui/27-plugin_obs_rsync_status_details.t @@ -55,16 +55,14 @@ foreach my $proj (sort keys %params) { if ($proj eq 'Batch1') { # click on the various buttons within the table $driver->find_element("tr#folder_$ident .obsbuildsupdate")->click; - is $driver->find_element("tr#folder_$ident .obsbuilds")->get_text, 'fake response', - 'builds update response shown'; + is $driver->find_element("tr#folder_$ident .obsbuilds")->get_text, 'fake response', 'builds update response shown'; $driver->find_element("tr#folder_$ident .lastsyncforget")->click; $driver->accept_alert; is $driver->find_element("tr#folder_$ident .lastsync")->get_text, 'fake response', 'forget response shown'; $driver->find_element("tr#folder_$ident .dirtystatusupdate")->click; - is $driver->find_element("tr#folder_$ident .dirtystatuscol .dirtystatus")->get_text, 'fake response', - 'dirty status update response shown'; + is $driver->find_element("tr#folder_$ident .dirtystatuscol .dirtystatus")->get_text, 'fake response', 'dirty status update response shown'; my $actual_requests = $driver->execute_script('return window.ajaxRequests;'); my @expected_requests = ( diff --git a/t/ui/28-keys_to_render_as_links.t b/t/ui/28-keys_to_render_as_links.t index 40af9c06bca3..69ba60ad736b 100644 --- a/t/ui/28-keys_to_render_as_links.t +++ b/t/ui/28-keys_to_render_as_links.t @@ -33,10 +33,8 @@ $schema->resultset('Jobs')->find($job_id)->settings->create({key => 'SOME_URLS', driver_missing unless my $driver = call_driver; my $url = 'http://localhost:' . OpenQA::SeleniumTest::get_mojoport; -$t->get_ok($uri_path_from_root_dir)->status_is(200) - ->content_like(qr|test|i, 'setting file source found from the root of the test distribution'); -$t->get_ok($uri_path_from_default_data_dir)->status_is(200) - ->content_like(qr|test|i, 'setting file source found in default_data_dir'); +$t->get_ok($uri_path_from_root_dir)->status_is(200)->content_like(qr|test|i, 'setting file source found from the root of the test distribution'); +$t->get_ok($uri_path_from_default_data_dir)->status_is(200)->content_like(qr|test|i, 'setting file source found in default_data_dir'); $driver->get("/tests/$job_id#settings"); note 'Finding link associated with keys_to_render_as_links';