Skip to content

Commit

Permalink
Merge pull request #958 from jimmybigcommerce/quorum_queue_bugfix
Browse files Browse the repository at this point in the history
Bugfix: Fix parsing issue for queue policies targeted at quorum queues
  • Loading branch information
wyardley committed Nov 5, 2023
2 parents b0ce7f3 + 29843ea commit 6764328
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/puppet/provider/rabbitmq_policy/rabbitmqctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def self.policies(vhost, name)
# / ha-all all .* {"ha-mode":"all","ha-sync-mode":"automatic"} 0 << This is for RabbitMQ v < 3.7.0
# / ha-all .* all {"ha-mode":"all","ha-sync-mode":"automatic"} 0 << This is for RabbitMQ v >= 3.7.0
if Puppet::Util::Package.versioncmp(rabbitmq_version, '3.7') >= 0
regex = %r{^(\S+)\s+(\S+)\s+(\S+)\s+(all|exchanges|queues)?\s+(\S+)\s+(\d+)$}
regex = %r{^(\S+)\s+(\S+)\s+(\S+)\s+(all|exchanges|(?:classic_|quorum_)?queues|streams)?\s+(\S+)\s+(\d+)$}
applyto_index = 4
pattern_index = 3
else
Expand Down
17 changes: 17 additions & 0 deletions spec/unit/puppet/provider/rabbitmq_policy/rabbitmqctl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@
'ha-sync-mode' => 'automatic'
})
end

it 'matches policies from list targeting quorum queues' do
provider.class.expects(:rabbitmq_version).returns '3.7.0'
provider.class.expects(:rabbitmqctl_list).with('policies', '-p', '/').returns <<~EOT
/ ha-all ^.*$ quorum_queues {"delivery-limit":10,"initial-cluster-size":3,"max-length":100000000,"overflow":"reject-publish-dlx"} 0
/ test .* exchanges {"ha-mode":"all"} 0
EOT
expect(provider.exists?).to eq(applyto: 'quorum_queues',
pattern: '^.*$',
priority: '0',
definition: {
'delivery-limit' => 10,
'initial-cluster-size' => 3,
'max-length' => 100_000_000,
'overflow' => 'reject-publish-dlx'
})
end
end

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

0 comments on commit 6764328

Please sign in to comment.