Switch zaqar to use rspec-puppet-facts

This change updates the tests to use rspec-puppet-facts. Additionally
this change fixes the relationship in zaqar::server_instance for Debian
based systems.

Change-Id: I03ce4ee17feec1f0ea7012ea116c9c12cf3bde5f
This commit is contained in:
Alex Schultz 2016-02-18 21:32:17 -07:00
parent 6c05509bcc
commit 366deb93cb
14 changed files with 497 additions and 407 deletions

View File

@ -30,13 +30,13 @@ define zaqar::server_instance(
include ::zaqar
include ::zaqar::params
service { "openstack-zaqar@${name}":
service { "${::zaqar::params::service_name}@${name}":
ensure => $service_ensure,
enable => $enabled,
}
Package[$::zaqar::params::package_name] ~> Service["${::zaqar::params::service_name}@${name}"]
Package[$::zaqar::params::package_name] ~> File["/etc/zaqar/${name}.conf"]
Package['zaqar-common'] ~> Service["${::zaqar::params::service_name}@${name}"]
Package['zaqar-common'] ~> File["/etc/zaqar/${name}.conf"]
File["/etc/zaqar/${name}.conf"] ~> Service["${::zaqar::params::service_name}@${name}"]
Zaqar_config<||> ~> Service["${::zaqar::params::service_name}@${name}"]

View File

@ -2,6 +2,7 @@ require 'spec_helper'
describe 'zaqar::db::mysql' do
shared_examples_for 'zaqar::db::mysql' do
let :pre_condition do
[
'include mysql::server',
@ -9,10 +10,6 @@ describe 'zaqar::db::mysql' do
]
end
let :facts do
{ :osfamily => 'Debian' }
end
let :params do
{
'password' => 'fooboozoo_default_password',
@ -56,7 +53,19 @@ describe 'zaqar::db::mysql' do
:allowed_hosts => '127.0.0.1'
}
end
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_configures 'zaqar::db::mysql'
end
end
end

View File

@ -2,6 +2,7 @@ require 'spec_helper'
describe 'zaqar::db::postgresql' do
shared_examples_for 'zaqar::db::postgresql' do
let :req_params do
{ :password => 'pw' }
end
@ -10,15 +11,6 @@ describe 'zaqar::db::postgresql' do
'include postgresql::server'
end
context 'on a RedHat osfamily' do
let :facts do
{
:osfamily => 'RedHat',
:operatingsystemrelease => '7.0',
:concat_basedir => '/var/lib/puppet/concat'
}
end
context 'with only required parameters' do
let :params do
req_params
@ -32,27 +24,16 @@ describe 'zaqar::db::postgresql' do
end
context 'on a Debian osfamily' do
let :facts do
{
:operatingsystemrelease => '7.8',
:operatingsystem => 'Debian',
:osfamily => 'Debian',
:concat_basedir => '/var/lib/puppet/concat'
}
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' }))
end
context 'with only required parameters' do
let :params do
req_params
it_configures 'zaqar::db::postgresql'
end
it { is_expected.to contain_postgresql__server__db('zaqar').with(
:user => 'zaqar',
:password => 'md52e9c9a1a01bb2fef7463b70dd24d4b25'
)}
end
end
end

View File

@ -1,15 +1,12 @@
require 'spec_helper'
describe 'zaqar' do
shared_examples 'zaqar' do
let :req_params do
{
:admin_password => 'foo',
}
end
let :facts do
{ :osfamily => 'RedHat' }
end
describe 'with only required params' do
let :params do
req_params
@ -17,7 +14,8 @@ describe 'zaqar' do
it { is_expected.to contain_package('zaqar-common').with(
:ensure => 'present',
:name => 'openstack-zaqar'
:name => platform_params[:zaqar_common_package],
:tag => ['openstack', 'zaqar-package']
)}
it { is_expected.to contain_class('zaqar::params') }
@ -38,6 +36,9 @@ describe 'zaqar' do
is_expected.to contain_zaqar_config('keystone_authtoken/admin_password').with(
:value => 'foo'
)
is_expected.to contain_zaqar_config('DEFAULT/auth_strategy').with(
:value => 'keystone'
)
end
end
@ -57,5 +58,25 @@ describe 'zaqar' do
is_expected.to contain_zaqar_config('DEFAULT/pooling').with_value(true)
end
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
let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :zaqar_common_package => 'zaqar' }
when 'RedHat'
{ :zaqar_common_package => 'openstack-zaqar' }
end
end
it_behaves_like 'zaqar'
end
end
end

View File

@ -6,10 +6,8 @@ require 'spec_helper'
describe 'zaqar::keystone::auth' do
let :facts do
{ :osfamily => 'Debian' }
end
shared_examples_for 'zaqar::keystone::auth' do
describe 'with default class parameters' do
let :params do
{ :password => 'zaqar_password',
@ -117,5 +115,18 @@ describe 'zaqar::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_configures 'zaqar::keystone::auth'
end
end
end

View File

@ -88,20 +88,15 @@ describe 'zaqar::logging' do
}
end
context 'on Debian platforms' do
let :facts do
{ :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 'zaqar-logging'
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end
it_configures 'zaqar-logging'
end
end

View File

@ -2,16 +2,13 @@ require 'spec_helper'
describe 'zaqar::management::mongodb' do
shared_examples_for 'zaqar::management::mongodb' do
let :req_params do
{
:uri => 'mongodb://127.0.0.1:27017',
}
end
let :facts do
{ :osfamily => 'RedHat' }
end
describe 'with only required params' do
let :params do
req_params
@ -57,5 +54,18 @@ describe 'zaqar::management::mongodb' do
is_expected.to contain_zaqar_config('drivers:management_store:mongodb/reconnect_sleep').with_value('5')
end
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_configures 'zaqar::management::mongodb'
end
end
end

View File

@ -2,16 +2,13 @@ require 'spec_helper'
describe 'zaqar::messaging::mongodb' do
shared_examples_for 'zaqar::messaging::mongodb' do
let :req_params do
{
:uri => 'mongodb://127.0.0.1:27017',
}
end
let :facts do
{ :osfamily => 'RedHat' }
end
describe 'with only required params' do
let :params do
req_params
@ -59,5 +56,17 @@ describe 'zaqar::messaging::mongodb' do
is_expected.to contain_zaqar_config('drivers:message_store:mongodb/partitions').with_value('6')
end
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_configures 'zaqar::messaging::mongodb'
end
end
end

View File

@ -23,19 +23,15 @@ describe 'zaqar::policy' do
end
end
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end
it_configures 'zaqar policies'
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
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 'zaqar policies'
end
end
end

View File

@ -1,26 +0,0 @@
require 'spec_helper'
describe 'zaqar' do
let :pre_condition do
"zaqar::server_instance{ '1': transport => 'websocket' }"
end
let :facts do
{ :osfamily => 'RedHat' }
end
let :params do
{ :admin_password => 'foo' }
end
describe 'with a websocket server instance 1' do
it { is_expected.to contain_service('openstack-zaqar@1').with(
:ensure => 'running',
:enable => true
)}
it {is_expected.to contain_file('/etc/zaqar/1.conf') }
end
end

View File

@ -1,20 +1,38 @@
require 'spec_helper'
describe 'zaqar::server' do
let :facts do
{ :osfamily => 'RedHat' }
end
shared_examples_for 'zaqar::server' do
describe 'with a zaqar server enabled' do
let :pre_condition do
"class {'::zaqar': admin_password => 'foo'}"
end
it { is_expected.to contain_service('openstack-zaqar').with(
it { is_expected.to contain_service(platform_params[:zaqar_service_name]).with(
:ensure => 'running',
:enable => true
)}
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
let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :zaqar_service_name => 'zaqar' }
when 'RedHat'
{ :zaqar_service_name => 'openstack-zaqar' }
end
end
it_configures 'zaqar::server'
end
end
end

View File

@ -2,10 +2,7 @@ require 'spec_helper'
describe 'zaqar::transport::websocket' do
let :facts do
{ :osfamily => 'RedHat' }
end
shared_examples_for 'zaqar::transport::websocket' do
describe 'with custom values' do
let :params do
{
@ -21,5 +18,17 @@ describe 'zaqar::transport::websocket' do
is_expected.to contain_zaqar_config('drivers:transport:websocket/external-port').with_value('3')
end
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_configures 'zaqar::transport::websocket'
end
end
end

View File

@ -2,10 +2,7 @@ require 'spec_helper'
describe 'zaqar::transport::wsgi' do
let :facts do
{ :osfamily => 'RedHat' }
end
shared_examples_for 'zaqar::transport::wsgi' do
describe 'with custom values' do
let :params do
{
@ -19,5 +16,17 @@ describe 'zaqar::transport::wsgi' do
is_expected.to contain_zaqar_config('drivers:transport:wsgi/port').with_value('2')
end
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_configures 'zaqar::transport::wsgi'
end
end
end

View File

@ -0,0 +1,48 @@
require 'spec_helper'
describe 'zaqar::server_instance' do
shared_examples_for 'zaqar::server_instance' do
let(:title) { '1' }
let :pre_condition do
"class { 'zaqar': admin_password => 'foo' }"
end
let :params do
{
:transport => 'websocket'
}
end
describe 'with a websocket server instance 1' do
it { is_expected.to contain_service("#{platform_params[:zaqar_service_name]}@1").with(
:ensure => 'running',
:enable => true
)}
it { is_expected.to contain_file('/etc/zaqar/1.conf') }
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
let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :zaqar_service_name => 'zaqar' }
when 'RedHat'
{ :zaqar_service_name => 'openstack-zaqar' }
end
end
it_configures 'zaqar::server_instance'
end
end
end