Skip to content

Commit 008c89b

Browse files
committed
Rework some logic and testing cases per github discussion. Should be fully dependent on an enablement variable now, with tests to verify that behavior.
1 parent 58680e9 commit 008c89b

File tree

4 files changed

+51
-103
lines changed

4 files changed

+51
-103
lines changed

REFERENCE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ Data type: `Optional[Boolean]`
821821
Boolean - Enables or disables automatic removal of member nodes that are no longer part of the cluster,
822822
but still a member of the quorum queue. This requires RabbitMQ 3.13 or higher. More information on this configuration
823823
can be found here: https://www.rabbitmq.com/docs/quorum-queues
824+
Important Note: This only takes affect if quorum_membership_reconciliation_enabled is set to true.
824825

825826
Default value: `undef`
826827

@@ -830,6 +831,7 @@ Data type: `Optional[Integer]`
830831

831832
Integer - The default evaluation interval in milliseconds. This requires RabbitMQ 3.13 or higher. More information on this configuration
832833
can be found here: https://www.rabbitmq.com/docs/quorum-queues
834+
Important Note: This only takes affect if quorum_membership_reconciliation_enabled is set to true.
833835

834836
Default value: `undef`
835837

@@ -842,6 +844,7 @@ for example, a node is added or removed from the cluster or an applicable policy
842844
This delay will be applied only once, then the regular interval will be used again.
843845
This requires RabbitMQ 3.13 or higher. More information on this configuration
844846
can be found here: https://www.rabbitmq.com/docs/quorum-queues
847+
Important Note: This only takes affect if quorum_membership_reconciliation_enabled is set to true.
845848

846849
Default value: `undef`
847850

@@ -852,6 +855,7 @@ Data type: `Optional[Integer]`
852855
Integer - Controls the target group size for a quorum queue
853856
This requires RabbitMQ 3.13 or higher. More information on this configuration
854857
can be found here: https://www.rabbitmq.com/docs/quorum-queues
858+
Important Note: This only takes affect if quorum_membership_reconciliation_enabled is set to true.
855859

856860
Default value: `undef`
857861

manifests/init.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,19 +248,23 @@
248248
# Boolean - Enables or disables automatic removal of member nodes that are no longer part of the cluster,
249249
# but still a member of the quorum queue. This requires RabbitMQ 3.13 or higher. More information on this configuration
250250
# can be found here: https://www.rabbitmq.com/docs/quorum-queues
251+
# Important Note: This only takes affect if quorum_membership_reconciliation_enabled is set to true.
251252
# @param quorum_membership_reconciliation_interval
252253
# Integer - The default evaluation interval in milliseconds. This requires RabbitMQ 3.13 or higher. More information on this configuration
253254
# can be found here: https://www.rabbitmq.com/docs/quorum-queues
255+
# Important Note: This only takes affect if quorum_membership_reconciliation_enabled is set to true.
254256
# @param quorum_membership_reconciliation_trigger_interval
255257
# Integer - The reconciliation delay in milliseconds, used when a trigger event occurs,
256258
# for example, a node is added or removed from the cluster or an applicable policy changes.
257259
# This delay will be applied only once, then the regular interval will be used again.
258260
# This requires RabbitMQ 3.13 or higher. More information on this configuration
259261
# can be found here: https://www.rabbitmq.com/docs/quorum-queues
262+
# Important Note: This only takes affect if quorum_membership_reconciliation_enabled is set to true.
260263
# @param quorum_membership_reconciliation_target_group_size
261264
# Integer - Controls the target group size for a quorum queue
262265
# This requires RabbitMQ 3.13 or higher. More information on this configuration
263266
# can be found here: https://www.rabbitmq.com/docs/quorum-queues
267+
# Important Note: This only takes affect if quorum_membership_reconciliation_enabled is set to true.
264268
# @param repos_ensure
265269
# Ensure that a repo with the official (and newer) RabbitMQ package is configured, along with its signing key.
266270
# Defaults to false (use system packages). This does not ensure that soft dependencies are present.

spec/classes/rabbitmq_spec.rb

