Finish converting to rspec-puppet-facts

Change-Id: I66c41584347c9986ac7e884e80efa982b4050175
This commit is contained in:
Mykyta Karpin 2016-11-22 16:11:28 +02:00
parent 9b0aa85594
commit ca26a6bbc8
29 changed files with 507 additions and 541 deletions

View File

@ -138,7 +138,7 @@ describe 'ironic::api::authtoken' do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'ironic api authtoken'
it_behaves_like 'ironic api authtoken'
end
end

View File

@ -146,41 +146,26 @@ describe 'ironic::api' do
end
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '8.0',
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld',
})
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'
{ :api_package => 'ironic-api',
:api_service => 'ironic-api' }
end
it_configures 'ironic api'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '7.2',
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld',
})
end
let :platform_params do
when 'RedHat'
{ :api_service => 'openstack-ironic-api' }
end
end
it_configures 'ironic api'
it_behaves_like 'ironic api'
end
end
end

View File

@ -22,19 +22,17 @@ require 'spec_helper'
describe 'ironic::client' do
context 'on Debian platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
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 { is_expected.to contain_class('ironic::client') }
end
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it { is_expected.to contain_class('ironic::client') }
end
end

View File

@ -124,18 +124,20 @@ describe 'ironic::conductor' do
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
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
case facts[:osfamily]
when 'Debian'
let :platform_params do
{ :conductor_package => 'ironic-conductor',
:conductor_service => 'ironic-conductor' }
end
it_configures 'ironic conductor'
# https://bugs.launchpad.net/cloud-archive/+bug/1572800
it 'installs ipmitool package' do
is_expected.to contain_package('ipmitool').with(
@ -144,18 +146,14 @@ describe 'ironic::conductor' do
:tag => ['openstack', 'ironic-package'],
)
end
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
when 'RedHat'
let :platform_params do
{ :conductor_service => 'ironic-conductor' }
end
end
it_configures 'ironic conductor'
it_behaves_like 'ironic conductor'
end
end
end

View File

@ -42,7 +42,7 @@ describe 'ironic::cors' do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'ironic cors'
it_behaves_like 'ironic cors'
end
end

View File

@ -30,13 +30,12 @@ describe 'ironic::db::mysql' do
{ :password => 'passw0rd' }
end
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
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 { is_expected.to contain_openstacklib__db__mysql('ironic').with(
@ -45,19 +44,8 @@ describe 'ironic::db::mysql' do
:charset => 'utf8',
:collate => 'utf8_general_ci',
)}
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it { is_expected.to contain_openstacklib__db__mysql('ironic').with(
:user => 'ironic',
:password_hash => '*74B1C21ACE0C2D6B0678A5E503D2A60E8F9651A3',
:charset => 'utf8',
:collate => 'utf8_general_ci',
)}
end
describe "overriding allowed_hosts param to array" do

View File

@ -35,7 +35,7 @@ describe 'ironic::db::postgresql' do
}))
end
it_configures 'ironic::db::postgresql'
it_behaves_like 'ironic::db::postgresql'
end
end

View File

@ -78,15 +78,7 @@ describe 'ironic::db' do
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => 'jessie',
})
end
it_configures 'ironic::db'
shared_examples_for 'ironic::db on Debian platforms' do
context 'using pymysql driver' do
let :params do
@ -118,14 +110,7 @@ describe 'ironic::db' do
end
context 'on Redhat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat',
:operatingsystemrelease => '7.1',
})
end
it_configures 'ironic::db'
shared_examples_for 'ironic::db on RedHat platforms' do
context 'using pymysql driver' do
let :params do
@ -136,4 +121,26 @@ describe 'ironic::db' do
end
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({
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld',
}))
end
case facts[:osfamily]
when 'Debian'
it_behaves_like 'ironic::db on Debian platforms'
when 'RedHat'
it_behaves_like 'ironic::db on RedHat platforms'
end
it_behaves_like 'ironic::db'
end
end
end

