Merge "Switch zaqar to use rspec-puppet-facts"

This commit is contained in:
Jenkins 2016-02-24 04:32:16 +00:00 committed by Gerrit Code Review
commit 4d8c83ee55
14 changed files with 497 additions and 407 deletions

View File

@ -30,13 +30,13 @@ define zaqar::server_instance(
include ::zaqar include ::zaqar
include ::zaqar::params include ::zaqar::params
service { "openstack-zaqar@${name}": service { "${::zaqar::params::service_name}@${name}":
ensure => $service_ensure, ensure => $service_ensure,
enable => $enabled, enable => $enabled,
} }
Package[$::zaqar::params::package_name] ~> Service["${::zaqar::params::service_name}@${name}"] Package['zaqar-common'] ~> Service["${::zaqar::params::service_name}@${name}"]
Package[$::zaqar::params::package_name] ~> File["/etc/zaqar/${name}.conf"] Package['zaqar-common'] ~> File["/etc/zaqar/${name}.conf"]
File["/etc/zaqar/${name}.conf"] ~> Service["${::zaqar::params::service_name}@${name}"] File["/etc/zaqar/${name}.conf"] ~> Service["${::zaqar::params::service_name}@${name}"]
Zaqar_config<||> ~> 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 describe 'zaqar::db::mysql' do
shared_examples_for 'zaqar::db::mysql' do
let :pre_condition do let :pre_condition do
[ [
'include mysql::server', 'include mysql::server',
@ -9,10 +10,6 @@ describe 'zaqar::db::mysql' do
] ]
end end
let :facts do
{ :osfamily => 'Debian' }
end
let :params do let :params do
{ {
'password' => 'fooboozoo_default_password', 'password' => 'fooboozoo_default_password',
@ -56,7 +53,19 @@ describe 'zaqar::db::mysql' do
:allowed_hosts => '127.0.0.1' :allowed_hosts => '127.0.0.1'
} }
end 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
end end

View File

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

View File

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

View File

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

View File

@ -88,20 +88,15 @@ describe 'zaqar::logging' do
} }
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
{ :osfamily => 'Debian' } }).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end end
it_configures 'zaqar-logging' it_configures 'zaqar-logging'
end end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end end
it_configures 'zaqar-logging'
end
end end

View File

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

View File

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

View File

@ -23,19 +23,15 @@ describe 'zaqar::policy' do
end end
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
{ :osfamily => 'Debian' } }).each do |os,facts|
end context "on #{os}" do
let (:facts) do
it_configures 'zaqar policies' facts.merge!(OSDefaults.get_facts())
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end end
it_configures 'zaqar policies' it_configures 'zaqar policies'
end end
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' require 'spec_helper'
describe 'zaqar::server' do describe 'zaqar::server' do
let :facts do shared_examples_for 'zaqar::server' do
{ :osfamily => 'RedHat' }
end
describe 'with a zaqar server enabled' do describe 'with a zaqar server enabled' do
let :pre_condition do let :pre_condition do
"class {'::zaqar': admin_password => 'foo'}" "class {'::zaqar': admin_password => 'foo'}"
end end
it { is_expected.to contain_service('openstack-zaqar').with( it { is_expected.to contain_service(platform_params[:zaqar_service_name]).with(
:ensure => 'running', :ensure => 'running',
:enable => true :enable => 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_service_name => 'zaqar' }
when 'RedHat'
{ :zaqar_service_name => 'openstack-zaqar' }
end
end
it_configures 'zaqar::server'
end
end
end end

View File

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

View File

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