diff --git a/23-fedora-messaging.t b/23-fedora-messaging.t index 7ddd5a6..102fb03 100644 --- a/23-fedora-messaging.t +++ b/23-fedora-messaging.t @@ -314,4 +314,47 @@ subtest 'create update job' => sub { is_deeply($body, $expected, 'update job create triggers standardized amqp'); }; +subtest 'create update job (new-style ADVISORY_NVR_N)' => sub { + $plugin_mock_callcount = 0; + diag("Count: $plugin_mock_callcount"); + delete $settings->{ADVISORY_NVRS}; + # these are intentionally not in alphabetical order + $settings->{ADVISORY_NVRS_1} = 'kernel-5.2.8-100.fc29 kernel-tools-5.2.8-100.fc29'; + $settings->{ADVISORY_NVRS_2} = 'kernel-headers-5.2.8-100.fc29'; + $t->post_ok("/api/v1/jobs" => form => $settings)->status_is(200); + ok(my $newupdatejob = $t->tx->res->json->{id}, 'got ID of new-style update job'); + diag("Count: $plugin_mock_callcount"); + ok($plugin_mock_callcount == 1, 'mock was called'); + my ($body, $headerframe) = @{$published{'org.fedoraproject.stg.ci.fedora-update.test.queued'}}; + $expected_artifact = { + alias => 'FEDORA-2019-6bda4c81f4', + builds => [ + { + nvr => 'kernel-5.2.8-100.fc29' + }, + { + nvr => 'kernel-headers-5.2.8-100.fc29' + }, + { + nvr => 'kernel-tools-5.2.8-100.fc29' + } + ], + id => 'sha256:b85bba148cec9d9c4dafea3a49785abef1f549fbad368f3818e20d9802340b16', + type => 'fedora-update', + release => { + version => '42', + name => 'F42' + }, + }; + $expected_run = { + url => "https://openqa.stg.fedoraproject.org/tests/$newupdatejob", + log => "https://openqa.stg.fedoraproject.org/tests/$newupdatejob/file/autoinst-log.txt", + id => $newupdatejob, + }; + my $expected = get_expected; + # no image for update message + delete $expected->{'image'}; + is_deeply($body, $expected, 'update job create triggers standardized amqp'); +}; + done_testing(); diff --git a/FedoraMessaging.pm b/FedoraMessaging.pm index 4c06c4a..b1ea11b 100644 --- a/FedoraMessaging.pm +++ b/FedoraMessaging.pm @@ -149,10 +149,24 @@ sub log_event_fedora_ci_messages { version => $job->VERSION, name => "F" . $job->VERSION }; + # handle old-style single ADVISORY_NVRS with all NVRs my @nvrs = split(/ /, $job->settings_hash->{ADVISORY_NVRS} || ''); unless (@nvrs) { - log_error "ADVISORY_NVRS not found for update test $job_id! Cannot publish!"; - return; + # handle new-style chunked ADVISORY_NVRS_N settings + my $count = 1; + while ($count) { + if ($job->settings_hash->{"ADVISORY_NVRS_$count"}) { + push @nvrs, split(/ /, $job->settings_hash->{"ADVISORY_NVRS_$count"}); + $count++; + } + else { + $count = 0; + } + } + unless (@nvrs) { + log_error "ADVISORY_NVRS(_N) not found for update test $job_id! Cannot publish!"; + return; + } } @nvrs = sort(@nvrs); my @builds; diff --git a/openqa.spec b/openqa.spec index 60fb9c3..38bed0f 100644 --- a/openqa.spec +++ b/openqa.spec @@ -92,7 +92,7 @@ Name: openqa Version: %{github_version}%{?github_date:^%{github_date}git%{shortcommit}} -Release: 1%{?dist} +Release: 2%{?dist} Summary: OS-level automated testing framework License: GPLv2+ Url: http://os-autoinst.github.io/openQA/ @@ -669,6 +669,9 @@ fi %{_datadir}/openqa/lib/OpenQA/WebAPI/Plugin/FedoraUpdateRestart.pm %changelog +* Thu Dec 01 2022 Adam Williamson - 4.6^20221123gitb93eb7f-2 +- FedoraMessaging: handle chunked ADVISORY_NVRS_N settings + * Thu Nov 24 2022 Adam Williamson - 4.6^20221123gitb93eb7f-1 - Update to latest git, re-sync spec, drop merged patches