2014-01-17 16:04:13 +00:00
|
|
|
# encoding: UTF-8
|
|
|
|
require_relative 'spec_helper'
|
2013-06-18 19:27:06 -04:00
|
|
|
|
2014-01-17 16:04:13 +00:00
|
|
|
describe 'openstack-ops-messaging::rabbitmq-server' do
|
|
|
|
describe 'ubuntu' do
|
2014-02-27 10:59:01 -06:00
|
|
|
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
|
|
|
let(:node) { runner.node }
|
|
|
|
let(:chef_run) { runner.converge(described_recipe) }
|
|
|
|
|
|
|
|
include_context 'ops_messaging_stubs'
|
2013-06-18 19:27:06 -04:00
|
|
|
|
2014-01-17 16:04:13 +00:00
|
|
|
it 'overrides default rabbit attributes' do
|
2014-02-18 14:49:32 -05:00
|
|
|
expect(chef_run.node['openstack']['endpoints']['mq']['port']).to eq('5672')
|
2014-02-27 10:59:01 -06:00
|
|
|
expect(chef_run.node['openstack']['mq']['listen']).to eq('127.0.0.1')
|
|
|
|
expect(chef_run.node['rabbitmq']['address']).to eq('127.0.0.1')
|
|
|
|
expect(chef_run.node['rabbitmq']['default_user']).to eq('guest')
|
|
|
|
expect(chef_run.node['rabbitmq']['default_pass']).to eq('rabbit-pass')
|
|
|
|
expect(chef_run.node['rabbitmq']['use_distro_version']).to be_true
|
2013-06-29 13:50:11 -07:00
|
|
|
end
|
|
|
|
|
2014-01-17 16:04:13 +00:00
|
|
|
it 'overrides rabbit and openstack image attributes' do
|
2014-02-18 14:49:32 -05:00
|
|
|
node.set['openstack']['endpoints']['mq']['bind_interface'] = 'eth0'
|
|
|
|
node.set['openstack']['endpoints']['mq']['port'] = '4242'
|
2014-02-27 10:59:01 -06:00
|
|
|
node.set['openstack']['mq']['user'] = 'foo'
|
|
|
|
node.set['openstack']['mq']['vhost'] = '/bar'
|
|
|
|
|
|
|
|
expect(chef_run.node['openstack']['mq']['listen']).to eq('33.44.55.66')
|
2014-02-18 14:49:32 -05:00
|
|
|
expect(chef_run.node['openstack']['endpoints']['mq']['port']).to eq('4242')
|
2014-02-27 10:59:01 -06:00
|
|
|
expect(chef_run.node['openstack']['mq']['user']).to eq('foo')
|
|
|
|
expect(chef_run.node['openstack']['mq']['vhost']).to eq('/bar')
|
|
|
|
expect(chef_run.node['openstack']['mq']['image']['rabbit']['port']).to eq('4242')
|
|
|
|
expect(chef_run.node['openstack']['mq']['image']['rabbit']['userid']).to eq('foo')
|
|
|
|
expect(chef_run.node['openstack']['mq']['image']['rabbit']['vhost']).to eq('/bar')
|
2013-10-30 14:27:09 -05:00
|
|
|
end
|
|
|
|
|
2014-01-17 16:04:13 +00:00
|
|
|
describe 'cluster' do
|
2013-06-29 13:50:11 -07:00
|
|
|
before do
|
2014-02-27 10:59:01 -06:00
|
|
|
node.set['openstack']['mq'] = {
|
|
|
|
'cluster' => true
|
|
|
|
}
|
2013-06-29 13:50:11 -07:00
|
|
|
end
|
|
|
|
|
2014-01-17 16:04:13 +00:00
|
|
|
it 'overrides cluster' do
|
2014-02-27 10:59:01 -06:00
|
|
|
expect(chef_run.node['rabbitmq']['cluster']).to be_true
|
2013-06-29 13:50:11 -07:00
|
|
|
end
|
|
|
|
|
2014-01-17 16:04:13 +00:00
|
|
|
it 'overrides erlang_cookie' do
|
2014-02-27 10:59:01 -06:00
|
|
|
expect(chef_run.node['rabbitmq']['erlang_cookie']).to eq(
|
2014-01-17 16:04:13 +00:00
|
|
|
'erlang-cookie'
|
2013-06-29 13:50:11 -07:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2014-01-17 16:04:13 +00:00
|
|
|
it 'overrides and sorts cluster_disk_nodes' do
|
2014-02-27 10:59:01 -06:00
|
|
|
expect(chef_run.node['rabbitmq']['cluster_disk_nodes']).to eq(
|
2014-01-17 16:04:13 +00:00
|
|
|
['guest@host1', 'guest@host2']
|
2013-06-29 13:50:11 -07:00
|
|
|
)
|
|
|
|
end
|
2013-06-22 02:12:04 -07:00
|
|
|
end
|
2013-06-18 19:27:06 -04:00
|
|
|
|
2014-01-17 16:04:13 +00:00
|
|
|
it 'includes rabbit recipes' do
|
2014-02-27 10:59:01 -06:00
|
|
|
expect(chef_run).to include_recipe 'rabbitmq'
|
|
|
|
expect(chef_run).to include_recipe 'rabbitmq::mgmt_console'
|
2013-06-18 19:27:06 -04:00
|
|
|
end
|
|
|
|
|
2014-01-17 16:04:13 +00:00
|
|
|
describe 'lwrps' do
|
2014-02-27 14:08:28 -06:00
|
|
|
context 'default mq attributes' do
|
|
|
|
it 'does not delete the guest user' do
|
|
|
|
expect(chef_run).not_to delete_rabbitmq_user('remove rabbit guest user')
|
|
|
|
end
|
2013-06-22 02:12:04 -07:00
|
|
|
end
|
|
|
|
|
2014-02-27 14:08:28 -06:00
|
|
|
context 'custom mq attributes' do
|
|
|
|
before do
|
|
|
|
node.set['openstack']['mq']['user'] = 'not-a-guest'
|
|
|
|
node.set['openstack']['mq']['vhost'] = '/foo'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'deletes the guest user' do
|
|
|
|
expect(chef_run).to delete_rabbitmq_user(
|
|
|
|
'remove rabbit guest user'
|
|
|
|
).with(user: 'guest')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'adds openstack rabbit user' do
|
|
|
|
expect(chef_run).to add_rabbitmq_user(
|
|
|
|
'add openstack rabbit user'
|
|
|
|
).with(user: 'not-a-guest', password: 'rabbit-pass')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'changes openstack rabbit user password' do
|
|
|
|
expect(chef_run).to rabbitmq_user_change_password(
|
|
|
|
'change openstack rabbit user password'
|
|
|
|
).with(user: 'not-a-guest', password: 'rabbit-pass')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'adds openstack rabbit vhost' do
|
|
|
|
expect(chef_run).to add_rabbitmq_vhost(
|
|
|
|
'add openstack rabbit vhost'
|
|
|
|
).with(vhost: '/foo')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sets openstack user permissions' do
|
|
|
|
expect(chef_run).to rabbitmq_user_set_permissions(
|
|
|
|
'set openstack user permissions'
|
|
|
|
).with(user: 'not-a-guest', vhost: '/foo', permissions: '.* .* .*')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sets administrator tag' do
|
|
|
|
expect(chef_run).to rabbitmq_user_set_tags(
|
|
|
|
'set rabbit administrator tag'
|
|
|
|
).with(user: 'not-a-guest', tag: 'administrator')
|
|
|
|
end
|
2013-06-22 02:12:04 -07:00
|
|
|
end
|
2013-06-18 19:27:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|