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
|
2015-04-29 10:35:33 +02:00
|
|
|
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
|
2014-02-27 10:59:01 -06:00
|
|
|
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')
|
2014-08-07 16:27:42 +08:00
|
|
|
expect(chef_run.node['openstack']['mq']['rabbitmq']['use_ssl']).to be_falsey
|
2016-01-26 18:08:04 +01:00
|
|
|
expect(chef_run.node['rabbitmq']['port']).to eq('5672')
|
2014-02-27 10:59:01 -06:00
|
|
|
expect(chef_run.node['rabbitmq']['address']).to eq('127.0.0.1')
|
2014-07-29 11:51:48 -05:00
|
|
|
expect(chef_run.node['rabbitmq']['use_distro_version']).to be_truthy
|
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
|
2017-11-27 00:09:44 -08:00
|
|
|
node.override['openstack']['bind_service']['mq']['interface'] = 'enp0s3'
|
|
|
|
node.override['openstack']['bind_service']['mq']['port'] = '4242'
|
|
|
|
node.override['openstack']['endpoints']['mq']['port'] = '4242'
|
|
|
|
node.override['openstack']['mq']['user'] = 'foo'
|
|
|
|
node.override['openstack']['mq']['vhost'] = '/bar'
|
2014-02-27 10:59:01 -06:00
|
|
|
expect(chef_run.node['openstack']['mq']['listen']).to eq('33.44.55.66')
|
|
|
|
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-08-07 16:27:42 +08:00
|
|
|
describe 'rabbit ssl' do
|
|
|
|
before do
|
2017-11-27 00:09:44 -08:00
|
|
|
node.override['openstack']['mq']['rabbitmq']['use_ssl'] = true
|
|
|
|
node.override['openstack']['bind_service']['mq']['port'] = '1234'
|
2014-08-07 16:27:42 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'overrides rabbit ssl attributes' do
|
|
|
|
expect(chef_run.node['openstack']['mq']['rabbitmq']['use_ssl']).to be_truthy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-01-17 16:04:13 +00:00
|
|
|
describe 'cluster' do
|
2013-06-29 13:50:11 -07:00
|
|
|
before do
|
2017-11-27 00:09:44 -08:00
|
|
|
node.override['openstack']['mq'] = {
|
2017-08-23 22:37:44 -04:00
|
|
|
'cluster' => true,
|
2014-02-27 10:59:01 -06:00
|
|
|
}
|
2013-06-29 13:50:11 -07:00
|
|
|
end
|
|
|
|
|
2014-01-17 16:04:13 +00:00
|
|
|
it 'overrides cluster' do
|
2016-02-11 07:42:46 +01:00
|
|
|
expect(chef_run.node['rabbitmq']['clustering']['enable']).to be_truthy
|
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
|
2016-02-11 07:42:46 +01:00
|
|
|
expect(chef_run.node['rabbitmq']['clustering']['cluster_nodes']).to eq(
|
2017-05-29 12:06:05 +02:00
|
|
|
[{ 'name' => 'openstack@host1' }, { 'name' => 'openstack@host2' }]
|
2013-06-29 13:50:11 -07:00
|
|
|
)
|
|
|
|
end
|
2015-01-20 11:29:14 -06:00
|
|
|
|
|
|
|
it 'does not search for cluster_disk_nodes' do
|
2017-11-27 00:09:44 -08:00
|
|
|
node.override['openstack']['mq']['search_for_cluster_disk_nodes'] = false
|
2016-02-11 07:42:46 +01:00
|
|
|
expect(chef_run.node['rabbitmq']['clustering']['cluster_nodes']).to eq([])
|
2015-01-20 11:29:14 -06: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 'custom mq attributes' do
|
|
|
|
before do
|
2017-11-27 00:09:44 -08:00
|
|
|
node.override['openstack']['mq']['user'] = 'not-a-guest'
|
|
|
|
node.override['openstack']['mq']['vhost'] = '/foo'
|
2014-02-27 14:08:28 -06:00
|
|
|
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
|
2014-03-28 12:34:18 -05:00
|
|
|
expect(chef_run).to change_password_rabbitmq_user(
|
2014-02-27 14:08:28 -06:00
|
|
|
'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
|
2014-03-28 12:34:18 -05:00
|
|
|
expect(chef_run).to set_permissions_rabbitmq_user(
|
2014-02-27 14:08:28 -06:00
|
|
|
'set openstack user permissions'
|
|
|
|
).with(user: 'not-a-guest', vhost: '/foo', permissions: '.* .* .*')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sets administrator tag' do
|
2014-03-28 12:34:18 -05:00
|
|
|
expect(chef_run).to set_tags_rabbitmq_user(
|
2014-02-27 14:08:28 -06:00
|
|
|
'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
|