View File

@ -42,7 +42,7 @@ describe 'ironic::db::sync' do
}))
end
it_configures 'ironic-dbsync'
it_behaves_like 'ironic-dbsync'
end
end

View File

@ -69,7 +69,7 @@ describe 'ironic::drivers::agent' do
let (:facts) do
facts.merge(OSDefaults.get_facts())
end
it_configures 'ironic agent driver'
it_behaves_like 'ironic agent driver'
end
end

View File

@ -40,7 +40,7 @@ describe 'ironic::drivers::drac' do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'ironic drac driver'
it_behaves_like 'ironic drac driver'
end
end

View File

@ -65,7 +65,7 @@ describe 'ironic::drivers::ilo' do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'ironic ilo driver'
it_behaves_like 'ironic ilo driver'
end
end

View File

@ -50,20 +50,17 @@ describe 'ironic::drivers::ipmi' do
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
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 'ironic ipmi driver'
end
it_behaves_like 'ironic ipmi driver'
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it_configures 'ironic ipmi driver'
end
end

View File

@ -111,20 +111,20 @@ describe 'ironic::drivers::pxe' do
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
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({
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld',
}))
end
it_configures 'ironic pxe driver'
end
it_behaves_like 'ironic pxe driver'
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it_configures 'ironic pxe driver'
end
end

View File

@ -43,7 +43,7 @@ describe 'ironic::drivers::ssh' do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'ironic driver ssh'
it_behaves_like 'ironic driver ssh'
end
end

View File

@ -282,29 +282,30 @@ describe 'ironic' do
end
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
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({
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld',
}))
end
let :platform_params do
case facts[:osfamily]
when 'Debian'
{ :common_package_name => 'ironic-common',
:lib_package_name => 'python-ironic-lib' }
end
it_configures 'ironic'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
let :platform_params do
when 'RedHat'
{ :common_package_name => 'openstack-ironic-common',
:lib_package_name => 'python-ironic-lib' }
end
it_configures 'ironic'
end
it_behaves_like 'ironic'
end
end
end

View File

@ -138,7 +138,7 @@ describe 'ironic::inspector::authtoken' do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'ironic inspector authtoken'
it_behaves_like 'ironic inspector authtoken'
end
end

View File

@ -54,7 +54,7 @@ describe 'ironic::inspector::db::mysql' do
facts.merge(OSDefaults.get_facts())
end
it_configures 'ironic::inspector::db::mysql'
it_behaves_like 'ironic::inspector::db::mysql'
end
end

View File

@ -32,7 +32,7 @@ describe 'ironic::inspector::db::postgresql' do
facts.merge(OSDefaults.get_facts())
end
it_configures 'ironic::inspector::db::postgresql'
it_behaves_like 'ironic::inspector::db::postgresql'
end
end

View File

@ -74,15 +74,7 @@ describe 'ironic::inspector::db' do
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => 'jessie',
})
end
it_configures 'ironic::inspector::db'
shared_examples 'ironic::inspector::db on Debian platforms' do
context 'using pymysql driver' do
let :params do
@ -114,14 +106,7 @@ describe 'ironic::inspector::db' do
end
context 'on Redhat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat',
:operatingsystemrelease => '7.1',
})
end
it_configures 'ironic::inspector::db'
shared_examples 'ironic::inspector::db on Redhat platforms' do
context 'using pymysql driver' do
let :params do
@ -132,4 +117,26 @@ describe 'ironic::inspector::db' do
end
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({
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld',
}))
end
case facts[:osfamily]
when 'Debian'
it_behaves_like 'ironic::inspector::db on Debian platforms'
when 'RedHat'
it_behaves_like 'ironic::inspector::db on Redhat platforms'
end
it_behaves_like 'ironic::inspector::db'
end
end
end

View File

