Skip to content

Commit 29843ea

Browse files
Fix issue parsing queue policies targeted at quorum queues
1 parent b0ce7f3 commit 29843ea

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/puppet/provider/rabbitmq_policy/rabbitmqctl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def self.policies(vhost, name)
2121
# / ha-all all .* {"ha-mode":"all","ha-sync-mode":"automatic"} 0 << This is for RabbitMQ v < 3.7.0
2222
# / ha-all .* all {"ha-mode":"all","ha-sync-mode":"automatic"} 0 << This is for RabbitMQ v >= 3.7.0
2323
if Puppet::Util::Package.versioncmp(rabbitmq_version, '3.7') >= 0
24-
regex = %r{^(\S+)\s+(\S+)\s+(\S+)\s+(all|exchanges|queues)?\s+(\S+)\s+(\d+)$}
24+
regex = %r{^(\S+)\s+(\S+)\s+(\S+)\s+(all|exchanges|(?:classic_|quorum_)?queues|streams)?\s+(\S+)\s+(\d+)$}
2525
applyto_index = 4
2626
pattern_index = 3
2727
else

spec/unit/puppet/provider/rabbitmq_policy/rabbitmqctl_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,23 @@
6161
'ha-sync-mode' => 'automatic'
6262
})
6363
end
64+
65+
it 'matches policies from list targeting quorum queues' do
66+
provider.class.expects(:rabbitmq_version).returns '3.7.0'
67+
provider.class.expects(:rabbitmqctl_list).with('policies', '-p', '/').returns <<~EOT
68+
/ ha-all ^.*$ quorum_queues {"delivery-limit":10,"initial-cluster-size":3,"max-length":100000000,"overflow":"reject-publish-dlx"} 0
69+
/ test .* exchanges {"ha-mode":"all"} 0
70+
EOT
71+
expect(provider.exists?).to eq(applyto: 'quorum_queues',
72+
pattern: '^.*$',
73+
priority: '0',
74+
definition: {
75+
'delivery-limit' => 10,
76+
'initial-cluster-size' => 3,
77+
'max-length' => 100_000_000,
78+
'overflow' => 'reject-publish-dlx'
79+
})
80+
end
6481
end
6582

6683
context 'with RabbitMQ version >=3.2.0 and < 3.7.0' do

0 commit comments

Comments
 (0)