Lines changed: 41 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,138 +1794,78 @@
17941794
end
17951795
end
17961796

1797+
# Ensure that whenever Param quorum_membership_reconciliation_enabled is unset - none of the
1798+
# other quorum_membership_reconciliation paramaters are set at all
1799+
# This ensures full backward compatibility with PRE RabbitMQ 3.13
17971800
describe 'rabbitmq-quorum_membership_reconciliation_enabled undef options' do
17981801
let(:params) { { quorum_membership_reconciliation_enabled: :undef } }
17991802

18001803
it 'sets quorum_membership_reconciliation_enabled parameter undef in config file' do
18011804
is_expected.not_to contain_file('rabbitmq.config'). \
1802-
with_content(%r{\{quorum_membership_reconciliation_enabled, .*\}})
1805+
with_content(%r{\{quorum_membership_reconciliation_enabled, .*\}}). \
1806+
with_content(%r{\{quorum_membership_reconciliation_auto_remove, .*\}}). \
1807+
with_content(%r{\{quorum_membership_reconciliation_interval, .*\}}). \
1808+
with_content(%r{\{quorum_membership_reconciliation_trigger_interval, .*\}}). \
1809+
with_content(%r{\{quorum_membership_reconciliation_target_group_size, .*\}})
18031810
end
18041811
end
18051812

1813+
# Ensure that whenever Param quorum_membership_reconciliation_enabled is false - none of the
1814+
# other quorum_membership_reconciliation paramaters are set at all
1815+
# This ensures full backward compatibility with PRE RabbitMQ 3.13
18061816
describe 'rabbitmq-quorum_membership_reconciliation_enabled false options' do
18071817
let(:params) { { quorum_membership_reconciliation_enabled: false } }
18081818

18091819
it 'sets quorum_membership_reconciliation_enabled parameter false in config file' do
1810-
is_expected.to contain_file('rabbitmq.config'). \
1811-
with_content(%r{\{quorum_membership_reconciliation_enabled, false\}})
1820+
is_expected.not_to contain_file('rabbitmq.config'). \
1821+
with_content(%r{\{quorum_membership_reconciliation_enabled, .*\}}). \
1822+
with_content(%r{\{quorum_membership_reconciliation_auto_remove, .*\}}). \
1823+
with_content(%r{\{quorum_membership_reconciliation_interval, .*\}}). \
1824+
with_content(%r{\{quorum_membership_reconciliation_trigger_interval, .*\}}). \
1825+
with_content(%r{\{quorum_membership_reconciliation_target_group_size, .*\}})
18121826
end
18131827
end
18141828

1829+
# Ensure that whenever Param quorum_membership_reconciliation_enabled is true - the defaults
1830+
# of all other quorum_membership_reconciliation parameters ensure they are UNSET until
1831+
# explicitly set.
18151832
describe 'rabbitmq-quorum_membership_reconciliation_enabled true options' do
18161833
let(:params) { { quorum_membership_reconciliation_enabled: true } }
18171834