@ -23,7 +23,7 @@ describe 'ironic::inspector::db::sync' do
let (:facts) do
facts.merge(OSDefaults.get_facts())
end
it_configures 'inspector-dbsync'
it_behaves_like 'inspector-dbsync'
end
end

View File

@ -120,20 +120,16 @@ describe 'ironic::inspector::logging' do
}
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
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 'ironic-inspector-logging'
it_behaves_like 'ironic-inspector-logging'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it_configures 'ironic-inspector-logging'
end
end

View File

@ -220,37 +220,29 @@ describe 'ironic::inspector' do
end
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '7.0'
})
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({
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld',
}))
end
let :platform_params do
case facts[:osfamily]
when 'Debian'
{ :inspector_package => 'ironic-inspector',
:inspector_service => 'ironic-inspector' }
end
it_configures 'ironic inspector'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
:operatingsystem => 'CentOS',
:operatingsystemrelease => '7.2.1511'
})
end
let :platform_params do
when 'RedHat'
{ :inspector_service => 'ironic-inspector' }
end
end
it_configures 'ironic inspector'
it_behaves_like 'ironic inspector'
end
end
end

View File

@ -22,9 +22,7 @@ require 'spec_helper'
describe 'ironic::keystone::auth_inspector' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
end
shared_examples_for 'ironic keystone auth inspector' do
describe 'with default class parameters' do
let :params do
@ -152,5 +150,18 @@ describe 'ironic::keystone::auth_inspector' do
) }
end
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 'ironic keystone auth inspector'
end
end
end

View File

@ -22,9 +22,7 @@ require 'spec_helper'
describe 'ironic::keystone::auth' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
end
shared_examples_for 'ironic keystone auth' do
describe 'with default class parameters' do
let :params do
@ -151,4 +149,18 @@ describe 'ironic::keystone::auth' do
end
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 'ironic keystone auth'
end
end
end

View File

@ -120,20 +120,17 @@ describe 'ironic::logging' do
}
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
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 'ironic-logging'
end
it_behaves_like 'ironic-logging'
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it_configures 'ironic-logging'
end
end

View File

@ -32,7 +32,7 @@ describe 'ironic::policy' do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'ironic policies'
it_behaves_like 'ironic policies'
end
end

View File

@ -123,28 +123,17 @@ describe 'ironic::pxe' do
end
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '7.0'
})
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 'ironic pxe'
end
it_behaves_like 'ironic pxe'
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
:operatingsystem => 'CentOS',
:operatingsystemrelease => '7.2.1511'
})
end
it_configures 'ironic pxe'
end
end

View File

