Convert to rspec-puppet-facts

Converts those that were missing it.

Change-Id: Ic7821f3a4b2db1123c9ed53a61d740883b02fbe4
This commit is contained in:
Tobias Urdin 2018-11-28 17:34:42 +01:00
parent 83396bb3ef
commit 1aaf10e886
7 changed files with 428 additions and 388 deletions

View File

@ -1,55 +1,47 @@
require 'spec_helper'
describe 'nova::cell_v2::map_cell0' do
shared_examples_for 'nova::cell_v2::map_cell0' do
shared_examples 'nova::cell_v2::map_cell0' do
context 'with defaults' do
it {
is_expected.to contain_exec('nova-cell_v2-map_cell0').with(
:path => ['/bin', '/usr/bin'],
:command => 'nova-manage cell_v2 map_cell0',
:user => 'nova',
:refreshonly => 'true',
:logoutput => 'on_failure',
:subscribe => 'Anchor[nova::cell_v2::begin]',
:notify => 'Anchor[nova::cell_v2::end]',
)
}
it { should contain_exec('nova-cell_v2-map_cell0').with(
:path => ['/bin', '/usr/bin'],
:command => 'nova-manage cell_v2 map_cell0',
:user => 'nova',
:refreshonly => 'true',
:logoutput => 'on_failure',
:subscribe => 'Anchor[nova::cell_v2::begin]',
:notify => 'Anchor[nova::cell_v2::end]',
)}
end
context "overriding extra_params" do
let :params do
{
:extra_params => '--config-file /etc/nova/nova.conf',
:extra_params => '--config-file /etc/nova/nova.conf',
}
end
it {
is_expected.to contain_exec('nova-cell_v2-map_cell0').with(
:path => ['/bin', '/usr/bin'],
:command => 'nova-manage --config-file /etc/nova/nova.conf cell_v2 map_cell0',
:user => 'nova',
:refreshonly => 'true',
:logoutput => 'on_failure',
:subscribe => 'Anchor[nova::cell_v2::begin]',
:notify => 'Anchor[nova::cell_v2::end]',
)
}
it { should contain_exec('nova-cell_v2-map_cell0').with(
:path => ['/bin', '/usr/bin'],
:command => 'nova-manage --config-file /etc/nova/nova.conf cell_v2 map_cell0',
:user => 'nova',
:refreshonly => 'true',
:logoutput => 'on_failure',
:subscribe => 'Anchor[nova::cell_v2::begin]',
:notify => 'Anchor[nova::cell_v2::end]',
)}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge(OSDefaults.get_facts())
end
it_configures 'nova::cell_v2::map_cell0'
it_behaves_like 'nova::cell_v2::map_cell0'
end
end
end

View File

@ -1,18 +1,32 @@
require 'spec_helper'
describe 'nova::compute::serial' do
shared_examples 'nova::compute::serial' do
it { should contain_nova_config('serial_console/enabled').with_value('true') }
it { should contain_nova_config('serial_console/port_range').with_value('10000:20000')}
it { should contain_nova_config('serial_console/base_url').with_value('ws://127.0.0.1:6083/')}
it { should contain_nova_config('serial_console/proxyclient_address').with_value('127.0.0.1')}
it { is_expected.to contain_nova_config('serial_console/enabled').with_value('true') }
it { is_expected.to contain_nova_config('serial_console/port_range').with_value('10000:20000')}
it { is_expected.to contain_nova_config('serial_console/base_url').with_value('ws://127.0.0.1:6083/')}
it { is_expected.to contain_nova_config('serial_console/proxyclient_address').with_value('127.0.0.1')}
context 'when overriding params' do
let :params do
{
:proxyclient_address => '10.10.10.10',
}
end
context 'when overriding params' do
let :params do
{
:proxyclient_address => '10.10.10.10',
}
it { should contain_nova_config('serial_console/proxyclient_address').with_value('10.10.10.10')}
end
it { is_expected.to contain_nova_config('serial_console/proxyclient_address').with_value('10.10.10.10')}
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'nova::compute::serial'
end
end
end

View File

