diff --git a/0001-AMQP-allow-no-message-prefix.patch b/0001-AMQP-allow-no-message-prefix.patch new file mode 100644 index 0000000..3d296e5 --- /dev/null +++ b/0001-AMQP-allow-no-message-prefix.patch @@ -0,0 +1,50 @@ +From 06498add6bef52a790cf6294503f4171786a1c85 Mon Sep 17 00:00:00 2001 +From: Adam Williamson +Date: Thu, 1 Aug 2019 16:52:17 -0700 +Subject: [PATCH] AMQP: allow no message prefix + +For Fedora messages we do not actually want a prefix, the topic +is *just* openqa.job.done or whatever. This allows setting +'topic_prefix = ' in the config file to make that work. + +Signed-off-by: Adam Williamson +--- + lib/OpenQA/WebAPI/Plugin/AMQP.pm | 3 ++- + t/23-amqp.t | 7 +++++++ + 2 files changed, 9 insertions(+), 1 deletion(-) + +diff --git a/lib/OpenQA/WebAPI/Plugin/AMQP.pm b/lib/OpenQA/WebAPI/Plugin/AMQP.pm +index f6402c7b..d13b2baa 100644 +--- a/lib/OpenQA/WebAPI/Plugin/AMQP.pm ++++ b/lib/OpenQA/WebAPI/Plugin/AMQP.pm +@@ -59,7 +59,8 @@ sub log_event { + $event =~ s/_/\./; + $event =~ s/_/\./; + +- my $topic = $self->{config}->{amqp}{topic_prefix} . '.' . $event; ++ my $prefix = $self->{config}->{amqp}{topic_prefix}; ++ my $topic = $prefix ? $prefix . '.' . $event : $event; + + # seperate function for tests + $self->publish_amqp($topic, $event_data); +diff --git a/t/23-amqp.t b/t/23-amqp.t +index fef54d7c..933b86e5 100644 +--- a/t/23-amqp.t ++++ b/t/23-amqp.t +@@ -236,6 +236,13 @@ subtest 'create parent group comment' => sub { + is($json->{parent_group_id}, 2000, 'parent group id'); + }; + ++$t->app->config->{amqp}{topic_prefix} = ''; ++ ++subtest 'publish without topic prefix' => sub { ++ $t->post_ok("/api/v1/jobs" => form => $settings)->status_is(200); ++ is($published{'openqa.job.create'}->{ARCH}, "x86_64", 'got message with correct topic'); ++}; ++ + # Now let's unmock publish_amqp so we can test it... + $plugin_mock->unmock('publish_amqp'); + %published = (); +-- +2.22.0 + diff --git a/openqa.spec b/openqa.spec index ff96dc5..8a0c386 100644 --- a/openqa.spec +++ b/openqa.spec @@ -47,7 +47,7 @@ Name: openqa Version: %{github_version} -Release: 20%{?github_date:.%{github_date}git%{shortcommit}}%{?dist} +Release: 21%{?github_date:.%{github_date}git%{shortcommit}}%{?dist} Summary: OS-level automated testing framework License: GPLv2+ Url: http://os-autoinst.github.io/openQA/ @@ -77,6 +77,9 @@ Patch1: 0001-Add-dependency-on-CommonMark-which-will-soon-replace.patch # https://github.com/os-autoinst/openQA/pull/2232 # Switch to CommonMark for markdown rendering: faster, also safer Patch2: 2232.patch +# https://github.com/os-autoinst/openQA/pull/2236 +# Allow AMQP messages with no additional prefix +Patch3: 0001-AMQP-allow-no-message-prefix.patch BuildRequires: %{t_requires} BuildRequires: %{python_scripts_requires} @@ -565,6 +568,9 @@ fi %{_datadir}/openqa/lib/OpenQA/WebAPI/Plugin/FedoraUpdateRestart.pm %changelog +* Thu Aug 01 2019 Adam Williamson - 4.6-21.20190726git92e8f3c +- Allow AMQP messages with no prefix (backport PR #2236) + * Tue Jul 30 2019 Adam Williamson - 4.6-20.20190726git92e8f3c - Add plugin for publishing fedora-messaging messages - Backport PR #2232 (faster and safer markdown rendering)