18181835
it 'sets quorum_membership_reconciliation_enabled parameter true in config file' do
18191836
is_expected.to contain_file('rabbitmq.config'). \
18201837
with_content(%r{\{quorum_membership_reconciliation_enabled, true\}})
18211838
end
1822-
end
1823-
1824-
describe 'rabbitmq-quorum_membership_reconciliation_auto_remove undef options' do
1825-
let(:params) { { quorum_membership_reconciliation_auto_remove: :undef } }
1826-
1827-
it 'sets quorum_membership_reconciliation_auto_remove parameter undef in config file' do
1828-
is_expected.not_to contain_file('rabbitmq.config'). \
1829-
with_content(%r{\{quorum_membership_reconciliation_auto_remove, .*\}})
1830-
end
1831-
end
1832-
1833-
describe 'rabbitmq-quorum_membership_reconciliation_auto_remove false options' do
1834-
let(:params) { { quorum_membership_reconciliation_auto_remove: false } }
1835-
1836-
it 'sets quorum_membership_reconciliation_auto_remove parameter false in config file' do
1837-
is_expected.to contain_file('rabbitmq.config'). \
1838-
with_content(%r{\{quorum_membership_reconciliation_auto_remove, false\}})
1839-
end
1840-
end
1841-
1842-
describe 'rabbitmq-quorum_membership_reconciliation_auto_remove true options' do
1843-
let(:params) { { quorum_membership_reconciliation_auto_remove: true } }
1844-
1845-
it 'sets quorum_membership_reconciliation_auto_remove parameter true in config file' do
1846-
is_expected.to contain_file('rabbitmq.config'). \
1847-
with_content(%r{\{quorum_membership_reconciliation_auto_remove, true\}})
1848-
end
1849-
end
1850-
1851-
describe 'rabbitmq-quorum_membership_reconciliation_interval undef options' do
1852-
let(:params) { { quorum_membership_reconciliation_interval: :undef } }
1853-
1854-
it 'sets quorum_membership_reconciliation_interval parameter undef in config file' do
1855-
is_expected.not_to contain_file('rabbitmq.config'). \
1856-
with_content(%r{\{quorum_membership_reconciliation_interval, .*\}})
1857-
end
1858-
end
1859-
1860-
describe 'rabbitmq-quorum_membership_reconciliation_interval 36000 options' do
1861-
let(:params) { { quorum_membership_reconciliation_interval: 36_000 } }
1862-
1863-
it 'sets quorum_membership_reconciliation_interval parameter 36000 in config file' do
1864-
is_expected.to contain_file('rabbitmq.config'). \
1865-
with_content(%r{\{quorum_membership_reconciliation_interval, 36000\}})
1866-
end
1867-
end
1868-
1869-
describe 'rabbitmq-quorum_membership_reconciliation_interval 36000000000 options' do
1870-
let(:params) { { quorum_membership_reconciliation_interval: 36_000_000_000 } }
1871-
1872-
it 'sets quorum_membership_reconciliation_interval parameter 36000000000 in config file' do
1873-
is_expected.to contain_file('rabbitmq.config'). \
1874-
with_content(%r{\{quorum_membership_reconciliation_interval, 36000000000\}})
1875-
end
1876-
end
18771839

1878-
describe 'rabbitmq-quorum_membership_reconciliation_trigger_interval undef options' do
1879-
let(:params) { { quorum_membership_reconciliation_trigger_interval: :undef } }
1880-
1881-
it 'sets quorum_membership_reconciliation_trigger_interval parameter undef in config file' do
1882-
is_expected.not_to contain_file('rabbitmq.config'). \
1883-
with_content(%r{\{quorum_membership_reconciliation_trigger_interval, .*\}})
1884-
end
1885-
end
1886-
1887-
describe 'rabbitmq-quorum_membership_reconciliation_trigger_interval 3600 options' do
1888-
let(:params) { { quorum_membership_reconciliation_trigger_interval: 3600 } }
1889-
1890-
it 'sets quorum_membership_reconciliation_trigger_interval parameter 3600 in config file' do
1891-
is_expected.to contain_file('rabbitmq.config'). \
1892-
with_content(%r{\{quorum_membership_reconciliation_trigger_interval, 3600\}})
1893-
end
1894-
end
1895-
1896-
describe 'rabbitmq-quorum_membership_reconciliation_trigger_interval 36000000000 options' do
1897-
let(:params) { { quorum_membership_reconciliation_trigger_interval: 36_000_000_000 } }
1898-
1899-
it 'sets quorum_membership_reconciliation_trigger_interval parameter 36000000000 in config file' do
1900-
is_expected.to contain_file('rabbitmq.config'). \
1901-
with_content(%r{\{quorum_membership_reconciliation_trigger_interval, 36000000000\}})
1902-
end
1903-
end
1904-
1905-
describe 'rabbitmq-quorum_membership_reconciliation_target_group_size undef options' do
1906-
let(:params) { { quorum_membership_reconciliation_target_group_size: :undef } }
1907-
1908-
it 'sets quorum_membership_reconciliation_target_group_size parameter undef in config file' do
1840+
it 'sets quorum_membership_reconciliation_enabled parameter true in config file ONLY' do
19091841
is_expected.not_to contain_file('rabbitmq.config'). \
1842+
with_content(%r{\{quorum_membership_reconciliation_auto_remove, .*\}}). \
1843+
with_content(%r{\{quorum_membership_reconciliation_interval, .*\}}). \
1844+
with_content(%r{\{quorum_membership_reconciliation_trigger_interval, .*\}}). \
19101845
with_content(%r{\{quorum_membership_reconciliation_target_group_size, .*\}})
19111846
end
19121847
end
19131848