@ -1,22 +1,36 @@
require 'spec_helper'
describe 'nova::compute::spice' do
shared_examples 'nova::compute::spice' do
it { should contain_nova_config('spice/agent_enabled').with_value('true')}
it { should contain_nova_config('spice/server_proxyclient_address').with_value('127.0.0.1')}
it { should_not contain_nova_config('spice/html5proxy_base_url')}
it { should contain_nova_config('spice/server_listen').with_value(nil)}
it { is_expected.to contain_nova_config('spice/agent_enabled').with_value('true')}
it { is_expected.to contain_nova_config('spice/server_proxyclient_address').with_value('127.0.0.1')}
it { is_expected.to_not contain_nova_config('spice/html5proxy_base_url')}
it { is_expected.to contain_nova_config('spice/server_listen').with_value(nil)}
context 'when overriding params' do
let :params do
{
context 'when overriding params' do
let :params do
{
:proxy_host => '10.10.10.10',
:server_listen => '10.10.11.11',
:agent_enabled => false
}
}
end
it { should contain_nova_config('spice/html5proxy_base_url').with_value('http://10.10.10.10:6082/spice_auto.html')}
it { should contain_nova_config('spice/server_listen').with_value('10.10.11.11')}
it { should contain_nova_config('spice/agent_enabled').with_value('false')}
end
it { is_expected.to contain_nova_config('spice/html5proxy_base_url').with_value('http://10.10.10.10:6082/spice_auto.html')}
it { is_expected.to contain_nova_config('spice/server_listen').with_value('10.10.11.11')}
it { is_expected.to contain_nova_config('spice/agent_enabled').with_value('false')}
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'nova::compute::spice'
end
end
end

View File

