71 lines
2.1 KiB
Ruby
71 lines
2.1 KiB
Ruby
require 'chefspec'
|
|
require 'pry'
|
|
require 'chefspec/berkshelf'
|
|
require 'chef/application'
|
|
|
|
RSpec.configure do |config|
|
|
config.color = true
|
|
config.formatter = :documentation
|
|
config.log_level = :warn
|
|
end
|
|
|
|
REDHAT_7 = {
|
|
platform: 'redhat',
|
|
version: '7',
|
|
}.freeze
|
|
|
|
REDHAT_8 = {
|
|
platform: 'redhat',
|
|
version: '8',
|
|
}.freeze
|
|
|
|
ALL_RHEL = [
|
|
REDHAT_7,
|
|
REDHAT_8,
|
|
].freeze
|
|
|
|
UBUNTU_OPTS = {
|
|
platform: 'ubuntu',
|
|
version: '18.04',
|
|
}.freeze
|
|
|
|
shared_context 'neutron-stubs' do
|
|
before do
|
|
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
|
.with('token', 'openstack_identity_bootstrap_token')
|
|
.and_return('bootstrap-token')
|
|
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
|
.with('token', 'neutron_metadata_secret')
|
|
.and_return('metadata-secret')
|
|
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
|
.with('db', anything)
|
|
.and_return('neutron')
|
|
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
|
.with('service', 'openstack-network')
|
|
.and_return('neutron-pass')
|
|
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
|
.with('user', 'guest')
|
|
.and_return('mq-pass')
|
|
allow(Chef::Application).to receive(:fatal!)
|
|
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
|
.with('service', 'openstack-compute')
|
|
.and_return('nova-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('network')
|
|
.and_return('rabbit://guest:mypass@127.0.0.1:5672')
|
|
end
|
|
|
|
shared_examples 'common network attributes displayer' do |plugin|
|
|
cached(:chef_run) do
|
|
node.override['openstack']["network_#{plugin}"]['conf']['DEFAULT']['interface_driver'] = 'network_interface_driver_value'
|
|
runner.converge(described_recipe)
|
|
end
|
|
it 'displays the interface_driver common attribute' do
|
|
expect(chef_run).to render_file(file_name).with_content(/^interface_driver = network_interface_driver_value$/)
|
|
end
|
|
end
|
|
end
|