1914-
describe 'rabbitmq-quorum_membership_reconciliation_target_group_size 2 options' do
1915-
let(:params) { { quorum_membership_reconciliation_target_group_size: 2 } }
1916-
1917-
it 'sets quorum_membership_reconciliation_target_group_size parameter 2 in config file' do
1918-
is_expected.to contain_file('rabbitmq.config'). \
1919-
with_content(%r{\{quorum_membership_reconciliation_target_group_size, 2\}})
1849+
# Ensure that whenever Param quorum_membership_reconciliation_enabled is true
1850+
# and the other parameters are set - they pass as expected.
1851+
describe 'rabbitmq-quorum_membership_reconciliation_enabled true options' do
1852+
let(:params) do
1853+
{
1854+
quorum_membership_reconciliation_enabled: true,
1855+
quorum_membership_reconciliation_auto_remove: true,
1856+
quorum_membership_reconciliation_interval: 36_000,
1857+
quorum_membership_reconciliation_trigger_interval: 3600,
1858+
quorum_membership_reconciliation_target_group_size: 2
1859+
}
19201860
end
1921-
end
19221861

1923-
describe 'rabbitmq-quorum_membership_reconciliation_target_group_size 4 options' do
1924-
let(:params) { { quorum_membership_reconciliation_target_group_size: 4 } }
1925-
1926-
it 'sets quorum_membership_reconciliation_target_group_size parameter 4 in config file' do
1862+
it 'sets quorum_membership_reconciliation_enabled parameter true in config file' do
19271863
is_expected.to contain_file('rabbitmq.config'). \
1928-
with_content(%r{\{quorum_membership_reconciliation_target_group_size, 4\}})
1864+
with_content(%r{\{quorum_membership_reconciliation_enabled, true\}}). \
1865+
with_content(%r{\{quorum_membership_reconciliation_auto_remove, true\}}). \
1866+
with_content(%r{\{quorum_membership_reconciliation_interval, 36000\}}). \
1867+
with_content(%r{\{quorum_membership_reconciliation_trigger_interval, 3600\}}). \
1868+
with_content(%r{\{quorum_membership_reconciliation_target_group_size, 2\}})
19291869
end
19301870
end
19311871

templates/rabbitmq.config.epp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626
<%- } -%>
2727
{cluster_partition_handling, <%= $rabbitmq::config::cluster_partition_handling %>},
2828
<% } -%>
29-
<% unless $rabbitmq::config::quorum_membership_reconciliation_enabled =~ Undef {-%>
29+
<% if $rabbitmq::config::quorum_membership_reconciliation_enabled {-%>
3030
{quorum_membership_reconciliation_enabled, <%= $rabbitmq::config::quorum_membership_reconciliation_enabled %>},
31-
<% } -%>
3231
<% unless $rabbitmq::config::quorum_membership_reconciliation_auto_remove =~ Undef {-%>
3332
{quorum_membership_reconciliation_auto_remove, <%= $rabbitmq::config::quorum_membership_reconciliation_auto_remove %>},
3433
<% } -%>
@@ -40,6 +39,7 @@
4039
<% } -%>
4140
<% unless $rabbitmq::config::quorum_membership_reconciliation_target_group_size =~ Undef {-%>
4241
{quorum_membership_reconciliation_target_group_size, <%= $rabbitmq::config::quorum_membership_reconciliation_target_group_size %>},
42+
<% } -%>
4343
<% } -%>
4444
{tcp_listen_options, [
4545
<%- unless $rabbitmq::config::config_ranch {-%>

0 commit comments

Comments
 (0)