@ -3,13 +3,16 @@ require 'spec_helper'
describe 'nova::compute::xenserver' do
let :params do
{ :connection_url => 'https://127.0.0.1',
{
:connection_url => 'https://127.0.0.1',
:connection_username => 'root',
:connection_password => 'passw0rd' }
:connection_password => 'passw0rd'
}
end
let :optional_params do
{ :ovs_integration_bridge => 'xapi1',
{
:ovs_integration_bridge => 'xapi1',
:agent_timeout => '30',
:agent_version_timeout => '300',
:agent_resetnetwork_timeout => '60',
@ -49,87 +52,101 @@ describe 'nova::compute::xenserver' do
:ipxe_boot_menu_url => 'http://127.0.0.1/',
:ipxe_mkisofs_cmd => 'mkisofs',
:running_timeout => '10',
:vif_driver => 'nova.virt.xenapi.vif.XenAPIBridgeDriver',
:vif_driver => 'nova.virt.xenapi.vif.XenAPIBridgeDriver',
:image_upload_handler => 'nova.virt.xenapi.image.glance.GlanceStore',
:introduce_vdi_retry_wait => '20' }
:introduce_vdi_retry_wait => '20'
}
end
context 'with required parameters' do
shared_examples 'nova::compute::xenserver' do
context 'with required parameters' do
it 'configures xenapi in nova.conf' do
should contain_nova_config('DEFAULT/compute_driver').with_value('xenapi.XenAPIDriver')
should contain_nova_config('xenserver/connection_url').with_value(params[:connection_url])
should contain_nova_config('xenserver/connection_username').with_value(params[:connection_username])
should contain_nova_config('xenserver/connection_password').with_value(params[:connection_password])
end
it 'configures xenapi in nova.conf' do
is_expected.to contain_nova_config('DEFAULT/compute_driver').with_value('xenapi.XenAPIDriver')
is_expected.to contain_nova_config('xenserver/connection_url').with_value(params[:connection_url])
is_expected.to contain_nova_config('xenserver/connection_username').with_value(params[:connection_username])
is_expected.to contain_nova_config('xenserver/connection_password').with_value(params[:connection_password])
it 'installs xenapi with pip' do
should contain_package('xenapi').with(
:ensure => 'present',
:provider => 'pip'
)
end
end
it 'installs xenapi with pip' do
is_expected.to contain_package('xenapi').with(
:ensure => 'present',
:provider => 'pip'
)
context 'with overridden parameters' do
before do
params.merge!({:compute_driver => 'xenapi.FoobarDriver'})
end
it 'configures xenapi in nova.conf' do
should contain_nova_config('DEFAULT/compute_driver').with_value('xenapi.FoobarDriver')
end
end
context 'with optional parameters' do
before :each do
params.merge!(optional_params)
end
it 'configures xenapi in nova.conf' do
should contain_nova_config('xenserver/ovs_integration_bridge').with_value(params[:ovs_integration_bridge])
should contain_nova_config('xenserver/agent_timeout').with_value(params[:agent_timeout])
should contain_nova_config('xenserver/agent_version_timeout').with_value(params[:agent_version_timeout])
should contain_nova_config('xenserver/agent_resetnetwork_timeout').with_value(params[:agent_resetnetwork_timeout])
should contain_nova_config('xenserver/agent_path').with_value(params[:agent_path])
should contain_nova_config('xenserver/disable_agent').with_value(params[:disable_agent])
should contain_nova_config('xenserver/use_agent_default').with_value(params[:use_agent_default])
should contain_nova_config('xenserver/login_timeout').with_value(params[:login_timeout])
should contain_nova_config('xenserver/connection_concurrent').with_value(params[:connection_concurrent])
should contain_nova_config('xenserver/vhd_coalesce_poll_interval').with_value(params[:vhd_coalesce_poll_interval])
should contain_nova_config('xenserver/check_host').with_value(params[:check_host])
should contain_nova_config('xenserver/vhd_coalesce_max_attempts').with_value(params[:vhd_coalesce_max_attempts])
should contain_nova_config('xenserver/sr_base_path').with_value(params[:sr_base_path])
should contain_nova_config('xenserver/target_host').with_value(params[:target_host])
should contain_nova_config('xenserver/target_port').with_value(params[:target_port])
should contain_nova_config('xenserver/iqn_prefix').with_value(params[:iqn_prefix])
should contain_nova_config('xenserver/remap_vbd_dev').with_value(params[:remap_vbd_dev])
should contain_nova_config('xenserver/remap_vbd_dev_prefix').with_value(params[:remap_vbd_dev_prefix])
should contain_nova_config('xenserver/torrent_base_url').with_value(params[:torrent_base_url])
should contain_nova_config('xenserver/torrent_seed_chance').with_value(params[:torrent_seed_chance])
should contain_nova_config('xenserver/torrent_seed_duration').with_value(params[:torrent_seed_duration])
should contain_nova_config('xenserver/torrent_max_last_accessed').with_value(params[:torrent_max_last_accessed])
should contain_nova_config('xenserver/torrent_listen_port_start').with_value(params[:torrent_listen_port_start])
should contain_nova_config('xenserver/torrent_listen_port_end').with_value(params[:torrent_listen_port_end])
should contain_nova_config('xenserver/torrent_download_stall_cutoff').with_value(params[:torrent_download_stall_cutoff])
should contain_nova_config('xenserver/torrent_max_seeder_processes_per_host').with_value(params[:torrent_max_seeder_processes_per_host])
should contain_nova_config('xenserver/use_join_force').with_value(params[:use_join_force])
should contain_nova_config('xenserver/cache_images').with_value(params[:cache_images])
should contain_nova_config('xenserver/image_compression_level').with_value(params[:image_compression_level])
should contain_nova_config('xenserver/default_os_type').with_value(params[:default_os_type])
should contain_nova_config('xenserver/block_device_creation_timeout').with_value(params[:block_device_creation_timeout])
should contain_nova_config('xenserver/max_kernel_ramdisk_size').with_value(params[:max_kernel_ramdisk_size])
should contain_nova_config('xenserver/sr_matching_filter').with_value(params[:sr_matching_filter])
should contain_nova_config('xenserver/sparse_copy').with_value(params[:sparse_copy])
should contain_nova_config('xenserver/num_vbd_unplug_retries').with_value(params[:num_vbd_unplug_retries])
should contain_nova_config('xenserver/torrent_images').with_value(params[:torrent_images])
should contain_nova_config('xenserver/ipxe_network_name').with_value(params[:ipxe_network_name])
should contain_nova_config('xenserver/ipxe_boot_menu_url').with_value(params[:ipxe_boot_menu_url])
should contain_nova_config('xenserver/ipxe_mkisofs_cmd').with_value(params[:ipxe_mkisofs_cmd])
should contain_nova_config('xenserver/running_timeout').with_value(params[:running_timeout])
should contain_nova_config('xenserver/vif_driver').with_value(params[:vif_driver])
should contain_nova_config('xenserver/image_upload_handler').with_value(params[:image_upload_handler])
should contain_nova_config('xenserver/introduce_vdi_retry_wait').with_value(params[:introduce_vdi_retry_wait])
end
end
end
context 'with overridden parameters' do
before do
params.merge!({:compute_driver => 'xenapi.FoobarDriver'})
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it 'configures xenapi in nova.conf' do
is_expected.to contain_nova_config('DEFAULT/compute_driver').with_value('xenapi.FoobarDriver')
end
end
context 'with optional parameters' do
before :each do
params.merge!(optional_params)
end
it 'configures xenapi in nova.conf' do
is_expected.to contain_nova_config('xenserver/ovs_integration_bridge').with_value(params[:ovs_integration_bridge])
is_expected.to contain_nova_config('xenserver/agent_timeout').with_value(params[:agent_timeout])
is_expected.to contain_nova_config('xenserver/agent_version_timeout').with_value(params[:agent_version_timeout])
is_expected.to contain_nova_config('xenserver/agent_resetnetwork_timeout').with_value(params[:agent_resetnetwork_timeout])
is_expected.to contain_nova_config('xenserver/agent_path').with_value(params[:agent_path])
is_expected.to contain_nova_config('xenserver/disable_agent').with_value(params[:disable_agent])
is_expected.to contain_nova_config('xenserver/use_agent_default').with_value(params[:use_agent_default])
is_expected.to contain_nova_config('xenserver/login_timeout').with_value(params[:login_timeout])
is_expected.to contain_nova_config('xenserver/connection_concurrent').with_value(params[:connection_concurrent])
is_expected.to contain_nova_config('xenserver/vhd_coalesce_poll_interval').with_value(params[:vhd_coalesce_poll_interval])
is_expected.to contain_nova_config('xenserver/check_host').with_value(params[:check_host])
is_expected.to contain_nova_config('xenserver/vhd_coalesce_max_attempts').with_value(params[:vhd_coalesce_max_attempts])
is_expected.to contain_nova_config('xenserver/sr_base_path').with_value(params[:sr_base_path])
is_expected.to contain_nova_config('xenserver/target_host').with_value(params[:target_host])
is_expected.to contain_nova_config('xenserver/target_port').with_value(params[:target_port])
is_expected.to contain_nova_config('xenserver/iqn_prefix').with_value(params[:iqn_prefix])
is_expected.to contain_nova_config('xenserver/remap_vbd_dev').with_value(params[:remap_vbd_dev])
is_expected.to contain_nova_config('xenserver/remap_vbd_dev_prefix').with_value(params[:remap_vbd_dev_prefix])
is_expected.to contain_nova_config('xenserver/torrent_base_url').with_value(params[:torrent_base_url])
is_expected.to contain_nova_config('xenserver/torrent_seed_chance').with_value(params[:torrent_seed_chance])
is_expected.to contain_nova_config('xenserver/torrent_seed_duration').with_value(params[:torrent_seed_duration])
is_expected.to contain_nova_config('xenserver/torrent_max_last_accessed').with_value(params[:torrent_max_last_accessed])
is_expected.to contain_nova_config('xenserver/torrent_listen_port_start').with_value(params[:torrent_listen_port_start])
is_expected.to contain_nova_config('xenserver/torrent_listen_port_end').with_value(params[:torrent_listen_port_end])
is_expected.to contain_nova_config('xenserver/torrent_download_stall_cutoff').with_value(params[:torrent_download_stall_cutoff])
is_expected.to contain_nova_config('xenserver/torrent_max_seeder_processes_per_host').with_value(params[:torrent_max_seeder_processes_per_host])
is_expected.to contain_nova_config('xenserver/use_join_force').with_value(params[:use_join_force])
is_expected.to contain_nova_config('xenserver/cache_images').with_value(params[:cache_images])
is_expected.to contain_nova_config('xenserver/image_compression_level').with_value(params[:image_compression_level])
is_expected.to contain_nova_config('xenserver/default_os_type').with_value(params[:default_os_type])
is_expected.to contain_nova_config('xenserver/block_device_creation_timeout').with_value(params[:block_device_creation_timeout])
is_expected.to contain_nova_config('xenserver/max_kernel_ramdisk_size').with_value(params[:max_kernel_ramdisk_size])
is_expected.to contain_nova_config('xenserver/sr_matching_filter').with_value(params[:sr_matching_filter])
is_expected.to contain_nova_config('xenserver/sparse_copy').with_value(params[:sparse_copy])
is_expected.to contain_nova_config('xenserver/num_vbd_unplug_retries').with_value(params[:num_vbd_unplug_retries])
is_expected.to contain_nova_config('xenserver/torrent_images').with_value(params[:torrent_images])
is_expected.to contain_nova_config('xenserver/ipxe_network_name').with_value(params[:ipxe_network_name])
is_expected.to contain_nova_config('xenserver/ipxe_boot_menu_url').with_value(params[:ipxe_boot_menu_url])
is_expected.to contain_nova_config('xenserver/ipxe_mkisofs_cmd').with_value(params[:ipxe_mkisofs_cmd])
is_expected.to contain_nova_config('xenserver/running_timeout').with_value(params[:running_timeout])
is_expected.to contain_nova_config('xenserver/vif_driver').with_value(params[:vif_driver])
is_expected.to contain_nova_config('xenserver/image_upload_handler').with_value(params[:image_upload_handler])
is_expected.to contain_nova_config('xenserver/introduce_vdi_retry_wait').with_value(params[:introduce_vdi_retry_wait])
it_behaves_like 'nova::compute::xenserver'
end
end
end

