Fix unit tests

The unit tests were broken by a change to openstacklib
Id09c3358c5843510e6a2a8c0e2d4aeb3607e098b which renamed some of the
resources in the openstacklib classes. The problem is that our tests in
this module should not have been testing what occurs within the modules
so this fix updates the tests to only check what we are doing within
this module.

Depends-On: I9d535ab38afea852559df2b3073bd4b74a2a3947
Change-Id: I3a43867c18fec07360333e876312c2d25b868b57
This commit is contained in:
Alex Schultz 2017-07-13 12:59:31 -06:00
parent ebb89cdddf
commit ff924133a4
4 changed files with 120 additions and 289 deletions

View File

@ -196,17 +196,11 @@ describe 'nova::api' do
:validate => true,
})
end
it { is_expected.to contain_exec('execute nova-api validation').with(
:path => '/usr/bin:/bin:/usr/sbin:/sbin',
:provider => 'shell',
:tries => '10',
:try_sleep => '2',
it { is_expected.to contain_openstacklib__service_validation('nova-api').with(
:command => 'nova --os-auth-url http://127.0.0.1:5000/ --os-project-name services --os-username nova --os-password passw0rd flavor-list',
:subscribe => 'Service[nova-api]',
)}
it { is_expected.to contain_anchor('create nova-api anchor').with(
:require => 'Exec[execute nova-api validation]',
)}
end
context 'while validating the service with custom command' do
@ -216,16 +210,9 @@ describe 'nova::api' do
:validation_options => { 'nova-api' => { 'command' => 'my-script' } }
})
end
it { is_expected.to contain_exec('execute nova-api validation').with(
:path => '/usr/bin:/bin:/usr/sbin:/sbin',
:provider => 'shell',
:tries => '10',
:try_sleep => '2',
it { is_expected.to contain_openstacklib__service_validation('nova-api').with(
:command => 'my-script',
)}
it { is_expected.to contain_anchor('create nova-api anchor').with(
:require => 'Exec[execute nova-api validation]',
:subscribe => 'Service[nova-api]',
)}
end

View File

@ -1,32 +1,8 @@
require 'spec_helper'
describe 'nova::wsgi::apache_api' do
let :global_facts do
@default_facts.merge({
:processorcount => 42,
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld'
})
end
let :pre_condition do
"include nova
class { '::nova::keystone::authtoken':
password => 'secrete',
}
class { '::nova::api':
service_name => 'httpd',
}"
end
shared_examples_for 'apache serving nova with mod_wsgi' do
it { is_expected.to contain_service('httpd').with_name(platform_params[:httpd_service_name]) }
it { is_expected.to contain_class('nova::params') }
it { is_expected.to contain_class('apache') }
it { is_expected.to contain_class('apache::mod::wsgi') }
describe 'with default parameters' do
context 'with default parameters' do
let :pre_condition do
"include nova
@ -37,61 +13,28 @@ describe 'nova::wsgi::apache_api' do
service_name => 'httpd',
}"
end
it { is_expected.to contain_file("#{platform_params[:wsgi_script_path]}").with(
'ensure' => 'directory',
'owner' => 'nova',
'group' => 'nova',
'require' => 'Package[httpd]'
it { is_expected.to contain_class('nova::params') }
it { is_expected.to contain_class('apache') }
it { is_expected.to contain_class('apache::mod::wsgi') }
it { is_expected.to contain_class('apache::mod::ssl') }
it { is_expected.to contain_openstacklib__wsgi__apache('nova_api_wsgi').with(
:bind_port => 8774,
:group => 'nova',
:path => '/',
:servername => facts[:fqdn],
:ssl => true,
:threads => facts[:os_workers],
:user => 'nova',
:workers => 1,
:wsgi_daemon_process => 'nova-api',
:wsgi_process_group => 'nova-api',
:wsgi_script_dir => platform_params[:wsgi_script_path],
:wsgi_script_file => 'nova-api',
:wsgi_script_source => platform_params[:api_wsgi_script_source],
)}
it { is_expected.to contain_file('nova_api_wsgi').with(
'ensure' => 'file',
'path' => "#{platform_params[:wsgi_script_path]}/nova-api",
'source' => platform_params[:api_wsgi_script_source],
'owner' => 'nova',
'group' => 'nova',
'mode' => '0644'
)}
it { is_expected.to contain_file('nova_api_wsgi').that_requires("File[#{platform_params[:wsgi_script_path]}]") }
it { is_expected.to contain_apache__vhost('nova_api_wsgi').with(
'servername' => 'some.host.tld',
'ip' => nil,
'port' => '8774',
'docroot' => "#{platform_params[:wsgi_script_path]}",
'docroot_owner' => 'nova',
'docroot_group' => 'nova',
'ssl' => 'true',
'wsgi_daemon_process' => 'nova-api',
'wsgi_daemon_process_options' => {
'user' => 'nova',
'group' => 'nova',
'processes' => 1,
'threads' => '42',
'display-name' => 'nova_api_wsgi',
},
'wsgi_process_group' => 'nova-api',
'wsgi_script_aliases' => { '/' => "#{platform_params[:wsgi_script_path]}/nova-api" },
'require' => 'File[nova_api_wsgi]'
)}
it { is_expected.to contain_concat("#{platform_params[:httpd_ports_file]}") }
it { is_expected.to contain_file('nova_api_wsgi').with(
'ensure' => 'file',
'path' => "#{platform_params[:wsgi_script_path]}/nova-api",
'source' => platform_params[:api_wsgi_script_source],
'owner' => 'nova',
'group' => 'nova',
'mode' => '0644'
)}
it { is_expected.to contain_file('nova_api_wsgi').that_requires("File[#{platform_params[:wsgi_script_path]}]") }
it { is_expected.to contain_concat("#{platform_params[:httpd_ports_file]}") }
end
describe 'when overriding parameters using different ports' do
context 'when overriding parameters using different ports' do
let :pre_condition do
"include nova
class { '::nova::keystone::authtoken':
@ -113,29 +56,30 @@ describe 'nova::wsgi::apache_api' do
}
end
it { is_expected.to contain_apache__vhost('nova_api_wsgi').with(
'servername' => 'dummy.host',
'ip' => '10.42.51.1',
'port' => '12345',
'docroot' => "#{platform_params[:wsgi_script_path]}",
'docroot_owner' => 'nova',
'docroot_group' => 'nova',
'ssl' => 'false',
'wsgi_daemon_process' => 'nova-api',
'wsgi_daemon_process_options' => {
'user' => 'nova',
'group' => 'nova',
'processes' => 37,
'threads' => '42',
'display-name' => 'nova-api',
},
'wsgi_process_group' => 'nova-api',
'wsgi_script_aliases' => { '/' => "#{platform_params[:wsgi_script_path]}/nova-api" },
'require' => 'File[nova_api_wsgi]'
it { is_expected.to contain_class('nova::params') }
it { is_expected.to contain_class('apache') }
it { is_expected.to contain_class('apache::mod::wsgi') }
it { is_expected.to_not contain_class('apache::mod::ssl') }
it { is_expected.to contain_openstacklib__wsgi__apache('nova_api_wsgi').with(
:bind_host => '10.42.51.1',
:bind_port => 12345,
:group => 'nova',
:path => '/',
:servername => 'dummy.host',
:ssl => false,
:threads => facts[:os_workers],
:user => 'nova',
:workers => 37,
:wsgi_daemon_process => 'nova-api',
:wsgi_process_display_name => 'nova-api',
:wsgi_process_group => 'nova-api',
:wsgi_script_dir => platform_params[:wsgi_script_path],
:wsgi_script_file => 'nova-api',
:wsgi_script_source => platform_params[:api_wsgi_script_source],
)}
end
describe 'when ::nova::api is missing in the composition layer' do
context 'when ::nova::api is missing in the composition layer' do
let :pre_condition do
"include nova"

View File

@ -1,30 +1,8 @@
require 'spec_helper'
describe 'nova::wsgi::apache_placement' do
let :global_facts do
@default_facts.merge({
:processorcount => 42,
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld'
})
end
let :pre_condition do
"include nova
class { '::nova::keystone::authtoken':
password => 'secrete',
}
"
end
shared_examples_for 'apache serving nova with mod_wsgi' do
it { is_expected.to contain_service('httpd').with_name(platform_params[:httpd_service_name]) }
it { is_expected.to contain_class('nova::params') }
it { is_expected.to contain_class('apache') }
it { is_expected.to contain_class('apache::mod::wsgi') }
describe 'with default parameters' do
context 'with default parameters' do
let :pre_condition do
"include nova
@ -34,68 +12,35 @@ describe 'nova::wsgi::apache_placement' do
"
end
it { is_expected.to contain_package('nova-placement-api').with(
:name => "#{platform_params[:placement_package_name]}",
:ensure => 'present',
:tag => ['openstack', 'nova-package'],
it { is_expected.to contain_class('nova::params') }
it { is_expected.to contain_class('apache') }
it { is_expected.to contain_class('apache::mod::wsgi') }
it { is_expected.to contain_class('apache::mod::ssl') }
it { is_expected.to contain_nova__generic_service('placement-api').with(
:service_name => false,
:package_name => platform_params[:placement_package_name],
:ensure_package => 'present',
)}
it { is_expected.to contain_file("#{platform_params[:wsgi_script_path]}").with(
'ensure' => 'directory',
'owner' => 'nova',
'group' => 'nova',
'require' => 'Package[httpd]'
)}
it { is_expected.to contain_file('placement_wsgi').with(
'ensure' => 'file',
'path' => "#{platform_params[:wsgi_script_path]}/nova-placement-api",
'source' => platform_params[:placement_wsgi_script_source],
'owner' => 'nova',
'group' => 'nova',
'mode' => '0644'
)}
it { is_expected.to contain_file('placement_wsgi').that_requires("File[#{platform_params[:wsgi_script_path]}]") }
it { is_expected.to contain_apache__vhost('placement_wsgi').with(
'servername' => 'some.host.tld',
'ip' => nil,
'port' => '80',
'docroot' => "#{platform_params[:wsgi_script_path]}",
'docroot_owner' => 'nova',
'docroot_group' => 'nova',
'ssl' => 'true',
'wsgi_daemon_process' => 'placement-api',
'wsgi_daemon_process_options' => {
'user' => 'nova',
'group' => 'nova',
'processes' => 1,
'threads' => '42',
'display-name' => 'placement_wsgi',
},
'wsgi_process_group' => 'placement-api',
'wsgi_script_aliases' => { '/placement' => "#{platform_params[:wsgi_script_path]}/nova-placement-api" },
'require' => 'File[placement_wsgi]'
)}
it { is_expected.to contain_concat("#{platform_params[:httpd_ports_file]}") }
it { is_expected.to contain_file('placement_wsgi').with(
'ensure' => 'file',
'path' => "#{platform_params[:wsgi_script_path]}/nova-placement-api",
'source' => platform_params[:placement_wsgi_script_source],
'owner' => 'nova',
'group' => 'nova',
'mode' => '0644'
)}
it { is_expected.to contain_file('placement_wsgi').that_requires("File[#{platform_params[:wsgi_script_path]}]") }
it { is_expected.to contain_concat("#{platform_params[:httpd_ports_file]}") }
it { is_expected.to contain_file(platform_params[:placement_httpd_config_file]) }
it { is_expected.to contain_openstacklib__wsgi__apache('placement_wsgi').with(
:bind_port => 80,
:group => 'nova',
:path => '/placement',
:servername => facts[:fqdn],
:ssl => true,
:threads => facts[:os_workers],
:user => 'nova',
:workers => 1,
:wsgi_daemon_process => 'placement-api',
:wsgi_process_group => 'placement-api',
:wsgi_script_dir => platform_params[:wsgi_script_path],
:wsgi_script_file => 'nova-placement-api',
:wsgi_script_source => platform_params[:placement_wsgi_script_source],
)}
end
describe 'when overriding parameters using different ports' do
context 'when overriding parameters using different ports' do
let :pre_condition do
"include nova
class { '::nova::keystone::authtoken':
@ -115,28 +60,34 @@ describe 'nova::wsgi::apache_placement' do
}
end
it { is_expected.to contain_apache__vhost('placement_wsgi').with(
'servername' => 'dummy.host',
'ip' => '10.42.51.1',
'port' => '12345',
'docroot' => "#{platform_params[:wsgi_script_path]}",
'docroot_owner' => 'nova',
'docroot_group' => 'nova',
'ssl' => 'false',
'wsgi_daemon_process' => 'placement-api',
'wsgi_daemon_process_options' => {
'user' => 'nova',
'group' => 'nova',
'processes' => 37,
'threads' => '42',
'display-name' => 'placement-api',
},
'wsgi_process_group' => 'placement-api',
'wsgi_script_aliases' => { '/placement' => "#{platform_params[:wsgi_script_path]}/nova-placement-api" },
'require' => 'File[placement_wsgi]'
it { is_expected.to contain_class('nova::params') }
it { is_expected.to contain_class('apache') }
it { is_expected.to contain_class('apache::mod::wsgi') }
it { is_expected.to_not contain_class('apache::mod::ssl') }
it { is_expected.to contain_nova__generic_service('placement-api').with(
:service_name => false,
:package_name => platform_params[:placement_package_name],
:ensure_package => 'present',
)}
it { is_expected.to contain_file(platform_params[:placement_httpd_config_file]) }
it { is_expected.to contain_openstacklib__wsgi__apache('placement_wsgi').with(
:bind_host => '10.42.51.1',
:bind_port => 12345,
:group => 'nova',
:path => '/placement',
:servername => 'dummy.host',
:ssl => false,
:workers => 37,
:threads => facts[:os_workers],
:user => 'nova',
:wsgi_daemon_process => 'placement-api',
:wsgi_process_display_name => 'placement-api',
:wsgi_process_group => 'placement-api',
:wsgi_script_dir => platform_params[:wsgi_script_path],
:wsgi_script_file => 'nova-placement-api',
:wsgi_script_source => platform_params[:placement_wsgi_script_source],
)}
end
end
on_supported_os({

View File

@ -14,11 +14,6 @@ describe 'nova::wsgi::apache' do
end
shared_examples_for 'apache serving nova with mod_wsgi' do
it { is_expected.to contain_service('httpd').with_name(platform_params[:httpd_service_name]) }
it { is_expected.to contain_class('nova::params') }
it { is_expected.to contain_class('apache') }
it { is_expected.to contain_class('apache::mod::wsgi') }
context 'with default parameters' do
let :pre_condition do
@ -31,57 +26,19 @@ describe 'nova::wsgi::apache' do
}"
end
it { is_expected.to contain_file("#{platform_params[:wsgi_script_path]}").with(
'ensure' => 'directory',
'owner' => 'nova',
'group' => 'nova',
'require' => 'Package[httpd]'
it { is_expected.to contain_class('nova::params') }
it { is_expected.to contain_class('apache') }
it { is_expected.to contain_class('apache::mod::wsgi') }
it { is_expected.to contain_class('apache::mod::ssl') }
it { is_expected.to contain_class('nova::wsgi::apache_api').with(
:servername => facts[:fqdn],
:api_port => 8774,
:path => '/',
:ssl => true,
:workers => 1,
:threads => facts[:os_workers],
:priority => '10',
)}
it { is_expected.to contain_file('nova_api_wsgi').with(
'ensure' => 'file',
'path' => "#{platform_params[:wsgi_script_path]}/nova-api",
'source' => platform_params[:api_wsgi_script_source],
'owner' => 'nova',
'group' => 'nova',
'mode' => '0644'
)}
it { is_expected.to contain_file('nova_api_wsgi').that_requires("File[#{platform_params[:wsgi_script_path]}]") }
it { is_expected.to contain_apache__vhost('nova_api_wsgi').with(
'servername' => 'some.host.tld',
'ip' => nil,
'port' => '8774',
'docroot' => "#{platform_params[:wsgi_script_path]}",
'docroot_owner' => 'nova',
'docroot_group' => 'nova',
'ssl' => 'true',
'wsgi_daemon_process' => 'nova-api',
'wsgi_daemon_process_options' => {
'user' => 'nova',
'group' => 'nova',
'processes' => 1,
'threads' => '8',
'display-name' => 'nova_api_wsgi',
},
'wsgi_process_group' => 'nova-api',
'wsgi_script_aliases' => { '/' => "#{platform_params[:wsgi_script_path]}/nova-api" },
'require' => 'File[nova_api_wsgi]'
)}
it { is_expected.to contain_concat("#{platform_params[:httpd_ports_file]}") }
it { is_expected.to contain_file('nova_api_wsgi').with(
'ensure' => 'file',
'path' => "#{platform_params[:wsgi_script_path]}/nova-api",
'source' => platform_params[:api_wsgi_script_source],
'owner' => 'nova',
'group' => 'nova',
'mode' => '0644'
)}
it { is_expected.to contain_file('nova_api_wsgi').that_requires("File[#{platform_params[:wsgi_script_path]}]") }
it { is_expected.to contain_concat("#{platform_params[:httpd_ports_file]}") }
end
context 'when overriding parameters using different ports' do
@ -106,26 +63,18 @@ describe 'nova::wsgi::apache' do
}
end
it { is_expected.to contain_apache__vhost('nova_api_wsgi').with(
'servername' => 'dummy.host',
'ip' => '10.42.51.1',
'port' => '12345',
'docroot' => "#{platform_params[:wsgi_script_path]}",
'docroot_owner' => 'nova',
'docroot_group' => 'nova',
'ssl' => 'false',
'wsgi_daemon_process' => 'nova-api',
'wsgi_daemon_process_options' => {
'user' => 'nova',
'group' => 'nova',
'processes' => '37',
'threads' => '8',
'display-name' => 'nova-api',
},
'wsgi_process_group' => 'nova-api',
'wsgi_script_aliases' => { '/' => "#{platform_params[:wsgi_script_path]}/nova-api" },
'require' => 'File[nova_api_wsgi]'
it { is_expected.to_not contain_class('apache::mod::ssl') }
it { is_expected.to contain_class('nova::wsgi::apache_api').with(
:servername => 'dummy.host',
:api_port => 12345,
:path => '/',
:ssl => false,
:wsgi_process_display_name => 'nova-api',
:workers => 37,
:threads => facts[:os_workers],
:priority => '10',
)}
end
context 'when ::nova::api is missing in the composition layer' do