Convert spec testing to use rspec-puppet-facts
Change-Id: I1cc953467862e0dbdf25898a91f3331fcffd05db
This commit is contained in:
parent
eb4aecb517
commit
cdab2825cc
@ -1,125 +1,136 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'openstack_extras::auth_file' do
|
||||
shared_examples 'openstack_extras::auth_file' do
|
||||
context 'when only passing default class parameters' do
|
||||
let :params do
|
||||
{
|
||||
:password => 'admin'
|
||||
}
|
||||
end
|
||||
|
||||
describe "when only passing default class parameters" do
|
||||
|
||||
let :params do
|
||||
{ :password => 'admin' }
|
||||
end
|
||||
|
||||
it 'should create a openrc file' do
|
||||
verify_contents(catalogue, '/root/openrc', [
|
||||
'export OS_NO_CACHE=\'true\'',
|
||||
'export OS_PROJECT_NAME=\'openstack\'',
|
||||
'export OS_USERNAME=\'admin\'',
|
||||
'export OS_PASSWORD=\'admin\'',
|
||||
'export OS_AUTH_URL=\'http://127.0.0.1:5000/v3/\'',
|
||||
'export OS_AUTH_STRATEGY=\'keystone\'',
|
||||
'export OS_REGION_NAME=\'RegionOne\'',
|
||||
'export OS_PROJECT_DOMAIN_NAME=\'default\'',
|
||||
'export OS_USER_DOMAIN_NAME=\'default\'',
|
||||
'export OS_INTERFACE=\'public\'',
|
||||
'export OS_ENDPOINT_TYPE=\'publicURL\'',
|
||||
'export CINDER_ENDPOINT_TYPE=\'publicURL\'',
|
||||
'export GLANCE_ENDPOINT_TYPE=\'publicURL\'',
|
||||
'export KEYSTONE_ENDPOINT_TYPE=\'publicURL\'',
|
||||
'export NOVA_ENDPOINT_TYPE=\'publicURL\'',
|
||||
'export NEUTRON_ENDPOINT_TYPE=\'publicURL\'',
|
||||
'export OS_IDENTITY_API_VERSION=\'3\'',
|
||||
])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when overriding parameters' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:password => 'admin',
|
||||
:auth_url => 'http://127.0.0.2:5000/v3/',
|
||||
:service_token => 'servicetoken',
|
||||
:service_endpoint => 'http://127.0.0.2:5000/v3/',
|
||||
:username => 'myuser',
|
||||
:tenant_name => 'mytenant',
|
||||
:project_name => 'myproject',
|
||||
:region_name => 'myregion',
|
||||
:use_no_cache => 'false',
|
||||
:os_interface => 'internal',
|
||||
:os_endpoint_type => 'internalURL',
|
||||
:cinder_endpoint_type => 'internalURL',
|
||||
:glance_endpoint_type => 'internalURL',
|
||||
:keystone_endpoint_type => 'internalURL',
|
||||
:nova_endpoint_type => 'internalURL',
|
||||
:neutron_endpoint_type => 'internalURL',
|
||||
:auth_strategy => 'no_auth',
|
||||
:user_domain => 'anotherdomain',
|
||||
:project_domain => 'anotherdomain',
|
||||
:compute_api_version => '2.1',
|
||||
:network_api_version => '2.0',
|
||||
:image_api_version => '2',
|
||||
:volume_api_version => '2',
|
||||
:identity_api_version => '3.1',
|
||||
:object_api_version => '1',
|
||||
it {
|
||||
verify_contents(catalogue, '/root/openrc', [
|
||||
'export OS_NO_CACHE=\'true\'',
|
||||
'export OS_PROJECT_NAME=\'openstack\'',
|
||||
'export OS_USERNAME=\'admin\'',
|
||||
'export OS_PASSWORD=\'admin\'',
|
||||
'export OS_AUTH_URL=\'http://127.0.0.1:5000/v3/\'',
|
||||
'export OS_AUTH_STRATEGY=\'keystone\'',
|
||||
'export OS_REGION_NAME=\'RegionOne\'',
|
||||
'export OS_PROJECT_DOMAIN_NAME=\'default\'',
|
||||
'export OS_USER_DOMAIN_NAME=\'default\'',
|
||||
'export OS_INTERFACE=\'public\'',
|
||||
'export OS_ENDPOINT_TYPE=\'publicURL\'',
|
||||
'export CINDER_ENDPOINT_TYPE=\'publicURL\'',
|
||||
'export GLANCE_ENDPOINT_TYPE=\'publicURL\'',
|
||||
'export KEYSTONE_ENDPOINT_TYPE=\'publicURL\'',
|
||||
'export NOVA_ENDPOINT_TYPE=\'publicURL\'',
|
||||
'export NEUTRON_ENDPOINT_TYPE=\'publicURL\'',
|
||||
'export OS_IDENTITY_API_VERSION=\'3\'',
|
||||
])
|
||||
}
|
||||
end
|
||||
|
||||
it 'should create a openrc file' do
|
||||
verify_contents(catalogue, '/root/openrc', [
|
||||
'export OS_SERVICE_TOKEN=\'servicetoken\'',
|
||||
'export OS_SERVICE_ENDPOINT=\'http://127.0.0.2:5000/v3/\'',
|
||||
'export OS_NO_CACHE=\'false\'',
|
||||
'export OS_TENANT_NAME=\'mytenant\'',
|
||||
'export OS_PROJECT_NAME=\'myproject\'',
|
||||
'export OS_USERNAME=\'myuser\'',
|
||||
'export OS_PASSWORD=\'admin\'',
|
||||
'export OS_AUTH_URL=\'http://127.0.0.2:5000/v3/\'',
|
||||
'export OS_AUTH_STRATEGY=\'no_auth\'',
|
||||
'export OS_REGION_NAME=\'myregion\'',
|
||||
'export OS_PROJECT_DOMAIN_NAME=\'anotherdomain\'',
|
||||
'export OS_USER_DOMAIN_NAME=\'anotherdomain\'',
|
||||
'export OS_INTERFACE=\'internal\'',
|
||||
'export OS_ENDPOINT_TYPE=\'internalURL\'',
|
||||
'export CINDER_ENDPOINT_TYPE=\'internalURL\'',
|
||||
'export GLANCE_ENDPOINT_TYPE=\'internalURL\'',
|
||||
'export KEYSTONE_ENDPOINT_TYPE=\'internalURL\'',
|
||||
'export NOVA_ENDPOINT_TYPE=\'internalURL\'',
|
||||
'export NEUTRON_ENDPOINT_TYPE=\'internalURL\'',
|
||||
'export OS_COMPUTE_API_VERSION=\'2.1\'',
|
||||
'export OS_NETWORK_API_VERSION=\'2.0\'',
|
||||
'export OS_IMAGE_API_VERSION=\'2\'',
|
||||
'export OS_VOLUME_API_VERSION=\'2\'',
|
||||
'export OS_IDENTITY_API_VERSION=\'3.1\'',
|
||||
'export OS_OBJECT_API_VERSION=\'1\'',
|
||||
])
|
||||
end
|
||||
end
|
||||
context 'when overriding parameters' do
|
||||
let :params do
|
||||
{
|
||||
:password => 'admin',
|
||||
:auth_url => 'http://127.0.0.2:5000/v3/',
|
||||
:service_token => 'servicetoken',
|
||||
:service_endpoint => 'http://127.0.0.2:5000/v3/',
|
||||
:username => 'myuser',
|
||||
:tenant_name => 'mytenant',
|
||||
:project_name => 'myproject',
|
||||
:region_name => 'myregion',
|
||||
:use_no_cache => 'false',
|
||||
:os_interface => 'internal',
|
||||
:os_endpoint_type => 'internalURL',
|
||||
:cinder_endpoint_type => 'internalURL',
|
||||
:glance_endpoint_type => 'internalURL',
|
||||
:keystone_endpoint_type => 'internalURL',
|
||||
:nova_endpoint_type => 'internalURL',
|
||||
:neutron_endpoint_type => 'internalURL',
|
||||
:auth_strategy => 'no_auth',
|
||||
:user_domain => 'anotherdomain',
|
||||
:project_domain => 'anotherdomain',
|
||||
:compute_api_version => '2.1',
|
||||
:network_api_version => '2.0',
|
||||
:image_api_version => '2',
|
||||
:volume_api_version => '2',
|
||||
:identity_api_version => '3.1',
|
||||
:object_api_version => '1',
|
||||
}
|
||||
end
|
||||
|
||||
describe "handle password and token with single quotes" do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:password => 'singlequote\'',
|
||||
:service_token => 'key\'stone'
|
||||
it {
|
||||
verify_contents(catalogue, '/root/openrc', [
|
||||
'export OS_SERVICE_TOKEN=\'servicetoken\'',
|
||||
'export OS_SERVICE_ENDPOINT=\'http://127.0.0.2:5000/v3/\'',
|
||||
'export OS_NO_CACHE=\'false\'',
|
||||
'export OS_TENANT_NAME=\'mytenant\'',
|
||||
'export OS_PROJECT_NAME=\'myproject\'',
|
||||
'export OS_USERNAME=\'myuser\'',
|
||||
'export OS_PASSWORD=\'admin\'',
|
||||
'export OS_AUTH_URL=\'http://127.0.0.2:5000/v3/\'',
|
||||
'export OS_AUTH_STRATEGY=\'no_auth\'',
|
||||
'export OS_REGION_NAME=\'myregion\'',
|
||||
'export OS_PROJECT_DOMAIN_NAME=\'anotherdomain\'',
|
||||
'export OS_USER_DOMAIN_NAME=\'anotherdomain\'',
|
||||
'export OS_INTERFACE=\'internal\'',
|
||||
'export OS_ENDPOINT_TYPE=\'internalURL\'',
|
||||
'export CINDER_ENDPOINT_TYPE=\'internalURL\'',
|
||||
'export GLANCE_ENDPOINT_TYPE=\'internalURL\'',
|
||||
'export KEYSTONE_ENDPOINT_TYPE=\'internalURL\'',
|
||||
'export NOVA_ENDPOINT_TYPE=\'internalURL\'',
|
||||
'export NEUTRON_ENDPOINT_TYPE=\'internalURL\'',
|
||||
'export OS_COMPUTE_API_VERSION=\'2.1\'',
|
||||
'export OS_NETWORK_API_VERSION=\'2.0\'',
|
||||
'export OS_IMAGE_API_VERSION=\'2\'',
|
||||
'export OS_VOLUME_API_VERSION=\'2\'',
|
||||
'export OS_IDENTITY_API_VERSION=\'3.1\'',
|
||||
'export OS_OBJECT_API_VERSION=\'1\'',
|
||||
])
|
||||
}
|
||||
end
|
||||
|
||||
it 'should create a openrc file' do
|
||||
verify_contents(catalogue, '/root/openrc', [
|
||||
'export OS_SERVICE_TOKEN=\'key\\\'stone\'',
|
||||
'export OS_PASSWORD=\'singlequote\\\'\'',
|
||||
])
|
||||
end
|
||||
end
|
||||
context 'handle password and token with single quotes' do
|
||||
let :params do
|
||||
{
|
||||
:password => 'singlequote\'',
|
||||
:service_token => 'key\'stone'
|
||||
}
|
||||
end
|
||||
|
||||
describe "when the file is in /tmp" do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:password => 'secret',
|
||||
:path => '/tmp/openrc'
|
||||
it {
|
||||
verify_contents(catalogue, '/root/openrc', [
|
||||
'export OS_SERVICE_TOKEN=\'key\\\'stone\'',
|
||||
'export OS_PASSWORD=\'singlequote\\\'\'',
|
||||
])
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_file('/tmp/openrc')}
|
||||
context 'when the file is in /tmp' do
|
||||
let :params do
|
||||
{
|
||||
:password => 'secret',
|
||||
:path => '/tmp/openrc'
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_file('/tmp/openrc')}
|
||||
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 'openstack_extras::auth_file'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,85 +1,75 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'openstack_extras::repo::debian::debian' do
|
||||
let :class_params do
|
||||
{
|
||||
:manage_deb => true,
|
||||
:source_hash => {},
|
||||
:source_defaults => {},
|
||||
:package_require => false
|
||||
}
|
||||
end
|
||||
|
||||
let :paramclass_defaults do
|
||||
{
|
||||
:release => 'rocky'
|
||||
}
|
||||
end
|
||||
|
||||
let :default_params do
|
||||
class_params.merge!(paramclass_defaults)
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:lsbdistid => 'Debian',
|
||||
:lsbdistcodename => 'stretch',
|
||||
:lsbdistrelease => '9'
|
||||
})
|
||||
shared_examples 'openstack_extras::repo::debian::debian' do
|
||||
let :class_params do
|
||||
{
|
||||
:manage_deb => true,
|
||||
:source_hash => {},
|
||||
:source_defaults => {},
|
||||
:package_require => false
|
||||
}
|
||||
end
|
||||
|
||||
describe 'with default parameters' do
|
||||
let :paramclass_defaults do
|
||||
{
|
||||
:release => 'rocky'
|
||||
}
|
||||
end
|
||||
|
||||
let :default_params do
|
||||
class_params.merge!(paramclass_defaults)
|
||||
end
|
||||
|
||||
context 'with default parameters' do
|
||||
let :params do
|
||||
{}.merge!(default_params)
|
||||
default_params
|
||||
end
|
||||
|
||||
it { is_expected.to contain_apt__source('debian-openstack-backports').with(
|
||||
:location => 'http://stretch-rocky.debian.net/debian',
|
||||
:release => 'stretch-rocky-backports',
|
||||
:repos => 'main',
|
||||
it { should contain_apt__source('debian-openstack-backports').with(
|
||||
:location => 'http://stretch-rocky.debian.net/debian',
|
||||
:release => 'stretch-rocky-backports',
|
||||
:repos => 'main',
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_apt__source('debian-openstack-backports-nochange').with(
|
||||
it { should contain_apt__source('debian-openstack-backports-nochange').with(
|
||||
:location => 'http://stretch-rocky.debian.net/debian',
|
||||
:release => 'stretch-rocky-backports-nochange',
|
||||
:repos => 'main'
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_exec('installing openstack-backports-archive-keyring') }
|
||||
it { should contain_exec('installing openstack-backports-archive-keyring') }
|
||||
end
|
||||
|
||||
describe 'with overridden release' do
|
||||
context 'with overridden release' do
|
||||
let :params do
|
||||
default_params.merge!({ :release => 'pike' })
|
||||
end
|
||||
|
||||
it { is_expected.to contain_apt__source('debian-openstack-backports').with(
|
||||
:location => 'http://stretch-pike.debian.net/debian',
|
||||
:release => 'stretch-pike-backports',
|
||||
:repos => 'main',
|
||||
it { should contain_apt__source('debian-openstack-backports').with(
|
||||
:location => 'http://stretch-pike.debian.net/debian',
|
||||
:release => 'stretch-pike-backports',
|
||||
:repos => 'main',
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_apt__source('debian-openstack-backports-nochange').with(
|
||||
it { should contain_apt__source('debian-openstack-backports-nochange').with(
|
||||
:location => 'http://stretch-pike.debian.net/debian',
|
||||
:release => 'stretch-pike-backports-nochange',
|
||||
:repos => 'main'
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_exec('installing openstack-backports-archive-keyring') }
|
||||
it { should contain_exec('installing openstack-backports-archive-keyring') }
|
||||
end
|
||||
|
||||
describe 'when not managing stretch repo' do
|
||||
context 'when not managing stretch repo' do
|
||||
let :params do
|
||||
default_params.merge!({ :manage_deb => false })
|
||||
end
|
||||
|
||||
it { is_expected.to_not contain_exec('installing openstack-backports-archive-keyring') }
|
||||
it { should_not contain_exec('installing openstack-backports-archive-keyring') }
|
||||
end
|
||||
|
||||
describe 'with overridden source hash' do
|
||||
context 'with overridden source hash' do
|
||||
let :params do
|
||||
default_params.merge!({ :source_hash => {
|
||||
'debian_unstable' => {
|
||||
@ -98,24 +88,24 @@ describe 'openstack_extras::repo::debian::debian' do
|
||||
})
|
||||
end
|
||||
|
||||
it { is_expected.to contain_apt__source('debian_unstable').with(
|
||||
:location => 'http://mymirror/debian/',
|
||||
:release => 'unstable',
|
||||
:repos => 'main'
|
||||
it { should contain_apt__source('debian_unstable').with(
|
||||
:location => 'http://mymirror/debian/',
|
||||
:release => 'unstable',
|
||||
:repos => 'main'
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_apt__source('puppetlabs').with(
|
||||
:location => 'http://apt.puppetlabs.com',
|
||||
:repos => 'main',
|
||||
:release => 'stretch',
|
||||
:key => '4BD6EC30',
|
||||
:key_server => 'pgp.mit.edu'
|
||||
it { should contain_apt__source('puppetlabs').with(
|
||||
:location => 'http://apt.puppetlabs.com',
|
||||
:repos => 'main',
|
||||
:release => 'stretch',
|
||||
:key => '4BD6EC30',
|
||||
:key_server => 'pgp.mit.edu'
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_exec('installing openstack-backports-archive-keyring') }
|
||||
it { should contain_exec('installing openstack-backports-archive-keyring') }
|
||||
end
|
||||
|
||||
describe 'with overridden source default' do
|
||||
context 'with overridden source default' do
|
||||
let :params do
|
||||
default_params.merge!({ :source_hash => {
|
||||
'debian_unstable' => {
|
||||
@ -131,14 +121,30 @@ describe 'openstack_extras::repo::debian::debian' do
|
||||
})
|
||||
end
|
||||
|
||||
it { is_expected.to contain_apt__source('debian_unstable').with(
|
||||
:location => 'http://mymirror/debian/',
|
||||
:release => 'unstable',
|
||||
:repos => 'main',
|
||||
:include_src => 'true'
|
||||
it { should contain_apt__source('debian_unstable').with(
|
||||
:location => 'http://mymirror/debian/',
|
||||
:release => 'unstable',
|
||||
:repos => 'main',
|
||||
:include_src => 'true'
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_exec('installing openstack-backports-archive-keyring') }
|
||||
it { should contain_exec('installing openstack-backports-archive-keyring') }
|
||||
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({ :lsbdistid => 'Debian',
|
||||
:lsbdistcodename => 'stretch',
|
||||
:lsbdistrelease => '9' }))
|
||||
end
|
||||
|
||||
if facts[:osfamily] == 'Debian' and facts[:operatingsystem] == 'Debian'
|
||||
it_behaves_like 'openstack_extras::repo::debian::debian'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,74 +1,63 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'openstack_extras::repo::debian::ubuntu' do
|
||||
let :class_params do
|
||||
{
|
||||
:manage_uca => true,
|
||||
:source_hash => {},
|
||||
:source_defaults => {},
|
||||
:package_require => false
|
||||
}
|
||||
end
|
||||
|
||||
let :paramclass_defaults do
|
||||
{
|
||||
:release => 'rocky'
|
||||
}
|
||||
end
|
||||
|
||||
let :default_params do
|
||||
class_params.merge!(paramclass_defaults)
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Ubuntu',
|
||||
:lsbdistid => 'Ubuntu',
|
||||
:lsbdistcodename => 'trusty',
|
||||
:lsbdistrelease => '14.04'
|
||||
})
|
||||
shared_examples 'openstack_extras::repo::debian::ubuntu' do
|
||||
let :class_params do
|
||||
{
|
||||
:manage_uca => true,
|
||||
:source_hash => {},
|
||||
:source_defaults => {},
|
||||
:package_require => false
|
||||
}
|
||||
end
|
||||
|
||||
describe 'with default parameters' do
|
||||
let :paramclass_defaults do
|
||||
{
|
||||
:release => 'rocky'
|
||||
}
|
||||
end
|
||||
|
||||
let :default_params do
|
||||
class_params.merge!(paramclass_defaults)
|
||||
end
|
||||
|
||||
context 'with default parameters' do
|
||||
let :params do
|
||||
{}.merge!(default_params)
|
||||
default_params
|
||||
end
|
||||
|
||||
it { is_expected.to contain_apt__source('ubuntu-cloud-archive').with(
|
||||
:location => 'http://ubuntu-cloud.archive.canonical.com/ubuntu',
|
||||
:release => 'trusty-updates/rocky',
|
||||
:repos => 'main',
|
||||
it { should contain_apt__source('ubuntu-cloud-archive').with(
|
||||
:location => 'http://ubuntu-cloud.archive.canonical.com/ubuntu',
|
||||
:release => 'trusty-updates/rocky',
|
||||
:repos => 'main',
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_exec('installing ubuntu-cloud-keyring') }
|
||||
|
||||
it { should contain_exec('installing ubuntu-cloud-keyring') }
|
||||
end
|
||||
|
||||
describe 'with overridden release' do
|
||||
context 'with overridden release' do
|
||||
let :params do
|
||||
default_params.merge!({ :release => 'juno' })
|
||||
end
|
||||
|
||||
it { is_expected.to contain_apt__source('ubuntu-cloud-archive').with(
|
||||
:location => 'http://ubuntu-cloud.archive.canonical.com/ubuntu',
|
||||
:release => 'trusty-updates/juno',
|
||||
:repos => 'main',
|
||||
it { should contain_apt__source('ubuntu-cloud-archive').with(
|
||||
:location => 'http://ubuntu-cloud.archive.canonical.com/ubuntu',
|
||||
:release => 'trusty-updates/juno',
|
||||
:repos => 'main',
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_exec('installing ubuntu-cloud-keyring') }
|
||||
it { should contain_exec('installing ubuntu-cloud-keyring') }
|
||||
end
|
||||
|
||||
describe 'when not managing UCA' do
|
||||
context 'when not managing UCA' do
|
||||
let :params do
|
||||
default_params.merge!({ :manage_uca => false })
|
||||
end
|
||||
|
||||
it { is_expected.to_not contain_exec('installing ubuntu-cloud-keyring') }
|
||||
it { should_not contain_exec('installing ubuntu-cloud-keyring') }
|
||||
end
|
||||
|
||||
describe 'with overridden source hash' do
|
||||
context 'with overridden source hash' do
|
||||
let :params do
|
||||
default_params.merge!({ :source_hash => {
|
||||
'local_mirror' => {
|
||||
@ -87,24 +76,24 @@ describe 'openstack_extras::repo::debian::ubuntu' do
|
||||
})
|
||||
end
|
||||
|
||||
it { is_expected.to contain_apt__source('local_mirror').with(
|
||||
:location => 'http://mymirror/ubuntu/',
|
||||
:release => 'trusty',
|
||||
:repos => 'main'
|
||||
it { should contain_apt__source('local_mirror').with(
|
||||
:location => 'http://mymirror/ubuntu/',
|
||||
:release => 'trusty',
|
||||
:repos => 'main'
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_apt__source('puppetlabs').with(
|
||||
:location => 'http://apt.puppetlabs.com',
|
||||
:release => 'trusty',
|
||||
:repos => 'main',
|
||||
:key => '4BD6EC30',
|
||||
:key_server => 'pgp.mit.edu'
|
||||
it { should contain_apt__source('puppetlabs').with(
|
||||
:location => 'http://apt.puppetlabs.com',
|
||||
:release => 'trusty',
|
||||
:repos => 'main',
|
||||
:key => '4BD6EC30',
|
||||
:key_server => 'pgp.mit.edu'
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_exec('installing ubuntu-cloud-keyring') }
|
||||
it { should contain_exec('installing ubuntu-cloud-keyring') }
|
||||
end
|
||||
|
||||
describe 'with overridden source default' do
|
||||
context 'with overridden source default' do
|
||||
let :params do
|
||||
default_params.merge!({ :source_hash => {
|
||||
'local_mirror' => {
|
||||
@ -120,28 +109,43 @@ describe 'openstack_extras::repo::debian::ubuntu' do
|
||||
})
|
||||
end
|
||||
|
||||
it { is_expected.to contain_apt__source('local_mirror').with(
|
||||
:include_src => 'true',
|
||||
:location => 'http://mymirror/ubuntu/',
|
||||
:release => 'trusty',
|
||||
:repos => 'main',
|
||||
it { should contain_apt__source('local_mirror').with(
|
||||
:include_src => 'true',
|
||||
:location => 'http://mymirror/ubuntu/',
|
||||
:release => 'trusty',
|
||||
:repos => 'main',
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_exec('installing ubuntu-cloud-keyring') }
|
||||
it { should contain_exec('installing ubuntu-cloud-keyring') }
|
||||
end
|
||||
|
||||
describe 'with overridden uca repo name' do
|
||||
context 'with overridden uca repo name' do
|
||||
let :params do
|
||||
default_params.merge!({ :repo => 'proposed',
|
||||
:uca_location => 'http://mirror.dfw.rax.openstack.org/ubuntu-cloud-archive' })
|
||||
end
|
||||
|
||||
it { is_expected.to contain_apt__source('ubuntu-cloud-archive').with(
|
||||
:location => 'http://mirror.dfw.rax.openstack.org/ubuntu-cloud-archive',
|
||||
:release => 'trusty-proposed/rocky',
|
||||
:repos => 'main',
|
||||
it { should contain_apt__source('ubuntu-cloud-archive').with(
|
||||
:location => 'http://mirror.dfw.rax.openstack.org/ubuntu-cloud-archive',
|
||||
:release => 'trusty-proposed/rocky',
|
||||
:repos => 'main',
|
||||
)}
|
||||
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({ :lsbdistid => 'Ubuntu',
|
||||
:lsbdistcodename => 'trusty',
|
||||
:lsbdistrelease => '14.04' }))
|
||||
end
|
||||
|
||||
if facts[:operatingsystem] == 'Ubuntu'
|
||||
it_behaves_like 'openstack_extras::repo::debian::ubuntu'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,77 +1,67 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'openstack_extras::repo::redhat::redhat' do
|
||||
let :class_params do
|
||||
{
|
||||
:manage_rdo => true,
|
||||
:manage_epel => true,
|
||||
:repo_hash => {},
|
||||
:gpgkey_hash => {},
|
||||
:purge_unmanaged => false,
|
||||
:package_require => false
|
||||
}
|
||||
end
|
||||
|
||||
let :paramclass_defaults do
|
||||
{
|
||||
:release => 'rocky',
|
||||
:repo_defaults => { 'enabled' => '1',
|
||||
'gpgcheck' => '1',
|
||||
'notify' => "Exec[yum_refresh]",
|
||||
'mirrorlist' => 'absent',
|
||||
'require' => "Anchor[openstack_extras_redhat]"
|
||||
},
|
||||
:gpgkey_defaults => { 'owner' => 'root',
|
||||
'group' => 'root',
|
||||
'mode' => '0644',
|
||||
'before' => "Anchor[openstack_extras_redhat]"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
let :default_params do
|
||||
class_params.merge!(paramclass_defaults)
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({
|
||||
:osfamily => 'RedHat',
|
||||
:operatingsystem => 'RedHat',
|
||||
:operatingsystemrelease => '7.1',
|
||||
:operatingsystemmajrelease => '7',
|
||||
:puppetversion => Puppet.version,
|
||||
})
|
||||
shared_examples 'openstack_extras::repo::redhat::redhat' do
|
||||
let :class_params do
|
||||
{
|
||||
:manage_rdo => true,
|
||||
:manage_epel => true,
|
||||
:repo_hash => {},
|
||||
:gpgkey_hash => {},
|
||||
:purge_unmanaged => false,
|
||||
:package_require => false
|
||||
}
|
||||
end
|
||||
|
||||
describe 'with default parameters' do
|
||||
let :paramclass_defaults do
|
||||
{
|
||||
:release => 'rocky',
|
||||
:repo_defaults => { 'enabled' => '1',
|
||||
'gpgcheck' => '1',
|
||||
'notify' => 'Exec[yum_refresh]',
|
||||
'mirrorlist' => 'absent',
|
||||
'require' => 'Anchor[openstack_extras_redhat]'
|
||||
},
|
||||
:gpgkey_defaults => { 'owner' => 'root',
|
||||
'group' => 'root',
|
||||
'mode' => '0644',
|
||||
'before' => 'Anchor[openstack_extras_redhat]'
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
let :default_params do
|
||||
class_params.merge!(paramclass_defaults)
|
||||
end
|
||||
|
||||
context 'with default parameters' do
|
||||
let :params do
|
||||
{}.merge!(default_params)
|
||||
default_params
|
||||
end
|
||||
|
||||
it { is_expected.to contain_yumrepo('rdo-release').with(
|
||||
it { should contain_yumrepo('rdo-release').with(
|
||||
:baseurl => "http://mirror.centos.org/centos/7/cloud/$basearch/openstack-rocky/",
|
||||
:descr => "OpenStack Rocky Repository",
|
||||
:gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud",
|
||||
:descr => 'OpenStack Rocky Repository',
|
||||
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud',
|
||||
:enabled => '1',
|
||||
:gpgcheck => '1',
|
||||
:mirrorlist => 'absent',
|
||||
:require => "Anchor[openstack_extras_redhat]",
|
||||
:notify => "Exec[yum_refresh]"
|
||||
:require => 'Anchor[openstack_extras_redhat]',
|
||||
:notify => 'Exec[yum_refresh]'
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_yumrepo('rdo-qemu-ev').with(
|
||||
it { should contain_yumrepo('rdo-qemu-ev').with(
|
||||
:baseurl => "http://mirror.centos.org/centos/7/virt/$basearch/kvm-common/",
|
||||
:descr => "RDO CentOS-7 - QEMU EV",
|
||||
:gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization",
|
||||
:descr => 'RDO CentOS-7 - QEMU EV',
|
||||
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization',
|
||||
:enabled => '1',
|
||||
:gpgcheck => '1',
|
||||
:mirrorlist => 'absent',
|
||||
:require => "Anchor[openstack_extras_redhat]",
|
||||
:notify => "Exec[yum_refresh]"
|
||||
:require => 'Anchor[openstack_extras_redhat]',
|
||||
:notify => 'Exec[yum_refresh]'
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_exec('installing_yum-plugin-priorities').with(
|
||||
it { should contain_exec('installing_yum-plugin-priorities').with(
|
||||
:command => '/usr/bin/yum install -y yum-plugin-priorities',
|
||||
:logoutput => 'on_failure',
|
||||
:tries => 3,
|
||||
@ -81,66 +71,65 @@ describe 'openstack_extras::repo::redhat::redhat' do
|
||||
|
||||
# 'metalink' property is supported from Puppet 3.5
|
||||
if Puppet.version.to_f >= 3.5
|
||||
it { is_expected.to contain_yumrepo('epel').with(
|
||||
it { should contain_yumrepo('epel').with(
|
||||
:metalink => "https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=\$basearch",
|
||||
:descr => 'Extra Packages for Enterprise Linux 7 - $basearch',
|
||||
:gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7",
|
||||
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7',
|
||||
:failovermethod => 'priority',
|
||||
:enabled => '1',
|
||||
:gpgcheck => '1',
|
||||
:mirrorlist => 'absent',
|
||||
:require => "Anchor[openstack_extras_redhat]",
|
||||
:notify => "Exec[yum_refresh]"
|
||||
:require => 'Anchor[openstack_extras_redhat]',
|
||||
:notify => 'Exec[yum_refresh]'
|
||||
)}
|
||||
else
|
||||
it { is_expected.to contain_yumrepo('epel').with(
|
||||
it { should contain_yumrepo('epel').with(
|
||||
:baseurl => "https://download.fedoraproject.org/pub/epel/7/\$basearch",
|
||||
:descr => 'Extra Packages for Enterprise Linux 7 - $basearch',
|
||||
:gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7",
|
||||
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7',
|
||||
:failovermethod => 'priority',
|
||||
:enabled => '1',
|
||||
:gpgcheck => '1',
|
||||
:mirrorlist => 'absent',
|
||||
:require => "Anchor[openstack_extras_redhat]",
|
||||
:notify => "Exec[yum_refresh]"
|
||||
:require => 'Anchor[openstack_extras_redhat]',
|
||||
:notify => 'Exec[yum_refresh]'
|
||||
)}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud').with(
|
||||
:source => "puppet:///modules/openstack_extras/RPM-GPG-KEY-CentOS-SIG-Cloud",
|
||||
:owner => 'root',
|
||||
:group => 'root',
|
||||
:mode => '0644',
|
||||
:before => "Anchor[openstack_extras_redhat]"
|
||||
it { should contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud').with(
|
||||
:source => 'puppet:///modules/openstack_extras/RPM-GPG-KEY-CentOS-SIG-Cloud',
|
||||
:owner => 'root',
|
||||
:group => 'root',
|
||||
:mode => '0644',
|
||||
:before => 'Anchor[openstack_extras_redhat]'
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization').with(
|
||||
:source => "puppet:///modules/openstack_extras/RPM-GPG-KEY-CentOS-SIG-Virtualization",
|
||||
:owner => 'root',
|
||||
:group => 'root',
|
||||
:mode => '0644',
|
||||
:before => "Anchor[openstack_extras_redhat]"
|
||||
it { should contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization').with(
|
||||
:source => 'puppet:///modules/openstack_extras/RPM-GPG-KEY-CentOS-SIG-Virtualization',
|
||||
:owner => 'root',
|
||||
:group => 'root',
|
||||
:mode => '0644',
|
||||
:before => 'Anchor[openstack_extras_redhat]'
|
||||
)}
|
||||
|
||||
end
|
||||
|
||||
describe 'with overridden release' do
|
||||
context 'with overridden release' do
|
||||
let :params do
|
||||
default_params.merge!({ :release => 'juno' })
|
||||
end
|
||||
|
||||
it { is_expected.to contain_yumrepo('rdo-release').with(
|
||||
:baseurl => "http://mirror.centos.org/centos/7/cloud/\$basearch/openstack-juno/",
|
||||
:descr => "OpenStack Juno Repository",
|
||||
:gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud"
|
||||
it { should contain_yumrepo('rdo-release').with(
|
||||
:baseurl => "http://mirror.centos.org/centos/7/cloud/\$basearch/openstack-juno/",
|
||||
:descr => 'OpenStack Juno Repository',
|
||||
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud'
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud').with(
|
||||
:source => "puppet:///modules/openstack_extras/RPM-GPG-KEY-CentOS-SIG-Cloud"
|
||||
it { should contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud').with(
|
||||
:source => 'puppet:///modules/openstack_extras/RPM-GPG-KEY-CentOS-SIG-Cloud'
|
||||
)}
|
||||
end
|
||||
|
||||
describe 'with overridden repo hash' do
|
||||
context 'with overridden repo hash' do
|
||||
let :params do
|
||||
default_params.merge!({ :repo_hash => {
|
||||
'CentOS-Base' => {
|
||||
@ -157,31 +146,31 @@ describe 'openstack_extras::repo::redhat::redhat' do
|
||||
})
|
||||
end
|
||||
|
||||
it { is_expected.to contain_yumrepo('CentOS-Base').with(
|
||||
it { should contain_yumrepo('CentOS-Base').with(
|
||||
:baseurl => "http://mymirror/$releasever/os/$basearch/",
|
||||
:descr => "CentOS-$releasever - Base",
|
||||
:enabled => '1',
|
||||
:gpgcheck => '1',
|
||||
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6',
|
||||
:mirrorlist => 'absent',
|
||||
:require => "Anchor[openstack_extras_redhat]",
|
||||
:notify => "Exec[yum_refresh]"
|
||||
:require => 'Anchor[openstack_extras_redhat]',
|
||||
:notify => 'Exec[yum_refresh]'
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_yumrepo('CentOS-Updates').with(
|
||||
it { should contain_yumrepo('CentOS-Updates').with(
|
||||
:baseurl => "http://mymirror/$releasever/updates/$basearch/",
|
||||
:descr => "CentOS-$releasever - Updates",
|
||||
:enabled => '1',
|
||||
:gpgcheck => '1',
|
||||
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6',
|
||||
:mirrorlist => 'absent',
|
||||
:require => "Anchor[openstack_extras_redhat]",
|
||||
:notify => "Exec[yum_refresh]"
|
||||
:require => 'Anchor[openstack_extras_redhat]',
|
||||
:notify => 'Exec[yum_refresh]'
|
||||
)}
|
||||
|
||||
end
|
||||
|
||||
describe 'with overridden repo default' do
|
||||
context 'with overridden repo default' do
|
||||
let :params do
|
||||
default_params.merge!({ :repo_defaults => {
|
||||
'proxy' => 'http://my.proxy.com:8000'
|
||||
@ -190,15 +179,15 @@ describe 'openstack_extras::repo::redhat::redhat' do
|
||||
})
|
||||
end
|
||||
|
||||
it { is_expected.to contain_yumrepo('rdo-release').with(
|
||||
:baseurl => "http://mirror.dfw.rax.openstack.org/centos/7/cloud/\$basearch/openstack-rocky/",
|
||||
:descr => "OpenStack Rocky Repository",
|
||||
:gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud",
|
||||
:proxy => "http://my.proxy.com:8000"
|
||||
it { should contain_yumrepo('rdo-release').with(
|
||||
:baseurl => "http://mirror.dfw.rax.openstack.org/centos/7/cloud/\$basearch/openstack-rocky/",
|
||||
:descr => 'OpenStack Rocky Repository',
|
||||
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud',
|
||||
:proxy => 'http://my.proxy.com:8000'
|
||||
)}
|
||||
end
|
||||
|
||||
describe 'with overridden gpgkey default' do
|
||||
context 'with overridden gpgkey default' do
|
||||
let :params do
|
||||
default_params.merge!({ :gpgkey_defaults => {
|
||||
'owner' => 'steve'
|
||||
@ -206,41 +195,58 @@ describe 'openstack_extras::repo::redhat::redhat' do
|
||||
})
|
||||
end
|
||||
|
||||
it { is_expected.to contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud').with(
|
||||
:owner => "steve"
|
||||
it { should contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud').with(
|
||||
:owner => 'steve'
|
||||
)}
|
||||
end
|
||||
|
||||
describe 'with epel management disabled' do
|
||||
context 'with epel management disabled' do
|
||||
let :params do
|
||||
default_params.merge!({ :manage_epel => false })
|
||||
end
|
||||
|
||||
it { is_expected.to_not contain_yumrepo('epel') }
|
||||
it { should_not contain_yumrepo('epel') }
|
||||
end
|
||||
|
||||
describe 'with rdo management disabled' do
|
||||
context 'with rdo management disabled' do
|
||||
let :params do
|
||||
default_params.merge!({ :manage_rdo => false })
|
||||
end
|
||||
|
||||
it { is_expected.to_not contain_yumrepo('rdo-release') }
|
||||
it { should_not contain_yumrepo('rdo-release') }
|
||||
end
|
||||
|
||||
describe 'with rdo-virt management disabled' do
|
||||
context 'with rdo-virt management disabled' do
|
||||
let :params do
|
||||
default_params.merge!({ :manage_virt => false })
|
||||
end
|
||||
|
||||
it { is_expected.to_not contain_yumrepo('rdo-qemu-ev') }
|
||||
it { should_not contain_yumrepo('rdo-qemu-ev') }
|
||||
end
|
||||
|
||||
describe 'with manage_priorities disabled' do
|
||||
context 'with manage_priorities disabled' do
|
||||
let :params do
|
||||
default_params.merge!({ :manage_priorities => false })
|
||||
end
|
||||
|
||||
it { is_expected.to_not contain_exec('installing_yum-plugin-priorities') }
|
||||
it { should_not contain_exec('installing_yum-plugin-priorities') }
|
||||
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({ :operatingsystem => 'RedHat',
|
||||
:operatingsystemrelease => '7.1',
|
||||
:operatingsystemmajrelease => '7',
|
||||
:puppetversion => Puppet.version }))
|
||||
end
|
||||
|
||||
if facts[:osfamily] == 'RedHat'
|
||||
it_behaves_like 'openstack_extras::repo::redhat::redhat'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,25 +1,18 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'openstack_extras::pacemaker::service', :type => :define do
|
||||
shared_examples 'openstack_extras::pacemaker::service' do
|
||||
let :pre_condition do
|
||||
[
|
||||
"class { '::glance::registry::authtoken': password => 'password', }",
|
||||
"include ::glance::registry",
|
||||
]
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
[
|
||||
"class { '::glance::registry::authtoken': password => 'password', }",
|
||||
"include ::glance::registry",
|
||||
]
|
||||
end
|
||||
let (:title) { 'glance-registry' }
|
||||
|
||||
let :facts do
|
||||
@default_facts.merge({
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian'
|
||||
})
|
||||
end
|
||||
|
||||
let (:title) { 'glance-registry' }
|
||||
|
||||
let :default_params do
|
||||
{
|
||||
let :default_params do
|
||||
{
|
||||
:ensure => 'present',
|
||||
:ocf_root_path => '/usr/lib/ocf',
|
||||
:primitive_class => 'ocf',
|
||||
@ -35,138 +28,114 @@ describe 'openstack_extras::pacemaker::service', :type => :define do
|
||||
:ocf_script_file => false,
|
||||
:create_primitive => true,
|
||||
:clone => false
|
||||
}
|
||||
end
|
||||
|
||||
context 'with defaults' do
|
||||
it 'should contain openstack_extras::pacemaker::service definition' do
|
||||
is_expected.to contain_openstack_extras__pacemaker__service(title).with(default_params)
|
||||
}
|
||||
end
|
||||
|
||||
it 'should override existing service provider' do
|
||||
is_expected.to contain_service('glance-registry').with(
|
||||
{
|
||||
:provider => 'pacemaker'
|
||||
})
|
||||
context 'with defaults' do
|
||||
it { should contain_openstack_extras__pacemaker__service(title).with(default_params) }
|
||||
it { should contain_service('glance-registry').with_provider('pacemaker') }
|
||||
|
||||
it { should contain_cs_primitive('p_glance-registry').with(
|
||||
:ensure => default_params[:ensure],
|
||||
:primitive_class => default_params[:primitive_class],
|
||||
:primitive_type => default_params[:primitive_type],
|
||||
:provided_by => default_params[:primitive_provider],
|
||||
:parameters => default_params[:parameters],
|
||||
:operations => default_params[:operations],
|
||||
:metadata => default_params[:metadata],
|
||||
:ms_metadata => default_params[:ms_metadata],
|
||||
)}
|
||||
|
||||
it { should contain_cs_clone('p_glance-registry-clone').with_ensure('absent') }
|
||||
end
|
||||
|
||||
it 'should create a pacemaker primitive' do
|
||||
is_expected.to contain_cs_primitive('p_glance-registry').with(
|
||||
{
|
||||
'ensure' => default_params[:ensure],
|
||||
'primitive_class' => default_params[:primitive_class],
|
||||
'primitive_type' => default_params[:primitive_type],
|
||||
'provided_by' => default_params[:primitive_provider],
|
||||
'parameters' => default_params[:parameters],
|
||||
'operations' => default_params[:operations],
|
||||
'metadata' => default_params[:metadata],
|
||||
'ms_metadata' => default_params[:ms_metadata],
|
||||
})
|
||||
context 'with custom OCF file' do
|
||||
let :params do
|
||||
default_params.merge( :ocf_script_file => 'foo/scripts/foo.ocf' )
|
||||
end
|
||||
|
||||
let (:ocf_dir_path) { "#{params[:ocf_root_path]}/resource.d" }
|
||||
let (:ocf_script_path) { "#{ocf_dir_path}/#{params[:primitive_provider]}/#{params[:primitive_type]}" }
|
||||
let (:ocf_handler_name) { "ocf_handler_#{title}" }
|
||||
let (:ocf_handler_path) { "#{params[:handler_root_path]}/#{ocf_handler_name}" }
|
||||
|
||||
it { should contain_file("#{title}-ocf-file").with(
|
||||
:ensure => 'present',
|
||||
:path => ocf_script_path,
|
||||
:mode => '0755',
|
||||
:owner => 'root',
|
||||
:group => 'root',
|
||||
:source => "puppet:///modules/#{params[:ocf_script_file]}"
|
||||
)}
|
||||
|
||||
it { should contain_file("#{ocf_handler_name}").with(
|
||||
:ensure => 'present',
|
||||
:path => ocf_handler_path,
|
||||
:owner => 'root',
|
||||
:group => 'root',
|
||||
:mode => '0700',
|
||||
:content => /OCF_ROOT/
|
||||
)}
|
||||
end
|
||||
it 'should not create a cloned resource' do
|
||||
is_expected.to contain_cs_clone('p_glance-registry-clone').with(
|
||||
{
|
||||
'ensure' => 'absent',
|
||||
})
|
||||
|
||||
context 'with custom OCF path, provider, erb and w/o a wrapper' do
|
||||
let(:params) do
|
||||
default_params.merge( :ocf_script_template => 'openstack_extras/ocf_handler.erb',
|
||||
:use_handler => false,
|
||||
:primitive_provider => 'some_provider',
|
||||
:ocf_root_path => '/usr/lib/some_path' )
|
||||
end
|
||||
|
||||
let (:ocf_dir_path) { "#{params[:ocf_root_path]}/resource.d" }
|
||||
let (:ocf_script_path) {
|
||||
"#{ocf_dir_path}/#{params[:primitive_provider]}/#{params[:primitive_type]}"
|
||||
}
|
||||
|
||||
it { should contain_file("#{title}-ocf-file").with(
|
||||
:path => ocf_script_path,
|
||||
:mode => '0755',
|
||||
:owner => 'root',
|
||||
:group => 'root',
|
||||
:content => /monitor/
|
||||
)}
|
||||
|
||||
it { should_not contain_file('ocf_handler_glance_registry') }
|
||||
|
||||
it { should contain_cs_primitive('p_glance-registry').with(
|
||||
:ensure => params[:ensure],
|
||||
:primitive_class => params[:primitive_class],
|
||||
:primitive_type => params[:primitive_type],
|
||||
:provided_by => params[:primitive_provider],
|
||||
:parameters => params[:parameters],
|
||||
:operations => params[:operations],
|
||||
:metadata => params[:metadata],
|
||||
:ms_metadata => params[:ms_metadata],
|
||||
)}
|
||||
end
|
||||
|
||||
context 'with cloned resources' do
|
||||
let (:params) do
|
||||
default_params.merge( :clone => true )
|
||||
end
|
||||
|
||||
it { should contain_cs_clone('p_glance-registry-clone').with(
|
||||
:ensure => 'present',
|
||||
:primitive => 'p_glance-registry',
|
||||
)}
|
||||
end
|
||||
end
|
||||
|
||||
context 'with custom OCF file' do
|
||||
let :params do
|
||||
default_params.merge(
|
||||
{
|
||||
:ocf_script_file => 'foo/scripts/foo.ocf'
|
||||
}
|
||||
)
|
||||
end
|
||||
let (:ocf_dir_path) { "#{params[:ocf_root_path]}/resource.d" }
|
||||
let (:ocf_script_path) { "#{ocf_dir_path}/#{params[:primitive_provider]}/#{params[:primitive_type]}" }
|
||||
let (:ocf_handler_name) { "ocf_handler_#{title}" }
|
||||
let (:ocf_handler_path) { "#{params[:handler_root_path]}/#{ocf_handler_name}" }
|
||||
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 'should create an OCF file' do
|
||||
is_expected.to contain_file("#{title}-ocf-file").with(
|
||||
{
|
||||
'ensure' => 'present',
|
||||
'path' => ocf_script_path,
|
||||
'mode' => '0755',
|
||||
'owner' => 'root',
|
||||
'group' => 'root',
|
||||
'source' => "puppet:///modules/#{params[:ocf_script_file]}"
|
||||
})
|
||||
end
|
||||
|
||||
it 'should create a handler file' do
|
||||
is_expected.to contain_file("#{ocf_handler_name}").with(
|
||||
{
|
||||
'ensure' => 'present',
|
||||
'path' => ocf_handler_path,
|
||||
'owner' => 'root',
|
||||
'group' => 'root',
|
||||
'mode' => '0700',
|
||||
}).with_content(/OCF_ROOT/)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'with custom OCF path, provider, erb and w/o a wrapper' do
|
||||
let(:params) do
|
||||
default_params.merge(
|
||||
{
|
||||
:ocf_script_template => 'openstack_extras/ocf_handler.erb',
|
||||
:use_handler => false,
|
||||
:primitive_provider => 'some_provider',
|
||||
:ocf_root_path => '/usr/lib/some_path',
|
||||
})
|
||||
end
|
||||
let (:ocf_dir_path) { "#{params[:ocf_root_path]}/resource.d" }
|
||||
let (:ocf_script_path) {
|
||||
"#{ocf_dir_path}/#{params[:primitive_provider]}/#{params[:primitive_type]}"
|
||||
}
|
||||
|
||||
it 'should create an OCF file from template' do
|
||||
is_expected.to contain_file("#{title}-ocf-file").with(
|
||||
{
|
||||
'path' => ocf_script_path,
|
||||
'mode' => '0755',
|
||||
'owner' => 'root',
|
||||
'group' => 'root'
|
||||
}).with_content(/monitor/)
|
||||
end
|
||||
|
||||
it 'should not create a handler file' do
|
||||
is_expected.to_not contain_file("ocf_handler_glance_registry")
|
||||
end
|
||||
|
||||
it 'should create a pacemaker primitive' do
|
||||
is_expected.to contain_cs_primitive('p_glance-registry').with(
|
||||
{
|
||||
'ensure' => params[:ensure],
|
||||
'primitive_class' => params[:primitive_class],
|
||||
'primitive_type' => params[:primitive_type],
|
||||
'provided_by' => params[:primitive_provider],
|
||||
'parameters' => params[:parameters],
|
||||
'operations' => params[:operations],
|
||||
'metadata' => params[:metadata],
|
||||
'ms_metadata' => params[:ms_metadata],
|
||||
})
|
||||
if facts[:osfamily] == 'Debian' and facts[:operatingsystem] == 'Debian'
|
||||
it_behaves_like 'openstack_extras::pacemaker::service'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with cloned resources' do
|
||||
let (:params) do
|
||||
default_params.merge(
|
||||
{
|
||||
:clone => true,
|
||||
})
|
||||
end
|
||||
it 'should create a cloned resource' do
|
||||
is_expected.to contain_cs_clone('p_glance-registry-clone').with(
|
||||
{
|
||||
'ensure' => 'present',
|
||||
'primitive' => 'p_glance-registry',
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user