Cleanup spec testing
Change-Id: I3c13fc2f8bc3582fd72206b3c711ff5863943b09
This commit is contained in:
parent
20ac1f925a
commit
4d08ab70cb
@ -1,33 +1,30 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'openstacklib::openstackclient' do
|
||||
|
||||
shared_examples_for 'openstacklib::openstackclient' do
|
||||
context 'with default params' do
|
||||
it 'installs openstackclient' do
|
||||
is_expected.to contain_package(platform_params[:openstackclient_package_name]).with(
|
||||
:ensure => 'present',
|
||||
:tag => 'openstack'
|
||||
)
|
||||
end
|
||||
it { should contain_package(platform_params[:openstackclient_package_name]).with(
|
||||
:ensure => 'present',
|
||||
:tag => 'openstack'
|
||||
)}
|
||||
end
|
||||
|
||||
context 'with non default package name' do
|
||||
let :params do
|
||||
{ :package_name => 'my-openstackclient' }
|
||||
{
|
||||
:package_name => 'my-openstackclient'
|
||||
}
|
||||
end
|
||||
|
||||
it 'installs my-openstackclient' do
|
||||
is_expected.to contain_package('my-openstackclient').with(
|
||||
:ensure => 'present',
|
||||
:tag => 'openstack'
|
||||
)
|
||||
end
|
||||
it { should contain_package('my-openstackclient').with(
|
||||
:ensure => 'present',
|
||||
:tag => 'openstack'
|
||||
)}
|
||||
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
|
||||
|
@ -1,8 +1,7 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'openstacklib::policy' do
|
||||
|
||||
shared_examples_for 'openstacklib::policy' do
|
||||
shared_examples 'openstacklib::policy' do
|
||||
context 'with basic configuration' do
|
||||
let :params do
|
||||
{
|
||||
@ -16,25 +15,23 @@ describe 'openstacklib::policy' do
|
||||
}
|
||||
end
|
||||
|
||||
it 'configures the proper policy' do
|
||||
is_expected.to contain_openstacklib__policy__base('foo').with(
|
||||
:file_path => '/etc/nova/policy.json',
|
||||
:key => 'context_is_admin',
|
||||
:value => 'foo:bar'
|
||||
)
|
||||
end
|
||||
it { should contain_openstacklib__policy__base('foo').with(
|
||||
:file_path => '/etc/nova/policy.json',
|
||||
:key => 'context_is_admin',
|
||||
:value => 'foo:bar'
|
||||
)}
|
||||
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 'openstacklib::policy'
|
||||
it_behaves_like 'openstacklib::policy'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -20,11 +20,12 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'openstacklib::policyrcd' do
|
||||
|
||||
shared_examples_for 'openstacklib::policyrcd on Debian platforms' do
|
||||
context "with single service" do
|
||||
shared_examples 'openstacklib::policyrcd on Debian platforms' do
|
||||
context 'with single service' do
|
||||
let :params do
|
||||
{ :services => ['keystone'] }
|
||||
{
|
||||
:services => ['keystone']
|
||||
}
|
||||
end
|
||||
|
||||
let(:contents) {
|
||||
@ -40,14 +41,14 @@ fi
|
||||
eof
|
||||
}
|
||||
|
||||
it 'creates policy-rc.d file' do
|
||||
is_expected.to contain_file('/usr/sbin/policy-rc.d').with_content(contents)
|
||||
end
|
||||
it { should contain_file('/usr/sbin/policy-rc.d').with_content(contents) }
|
||||
end
|
||||
|
||||
context "with multiple services" do
|
||||
context 'with multiple services' do
|
||||
let :params do
|
||||
{ :services => ['keystone', 'nova'] }
|
||||
{
|
||||
:services => ['keystone', 'nova']
|
||||
}
|
||||
end
|
||||
|
||||
let(:contents) {
|
||||
@ -68,35 +69,31 @@ fi
|
||||
eof
|
||||
}
|
||||
|
||||
it 'creates policy-rc.d file' do
|
||||
is_expected.to contain_file('/usr/sbin/policy-rc.d').with_content(contents)
|
||||
end
|
||||
it { should contain_file('/usr/sbin/policy-rc.d').with_content(contents) }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
shared_examples_for 'openstacklib::policyrcd on RedHat platforms' do
|
||||
describe "with single service" do
|
||||
shared_examples 'openstacklib::policyrcd on RedHat platforms' do
|
||||
context 'with single service' do
|
||||
let :params do
|
||||
{ :services => ['keystone'] }
|
||||
{
|
||||
:services => ['keystone']
|
||||
}
|
||||
end
|
||||
|
||||
it 'does not create policy-rc.d file' do
|
||||
is_expected.to_not contain_file('/usr/sbin/policy-rc.d')
|
||||
end
|
||||
it { should_not contain_file('/usr/sbin/policy-rc.d') }
|
||||
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 "openstacklib::policyrcd on #{facts[:osfamily]} platforms"
|
||||
it_behaves_like "openstacklib::policyrcd on #{facts[:osfamily]} platforms"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -1,7 +1,6 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'openstacklib::db::mysql::host_access' do
|
||||
|
||||
let :pre_condition do
|
||||
"include mysql::server\n" +
|
||||
"openstacklib::db::mysql { 'nova':\n" +
|
||||
@ -9,22 +8,24 @@ describe 'openstacklib::db::mysql::host_access' do
|
||||
end
|
||||
|
||||
shared_examples 'openstacklib::db::mysql::host_access examples' do
|
||||
|
||||
context 'with required parameters' do
|
||||
let (:title) { 'nova_10.0.0.1' }
|
||||
|
||||
let :params do
|
||||
{ :user => 'foobar',
|
||||
{
|
||||
:user => 'foobar',
|
||||
:password_hash => 'AA1420F182E88B9E5F874F6FBE7459291E8F4601',
|
||||
:database => 'nova',
|
||||
:privileges => 'ALL' }
|
||||
:privileges => 'ALL'
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_mysql_user("#{params[:user]}@10.0.0.1").with(
|
||||
it { should contain_mysql_user("#{params[:user]}@10.0.0.1").with(
|
||||
:password_hash => params[:password_hash],
|
||||
:tls_options => ['NONE']
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_mysql_grant("#{params[:user]}@10.0.0.1/#{params[:database]}.*").with(
|
||||
it { should contain_mysql_grant("#{params[:user]}@10.0.0.1/#{params[:database]}.*").with(
|
||||
:user => "#{params[:user]}@10.0.0.1",
|
||||
:privileges => 'ALL',
|
||||
:table => "#{params[:database]}.*"
|
||||
@ -33,8 +34,10 @@ describe 'openstacklib::db::mysql::host_access' do
|
||||
|
||||
context 'with skipping user creation' do
|
||||
let (:title) { 'nova_10.0.0.1' }
|
||||
|
||||
let :params do
|
||||
{ :user => 'foobar',
|
||||
{
|
||||
:user => 'foobar',
|
||||
:password_hash => 'AA1420F182E88B9E5F874F6FBE7459291E8F4601',
|
||||
:database => 'nova',
|
||||
:privileges => 'ALL',
|
||||
@ -42,9 +45,9 @@ describe 'openstacklib::db::mysql::host_access' do
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to_not contain_mysql_user("#{params[:user]}@10.0.0.1") }
|
||||
it { should_not contain_mysql_user("#{params[:user]}@10.0.0.1") }
|
||||
|
||||
it { is_expected.to contain_mysql_grant("#{params[:user]}@10.0.0.1/#{params[:database]}.*").with(
|
||||
it { should contain_mysql_grant("#{params[:user]}@10.0.0.1/#{params[:database]}.*").with(
|
||||
:user => "#{params[:user]}@10.0.0.1",
|
||||
:privileges => 'ALL',
|
||||
:table => "#{params[:database]}.*"
|
||||
@ -53,8 +56,10 @@ describe 'openstacklib::db::mysql::host_access' do
|
||||
|
||||
context 'with skipping grant creation' do
|
||||
let (:title) { 'nova_10.0.0.1' }
|
||||
|
||||
let :params do
|
||||
{ :user => 'foobar',
|
||||
{
|
||||
:user => 'foobar',
|
||||
:password_hash => 'AA1420F182E88B9E5F874F6FBE7459291E8F4601',
|
||||
:database => 'nova',
|
||||
:privileges => 'ALL',
|
||||
@ -62,17 +67,19 @@ describe 'openstacklib::db::mysql::host_access' do
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_mysql_user("#{params[:user]}@10.0.0.1").with(
|
||||
it { should contain_mysql_user("#{params[:user]}@10.0.0.1").with(
|
||||
:password_hash => params[:password_hash]
|
||||
)}
|
||||
|
||||
it { is_expected.to_not contain_mysql_grant("#{params[:user]}@10.0.0.1/#{params[:database]}.*") }
|
||||
it { should_not contain_mysql_grant("#{params[:user]}@10.0.0.1/#{params[:database]}.*") }
|
||||
end
|
||||
|
||||
context 'with skipping user and grant creation' do
|
||||
let (:title) { 'nova_10.0.0.1' }
|
||||
|
||||
let :params do
|
||||
{ :user => 'foobar',
|
||||
{
|
||||
:user => 'foobar',
|
||||
:password_hash => 'AA1420F182E88B9E5F874F6FBE7459291E8F4601',
|
||||
:database => 'nova',
|
||||
:privileges => 'ALL',
|
||||
@ -81,21 +88,20 @@ describe 'openstacklib::db::mysql::host_access' do
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to_not contain_mysql_user("#{params[:user]}@10.0.0.1") }
|
||||
|
||||
it { is_expected.to_not contain_mysql_grant("#{params[:user]}@10.0.0.1/#{params[:database]}.*") }
|
||||
it { should_not contain_mysql_user("#{params[:user]}@10.0.0.1") }
|
||||
it { should_not contain_mysql_grant("#{params[:user]}@10.0.0.1/#{params[:database]}.*") }
|
||||
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 'openstacklib::db::mysql::host_access examples'
|
||||
it_behaves_like 'openstacklib::db::mysql::host_access examples'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'openstacklib::db::mysql' do
|
||||
|
||||
let :pre_condition do
|
||||
'include mysql::server'
|
||||
end
|
||||
@ -9,21 +8,23 @@ describe 'openstacklib::db::mysql' do
|
||||
let (:title) { 'nova' }
|
||||
|
||||
let :required_params do
|
||||
{ :password_hash => 'AA1420F182E88B9E5F874F6FBE7459291E8F4601' }
|
||||
{
|
||||
:password_hash => 'AA1420F182E88B9E5F874F6FBE7459291E8F4601'
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples 'openstacklib::db::mysql examples' do
|
||||
|
||||
context 'with only required parameters' do
|
||||
let :params do
|
||||
required_params
|
||||
end
|
||||
|
||||
it { is_expected.to contain_mysql_database(title).with(
|
||||
it { should contain_mysql_database(title).with(
|
||||
:charset => 'utf8',
|
||||
:collate => 'utf8_general_ci'
|
||||
)}
|
||||
it { is_expected.to contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1").with(
|
||||
|
||||
it { should contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1").with(
|
||||
:user => title,
|
||||
:database => title,
|
||||
:privileges => 'ALL',
|
||||
@ -33,93 +34,100 @@ describe 'openstacklib::db::mysql' do
|
||||
|
||||
context 'with overriding dbname parameter' do
|
||||
let :params do
|
||||
{ :dbname => 'foobar' }.merge(required_params)
|
||||
required_params.merge!( :dbname => 'foobar' )
|
||||
end
|
||||
|
||||
it { is_expected.to contain_mysql_database(params[:dbname]).with(
|
||||
it { should contain_mysql_database(params[:dbname]).with(
|
||||
:charset => 'utf8',
|
||||
:collate => 'utf8_general_ci'
|
||||
)}
|
||||
it { is_expected.to contain_openstacklib__db__mysql__host_access("#{params[:dbname]}_127.0.0.1").with(
|
||||
|
||||
it { should contain_openstacklib__db__mysql__host_access("#{params[:dbname]}_127.0.0.1").with(
|
||||
:user => title,
|
||||
:database => params[:dbname],
|
||||
:privileges => 'ALL',
|
||||
:create_user => true,
|
||||
:create_grant => true,
|
||||
:tls_options => ['NONE'],
|
||||
:tls_options => ['NONE'],
|
||||
)}
|
||||
end
|
||||
|
||||
context 'with overriding user parameter' do
|
||||
let :params do
|
||||
{ :user => 'foobar' }.merge(required_params)
|
||||
required_params.merge!( :user => 'foobar' )
|
||||
end
|
||||
|
||||
it { is_expected.to contain_mysql_database(title).with(
|
||||
it { should contain_mysql_database(title).with(
|
||||
:charset => 'utf8',
|
||||
:collate => 'utf8_general_ci'
|
||||
)}
|
||||
it { is_expected.to contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1").with(
|
||||
|
||||
it { should contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1").with(
|
||||
:user => params[:user],
|
||||
:database => title,
|
||||
:privileges => 'ALL',
|
||||
:create_user => true,
|
||||
:create_grant => true,
|
||||
:tls_options => ['NONE'],
|
||||
:tls_options => ['NONE'],
|
||||
)}
|
||||
end
|
||||
|
||||
context 'when overriding charset parameter' do
|
||||
let :params do
|
||||
{ :charset => 'latin1' }.merge(required_params)
|
||||
required_params.merge!( :charset => 'latin1' )
|
||||
end
|
||||
|
||||
it { is_expected.to contain_mysql_database(title).with_charset(params[:charset]) }
|
||||
it { should contain_mysql_database(title).with_charset(params[:charset]) }
|
||||
end
|
||||
|
||||
context 'when omitting the required parameter password_hash' do
|
||||
let :params do
|
||||
required_params.delete(:password_hash)
|
||||
{}
|
||||
end
|
||||
it { expect { is_expected.to raise_error(Puppet::Error) } }
|
||||
|
||||
it { should raise_error(Puppet::Error) }
|
||||
end
|
||||
|
||||
context 'when notifying other resources' do
|
||||
let :pre_condition do
|
||||
'exec {"nova-db-sync":}'
|
||||
end
|
||||
|
||||
let :params do
|
||||
{ :notify => 'Exec[nova-db-sync]'}.merge(required_params)
|
||||
required_params.merge!( :notify => 'Exec[nova-db-sync]' )
|
||||
end
|
||||
|
||||
it { is_expected.to contain_exec('nova-db-sync').that_subscribes_to("Openstacklib::Db::Mysql[#{title}]") }
|
||||
it { should contain_exec('nova-db-sync').that_subscribes_to("Openstacklib::Db::Mysql[#{title}]") }
|
||||
end
|
||||
|
||||
context 'when required for other openstack services' do
|
||||
let :pre_condition do
|
||||
'service {"keystone":}'
|
||||
end
|
||||
|
||||
let :title do
|
||||
'keystone'
|
||||
end
|
||||
|
||||
let :params do
|
||||
{ :before => 'Service[keystone]'}.merge(required_params)
|
||||
required_params.merge!( :before => 'Service[keystone]' )
|
||||
end
|
||||
|
||||
it { is_expected.to contain_service('keystone').that_requires("Openstacklib::Db::Mysql[keystone]") }
|
||||
it { should contain_service('keystone').that_requires("Openstacklib::Db::Mysql[keystone]") }
|
||||
end
|
||||
|
||||
context "overriding allowed_hosts parameter with array value" do
|
||||
let :params do
|
||||
{ :allowed_hosts => ['127.0.0.1','%'] }.merge(required_params)
|
||||
required_params.merge!( :allowed_hosts => ['127.0.0.1', '%'] )
|
||||
end
|
||||
|
||||
it {is_expected.to contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1").with(
|
||||
it { should contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1").with(
|
||||
:user => title,
|
||||
:password_hash => params[:password_hash],
|
||||
:database => title
|
||||
)}
|
||||
it {is_expected.to contain_openstacklib__db__mysql__host_access("#{title}_%").with(
|
||||
|
||||
it { should contain_openstacklib__db__mysql__host_access("#{title}_%").with(
|
||||
:user => title,
|
||||
:password_hash => params[:password_hash],
|
||||
:database => title
|
||||
@ -128,10 +136,10 @@ describe 'openstacklib::db::mysql' do
|
||||
|
||||
context "overriding allowed_hosts parameter with string value" do
|
||||
let :params do
|
||||
{ :allowed_hosts => '192.168.1.1' }.merge(required_params)
|
||||
required_params.merge!( :allowed_hosts => '192.168.1.1' )
|
||||
end
|
||||
|
||||
it {is_expected.to contain_openstacklib__db__mysql__host_access("#{title}_192.168.1.1").with(
|
||||
it { should contain_openstacklib__db__mysql__host_access("#{title}_192.168.1.1").with(
|
||||
:user => title,
|
||||
:password_hash => params[:password_hash],
|
||||
:database => title
|
||||
@ -140,10 +148,10 @@ describe 'openstacklib::db::mysql' do
|
||||
|
||||
context "overriding allowed_hosts parameter equals to host param " do
|
||||
let :params do
|
||||
{ :allowed_hosts => '127.0.0.1' }.merge(required_params)
|
||||
required_params.merge!( :allowed_hosts => '127.0.0.1' )
|
||||
end
|
||||
|
||||
it {is_expected.to contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1").with(
|
||||
it { should contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1").with(
|
||||
:user => title,
|
||||
:password_hash => params[:password_hash],
|
||||
:database => title
|
||||
@ -152,14 +160,15 @@ describe 'openstacklib::db::mysql' do
|
||||
|
||||
context 'with skipping user creation' do
|
||||
let :params do
|
||||
{ :create_user => false }.merge(required_params)
|
||||
required_params.merge!( :create_user => false )
|
||||
end
|
||||
|
||||
it { is_expected.to contain_mysql_database(title).with(
|
||||
it { should contain_mysql_database(title).with(
|
||||
:charset => 'utf8',
|
||||
:collate => 'utf8_general_ci'
|
||||
)}
|
||||
it { is_expected.to contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1").with(
|
||||
|
||||
it { should contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1").with(
|
||||
:user => title,
|
||||
:database => title,
|
||||
:privileges => 'ALL',
|
||||
@ -170,14 +179,15 @@ describe 'openstacklib::db::mysql' do
|
||||
|
||||
context 'with skipping grant creation' do
|
||||
let :params do
|
||||
{ :create_grant => false }.merge(required_params)
|
||||
required_params.merge!( :create_grant => false )
|
||||
end
|
||||
|
||||
it { is_expected.to contain_mysql_database(title).with(
|
||||
it { should contain_mysql_database(title).with(
|
||||
:charset => 'utf8',
|
||||
:collate => 'utf8_general_ci'
|
||||
)}
|
||||
it { is_expected.to contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1").with(
|
||||
|
||||
it { should contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1").with(
|
||||
:user => title,
|
||||
:database => title,
|
||||
:privileges => 'ALL',
|
||||
@ -188,42 +198,41 @@ describe 'openstacklib::db::mysql' do
|
||||
|
||||
context 'with skipping user and grant creation' do
|
||||
let :params do
|
||||
{ :create_user => false,
|
||||
:create_grant => false }.merge(required_params)
|
||||
required_params.merge!( :create_user => false,
|
||||
:create_grant => false )
|
||||
end
|
||||
|
||||
it { is_expected.to contain_mysql_database(title).with(
|
||||
it { should contain_mysql_database(title).with(
|
||||
:charset => 'utf8',
|
||||
:collate => 'utf8_general_ci'
|
||||
)}
|
||||
it { is_expected.to_not contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1") }
|
||||
|
||||
it { should_not contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1") }
|
||||
end
|
||||
|
||||
context "overriding tls_options" do
|
||||
context 'overriding tls_options' do
|
||||
let :params do
|
||||
{ :tls_options => ['SSL'] }.merge(required_params)
|
||||
required_params.merge!( :tls_options => ['SSL'] )
|
||||
end
|
||||
|
||||
it {is_expected.to contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1").with(
|
||||
it { should contain_openstacklib__db__mysql__host_access("#{title}_127.0.0.1").with(
|
||||
:user => title,
|
||||
:password_hash => params[:password_hash],
|
||||
:database => title,
|
||||
:tls_options => ['SSL'],
|
||||
)}
|
||||
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 'openstacklib::db::mysql examples'
|
||||
it_behaves_like 'openstacklib::db::mysql examples'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -4,7 +4,9 @@ describe 'openstacklib::db::postgresql' do
|
||||
let (:title) { 'nova' }
|
||||
|
||||
let :required_params do
|
||||
{ :password_hash => 'AA1420F182E88B9E5F874F6FBE7459291E8F4601' }
|
||||
{
|
||||
:password_hash => 'AA1420F182E88B9E5F874F6FBE7459291E8F4601'
|
||||
}
|
||||
end
|
||||
|
||||
let (:pre_condition) do
|
||||
@ -17,7 +19,7 @@ describe 'openstacklib::db::postgresql' do
|
||||
required_params
|
||||
end
|
||||
|
||||
it { is_expected.to contain_postgresql__server__db(title).with(
|
||||
it { should contain_postgresql__server__db(title).with(
|
||||
:user => title,
|
||||
:password => params[:password_hash]
|
||||
)}
|
||||
@ -25,17 +27,18 @@ describe 'openstacklib::db::postgresql' do
|
||||
|
||||
context 'when overriding encoding' do
|
||||
let :params do
|
||||
{ :encoding => 'latin1' }.merge(required_params)
|
||||
required_params.merge!( :encoding => 'latin1' )
|
||||
end
|
||||
it { is_expected.to contain_postgresql__server__db(title).with_encoding(params[:encoding]) }
|
||||
|
||||
it { should contain_postgresql__server__db(title).with_encoding(params[:encoding]) }
|
||||
end
|
||||
|
||||
context 'when omitting the required parameter password_hash' do
|
||||
let :params do
|
||||
required_params.delete(:password_hash)
|
||||
{}
|
||||
end
|
||||
|
||||
it { expect { is_expected.to raise_error(Puppet::Error) } }
|
||||
it { should raise_error(Puppet::Error) }
|
||||
end
|
||||
|
||||
context 'when notifying other resources' do
|
||||
@ -43,11 +46,12 @@ describe 'openstacklib::db::postgresql' do
|
||||
"include ::postgresql::server
|
||||
exec { 'nova-db-sync': }"
|
||||
end
|
||||
|
||||
let :params do
|
||||
{ :notify => 'Exec[nova-db-sync]'}.merge(required_params)
|
||||
required_params.merge!( :notify => 'Exec[nova-db-sync]' )
|
||||
end
|
||||
|
||||
it {is_expected.to contain_exec('nova-db-sync').that_subscribes_to("Openstacklib::Db::Postgresql[#{title}]") }
|
||||
it { should contain_exec('nova-db-sync').that_subscribes_to("Openstacklib::Db::Postgresql[#{title}]") }
|
||||
end
|
||||
|
||||
context 'when required for other openstack services' do
|
||||
@ -55,27 +59,28 @@ describe 'openstacklib::db::postgresql' do
|
||||
"include ::postgresql::server
|
||||
service {'keystone':}"
|
||||
end
|
||||
|
||||
let :title do
|
||||
'keystone'
|
||||
end
|
||||
|
||||
let :params do
|
||||
{ :before => 'Service[keystone]'}.merge(required_params)
|
||||
required_params.merge!( :before => 'Service[keystone]' )
|
||||
end
|
||||
|
||||
it { is_expected.to contain_service('keystone').that_requires("Openstacklib::Db::Postgresql[keystone]") }
|
||||
it { should contain_service('keystone').that_requires("Openstacklib::Db::Postgresql[keystone]") }
|
||||
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 'openstacklib::db::postgresql examples'
|
||||
it_behaves_like 'openstacklib::db::postgresql examples'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -18,28 +18,28 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'openstacklib::messaging::rabbitmq' do
|
||||
|
||||
let (:title) { 'nova' }
|
||||
|
||||
shared_examples 'openstacklib::messaging::rabbitmq examples' do
|
||||
|
||||
let :params do
|
||||
{}
|
||||
end
|
||||
|
||||
context 'with default parameters' do
|
||||
it { is_expected.to contain_rabbitmq_user('guest').with(
|
||||
it { should contain_rabbitmq_user('guest').with(
|
||||
:admin => false,
|
||||
:password => 'guest',
|
||||
:provider => 'rabbitmqctl',
|
||||
)}
|
||||
it { is_expected.to contain_rabbitmq_user_permissions('guest@/').with(
|
||||
|
||||
it { should contain_rabbitmq_user_permissions('guest@/').with(
|
||||
:configure_permission => '.*',
|
||||
:write_permission => '.*',
|
||||
:read_permission => '.*',
|
||||
:provider => 'rabbitmqctl',
|
||||
)}
|
||||
it { is_expected.to contain_rabbitmq_vhost('/').with(
|
||||
|
||||
it { should contain_rabbitmq_vhost('/').with(
|
||||
:provider => 'rabbitmqctl',
|
||||
)}
|
||||
end
|
||||
@ -57,18 +57,20 @@ describe 'openstacklib::messaging::rabbitmq' do
|
||||
)
|
||||
end
|
||||
|
||||
it { is_expected.to contain_rabbitmq_user('nova').with(
|
||||
it { should contain_rabbitmq_user('nova').with(
|
||||
:admin => true,
|
||||
:password => 'secrete',
|
||||
:provider => 'rabbitmqctl',
|
||||
)}
|
||||
it { is_expected.to contain_rabbitmq_user_permissions('nova@/nova').with(
|
||||
|
||||
it { should contain_rabbitmq_user_permissions('nova@/nova').with(
|
||||
:configure_permission => '.nova',
|
||||
:write_permission => '.nova',
|
||||
:read_permission => '.nova',
|
||||
:provider => 'rabbitmqctl',
|
||||
)}
|
||||
it { is_expected.to contain_rabbitmq_vhost('/nova').with(
|
||||
|
||||
it { should contain_rabbitmq_vhost('/nova').with(
|
||||
:provider => 'rabbitmqctl',
|
||||
)}
|
||||
end
|
||||
@ -78,20 +80,19 @@ describe 'openstacklib::messaging::rabbitmq' do
|
||||
params.merge!( :manage_vhost => false )
|
||||
end
|
||||
|
||||
it { is_expected.not_to contain_rabbitmq_vhost('/') }
|
||||
it { should_not contain_rabbitmq_vhost('/') }
|
||||
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 'openstacklib::messaging::rabbitmq examples'
|
||||
it_behaves_like 'openstacklib::messaging::rabbitmq examples'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'openstacklib::policy::base' do
|
||||
|
||||
|
||||
shared_examples_for 'openstacklib::policy::base' do
|
||||
shared_examples 'openstacklib::policy::base' do
|
||||
context 'with some basic parameters' do
|
||||
let :title do
|
||||
'nova-contest_is_admin'
|
||||
@ -20,46 +18,39 @@ describe 'openstacklib::policy::base' do
|
||||
}
|
||||
end
|
||||
|
||||
it {
|
||||
is_expected.to contain_file('/etc/nova/policy.json').with(
|
||||
:mode => '0644',
|
||||
:owner => 'foo',
|
||||
:group => 'bar')
|
||||
}
|
||||
it { should contain_file('/etc/nova/policy.json').with(
|
||||
:mode => '0644',
|
||||
:owner => 'foo',
|
||||
:group => 'bar'
|
||||
)}
|
||||
|
||||
it 'configures (modifies) the proper policy' do
|
||||
is_expected.to contain_augeas('/etc/nova/policy.json-context_is_admin or owner-foo:bar').with(
|
||||
'lens' => 'Json.lns',
|
||||
'incl' => '/etc/nova/policy.json',
|
||||
'changes' => 'set dict/entry[*][.="context_is_admin or owner"]/string "foo:bar"',
|
||||
)
|
||||
end
|
||||
it { should contain_augeas('/etc/nova/policy.json-context_is_admin or owner-foo:bar').with(
|
||||
:lens => 'Json.lns',
|
||||
:incl => '/etc/nova/policy.json',
|
||||
:changes => 'set dict/entry[*][.="context_is_admin or owner"]/string "foo:bar"',
|
||||
)}
|
||||
|
||||
it 'configures (adds) the proper policy' do
|
||||
is_expected.to contain_augeas('/etc/nova/policy.json-context_is_admin or owner-foo:bar-add').with(
|
||||
'lens' => 'Json.lns',
|
||||
'incl' => '/etc/nova/policy.json',
|
||||
'changes' => [
|
||||
'set dict/entry[last()+1] "context_is_admin or owner"',
|
||||
'set dict/entry[last()]/string "foo:bar"'
|
||||
],
|
||||
'onlyif' => 'match dict/entry[*][.="context_is_admin or owner"] size == 0'
|
||||
)
|
||||
end
|
||||
it { should contain_augeas('/etc/nova/policy.json-context_is_admin or owner-foo:bar-add').with(
|
||||
:lens => 'Json.lns',
|
||||
:incl => '/etc/nova/policy.json',
|
||||
:changes => [
|
||||
'set dict/entry[last()+1] "context_is_admin or owner"',
|
||||
'set dict/entry[last()]/string "foo:bar"'
|
||||
],
|
||||
:onlyif => 'match dict/entry[*][.="context_is_admin or owner"] size == 0'
|
||||
)}
|
||||
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 'openstacklib::policy::base'
|
||||
it_behaves_like 'openstacklib::policy::base'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
@ -18,21 +18,21 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'openstacklib::service_validation' do
|
||||
|
||||
let (:title) { 'nova-api' }
|
||||
|
||||
let :required_params do
|
||||
{ :command => 'nova list' }
|
||||
{
|
||||
:command => 'nova list'
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples 'openstacklib::service_validation examples' do
|
||||
|
||||
context 'with only required parameters' do
|
||||
let :params do
|
||||
required_params
|
||||
end
|
||||
|
||||
it { is_expected.to contain_exec("execute #{title} validation").with(
|
||||
it { should contain_exec("execute #{title} validation").with(
|
||||
:path => '/usr/bin:/bin:/usr/sbin:/sbin',
|
||||
:provider => 'shell',
|
||||
:command => 'nova list',
|
||||
@ -50,7 +50,7 @@ describe 'openstacklib::service_validation' do
|
||||
required_params.merge!({ :unless => 'pwd' })
|
||||
end
|
||||
|
||||
it { is_expected.to contain_exec("execute #{title} validation").with(
|
||||
it { should contain_exec("execute #{title} validation").with(
|
||||
:path => '/usr/bin:/bin:/usr/sbin:/sbin',
|
||||
:provider => 'shell',
|
||||
:command => 'nova list',
|
||||
@ -67,7 +67,7 @@ describe 'openstacklib::service_validation' do
|
||||
required_params.merge!({ :onlyif => 'pwd' })
|
||||
end
|
||||
|
||||
it { is_expected.to contain_exec("execute #{title} validation").with(
|
||||
it { should contain_exec("execute #{title} validation").with(
|
||||
:path => '/usr/bin:/bin:/usr/sbin:/sbin',
|
||||
:provider => 'shell',
|
||||
:command => 'nova list',
|
||||
@ -84,31 +84,29 @@ describe 'openstacklib::service_validation' do
|
||||
required_params.merge!({ :environment => ['OS_PASSWORD=secret'] })
|
||||
end
|
||||
|
||||
it { is_expected.to contain_exec("execute #{title} validation").with(
|
||||
it { should contain_exec("execute #{title} validation").with(
|
||||
:environment => ['OS_PASSWORD=secret'],
|
||||
)}
|
||||
end
|
||||
|
||||
context 'when omitting a required parameter command' do
|
||||
let :params do
|
||||
required_params.delete(:command)
|
||||
{}
|
||||
end
|
||||
|
||||
it { expect { is_expected.to raise_error(Puppet::Error) } }
|
||||
it { should raise_error(Puppet::Error) }
|
||||
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 'openstacklib::service_validation examples'
|
||||
it_behaves_like 'openstacklib::service_validation examples'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -18,7 +18,6 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'openstacklib::wsgi::apache' do
|
||||
|
||||
let (:title) { 'keystone_wsgi' }
|
||||
|
||||
let :global_facts do
|
||||
@ -43,63 +42,65 @@ describe 'openstacklib::wsgi::apache' do
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'apache serving a service with mod_wsgi' do
|
||||
it { is_expected.to contain_service('httpd').with_name(platform_params[:httpd_service_name]) }
|
||||
it { is_expected.to contain_class('apache') }
|
||||
it { is_expected.to contain_class('apache::mod::wsgi') }
|
||||
shared_examples 'openstacklib::wsgi::apache' do
|
||||
it {
|
||||
should contain_service('httpd').with_name(platform_params[:httpd_service_name])
|
||||
should contain_class('apache')
|
||||
should contain_class('apache::mod::wsgi')
|
||||
}
|
||||
|
||||
describe 'with default parameters' do
|
||||
|
||||
it { is_expected.to contain_file('/var/www/cgi-bin/keystone').with(
|
||||
'ensure' => 'directory',
|
||||
'owner' => 'keystone',
|
||||
'group' => 'keystone',
|
||||
'mode' => '0755',
|
||||
context 'with default parameters' do
|
||||
it { should contain_file('/var/www/cgi-bin/keystone').with(
|
||||
:ensure => 'directory',
|
||||
:owner => 'keystone',
|
||||
:group => 'keystone',
|
||||
:mode => '0755',
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_file('keystone_wsgi').with(
|
||||
'ensure' => 'file',
|
||||
'links' => 'follow',
|
||||
'path' => '/var/www/cgi-bin/keystone/main',
|
||||
'source' => '/usr/share/keystone/keystone.wsgi',
|
||||
'owner' => 'keystone',
|
||||
'group' => 'keystone',
|
||||
'mode' => '0644',
|
||||
it { should contain_file('keystone_wsgi').with(
|
||||
:ensure => 'file',
|
||||
:links => 'follow',
|
||||
:path => '/var/www/cgi-bin/keystone/main',
|
||||
:source => '/usr/share/keystone/keystone.wsgi',
|
||||
:owner => 'keystone',
|
||||
:group => 'keystone',
|
||||
:mode => '0644',
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_apache__vhost('keystone_wsgi').with(
|
||||
'servername' => 'some.host.tld',
|
||||
'ip' => nil,
|
||||
'port' => '5000',
|
||||
'docroot' => '/var/www/cgi-bin/keystone',
|
||||
'docroot_owner' => 'keystone',
|
||||
'docroot_group' => 'keystone',
|
||||
'ssl' => 'true',
|
||||
'wsgi_daemon_process' => 'keystone_wsgi',
|
||||
'wsgi_process_group' => 'keystone_wsgi',
|
||||
'wsgi_script_aliases' => { '/' => "/var/www/cgi-bin/keystone/main" },
|
||||
'wsgi_daemon_process_options' => {
|
||||
it { should contain_apache__vhost('keystone_wsgi').with(
|
||||
:servername => 'some.host.tld',
|
||||
:ip => nil,
|
||||
:port => '5000',
|
||||
:docroot => '/var/www/cgi-bin/keystone',
|
||||
:docroot_owner => 'keystone',
|
||||
:docroot_group => 'keystone',
|
||||
:ssl => 'true',
|
||||
:wsgi_daemon_process => 'keystone_wsgi',
|
||||
:wsgi_process_group => 'keystone_wsgi',
|
||||
:wsgi_script_aliases => { '/' => "/var/www/cgi-bin/keystone/main" },
|
||||
:wsgi_daemon_process_options => {
|
||||
'user' => 'keystone',
|
||||
'group' => 'keystone',
|
||||
'processes' => global_facts[:os_workers],
|
||||
'threads' => 1,
|
||||
'display-name' => 'keystone_wsgi',
|
||||
},
|
||||
'wsgi_application_group' => '%{GLOBAL}',
|
||||
'headers' => nil,
|
||||
'setenvif' => ['X-Forwarded-Proto https HTTPS=1'],
|
||||
'access_log_file' => false,
|
||||
'access_log_pipe' => false,
|
||||
'access_log_syslog' => false,
|
||||
'access_log_format' => false,
|
||||
'error_log_file' => nil,
|
||||
'error_log_pipe' => nil,
|
||||
'error_log_syslog' => nil
|
||||
:wsgi_application_group => '%{GLOBAL}',
|
||||
:headers => nil,
|
||||
:setenvif => ['X-Forwarded-Proto https HTTPS=1'],
|
||||
:access_log_file => false,
|
||||
:access_log_pipe => false,
|
||||
:access_log_syslog => false,
|
||||
:access_log_format => false,
|
||||
:error_log_file => nil,
|
||||
:error_log_pipe => nil,
|
||||
:error_log_syslog => nil
|
||||
)}
|
||||
it { is_expected.to contain_concat("#{platform_params[:httpd_ports_file]}") }
|
||||
|
||||
it { should contain_concat("#{platform_params[:httpd_ports_file]}") }
|
||||
end
|
||||
|
||||
describe 'when overriding parameters' do
|
||||
context 'when overriding parameters' do
|
||||
let :params do
|
||||
{
|
||||
:wsgi_script_dir => '/var/www/cgi-bin/keystone',
|
||||
@ -126,41 +127,40 @@ describe 'openstacklib::wsgi::apache' do
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_apache__vhost('keystone_wsgi').with(
|
||||
'servername' => 'dummy.host',
|
||||
'ip' => '10.42.51.1',
|
||||
'port' => '4142',
|
||||
'docroot' => "/var/www/cgi-bin/keystone",
|
||||
'ssl' => 'false',
|
||||
'wsgi_daemon_process' => 'keystone_wsgi',
|
||||
'wsgi_daemon_process_options' => {
|
||||
'user' => 'keystone',
|
||||
'group' => 'keystone',
|
||||
'processes' => '37',
|
||||
'threads' => '1',
|
||||
'display-name' => 'keystone_wsgi',
|
||||
it { should contain_apache__vhost('keystone_wsgi').with(
|
||||
:servername => 'dummy.host',
|
||||
:ip => '10.42.51.1',
|
||||
:port => '4142',
|
||||
:docroot => "/var/www/cgi-bin/keystone",
|
||||
:ssl => 'false',
|
||||
:wsgi_daemon_process => 'keystone_wsgi',
|
||||
:wsgi_daemon_process_options => {
|
||||
'user' => 'keystone',
|
||||
'group' => 'keystone',
|
||||
'processes' => '37',
|
||||
'threads' => '1',
|
||||
'display-name' => 'keystone_wsgi',
|
||||
},
|
||||
'wsgi_process_group' => 'keystone_wsgi',
|
||||
'wsgi_script_aliases' => {
|
||||
:wsgi_process_group => 'keystone_wsgi',
|
||||
:wsgi_script_aliases => {
|
||||
'/' => '/var/www/cgi-bin/keystone/main',
|
||||
'/admin' => '/var/www/cgi-bin/keystone/admin',
|
||||
},
|
||||
'wsgi_application_group' => '%{GLOBAL}',
|
||||
'wsgi_pass_authorization' => 'On',
|
||||
'wsgi_chunked_request' => 'On',
|
||||
'headers' => 'set X-Frame-Options "DENY"',
|
||||
'custom_fragment' => 'LimitRequestFieldSize 81900',
|
||||
'allow_encoded_slashes' => 'on',
|
||||
'access_log_file' => '/var/log/httpd/access_log',
|
||||
'access_log_syslog' => 'syslog:local0',
|
||||
'access_log_format' => 'some format',
|
||||
'error_log_file' => '/var/log/httpd/error_log',
|
||||
'error_log_syslog' => 'syslog:local0'
|
||||
:wsgi_application_group => '%{GLOBAL}',
|
||||
:wsgi_pass_authorization => 'On',
|
||||
:wsgi_chunked_request => 'On',
|
||||
:headers => 'set X-Frame-Options "DENY"',
|
||||
:custom_fragment => 'LimitRequestFieldSize 81900',
|
||||
:allow_encoded_slashes => 'on',
|
||||
:access_log_file => '/var/log/httpd/access_log',
|
||||
:access_log_syslog => 'syslog:local0',
|
||||
:access_log_format => 'some format',
|
||||
:error_log_file => '/var/log/httpd/error_log',
|
||||
:error_log_syslog => 'syslog:local0'
|
||||
)}
|
||||
|
||||
end
|
||||
|
||||
describe 'when wsgi_daemon_process_options are overridden' do
|
||||
context 'when wsgi_daemon_process_options are overridden' do
|
||||
let :params do
|
||||
{
|
||||
:bind_port => 5000,
|
||||
@ -177,8 +177,9 @@ describe 'openstacklib::wsgi::apache' do
|
||||
},
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_apache__vhost('keystone_wsgi').with(
|
||||
'wsgi_daemon_process_options' => {
|
||||
|
||||
it { should contain_apache__vhost('keystone_wsgi').with(
|
||||
:wsgi_daemon_process_options => {
|
||||
'user' => 'someotheruser',
|
||||
'group' => 'someothergroup',
|
||||
'processes' => global_facts[:os_workers],
|
||||
@ -191,7 +192,7 @@ describe 'openstacklib::wsgi::apache' do
|
||||
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
|
||||
@ -201,15 +202,19 @@ describe 'openstacklib::wsgi::apache' do
|
||||
let(:platform_params) do
|
||||
case facts[:osfamily]
|
||||
when 'Debian'
|
||||
{ :httpd_service_name => 'apache2',
|
||||
:httpd_ports_file => '/etc/apache2/ports.conf', }
|
||||
{
|
||||
:httpd_service_name => 'apache2',
|
||||
:httpd_ports_file => '/etc/apache2/ports.conf'
|
||||
}
|
||||
when 'RedHat'
|
||||
{ :httpd_service_name => 'httpd',
|
||||
:httpd_ports_file => '/etc/httpd/conf/ports.conf', }
|
||||
{
|
||||
:httpd_service_name => 'httpd',
|
||||
:httpd_ports_file => '/etc/httpd/conf/ports.conf'
|
||||
}
|
||||
end
|
||||
end
|
||||
it_configures 'apache serving a service with mod_wsgi'
|
||||
|
||||
it_behaves_like 'openstacklib::wsgi::apache'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user