@ -2,23 +2,15 @@ require 'spec_helper'
describe 'ironic::wsgi::apache' do
let :global_facts do
OSDefaults.get_facts({
:os_workers => 8,
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld'
})
end
shared_examples_for 'apache serving ironic with mod_wsgi' do
it { is_expected.to contain_service('httpd').with_name(platform_parameters[:httpd_service_name]) }
it { is_expected.to contain_service('httpd').with_name(platform_params[:httpd_service_name]) }
it { is_expected.to contain_class('ironic::params') }
it { is_expected.to contain_class('apache') }
it { is_expected.to contain_class('apache::mod::wsgi') }
describe 'with default parameters' do
it { is_expected.to contain_file("#{platform_parameters[:wsgi_script_path]}").with(
it { is_expected.to contain_file("#{platform_params[:wsgi_script_path]}").with(
'ensure' => 'directory',
'owner' => 'ironic',
'group' => 'ironic',
@ -28,28 +20,28 @@ describe 'ironic::wsgi::apache' do
it { is_expected.to contain_file('ironic_wsgi').with(
'ensure' => 'file',
'path' => "#{platform_parameters[:wsgi_script_path]}/app",
'source' => "#{platform_parameters[:wsgi_script_source]}",
'path' => "#{platform_params[:wsgi_script_path]}/app",
'source' => "#{platform_params[:wsgi_script_source]}",
'owner' => 'ironic',
'group' => 'ironic',
'mode' => '0644'
)}
it { is_expected.to contain_file('ironic_wsgi').that_requires("File[#{platform_parameters[:wsgi_script_path]}]") }
it { is_expected.to contain_file('ironic_wsgi').that_requires("File[#{platform_params[:wsgi_script_path]}]") }
it { is_expected.to contain_apache__vhost('ironic_wsgi').with(
'servername' => 'some.host.tld',
'ip' => nil,
'port' => '6385',
'docroot' => "#{platform_parameters[:wsgi_script_path]}",
'docroot' => "#{platform_params[:wsgi_script_path]}",
'docroot_owner' => 'ironic',
'docroot_group' => 'ironic',
'ssl' => 'true',
'wsgi_daemon_process' => 'ironic',
'wsgi_process_group' => 'ironic',
'wsgi_script_aliases' => { '/' => "#{platform_parameters[:wsgi_script_path]}/app" },
'wsgi_script_aliases' => { '/' => "#{platform_params[:wsgi_script_path]}/app" },
'require' => 'File[ironic_wsgi]'
)}
it { is_expected.to contain_concat("#{platform_parameters[:httpd_ports_file]}") }
it { is_expected.to contain_concat("#{platform_params[:httpd_ports_file]}") }
end
describe 'when overriding parameters using different ports' do
@ -67,29 +59,42 @@ describe 'ironic::wsgi::apache' do
'servername' => 'dummy.host',
'ip' => '10.42.51.1',
'port' => '12345',
'docroot' => "#{platform_parameters[:wsgi_script_path]}",
'docroot' => "#{platform_params[:wsgi_script_path]}",
'docroot_owner' => 'ironic',
'docroot_group' => 'ironic',
'ssl' => 'false',
'wsgi_daemon_process' => 'ironic',
'wsgi_process_group' => 'ironic',
'wsgi_script_aliases' => { '/' => "#{platform_parameters[:wsgi_script_path]}/app" },
'wsgi_script_aliases' => { '/' => "#{platform_params[:wsgi_script_path]}/app" },
'require' => 'File[ironic_wsgi]'
)}
it { is_expected.to contain_concat("#{platform_parameters[:httpd_ports_file]}") }
it { is_expected.to contain_concat("#{platform_params[:httpd_ports_file]}") }
end
end
context 'on RedHat platforms' do
let :facts do
global_facts.merge({
:osfamily => 'RedHat',
:operatingsystemrelease => '7.0'
})
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({
:os_workers => 8,
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld'
}))
end
let :platform_parameters do
let :platform_params do
case facts[:osfamily]
when 'Debian'
{
:httpd_service_name => 'apache2',
:httpd_ports_file => '/etc/apache2/ports.conf',
:wsgi_script_path => '/usr/lib/cgi-bin/ironic',
:wsgi_script_source => '/usr/lib/python2.7/dist-packages/ironic/api/app.wsgi',
}
when 'RedHat'
{
:httpd_service_name => 'httpd',
:httpd_ports_file => '/etc/httpd/conf/ports.conf',
@ -97,28 +102,11 @@ describe 'ironic::wsgi::apache' do
:wsgi_script_source => '/usr/lib/python2.7/site-packages/ironic/api/app.wsgi',
}
end
it_configures 'apache serving ironic with mod_wsgi'
end
context 'on Debian platforms' do
let :facts do
global_facts.merge({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '7.0'
})
it_behaves_like 'apache serving ironic with mod_wsgi'
end
end
let :platform_parameters do
{
:httpd_service_name => 'apache2',
:httpd_ports_file => '/etc/apache2/ports.conf',
:wsgi_script_path => '/usr/lib/cgi-bin/ironic',
:wsgi_script_source => '/usr/lib/python2.7/dist-packages/ironic/api/app.wsgi',
}
end
it_configures 'apache serving ironic with mod_wsgi'
end
end