View File

@ -3,164 +3,184 @@ require 'spec_helper'
describe 'nova::keystone::auth' do
let :params do
{:password => 'nova_password'}
{
:password => 'nova_password'
}
end
let :default_params do
{ :auth_name => 'nova',
:service_name => 'nova',
:region => 'RegionOne',
:tenant => 'services',
:email => 'nova@localhost',
:public_url => 'http://127.0.0.1:8774/v2.1',
:internal_url => 'http://127.0.0.1:8774/v2.1',
:admin_url => 'http://127.0.0.1:8774/v2.1' }
end
context 'with default parameters' do
it { is_expected.to contain_keystone_user('nova').with(
:ensure => 'present',
:password => 'nova_password'
) }
it { is_expected.to contain_keystone_user_role('nova@services').with(
:ensure => 'present',
:roles => ['admin']
)}
it { is_expected.to contain_keystone_service('nova::compute').with(
:ensure => 'present',
:description => 'Openstack Compute Service'
)}
it { is_expected.to contain_keystone_endpoint('RegionOne/nova::compute').with(
:ensure => 'present',
{
:auth_name => 'nova',
:service_name => 'nova',
:region => 'RegionOne',
:tenant => 'services',
:email => 'nova@localhost',
:public_url => 'http://127.0.0.1:8774/v2.1',
:admin_url => 'http://127.0.0.1:8774/v2.1',
:internal_url => 'http://127.0.0.1:8774/v2.1'
)}
:internal_url => 'http://127.0.0.1:8774/v2.1',
:admin_url => 'http://127.0.0.1:8774/v2.1'
}
end
context 'when setting auth name' do
before do
params.merge!( :auth_name => 'foo' )
shared_examples 'nova::keystone::auth' do
context 'with default parameters' do
it { should contain_keystone_user('nova').with(
:ensure => 'present',
:password => 'nova_password'
)}
it { should contain_keystone_user_role('nova@services').with(
:ensure => 'present',
:roles => ['admin']
)}
it { should contain_keystone_service('nova::compute').with(
:ensure => 'present',
:description => 'Openstack Compute Service'
)}
it { should contain_keystone_endpoint('RegionOne/nova::compute').with(
:ensure => 'present',
:public_url => 'http://127.0.0.1:8774/v2.1',
:admin_url => 'http://127.0.0.1:8774/v2.1',
:internal_url => 'http://127.0.0.1:8774/v2.1'
)}
end
it { is_expected.to contain_keystone_user('foo').with(
:ensure => 'present',
:password => 'nova_password'
) }
context 'when setting auth name' do
before do
params.merge!( :auth_name => 'foo' )
end
it { is_expected.to contain_keystone_user_role('foo@services').with(
:ensure => 'present',
:roles => ['admin']
)}
it { should contain_keystone_user('foo').with(
:ensure => 'present',
:password => 'nova_password'
)}
it { is_expected.to contain_keystone_service('nova::compute').with(
:ensure => 'present',
:description => 'Openstack Compute Service'
)}
it { should contain_keystone_user_role('foo@services').with(
:ensure => 'present',
:roles => ['admin']
)}
it { should contain_keystone_service('nova::compute').with(
:ensure => 'present',
:description => 'Openstack Compute Service'
)}
end
context 'when overriding endpoint parameters' do
before do
params.merge!(
:region => 'RegionTwo',
:public_url => 'https://10.0.0.1:9774/v2.2',
:internal_url => 'https://10.0.0.3:9774/v2.2',
:admin_url => 'https://10.0.0.2:9774/v2.2',
)
end
it { should contain_keystone_endpoint('RegionTwo/nova::compute').with(
:ensure => 'present',
:public_url => params[:public_url],
:internal_url => params[:internal_url],
:admin_url => params[:admin_url]
)}
end
context 'when disabling endpoint configuration' do
before do
params.merge!( :configure_endpoint => false )
end
it { should_not contain_keystone_endpoint('RegionOne/nova::compute') }
end
context 'when disabling user configuration' do
before do
params.merge!( :configure_user => false )
end
it { should_not contain_keystone_user('nova') }
it { should contain_keystone_user_role('nova@services') }
it { should contain_keystone_service('nova::compute').with(
:ensure => 'present',
:description => 'Openstack Compute Service'
)}
end
context 'when disabling user and user role configuration' do
let :params do
{
:configure_user => false,
:configure_user_role => false,
:password => 'nova_password'
}
end
it { should_not contain_keystone_user('nova') }
it { should_not contain_keystone_user_role('nova@services') }
it { should contain_keystone_service('nova::compute').with(
:ensure => 'present',
:description => 'Openstack Compute Service'
)}
end
context 'when overriding service names' do
let :params do
{
:service_name => 'nova_service',
:password => 'nova_password'
}
end
it { should contain_keystone_user('nova') }
it { should contain_keystone_user_role('nova@services') }
it { should contain_keystone_service('nova_service::compute') }
it { should contain_keystone_endpoint('RegionOne/nova_service::compute') }
end
context 'when configuring nova-api and the keystone endpoint' do
let :pre_condition do
"class { '::nova::keystone::authtoken':
password => 'secrete',
}
class { 'nova::api': }
include nova"
end
let :params do
{
:password => 'test',
:service_name => 'nova',
}
end
it { should contain_keystone_endpoint('RegionOne/nova::compute').with_notify(platform_params[:nova_api_notify]) }
end
end
context 'when overriding endpoint parameters' do
before do
params.merge!(
:region => 'RegionTwo',
:public_url => 'https://10.0.0.1:9774/v2.2',
:internal_url => 'https://10.0.0.3:9774/v2.2',
:admin_url => 'https://10.0.0.2:9774/v2.2',
)
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
let (:platform_params) do
case facts[:osfamily]
when 'Debian'
{
:nova_api_notify => ['Service[nova-api]'],
}
when 'RedHat'
{
:nova_api_notify => [],
}
end
end
it_behaves_like 'nova::keystone::auth'
end
it { is_expected.to contain_keystone_endpoint('RegionTwo/nova::compute').with(
:ensure => 'present',
:public_url => params[:public_url],
:internal_url => params[:internal_url],
:admin_url => params[:admin_url]
)}
end
describe 'when disabling endpoint configuration' do
before do
params.merge!( :configure_endpoint => false )
end
it { is_expected.to_not contain_keystone_endpoint('RegionOne/nova::compute') }
end
describe 'when disabling user configuration' do
before do
params.merge!( :configure_user => false )
end
it { is_expected.to_not contain_keystone_user('nova') }
it { is_expected.to contain_keystone_user_role('nova@services') }
it { is_expected.to contain_keystone_service('nova::compute').with(
:ensure => 'present',
:description => 'Openstack Compute Service'
)}
end
describe 'when disabling user and user role configuration' do
let :params do
{
:configure_user => false,
:configure_user_role => false,
:password => 'nova_password'
}
end
it { is_expected.to_not contain_keystone_user('nova') }
it { is_expected.to_not contain_keystone_user_role('nova@services') }
it { is_expected.to contain_keystone_service('nova::compute').with(
:ensure => 'present',
:description => 'Openstack Compute Service'
)}
end
describe 'when configuring nova-api and the keystone endpoint' do
let :pre_condition do
"class { '::nova::keystone::authtoken':
password => 'secrete',
}
class { 'nova::api':}
include nova"
end
let :facts do
@default_facts.merge({
:osfamily => "Debian",
:os => { :name => 'Debian', :family => 'Debian', :release => { :major => '8', :minor => '0' } },
})
end
let :params do
{
:password => 'test'
}
end
it { is_expected.to contain_keystone_endpoint('RegionOne/nova::compute').with_notify(['Service[nova-api]']) }
end
describe 'when overriding service names' do
let :params do
{
:service_name => 'nova_service',
:password => 'nova_password'
}
end
it { is_expected.to contain_keystone_user('nova') }
it { is_expected.to contain_keystone_user_role('nova@services') }
it { is_expected.to contain_keystone_service('nova_service::compute') }
it { is_expected.to contain_keystone_endpoint('RegionOne/nova_service::compute') }
end
end

