97 lines
3.4 KiB
Ruby
97 lines
3.4 KiB
Ruby
# encoding: UTF-8
|
|
require 'chefspec'
|
|
require 'chefspec/berkshelf'
|
|
require 'chef/application'
|
|
|
|
RSpec.configure do |config|
|
|
config.color = true
|
|
config.formatter = :documentation
|
|
config.log_level = :warn
|
|
config.file_cache_path = '/var/chef/cache'
|
|
end
|
|
|
|
REDHAT_OPTS = {
|
|
platform: 'redhat',
|
|
version: '7',
|
|
}.freeze
|
|
UBUNTU_OPTS = {
|
|
platform: 'ubuntu',
|
|
version: '18.04',
|
|
}.freeze
|
|
|
|
shared_context 'telemetry-stubs' do
|
|
before do
|
|
allow_any_instance_of(Chef::Recipe).to receive(:rabbit_servers)
|
|
.and_return '1.1.1.1:5672,2.2.2.2:5672'
|
|
allow_any_instance_of(Chef::Recipe).to receive(:memcached_servers).and_return([])
|
|
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
|
.with('db', 'ceilometer')
|
|
.and_return('ceilometer-dbpass')
|
|
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
|
.with('db', 'gnocchi')
|
|
.and_return('gnocchi-dbpass')
|
|
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
|
.with('db', 'aodh')
|
|
.and_return('aodh-dbpass')
|
|
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
|
.with('service', 'openstack-telemetry')
|
|
.and_return('ceilometer-pass')
|
|
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
|
.with('service', 'openstack-telemetry_metric')
|
|
.and_return('gnocchi-pass')
|
|
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
|
.with('service', 'openstack-aodh')
|
|
.and_return('aodh-pass')
|
|
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
|
.with('user', 'guest')
|
|
.and_return('mq-pass')
|
|
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
|
.with('user', 'admin')
|
|
.and_return('admin-pass')
|
|
allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url)
|
|
.with('telemetry')
|
|
.and_return('rabbit://guest:mypass@127.0.0.1:5672')
|
|
allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url)
|
|
.with('aodh')
|
|
.and_return('rabbit://guest:mypass@127.0.0.1:5672')
|
|
allow(Chef::Application).to receive(:fatal!)
|
|
stub_command('/usr/sbin/apache2 -t')
|
|
stub_command('/usr/sbin/httpd -t')
|
|
# identity stubs
|
|
allow_any_instance_of(Chef::Recipe).to receive(:secret)
|
|
.with('secrets', 'credential_key0')
|
|
.and_return('thisiscredentialkey0')
|
|
allow_any_instance_of(Chef::Recipe).to receive(:secret)
|
|
.with('secrets', 'credential_key1')
|
|
.and_return('thisiscredentialkey1')
|
|
allow_any_instance_of(Chef::Recipe).to receive(:secret)
|
|
.with('secrets', 'fernet_key0') .and_return('thisisfernetkey0')
|
|
allow_any_instance_of(Chef::Recipe).to receive(:secret)
|
|
.with('secrets', 'fernet_key1')
|
|
.and_return('thisisfernetkey1')
|
|
allow_any_instance_of(Chef::Recipe).to receive(:search_for)
|
|
.with('os-identity').and_return(
|
|
[{
|
|
'openstack' => {
|
|
'identity' => {
|
|
'admin_tenant_name' => 'admin',
|
|
'admin_user' => 'admin',
|
|
},
|
|
},
|
|
}]
|
|
)
|
|
allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url)
|
|
.with('identity')
|
|
.and_return('rabbit://openstack:mypass@127.0.0.1:5672')
|
|
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
|
.with('db', 'keystone')
|
|
.and_return('keystone-dbpass')
|
|
end
|
|
end
|
|
|
|
shared_examples 'expect-runs-common-recipe' do
|
|
it 'runs common recipe' do
|
|
expect(chef_run).to include_recipe 'openstack-telemetry::common'
|
|
end
|
|
end
|