Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ha-sync-batch-size for rabbitmq_policy definition to be integer #500

Merged
merged 2 commits into from
Sep 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/puppet/type/rabbitmq_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ def validate_definition(definition)
raise ArgumentError, "Invalid shards-per-node value '#{shards_per_node_val}'"
end
end
if definition.key? 'ha-sync-batch-size'
ha_sync_batch_size_val = definition['ha-sync-batch-size']
unless ha_sync_batch_size_val.to_i.to_s == ha_sync_batch_size_val
raise ArgumentError, "Invalid ha-sync-batch-size value '#{ha_sync_batch_size_val}'"
end
end
end

def munge_definition(definition)
Expand All @@ -123,6 +129,9 @@ def munge_definition(definition)
if definition.key? 'shards-per-node'
definition['shards-per-node'] = definition['shards-per-node'].to_i
end
if definition.key? 'ha-sync-batch-size'
definition['ha-sync-batch-size'] = definition['ha-sync-batch-size'].to_i
end
definition
end
end
14 changes: 14 additions & 0 deletions spec/unit/puppet/type/rabbitmq_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,18 @@
@policy[:definition] = definition
}.to raise_error(Puppet::Error, /Invalid shards-per-node value.*future/)
end

it 'should accept and convert the ha-sync-batch-size value' do
definition = {'ha-sync-batch-size' => '1800000'}
@policy[:definition] = definition
@policy[:definition]['ha-sync-batch-size'].should be_a(Fixnum)
@policy[:definition]['ha-sync-batch-size'].should == 1800000
end

it 'should not accept non-numeric ha-sync-batch-size value' do
definition = {'ha-sync-batch-size' => 'future'}
expect {
@policy[:definition] = definition
}.to raise_error(Puppet::Error, /Invalid ha-sync-batch-size value.*future/)
end
end