View File

@ -6,33 +6,18 @@ describe 'nova::spicehtml5proxy' do
'include nova'
end
shared_examples 'nova-spicehtml5proxy debian package' do
let :params do
{ :enabled => true }
end
it { is_expected.to contain_file_line('/etc/default/nova-consoleproxy:NOVA_CONSOLE_PROXY_TYPE').with(
:path => '/etc/default/nova-consoleproxy',
:match => '^NOVA_CONSOLE_PROXY_TYPE=(.*)$',
:line => 'NOVA_CONSOLE_PROXY_TYPE=spicehtml5',
:tag => 'nova-consoleproxy',
:require => 'Anchor[nova::config::begin]',
:notify => 'Anchor[nova::config::end]',
)}
end
shared_examples 'nova-spicehtml5proxy' do
shared_examples 'nova::spicehtml5proxy' do
it 'configures nova.conf' do
is_expected.to contain_nova_config('spice/html5proxy_host').with(:value => '0.0.0.0')
is_expected.to contain_nova_config('spice/html5proxy_port').with(:value => '6082')
should contain_nova_config('spice/html5proxy_host').with(:value => '0.0.0.0')
should contain_nova_config('spice/html5proxy_port').with(:value => '6082')
end
it { is_expected.to contain_package('nova-spicehtml5proxy').with(
it { should contain_package('nova-spicehtml5proxy').with(
:ensure => 'present',
:name => platform_params[:spicehtml5proxy_package_name]
) }
it { is_expected.to contain_service('nova-spicehtml5proxy').with(
it { should contain_service('nova-spicehtml5proxy').with(
:ensure => 'running',
:name => platform_params[:spicehtml5proxy_service_name],
:hasstatus => true
@ -45,7 +30,7 @@ describe 'nova::spicehtml5proxy' do
}
end
it { is_expected.to contain_service('nova-spicehtml5proxy').without_ensure }
it { should contain_service('nova-spicehtml5proxy').without_ensure }
end
context 'with package version' do
@ -53,84 +38,71 @@ describe 'nova::spicehtml5proxy' do
{ :ensure_package => '2012.1-2' }
end
it { is_expected.to contain_package('nova-spicehtml5proxy').with(
it { should contain_package('nova-spicehtml5proxy').with(
:ensure => params[:ensure_package],
:name => platform_params[:spicehtml5proxy_package_name],
)}
end
end
context 'on Ubuntu system' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
:os_package_type => 'ubuntu',
:os => { :family => 'Debian', :release => { :major => '16'}}
})
shared_examples 'nova::spicehtml5proxy on Debian' do
let :params do
{
:enabled => true
}
end
let :platform_params do
{ :spicehtml5proxy_package_name => 'nova-spiceproxy',
:spicehtml5proxy_service_name => 'nova-spiceproxy' }
end
it_configures 'nova-spicehtml5proxy'
it { should contain_file_line('/etc/default/nova-consoleproxy:NOVA_CONSOLE_PROXY_TYPE').with(
:path => '/etc/default/nova-consoleproxy',
:match => '^NOVA_CONSOLE_PROXY_TYPE=(.*)$',
:line => 'NOVA_CONSOLE_PROXY_TYPE=spicehtml5',
:tag => 'nova-consoleproxy',
:require => 'Anchor[nova::config::begin]',
:notify => 'Anchor[nova::config::end]',
)}
end
context 'on Debian system' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemmajrelease => '9',
:os_package_type => 'debian',
:os => { :family => 'Debian', :release => { :major => '9'}}
})
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
if facts[:operatingsystem] == 'Debian'
extra = { :os_package_type => 'debian' }
else
extra = {}
end
let :platform_params do
{ :spicehtml5proxy_package_name => 'nova-consoleproxy',
:spicehtml5proxy_service_name => 'nova-spicehtml5proxy' }
end
facts.merge!(OSDefaults.get_facts(extra))
end
it_configures 'nova-spicehtml5proxy debian package'
it_configures 'nova-spicehtml5proxy'
let (:platform_params) do
case facts[:osfamily]
when 'Debian'
if facts[:os_package_type] == 'debian' then
package_name = 'nova-consoleproxy'
service_name = 'nova-spicehtml5proxy'
else
package_name = 'nova-spiceproxy'
service_name = 'nova-spiceproxy'
end
{
:spicehtml5proxy_package_name => package_name,
:spicehtml5proxy_service_name => service_name
}
when 'RedHat'
{
:spicehtml5proxy_package_name => 'openstack-nova-console',
:spicehtml5proxy_service_name => 'openstack-nova-spicehtml5proxy'
}
end
end
it_behaves_like 'nova::spicehtml5proxy'
if facts[:os_package_type] == 'debian'
it_behaves_like 'nova::spicehtml5proxy on Debian'
end
end
end
context 'on Ubuntu system with Debian packages' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
:os_package_type => 'debian',
:os => { :family => 'Debian', :release => { :major => '16'}}
})
end
let :platform_params do
{ :spicehtml5proxy_package_name => 'nova-consoleproxy',
:spicehtml5proxy_service_name => 'nova-spicehtml5proxy' }
end
it_configures 'nova-spicehtml5proxy debian package'
it_configures 'nova-spicehtml5proxy'
end
context 'on Redhat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat',
:os => { :family => 'RedHat', :release => { :major => '7'}}
})
end
let :platform_params do
{ :spicehtml5proxy_package_name => 'openstack-nova-console',
:spicehtml5proxy_service_name => 'openstack-nova-spicehtml5proxy' }
end
it_configures 'nova-spicehtml5proxy'
end
end

