Skip to content

Commit

Permalink
Add spec test for rabbitmq template
Browse files Browse the repository at this point in the history
Closes #232

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
  • Loading branch information
miketheman committed Apr 21, 2016
1 parent 43d1395 commit d8e88ca
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
65 changes: 65 additions & 0 deletions spec/integrations/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
describe 'datadog::rabbitmq' do
expected_yaml = <<-EOF
init_config:
instances:
- rabbitmq_api_url: http://localhost:15672/api/
rabbitmq_user: guest
rabbitmq_pass: guest
tags:
- optional_tag1
- optional_tag2
nodes:
- rabbit@localhost
- rabbit2@domain
nodes_regexes:
- bla.*
queues:
- queue1
- queue2
queues_regexes:
- thisqueue-.*
- another_\\d+queue
vhosts:
- vhost1
- vhost2
EOF

cached(:chef_run) do
ChefSpec::SoloRunner.new(step_into: ['datadog_monitor']) do |node|
node.automatic['languages'] = { 'python' => { 'version' => '2.7.2' } }
node.set['datadog'] = {
api_key: 'someapikey',
rabbitmq: {
instances: [
{
api_url: 'http://localhost:15672/api/',
user: 'guest',
pass: 'guest',
tags: ['optional_tag1', 'optional_tag2'],
nodes: ['rabbit@localhost', 'rabbit2@domain'],
nodes_regexes: ['bla.*'],
queues: ['queue1', 'queue2'],
queues_regexes: ['thisqueue-.*', 'another_\\d+queue'],
vhosts: ['vhost1', 'vhost2']
}
]
}
}
end.converge(described_recipe)
end

subject { chef_run }

it_behaves_like 'datadog-agent'

it { is_expected.to include_recipe('datadog::dd-agent') }

it { is_expected.to add_datadog_monitor('rabbitmq') }

it 'renders expected YAML config file' do
expect(chef_run).to render_file('/etc/dd-agent/conf.d/rabbitmq.yaml').with_content { |content|
expect(YAML.load(content).to_json).to be_json_eql(YAML.load(expected_yaml).to_json)
}
end
end
2 changes: 2 additions & 0 deletions templates/default/rabbitmq.yaml.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Generated by Chef, local modifications will be overwritten

instances:
# for every instance a 'rabbitmq_api_url' must be provided, pointing to the api
# url of the RabbitMQ Managment Plugin (http://www.rabbitmq.com/management.html)
Expand Down

0 comments on commit d8e88ca

Please sign in to comment.