View File

@ -1,37 +1,48 @@
require 'spec_helper'
describe 'nova::generic_service' do
describe 'package should come before service' do
let :pre_condition do
'include nova'
shared_examples 'nova::generic_service' do
describe 'package should come before service' do
let :pre_condition do
"include nova"
end
let :params do
{
:package_name => 'foo',
:service_name => 'food'
}
end
let :title do
'foo'
end
it { should contain_service('nova-foo').with(
:name => 'food',
:ensure => 'running',
:enable => true
)}
it { should contain_service('nova-foo').that_subscribes_to(
'Anchor[nova::service::begin]',
)}
it { should contain_service('nova-foo').that_notifies(
'Anchor[nova::service::end]',
)}
end
end
let :params do
{
:package_name => 'foo',
:service_name => 'food'
}
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'nova::generic_service'
end
let :facts do
@default_facts.merge({ :osfamily => 'RedHat', :os => { :family => 'RedHat', :release => { :major => '8'}}})
end
let :title do
'foo'
end
it { is_expected.to contain_service('nova-foo').with(
'name' => 'food',
'ensure' => 'running',
'enable' => true
)}
it { is_expected.to contain_service('nova-foo').that_subscribes_to(
'Anchor[nova::service::begin]',
)}
it { is_expected.to contain_service('nova-foo').that_notifies(
'Anchor[nova::service::end]',
)}
end
end