Fix rspec-puppet-facts testing

Moves all spec tests over to using rspec-puppet-facts
and runs the tests for all our supported operating systems.

Change-Id: Ie2d60acac835affaf46a5276c9755640a723bca4
This commit is contained in:
Tobias Urdin
2018-05-17 00:13:44 +02:00
parent ca7070a567
commit e7d670b13a
62 changed files with 2611 additions and 2395 deletions

View File

@@ -25,61 +25,49 @@ describe 'swift::bench' do
"class { 'swift': swift_hash_path_suffix => 'string' }" "class { 'swift': swift_hash_path_suffix => 'string' }"
end end
let :facts do
OSDefaults.get_facts({
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian'
})
end
let :params do let :params do
{} default_params
end end
shared_examples 'swift::bench' do shared_examples 'swift::bench' do
let (:p) { default_params.merge!(params) } describe 'with defaults' do
it 'configures swift-bench.conf' do it 'configures swift-bench.conf' do
is_expected.to contain_swift_bench_config( is_expected.to contain_swift_bench_config(
'bench/auth').with_value(p[:auth_url]) 'bench/auth').with_value(params[:auth_url])
is_expected.to contain_swift_bench_config( is_expected.to contain_swift_bench_config(
'bench/user').with_value(p[:swift_user]) 'bench/user').with_value(params[:swift_user])
is_expected.to contain_swift_bench_config( is_expected.to contain_swift_bench_config(
'bench/key').with_value(p[:swift_key]) 'bench/key').with_value(params[:swift_key])
is_expected.to contain_swift_bench_config( is_expected.to contain_swift_bench_config(
'bench/auth_version').with_value(p[:auth_version]) 'bench/auth_version').with_value(params[:auth_version])
is_expected.to contain_swift_bench_config( is_expected.to contain_swift_bench_config(
'bench/log-level').with_value(p[:log_level]) 'bench/log-level').with_value(params[:log_level])
is_expected.to contain_swift_bench_config( is_expected.to contain_swift_bench_config(
'bench/timeout').with_value(p[:test_timeout]) 'bench/timeout').with_value(params[:test_timeout])
is_expected.to contain_swift_bench_config( is_expected.to contain_swift_bench_config(
'bench/put_concurrency').with_value(p[:put_concurrency]) 'bench/put_concurrency').with_value(params[:put_concurrency])
is_expected.to contain_swift_bench_config( is_expected.to contain_swift_bench_config(
'bench/get_concurrency').with_value(p[:get_concurrency]) 'bench/get_concurrency').with_value(params[:get_concurrency])
is_expected.to contain_swift_bench_config( is_expected.to contain_swift_bench_config(
'bench/get_concurrency').with_value(p[:get_concurrency]) 'bench/get_concurrency').with_value(params[:get_concurrency])
is_expected.to contain_swift_bench_config( is_expected.to contain_swift_bench_config(
'bench/lower_object_size').with_value(p[:lower_object_size]) 'bench/lower_object_size').with_value(params[:lower_object_size])
is_expected.to contain_swift_bench_config( is_expected.to contain_swift_bench_config(
'bench/upper_object_size').with_value(p[:upper_object_size]) 'bench/upper_object_size').with_value(params[:upper_object_size])
is_expected.to contain_swift_bench_config( is_expected.to contain_swift_bench_config(
'bench/object_size').with_value(p[:object_size]) 'bench/object_size').with_value(params[:object_size])
is_expected.to contain_swift_bench_config( is_expected.to contain_swift_bench_config(
'bench/num_objects').with_value(p[:num_objects]) 'bench/num_objects').with_value(params[:num_objects])
is_expected.to contain_swift_bench_config( is_expected.to contain_swift_bench_config(
'bench/num_gets').with_value(p[:num_gets]) 'bench/num_gets').with_value(params[:num_gets])
is_expected.to contain_swift_bench_config( is_expected.to contain_swift_bench_config(
'bench/num_containers').with_value(p[:num_containers]) 'bench/num_containers').with_value(params[:num_containers])
is_expected.to contain_swift_bench_config( is_expected.to contain_swift_bench_config(
'bench/delete').with_value(p[:delete]) 'bench/delete').with_value(params[:delete])
end end
end end
describe 'with defaults' do describe 'with overriden' do
include_examples 'swift::bench'
end
describe 'when overridding' do
before do before do
params.merge!( params.merge!(
:auth_url => 'http://127.0.0.1:8080/auth/v1.0', :auth_url => 'http://127.0.0.1:8080/auth/v1.0',
@@ -89,6 +77,28 @@ describe 'swift::bench' do
) )
end end
include_examples 'swift::bench' it 'configures swift-bench.conf' do
is_expected.to contain_swift_bench_config(
'bench/auth').with_value(params[:auth_url])
is_expected.to contain_swift_bench_config(
'bench/user').with_value(params[:swift_user])
is_expected.to contain_swift_bench_config(
'bench/key').with_value(params[:swift_key])
is_expected.to contain_swift_bench_config(
'bench/put_concurrency').with_value(params[:put_concurrency])
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 'swift::bench'
end
end end
end end

View File

@@ -10,7 +10,7 @@ describe 'swift::client' do
{ :package_ensure => 'present' } { :package_ensure => 'present' }
end end
shared_examples_for 'swift client' do shared_examples 'swift::client' do
let :p do let :p do
default_params.merge(params) default_params.merge(params)
end end
@@ -50,7 +50,7 @@ describe 'swift::client' do
end end
end end
it_configures 'swift client' it_configures 'swift::client'
end end
end end

View File

@@ -1,7 +1,6 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::config' do describe 'swift::config' do
let :params do let :params do
{ :swift_config => { { :swift_config => {
'DEFAULT/foo' => { 'value' => 'fooValue' }, 'DEFAULT/foo' => { 'value' => 'fooValue' },
@@ -16,15 +15,29 @@ describe 'swift::config' do
} }
end end
shared_examples 'swift::config' do
it 'configures arbitrary swift configurations' do it 'configures arbitrary swift configurations' do
is_expected.to contain_swift_config('DEFAULT/foo').with_value('fooValue') is_expected.to contain_swift_config('DEFAULT/foo').with_value('fooValue')
is_expected.to contain_swift_config('DEFAULT/bar').with_value('barValue') is_expected.to contain_swift_config('DEFAULT/bar').with_value('barValue')
is_expected.to contain_swift_config('DEFAULT/baz').with_ensure('absent') is_expected.to contain_swift_config('DEFAULT/baz').with_ensure('absent')
end end
it 'configures arbitrary swift proxy configurations' do it 'configures arbitrary swift proxy configurations' do
is_expected.to contain_swift_proxy_config('DEFAULT/foo').with_value('fooValue') is_expected.to contain_swift_proxy_config('DEFAULT/foo').with_value('fooValue')
is_expected.to contain_swift_proxy_config('DEFAULT/bar').with_value('barValue') is_expected.to contain_swift_proxy_config('DEFAULT/bar').with_value('barValue')
is_expected.to contain_swift_proxy_config('DEFAULT/baz').with_ensure('absent') is_expected.to contain_swift_proxy_config('DEFAULT/baz').with_ensure('absent')
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 'swift::config'
end
end
end end

View File

@@ -21,7 +21,7 @@ describe 'swift::containerreconciler' do
'class { "memcached": max_memory => 1 }' 'class { "memcached": max_memory => 1 }'
end end
shared_examples_for 'swift-container-reconciler' do shared_examples 'swift::container::reconciler' do
let (:p) { default_params.merge!(params) } let (:p) { default_params.merge!(params) }
context 'with defaults' do context 'with defaults' do
@@ -101,7 +101,7 @@ describe 'swift::containerreconciler' do
end end
end end
it_configures 'swift-container-reconciler' it_configures 'swift::container::reconciler'
end end
end end

View File

@@ -20,23 +20,20 @@ describe 'swift::dispersion' do
"class { 'swift': swift_hash_path_suffix => 'string' }" "class { 'swift': swift_hash_path_suffix => 'string' }"
end end
let :facts do
OSDefaults.get_facts({ :osfamily => 'Debian' })
end
let :params do let :params do
{} {}
end end
it { is_expected.to contain_file('/etc/swift/dispersion.conf').with( shared_examples 'swift::dispersion' do
describe 'with default' do
let (:p) { default_params.merge!(params) }
it { should contain_file('/etc/swift/dispersion.conf').with(
:ensure => 'file', :ensure => 'file',
:owner => 'swift', :owner => 'swift',
:group => 'swift', :group => 'swift',
:mode => '0640',) :mode => '0640',
} )}
shared_examples 'swift::dispersion' do
let (:p) { default_params.merge!(params) }
it 'configures dispersion.conf' do it 'configures dispersion.conf' do
is_expected.to contain_swift_dispersion_config( is_expected.to contain_swift_dispersion_config(
@@ -72,11 +69,7 @@ describe 'swift::dispersion' do
end end
end end
describe 'with default parameters' do describe 'with override' do
include_examples 'swift::dispersion'
end
describe 'when parameters are overridden' do
before do before do
params.merge!( params.merge!(
:auth_url => 'https://10.0.0.10:7000/auth/v8.0/', :auth_url => 'https://10.0.0.10:7000/auth/v8.0/',
@@ -92,7 +85,18 @@ describe 'swift::dispersion' do
:dump_json => 'yes' :dump_json => 'yes'
) )
end end
end
end
include_examples 'swift::dispersion' 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({ :puppetversion => '4.8.0' }))
end
it_configures 'swift::dispersion'
end
end end
end end

View File

@@ -1,11 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::keymaster' do describe 'swift::keymaster' do
shared_examples 'swift::keymaster' do
let :facts do
{}
end
describe "when using default parameters" do describe "when using default parameters" do
it { is_expected.to contain_swift_keymaster_config('kms_keymaster/api_class').with_value('castellan.key_manager.barbican_key_manager.BarbicanKeyManager') } it { is_expected.to contain_swift_keymaster_config('kms_keymaster/api_class').with_value('castellan.key_manager.barbican_key_manager.BarbicanKeyManager') }
it { is_expected.to contain_swift_keymaster_config('kms_keymaster/username').with_value('swift') } it { is_expected.to contain_swift_keymaster_config('kms_keymaster/username').with_value('swift') }
@@ -23,10 +19,23 @@ describe 'swift::keymaster' do
:project_name => 'barbican_swift_service', :project_name => 'barbican_swift_service',
} }
end end
it { is_expected.to contain_swift_keymaster_config('kms_keymaster/key_id').with_value('dummy_key_id') } it { is_expected.to contain_swift_keymaster_config('kms_keymaster/key_id').with_value('dummy_key_id') }
it { is_expected.to contain_swift_keymaster_config('kms_keymaster/password').with_value('fake_password') } it { is_expected.to contain_swift_keymaster_config('kms_keymaster/password').with_value('fake_password') }
it { is_expected.to contain_swift_keymaster_config('kms_keymaster/auth_endpoint').with_value('http://127.0.0.1:5000') } it { is_expected.to contain_swift_keymaster_config('kms_keymaster/auth_endpoint').with_value('http://127.0.0.1:5000') }
it { is_expected.to contain_swift_keymaster_config('kms_keymaster/project_name').with_value('barbican_swift_service') } it { is_expected.to contain_swift_keymaster_config('kms_keymaster/project_name').with_value('barbican_swift_service') }
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 'swift::keymaster'
end
end
end end

View File

@@ -1,7 +1,6 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::keystone::auth' do describe 'swift::keystone::auth' do
let :params do let :params do
{ } { }
end end
@@ -25,9 +24,9 @@ describe 'swift::keystone::auth' do
} }
end end
shared_examples_for 'swift keystone auth' do shared_examples 'swift::keystone::auth' do
context 'with default class parameters' do context 'with default class parameters' do
it_configures 'keystone auth configuration' it_configures 'keystone::auth::configuration'
['admin', 'SwiftOperator'].each do |role_name| ['admin', 'SwiftOperator'].each do |role_name|
it { is_expected.to contain_keystone_role(role_name).with_ensure('present') } it { is_expected.to contain_keystone_role(role_name).with_ensure('present') }
@@ -52,7 +51,7 @@ describe 'swift::keystone::auth' do
}) })
end end
it_configures 'keystone auth configuration' it_configures 'keystone::auth::configuration'
['admin', 'SwiftOperator', 'Gopher'].each do |role_name| ['admin', 'SwiftOperator', 'Gopher'].each do |role_name|
it { is_expected.to contain_keystone_role(role_name).with_ensure('present') } it { is_expected.to contain_keystone_role(role_name).with_ensure('present') }
@@ -90,9 +89,35 @@ describe 'swift::keystone::auth' do
end end
end end
context 'when overriding service name' do
before do
params.merge!({
:service_name => 'swift_service',
:service_name_s3 => 'swift_service_s3',
})
end end
shared_examples_for 'keystone auth configuration' do it 'configures correct user name' do
is_expected.to contain_keystone_user('swift')
end
it 'configures correct user role' do
is_expected.to contain_keystone_user_role('swift@services')
end
it 'configures correct service name' do
is_expected.to contain_keystone_service('swift_service::object-store')
is_expected.to contain_keystone_service('swift_service_s3::s3')
end
it 'configures correct endpoint name' do
is_expected.to contain_keystone_endpoint('RegionOne/swift_service::object-store')
is_expected.to contain_keystone_endpoint('RegionOne/swift_service_s3::s3')
end
end
end
shared_examples 'keystone::auth::configuration' do
let :p do let :p do
default_params.merge( params ) default_params.merge( params )
end end
@@ -157,43 +182,15 @@ describe 'swift::keystone::auth' 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|
context "on #{os}" do
let (:facts) do
facts.merge(OSDefaults.get_facts())
end end
it_configures 'swift keystone auth' it_configures 'swift::keystone::auth'
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end
it_configures 'swift keystone auth'
end
context 'when overriding service name' do
before do
params.merge!({
:service_name => 'swift_service',
:service_name_s3 => 'swift_service_s3',
})
end
it 'configures correct user name' do
is_expected.to contain_keystone_user('swift')
end
it 'configures correct user role' do
is_expected.to contain_keystone_user_role('swift@services')
end
it 'configures correct service name' do
is_expected.to contain_keystone_service('swift_service::object-store')
is_expected.to contain_keystone_service('swift_service_s3::s3')
end
it 'configures correct endpoint name' do
is_expected.to contain_keystone_endpoint('RegionOne/swift_service::object-store')
is_expected.to contain_keystone_endpoint('RegionOne/swift_service_s3::s3')
end end
end end
end end

View File

@@ -1,9 +1,8 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::keystone::dispersion' do describe 'swift::keystone::dispersion' do
shared_examples 'swift::keystone::dispersion' do
describe 'with default class parameters' do describe 'with default class parameters' do
it { is_expected.to contain_keystone_user('dispersion').with( it { is_expected.to contain_keystone_user('dispersion').with(
:ensure => 'present', :ensure => 'present',
:password => 'dispersion_password', :password => 'dispersion_password',
@@ -17,7 +16,6 @@ describe 'swift::keystone::dispersion' do
end end
describe 'when overriding parameters' do describe 'when overriding parameters' do
let :params do let :params do
{ {
:auth_user => 'bar', :auth_user => 'bar',
@@ -34,7 +32,18 @@ describe 'swift::keystone::dispersion' do
) } ) }
it { is_expected.to contain_keystone_user_role('bar@dummyTenant') } it { is_expected.to contain_keystone_user_role('bar@dummyTenant') }
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 'swift::keystone::dispersion'
end
end
end end

View File

@@ -29,7 +29,7 @@ describe 'swift::objectexpirer' do
'class { "memcached": max_memory => 1 }' 'class { "memcached": max_memory => 1 }'
end end
shared_examples_for 'swift-object-expirer' do shared_examples 'swift::object::expirer' do
let (:p) { default_params.merge!(params) } let (:p) { default_params.merge!(params) }
context 'with defaults' do context 'with defaults' do
@@ -103,7 +103,6 @@ describe 'swift::objectexpirer' do
platform_params.merge!({ :service_provider => 'swiftinit' }) platform_params.merge!({ :service_provider => 'swiftinit' })
end end
end end
end end
on_supported_os({ on_supported_os({
@@ -125,7 +124,7 @@ describe 'swift::objectexpirer' do
end end
end end
it_configures 'swift-object-expirer' it_configures 'swift::object::expirer'
end end
end end

View File

@@ -21,8 +21,19 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::account_quotas' do describe 'swift::proxy::account_quotas' do
shared_examples 'swift::proxy::account_quotas' do
it { should contain_swift_proxy_config('filter:account_quotas/use').with_value('egg:swift#account_quotas') }
end
it do on_supported_os({
is_expected.to contain_swift_proxy_config('filter:account_quotas/use').with_value('egg:swift#account_quotas') :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 'swift::proxy::account_quotas'
end
end end
end end

View File

@@ -1,11 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::authtoken' do describe 'swift::proxy::authtoken' do
shared_examples 'swift::proxy::authtoken' do
let :facts do
{}
end
describe 'when using the default signing directory' do describe 'when using the default signing directory' do
let :file_defaults do let :file_defaults do
{ {
@@ -14,6 +10,7 @@ describe 'swift::proxy::authtoken' do
:group => 'swift', :group => 'swift',
} }
end end
it {is_expected.to contain_file('/var/cache/swift').with( it {is_expected.to contain_file('/var/cache/swift').with(
{:ensure => 'directory', {:ensure => 'directory',
:selinux_ignore_defaults => true}.merge(file_defaults) :selinux_ignore_defaults => true}.merge(file_defaults)
@@ -35,10 +32,8 @@ describe 'swift::proxy::authtoken' do
it { is_expected.to contain_swift_proxy_config('filter:authtoken/delay_auth_decision').with_value('1') } it { is_expected.to contain_swift_proxy_config('filter:authtoken/delay_auth_decision').with_value('1') }
it { is_expected.to contain_swift_proxy_config('filter:authtoken/cache').with_value('swift.cache') } it { is_expected.to contain_swift_proxy_config('filter:authtoken/cache').with_value('swift.cache') }
it { is_expected.to contain_swift_proxy_config('filter:authtoken/include_service_catalog').with_value('false') } it { is_expected.to contain_swift_proxy_config('filter:authtoken/include_service_catalog').with_value('false') }
end end
describe "when overriding parameters" do describe "when overriding parameters" do
let :params do let :params do
{ {
@@ -65,7 +60,6 @@ describe 'swift::proxy::authtoken' do
it { is_expected.to contain_swift_proxy_config('filter:authtoken/delay_auth_decision').with_value('0') } it { is_expected.to contain_swift_proxy_config('filter:authtoken/delay_auth_decision').with_value('0') }
it { is_expected.to contain_swift_proxy_config('filter:authtoken/cache').with_value('foo') } it { is_expected.to contain_swift_proxy_config('filter:authtoken/cache').with_value('foo') }
it { is_expected.to contain_swift_proxy_config('filter:authtoken/include_service_catalog').with_value('false') } it { is_expected.to contain_swift_proxy_config('filter:authtoken/include_service_catalog').with_value('false') }
end end
describe 'when overriding auth_uri' do describe 'when overriding auth_uri' do
@@ -97,5 +91,17 @@ describe 'swift::proxy::authtoken' do
it { is_expected.to contain_swift_proxy_config('filter:authtoken/www_authenticate_uri').with_value('https://foo.bar:5000/v2.0/') } it { is_expected.to contain_swift_proxy_config('filter:authtoken/www_authenticate_uri').with_value('https://foo.bar:5000/v2.0/') }
it { is_expected.to contain_swift_proxy_config('filter:authtoken/auth_url').with_value('https://foo.bar:35357/') } it { is_expected.to contain_swift_proxy_config('filter:authtoken/auth_url').with_value('https://foo.bar:35357/') }
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 'swift::proxy::authtoken'
end
end
end end

View File

@@ -21,7 +21,7 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::bulk' do describe 'swift::proxy::bulk' do
shared_examples 'swift::proxy::bulk' do
describe "when using default parameters" do describe "when using default parameters" do
it { is_expected.to contain_swift_proxy_config('filter:bulk/use').with_value('egg:swift#bulk') } it { is_expected.to contain_swift_proxy_config('filter:bulk/use').with_value('egg:swift#bulk') }
it { is_expected.to contain_swift_proxy_config('filter:bulk/max_containers_per_extraction').with_value('10000') } it { is_expected.to contain_swift_proxy_config('filter:bulk/max_containers_per_extraction').with_value('10000') }
@@ -46,5 +46,17 @@ describe 'swift::proxy::bulk' do
it { is_expected.to contain_swift_proxy_config('filter:bulk/max_deletes_per_request').with_value('5000') } it { is_expected.to contain_swift_proxy_config('filter:bulk/max_deletes_per_request').with_value('5000') }
it { is_expected.to contain_swift_proxy_config('filter:bulk/yield_frequency').with_value('10') } it { is_expected.to contain_swift_proxy_config('filter:bulk/yield_frequency').with_value('10') }
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 'swift::proxy::bulk'
end
end
end end

View File

@@ -1,16 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::cache' do describe 'swift::proxy::cache' do
shared_examples 'swift::proxy::cache' do
let :facts do
{
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:os_workers => 1,
:processorcount => 1,
}
end
describe 'with defaults' do describe 'with defaults' do
let :pre_condition do let :pre_condition do
'class { "memcached": max_memory => 1 }' 'class { "memcached": max_memory => 1 }'
@@ -20,6 +11,7 @@ describe 'swift::proxy::cache' do
is_expected.to contain_class('swift::deps') is_expected.to contain_class('swift::deps')
is_expected.to contain_class('swift::proxy::cache') is_expected.to contain_class('swift::proxy::cache')
end end
it { is_expected.to contain_swift_proxy_config('filter:cache/use').with_value('egg:swift#memcache') } it { is_expected.to contain_swift_proxy_config('filter:cache/use').with_value('egg:swift#memcache') }
it { is_expected.to contain_swift_proxy_config('filter:cache/memcache_servers').with_value('127.0.0.1:11211') } it { is_expected.to contain_swift_proxy_config('filter:cache/memcache_servers').with_value('127.0.0.1:11211') }
end end
@@ -47,5 +39,17 @@ describe 'swift::proxy::cache' do
it { is_expected.to contain_swift_proxy_config('filter:cache/use').with_value('egg:swift#memcache') } it { is_expected.to contain_swift_proxy_config('filter:cache/use').with_value('egg:swift#memcache') }
it { is_expected.to contain_swift_proxy_config('filter:cache/memcache_servers').with_value('10.0.0.1:1,10.0.0.2:2') } it { is_expected.to contain_swift_proxy_config('filter:cache/memcache_servers').with_value('10.0.0.1:1,10.0.0.2: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 'swift::proxy::cache'
end
end
end end

View File

@@ -1,11 +1,19 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::catch_errors' do describe 'swift::proxy::catch_errors' do
shared_examples 'swift::proxy::catch_errors' do
let :facts do it { should contain_swift_proxy_config('filter:catch_errors/use').with_value('egg:swift#catch_errors') }
{}
end end
it { is_expected.to contain_swift_proxy_config('filter:catch_errors/use').with_value('egg:swift#catch_errors') } 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 'swift::proxy::catch_errors'
end
end
end end

View File

@@ -8,8 +8,7 @@ describe 'swift::proxy::ceilometer' do
}' }'
end end
shared_examples 'swift-proxy-ceilometer' do shared_examples 'swift::proxy::ceilometer' do
describe "when using default parameters" do describe "when using default parameters" do
it { is_expected.to contain_swift_proxy_config('filter:ceilometer/paste.filter_factory').with_value('ceilometermiddleware.swift:filter_factory') } it { is_expected.to contain_swift_proxy_config('filter:ceilometer/paste.filter_factory').with_value('ceilometermiddleware.swift:filter_factory') }
it { is_expected.to contain_swift_proxy_config('filter:ceilometer/url').with_value('rabbit://guest:guest@127.0.0.1:5672//') } it { is_expected.to contain_swift_proxy_config('filter:ceilometer/url').with_value('rabbit://guest:guest@127.0.0.1:5672//') }
@@ -122,7 +121,7 @@ describe 'swift::proxy::ceilometer' do
let (:facts) do let (:facts) do
facts.merge!(OSDefaults.get_facts()) facts.merge!(OSDefaults.get_facts())
end end
it_behaves_like 'swift-proxy-ceilometer' it_behaves_like 'swift::proxy::ceilometer'
end end
end end

View File

@@ -21,11 +21,19 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::container_quotas' do describe 'swift::proxy::container_quotas' do
shared_examples 'swift::proxy::container_quotas' do
let :facts do it { should contain_swift_proxy_config('filter:container_quotas/use').with_value('egg:swift#container_quotas') }
{}
end end
it { is_expected.to contain_swift_proxy_config('filter:container_quotas/use').with_value('egg:swift#container_quotas') } 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 'swift::proxy::container_quotas'
end
end
end end

View File

@@ -6,11 +6,19 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::container_sync' do describe 'swift::proxy::container_sync' do
shared_examples 'swift::proxy::container_sync' do
let :facts do it { should contain_swift_proxy_config('filter:container_sync/use').with_value('egg:swift#container_sync') }
{}
end end
it { is_expected.to contain_swift_proxy_config('filter:container_sync/use').with_value('egg:swift#container_sync') } 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 'swift::proxy::container_sync'
end
end
end end

View File

@@ -1,15 +1,10 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::copy' do describe 'swift::proxy::copy' do
shared_examples 'swift::proxy::copy' do
let :facts do
{}
end
describe "when using default parameters" do describe "when using default parameters" do
it { is_expected.to contain_swift_proxy_config('filter:copy/use').with_value('egg:swift#copy') } it { is_expected.to contain_swift_proxy_config('filter:copy/use').with_value('egg:swift#copy') }
it { is_expected.to contain_swift_proxy_config('filter:copy/object_post_as_copy').with_value('true') } it { is_expected.to contain_swift_proxy_config('filter:copy/object_post_as_copy').with_value('true') }
end end
describe "when overriding default parameters" do describe "when overriding default parameters" do
@@ -18,7 +13,20 @@ describe 'swift::proxy::copy' do
:object_post_as_copy => false, :object_post_as_copy => false,
} }
end end
it { is_expected.to contain_swift_proxy_config('filter:copy/object_post_as_copy').with_value('false') } it { is_expected.to contain_swift_proxy_config('filter:copy/object_post_as_copy').with_value('false') }
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 'swift::proxy::copy'
end
end
end end

View File

@@ -1,11 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::crossdomain' do describe 'swift::proxy::crossdomain' do
shared_examples 'swift::proxy::crossdomain' do
let :facts do
{}
end
describe "when using default parameters" do describe "when using default parameters" do
it { is_expected.to contain_swift_proxy_config('filter:crossdomain/use').with_value('egg:swift#crossdomain') } it { is_expected.to contain_swift_proxy_config('filter:crossdomain/use').with_value('egg:swift#crossdomain') }
it { is_expected.to contain_swift_proxy_config('filter:crossdomain/cross_domain_policy').with_value('<allow-access-from domain="*" secure="false" />') } it { is_expected.to contain_swift_proxy_config('filter:crossdomain/cross_domain_policy').with_value('<allow-access-from domain="*" secure="false" />') }
@@ -17,9 +13,21 @@ describe 'swift::proxy::crossdomain' do
:cross_domain_policy => '<allow-access-from domain="xml-fragment-in-ini-file.so.wrong" secure="true" /><allow-access-from domain="*" secure="false" />', :cross_domain_policy => '<allow-access-from domain="xml-fragment-in-ini-file.so.wrong" secure="true" /><allow-access-from domain="*" secure="false" />',
} }
end end
it { is_expected.to contain_swift_proxy_config('filter:crossdomain/use').with_value('egg:swift#crossdomain') } it { is_expected.to contain_swift_proxy_config('filter:crossdomain/use').with_value('egg:swift#crossdomain') }
it { is_expected.to contain_swift_proxy_config('filter:crossdomain/cross_domain_policy').with_value('<allow-access-from domain="xml-fragment-in-ini-file.so.wrong" secure="true" /><allow-access-from domain="*" secure="false" />') } it { is_expected.to contain_swift_proxy_config('filter:crossdomain/cross_domain_policy').with_value('<allow-access-from domain="xml-fragment-in-ini-file.so.wrong" secure="true" /><allow-access-from domain="*" secure="false" />') }
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 'swift::proxy::crossdomain'
end
end
end end

View File

@@ -1,11 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::dlo' do describe 'swift::proxy::dlo' do
shared_examples 'swift::proxy::dlo' do
let :facts do
{}
end
describe "when using default parameters" do describe "when using default parameters" do
it { is_expected.to contain_swift_proxy_config('filter:dlo/use').with_value('egg:swift#dlo') } it { is_expected.to contain_swift_proxy_config('filter:dlo/use').with_value('egg:swift#dlo') }
it { is_expected.to contain_swift_proxy_config('filter:dlo/rate_limit_after_segment').with_value('10') } it { is_expected.to contain_swift_proxy_config('filter:dlo/rate_limit_after_segment').with_value('10') }
@@ -21,9 +17,22 @@ describe 'swift::proxy::dlo' do
:max_get_time => '6400', :max_get_time => '6400',
} }
end end
it { is_expected.to contain_swift_proxy_config('filter:dlo/rate_limit_after_segment').with_value('30') } it { is_expected.to contain_swift_proxy_config('filter:dlo/rate_limit_after_segment').with_value('30') }
it { is_expected.to contain_swift_proxy_config('filter:dlo/rate_limit_segments_per_sec').with_value('5') } it { is_expected.to contain_swift_proxy_config('filter:dlo/rate_limit_segments_per_sec').with_value('5') }
it { is_expected.to contain_swift_proxy_config('filter:dlo/max_get_time').with_value('6400') } it { is_expected.to contain_swift_proxy_config('filter:dlo/max_get_time').with_value('6400') }
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 'swift::proxy::dlo'
end
end
end end

View File

@@ -1,15 +1,10 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::encryption' do describe 'swift::proxy::encryption' do
shared_examples 'swift::proxy::encryption' do
let :facts do
{}
end
describe "when using default parameters" do describe "when using default parameters" do
it { is_expected.to contain_swift_proxy_config('filter:encryption/use').with_value('egg:swift#encryption') } it { is_expected.to contain_swift_proxy_config('filter:encryption/use').with_value('egg:swift#encryption') }
it { is_expected.to contain_swift_proxy_config('filter:encryption/disable_encryption').with_value('false') } it { is_expected.to contain_swift_proxy_config('filter:encryption/disable_encryption').with_value('false') }
end end
describe "when overriding default parameters" do describe "when overriding default parameters" do
@@ -18,7 +13,20 @@ describe 'swift::proxy::encryption' do
:disable_encryption => true, :disable_encryption => true,
} }
end end
it { is_expected.to contain_swift_proxy_config('filter:encryption/disable_encryption').with_value('true') } it { is_expected.to contain_swift_proxy_config('filter:encryption/disable_encryption').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
it_configures 'swift::proxy::encryption'
end
end
end end

View File

@@ -1,11 +1,19 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::formpost' do describe 'swift::proxy::formpost' do
shared_examples 'swift::proxy::formpost' do
let :facts do it { should contain_swift_proxy_config('filter:formpost/use').with_value('egg:swift#formpost') }
{}
end end
it { is_expected.to contain_swift_proxy_config('filter:formpost/use').with_value('egg:swift#formpost') } 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 'swift::proxy::formpost'
end
end
end end

View File

@@ -1,11 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::gatekeeper' do describe 'swift::proxy::gatekeeper' do
shared_examples 'swift::proxy::gatekeeper' do
let :facts do
{}
end
describe "when using default parameters" do describe "when using default parameters" do
it { is_expected.to contain_swift_proxy_config('filter:gatekeeper/use').with_value('egg:swift#gatekeeper') } it { is_expected.to contain_swift_proxy_config('filter:gatekeeper/use').with_value('egg:swift#gatekeeper') }
it { is_expected.to contain_swift_proxy_config('filter:gatekeeper/set log_name').with_value('gatekeeper') } it { is_expected.to contain_swift_proxy_config('filter:gatekeeper/set log_name').with_value('gatekeeper') }
@@ -23,9 +19,22 @@ describe 'swift::proxy::gatekeeper' do
:log_level => 'WARN', :log_level => 'WARN',
} }
end end
it { is_expected.to contain_swift_proxy_config('filter:gatekeeper/set log_name').with_value('newgatekeeper') } it { is_expected.to contain_swift_proxy_config('filter:gatekeeper/set log_name').with_value('newgatekeeper') }
it { is_expected.to contain_swift_proxy_config('filter:gatekeeper/set log_facility').with_value('LOG_LOCAL3') } it { is_expected.to contain_swift_proxy_config('filter:gatekeeper/set log_facility').with_value('LOG_LOCAL3') }
it { is_expected.to contain_swift_proxy_config('filter:gatekeeper/set log_level').with_value('WARN') } it { is_expected.to contain_swift_proxy_config('filter:gatekeeper/set log_level').with_value('WARN') }
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 'swift::proxy::gatekeeper'
end
end
end end

View File

@@ -1,11 +1,19 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::healthcheck' do describe 'swift::proxy::healthcheck' do
shared_examples 'swift::proxy::healthcheck' do
let :facts do it { should contain_swift_proxy_config('filter:healthcheck/use').with_value('egg:swift#healthcheck') }
{}
end end
it { is_expected.to contain_swift_proxy_config('filter:healthcheck/use').with_value('egg:swift#healthcheck') } 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 'swift::proxy::healthcheck'
end
end
end end

View File

@@ -1,22 +1,15 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::keystone' do describe 'swift::proxy::keystone' do
shared_examples 'swift::proxy::keystone' do
let :facts do
{}
end
it { is_expected.to contain_swift_proxy_config('filter:keystone/use').with_value('egg:swift#keystoneauth') } it { is_expected.to contain_swift_proxy_config('filter:keystone/use').with_value('egg:swift#keystoneauth') }
describe 'with defaults' do describe 'with defaults' do
it { is_expected.to contain_swift_proxy_config('filter:keystone/operator_roles').with_value('admin, SwiftOperator') } it { is_expected.to contain_swift_proxy_config('filter:keystone/operator_roles').with_value('admin, SwiftOperator') }
it { is_expected.to contain_swift_proxy_config('filter:keystone/reseller_prefix').with_value('AUTH_') } it { is_expected.to contain_swift_proxy_config('filter:keystone/reseller_prefix').with_value('AUTH_') }
end end
describe 'with parameter overrides' do describe 'with parameter overrides' do
let :params do let :params do
{ {
:operator_roles => 'foo', :operator_roles => 'foo',
@@ -27,9 +20,19 @@ describe 'swift::proxy::keystone' do
it { is_expected.to contain_swift_proxy_config('filter:keystone/operator_roles').with_value('foo') } it { is_expected.to contain_swift_proxy_config('filter:keystone/operator_roles').with_value('foo') }
it { is_expected.to contain_swift_proxy_config('filter:keystone/reseller_prefix').with_value('SWIFT_') } it { is_expected.to contain_swift_proxy_config('filter:keystone/reseller_prefix').with_value('SWIFT_') }
it { is_expected.to contain_swift_proxy_config('filter:keystone/reseller_admin_role').with_value('ResellerAdmin') } it { is_expected.to contain_swift_proxy_config('filter:keystone/reseller_admin_role').with_value('ResellerAdmin') }
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 end
it_configures 'swift::proxy::keystone'
end
end
end end

View File

@@ -1,15 +1,10 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::kms_keymaster' do describe 'swift::proxy::kms_keymaster' do
shared_examples 'swift::proxy::kms_keymaster' do
let :facts do
{}
end
describe "when using default parameters" do describe "when using default parameters" do
it { is_expected.to contain_swift_proxy_config('filter:kms_keymaster/use').with_value('egg:swift#kms_keymaster') } it { should contain_swift_proxy_config('filter:kms_keymaster/use').with_value('egg:swift#kms_keymaster') }
it { is_expected.to contain_swift_proxy_config('filter:kms_keymaster/keymaster_config_path').with_value('/etc/swift/keymaster.conf') } it { should contain_swift_proxy_config('filter:kms_keymaster/keymaster_config_path').with_value('/etc/swift/keymaster.conf') }
end end
describe "when overriding default parameters" do describe "when overriding default parameters" do
@@ -18,7 +13,20 @@ describe 'swift::proxy::kms_keymaster' do
:keymaster_config_path => '/tmp/keymaster.conf', :keymaster_config_path => '/tmp/keymaster.conf',
} }
end end
it { is_expected.to contain_swift_proxy_config('filter:kms_keymaster/keymaster_config_path').with_value('/tmp/keymaster.conf') }
it { should contain_swift_proxy_config('filter:kms_keymaster/keymaster_config_path').with_value('/tmp/keymaster.conf') }
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 'swift::proxy::kms_keymaster'
end
end
end end

View File

@@ -1,11 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::ratelimit' do describe 'swift::proxy::ratelimit' do
shared_examples 'swift::proxy::ratelimit' do
let :facts do
{}
end
describe "when using default parameters" do describe "when using default parameters" do
it { is_expected.to contain_swift_proxy_config('filter:ratelimit/use').with_value('egg:swift#ratelimit') } it { is_expected.to contain_swift_proxy_config('filter:ratelimit/use').with_value('egg:swift#ratelimit') }
it { is_expected.to contain_swift_proxy_config('filter:ratelimit/clock_accuracy').with_value('1000') } it { is_expected.to contain_swift_proxy_config('filter:ratelimit/clock_accuracy').with_value('1000') }
@@ -25,11 +21,24 @@ describe 'swift::proxy::ratelimit' do
:account_ratelimit => 69 :account_ratelimit => 69
} }
end end
it { is_expected.to contain_swift_proxy_config('filter:ratelimit/clock_accuracy').with_value('9436') } it { is_expected.to contain_swift_proxy_config('filter:ratelimit/clock_accuracy').with_value('9436') }
it { is_expected.to contain_swift_proxy_config('filter:ratelimit/max_sleep_time_seconds').with_value('3600') } it { is_expected.to contain_swift_proxy_config('filter:ratelimit/max_sleep_time_seconds').with_value('3600') }
it { is_expected.to contain_swift_proxy_config('filter:ratelimit/log_sleep_time_seconds').with_value('42') } it { is_expected.to contain_swift_proxy_config('filter:ratelimit/log_sleep_time_seconds').with_value('42') }
it { is_expected.to contain_swift_proxy_config('filter:ratelimit/rate_buffer_seconds').with_value('51') } it { is_expected.to contain_swift_proxy_config('filter:ratelimit/rate_buffer_seconds').with_value('51') }
it { is_expected.to contain_swift_proxy_config('filter:ratelimit/account_ratelimit').with_value('69') } it { is_expected.to contain_swift_proxy_config('filter:ratelimit/account_ratelimit').with_value('69') }
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 'swift::proxy::ratelimit'
end
end
end end

View File

@@ -1,15 +1,20 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::s3api' do describe 'swift::proxy::s3api' do
shared_examples 'swift::proxy::s3api' do
let :facts do
OSDefaults.get_facts({
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
})
end
it { is_expected.to contain_swift_proxy_config('filter:s3api/use').with_value('egg:swift#s3api') } it { is_expected.to contain_swift_proxy_config('filter:s3api/use').with_value('egg:swift#s3api') }
it { is_expected.to contain_swift_proxy_config('filter:s3api/auth_pipeline_check').with_value('false') } it { is_expected.to contain_swift_proxy_config('filter:s3api/auth_pipeline_check').with_value('false') }
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 'swift::proxy::s3api'
end
end
end end

View File

@@ -1,11 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::s3token' do describe 'swift::proxy::s3token' do
shared_examples 'swift::proxy::s3token' do
let :facts do
{}
end
describe "when using default parameters" do describe "when using default parameters" do
it { is_expected.to contain_swift_proxy_config('filter:s3token/use').with_value('egg:swift#s3token') } it { is_expected.to contain_swift_proxy_config('filter:s3token/use').with_value('egg:swift#s3token') }
it { is_expected.to contain_swift_proxy_config('filter:s3token/auth_uri').with_value('http://127.0.0.1:35357') } it { is_expected.to contain_swift_proxy_config('filter:s3token/auth_uri').with_value('http://127.0.0.1:35357') }
@@ -19,6 +15,7 @@ describe 'swift::proxy::s3token' do
:auth_port => '3452' :auth_port => '3452'
} }
end end
it { is_expected.to contain_swift_proxy_config('filter:s3token/auth_uri').with_value('https://192.168.4.2:3452') } it { is_expected.to contain_swift_proxy_config('filter:s3token/auth_uri').with_value('https://192.168.4.2:3452') }
end end
@@ -28,7 +25,20 @@ describe 'swift::proxy::s3token' do
:auth_uri => 'http://192.168.24.11:35357' :auth_uri => 'http://192.168.24.11:35357'
} }
end end
it { is_expected.to contain_swift_proxy_config('filter:s3token/auth_uri').with_value('http://192.168.24.11:35357') } it { is_expected.to contain_swift_proxy_config('filter:s3token/auth_uri').with_value('http://192.168.24.11:35357') }
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 'swift::proxy::s3token'
end
end
end end

View File

@@ -1,11 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::slo' do describe 'swift::proxy::slo' do
shared_examples 'swift::proxy::slo' do
let :facts do
{}
end
describe "when using default parameters" do describe "when using default parameters" do
it { is_expected.to contain_swift_proxy_config('filter:slo/use').with_value('egg:swift#slo') } it { is_expected.to contain_swift_proxy_config('filter:slo/use').with_value('egg:swift#slo') }
it { is_expected.to contain_swift_proxy_config('filter:slo/max_manifest_segments').with_value('1000') } it { is_expected.to contain_swift_proxy_config('filter:slo/max_manifest_segments').with_value('1000') }
@@ -25,10 +21,23 @@ describe 'swift::proxy::slo' do
:max_get_time => '6400', :max_get_time => '6400',
} }
end end
it { is_expected.to contain_swift_proxy_config('filter:slo/max_manifest_segments').with_value('2000') } it { is_expected.to contain_swift_proxy_config('filter:slo/max_manifest_segments').with_value('2000') }
it { is_expected.to contain_swift_proxy_config('filter:slo/max_manifest_size').with_value('500000') } it { is_expected.to contain_swift_proxy_config('filter:slo/max_manifest_size').with_value('500000') }
it { is_expected.to contain_swift_proxy_config('filter:slo/rate_limit_after_segment').with_value('30') } it { is_expected.to contain_swift_proxy_config('filter:slo/rate_limit_after_segment').with_value('30') }
it { is_expected.to contain_swift_proxy_config('filter:slo/max_get_time').with_value('6400') } it { is_expected.to contain_swift_proxy_config('filter:slo/max_get_time').with_value('6400') }
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 'swift::proxy::slo'
end
end
end end

View File

@@ -1,25 +1,12 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy' do describe 'swift::proxy' do
shared_examples 'swift::proxy' do
describe 'without memcached being included' do describe 'without memcached being included' do
it 'should raise an error' do it { should raise_error(Puppet::Error) }
expect { catalogue }.to raise_error(Puppet::Error)
end
end
# set os so memcache will not fail
let :facts do
OSDefaults.get_facts({
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:os_workers => 1,
:processorcount => 1,
})
end end
describe 'with proper dependencies' do describe 'with proper dependencies' do
let :pre_condition do let :pre_condition do
"class { memcached: max_memory => 1} "class { memcached: max_memory => 1}
class { swift: swift_hash_path_suffix => string } class { swift: swift_hash_path_suffix => string }
@@ -28,7 +15,6 @@ describe 'swift::proxy' do
include ::swift::proxy::tempauth" include ::swift::proxy::tempauth"
end end
describe 'without the proxy local network ip address being specified' do describe 'without the proxy local network ip address being specified' do
if Puppet::Util::Package.versioncmp(Puppet.version, '4.3.0') >= 0 if Puppet::Util::Package.versioncmp(Puppet.version, '4.3.0') >= 0
it_raises 'a Puppet::Error', /expects a value for parameter 'proxy_local_net_ip'/ it_raises 'a Puppet::Error', /expects a value for parameter 'proxy_local_net_ip'/
@@ -38,59 +24,53 @@ describe 'swift::proxy' do
end end
describe 'when proxy_local_net_ip is set' do describe 'when proxy_local_net_ip is set' do
let :params do let :params do
{:proxy_local_net_ip => '127.0.0.1'} {
:proxy_local_net_ip => '127.0.0.1'
}
end end
it { should contain_resources('swift_proxy_config').with(
it 'passes purge to swift_proxy_config resource' do
is_expected.to contain_resources('swift_proxy_config').with({
:purge => false :purge => false
}) )}
end
it { is_expected.to contain_package('swift-proxy').that_requires('Anchor[swift::install::begin]') it { should contain_package('swift-proxy').that_requires('Anchor[swift::install::begin]') }
is_expected.to contain_package('swift-proxy').that_notifies('Anchor[swift::install::end]') } it { should contain_package('swift-proxy').that_notifies('Anchor[swift::install::end]') }
it { is_expected.to contain_service('swift-proxy-server').with( it { should contain_service('swift-proxy-server').with(
{:ensure => 'running', :ensure => 'running',
:provider => nil, :provider => nil,
:enable => true, :enable => true,
:hasstatus => true, :hasstatus => true,
:tag => 'swift-service', :tag => 'swift-service',
}
)} )}
it { is_expected.to contain_service('swift-proxy-server').that_subscribes_to('Anchor[swift::service::begin]')} it { should contain_service('swift-proxy-server').that_subscribes_to('Anchor[swift::service::begin]') }
it { is_expected.to contain_service('swift-proxy-server').that_notifies('Anchor[swift::service::end]')} it { should contain_service('swift-proxy-server').that_notifies('Anchor[swift::service::end]') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/bind_port').with_value('8080')} it { should contain_swift_proxy_config('DEFAULT/bind_port').with_value('8080') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/bind_ip').with_value('127.0.0.1')} it { should contain_swift_proxy_config('DEFAULT/bind_ip').with_value('127.0.0.1') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/workers').with_value('1')} it { should contain_swift_proxy_config('DEFAULT/workers').with_value('2') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/user').with_value('swift')} it { should contain_swift_proxy_config('DEFAULT/user').with_value('swift') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/log_name').with_value('proxy-server')} it { should contain_swift_proxy_config('DEFAULT/log_name').with_value('proxy-server') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/log_facility').with_value('LOG_LOCAL2')} it { should contain_swift_proxy_config('DEFAULT/log_facility').with_value('LOG_LOCAL2') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/log_level').with_value('INFO')} it { should contain_swift_proxy_config('DEFAULT/log_level').with_value('INFO') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/log_headers').with_value('False')} it { should contain_swift_proxy_config('DEFAULT/log_headers').with_value('False') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/log_address').with_value('/dev/log')} it { should contain_swift_proxy_config('DEFAULT/log_address').with_value('/dev/log') }
it { is_expected.to contain_swift_proxy_config('pipeline:main/pipeline').with_value('healthcheck cache tempauth proxy-server')} it { should contain_swift_proxy_config('pipeline:main/pipeline').with_value('healthcheck cache tempauth proxy-server') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/use').with_value('egg:swift#proxy')} it { should contain_swift_proxy_config('app:proxy-server/use').with_value('egg:swift#proxy') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/set log_name').with_value('proxy-server')} it { should contain_swift_proxy_config('app:proxy-server/set log_name').with_value('proxy-server') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/set log_facility').with_value('LOG_LOCAL2')} it { should contain_swift_proxy_config('app:proxy-server/set log_facility').with_value('LOG_LOCAL2') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/set log_level').with_value('INFO')} it { should contain_swift_proxy_config('app:proxy-server/set log_level').with_value('INFO') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/set log_address').with_value('/dev/log')} it { should contain_swift_proxy_config('app:proxy-server/set log_address').with_value('/dev/log') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/log_handoffs').with_value('true')} it { should contain_swift_proxy_config('app:proxy-server/log_handoffs').with_value('true') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/allow_account_management').with_value('true')} it { should contain_swift_proxy_config('app:proxy-server/allow_account_management').with_value('true') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/account_autocreate').with_value('true')} it { should contain_swift_proxy_config('app:proxy-server/account_autocreate').with_value('true') }
it { should contain_service('swift-proxy-server').with_require([
it { is_expected.to contain_service('swift-proxy-server').with_require(
[
'Class[Swift::Proxy::Healthcheck]', 'Class[Swift::Proxy::Healthcheck]',
'Class[Swift::Proxy::Cache]', 'Class[Swift::Proxy::Cache]',
'Class[Swift::Proxy::Tempauth]' 'Class[Swift::Proxy::Tempauth]',
] ])}
)}
describe "when using swift_proxy_config resource" do describe "when using swift_proxy_config resource" do
let :pre_condition do let :pre_condition do
@@ -103,7 +83,8 @@ describe 'swift::proxy' do
include ::swift::proxy::tempauth include ::swift::proxy::tempauth
" "
end end
it { is_expected.to contain_swift_proxy_config('foo/bar').with_value('foo').that_notifies('Anchor[swift::config::end]')}
it { should contain_swift_proxy_config('foo/bar').with_value('foo').that_notifies('Anchor[swift::config::end]') }
end end
describe 'when more parameters are set' do describe 'when more parameters are set' do
@@ -130,32 +111,34 @@ describe 'swift::proxy' do
:cors_allow_origin => 'http://foo.bar:1234,https://foo.bar', :cors_allow_origin => 'http://foo.bar:1234,https://foo.bar',
} }
end end
it { is_expected.to contain_swift_proxy_config('DEFAULT/bind_port').with_value('80')}
it { is_expected.to contain_swift_proxy_config('DEFAULT/bind_ip').with_value('10.0.0.2')} it { should contain_swift_proxy_config('DEFAULT/bind_port').with_value('80') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/workers').with_value('3')} it { should contain_swift_proxy_config('DEFAULT/bind_ip').with_value('10.0.0.2') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/user').with_value('swift')} it { should contain_swift_proxy_config('DEFAULT/workers').with_value('3') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/log_name').with_value('swift-proxy-server')} it { should contain_swift_proxy_config('DEFAULT/user').with_value('swift') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/log_facility').with_value('LOG_LOCAL2')} it { should contain_swift_proxy_config('DEFAULT/log_name').with_value('swift-proxy-server') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/log_level').with_value('DEBUG')} it { should contain_swift_proxy_config('DEFAULT/log_facility').with_value('LOG_LOCAL2') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/log_headers').with_value('False')} it { should contain_swift_proxy_config('DEFAULT/log_level').with_value('DEBUG') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/log_address').with_value('/dev/log')} it { should contain_swift_proxy_config('DEFAULT/log_headers').with_value('False') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/cors_allow_origin').with_value('http://foo.bar:1234,https://foo.bar')} it { should contain_swift_proxy_config('DEFAULT/log_address').with_value('/dev/log') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/strict_cors_mode').with_value('true')} it { should contain_swift_proxy_config('DEFAULT/cors_allow_origin').with_value('http://foo.bar:1234,https://foo.bar') }
it { is_expected.to contain_swift_proxy_config('pipeline:main/pipeline').with_value('swauth proxy-server')} it { should contain_swift_proxy_config('DEFAULT/strict_cors_mode').with_value('true') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/use').with_value('egg:swift#proxy')} it { should contain_swift_proxy_config('pipeline:main/pipeline').with_value('swauth proxy-server') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/set log_name').with_value('swift-proxy-server')} it { should contain_swift_proxy_config('app:proxy-server/use').with_value('egg:swift#proxy') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/set log_facility').with_value('LOG_LOCAL2')} it { should contain_swift_proxy_config('app:proxy-server/set log_name').with_value('swift-proxy-server') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/set log_level').with_value('DEBUG')} it { should contain_swift_proxy_config('app:proxy-server/set log_facility').with_value('LOG_LOCAL2') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/set log_address').with_value('/dev/log')} it { should contain_swift_proxy_config('app:proxy-server/set log_level').with_value('DEBUG') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/log_handoffs').with_value('true')} it { should contain_swift_proxy_config('app:proxy-server/set log_address').with_value('/dev/log') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/allow_account_management').with_value('false')} it { should contain_swift_proxy_config('app:proxy-server/log_handoffs').with_value('true') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/account_autocreate').with_value('false')} it { should contain_swift_proxy_config('app:proxy-server/allow_account_management').with_value('false') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/sorting_method').with_value('affinity')} it { should contain_swift_proxy_config('app:proxy-server/account_autocreate').with_value('false') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/read_affinity').with_value('r1z1=100, r1=200')} it { should contain_swift_proxy_config('app:proxy-server/sorting_method').with_value('affinity') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/write_affinity').with_value('r1')} it { should contain_swift_proxy_config('app:proxy-server/read_affinity').with_value('r1z1=100, r1=200') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/write_affinity_node_count').with_value('2 * replicas')} it { should contain_swift_proxy_config('app:proxy-server/write_affinity').with_value('r1') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/node_timeout').with_value('20')} it { should contain_swift_proxy_config('app:proxy-server/write_affinity_node_count').with_value('2 * replicas') }
it { should contain_swift_proxy_config('app:proxy-server/node_timeout').with_value('20') }
end end
describe "when log udp port is set" do describe "when log udp port is set" do
context 'and log_udp_host is not set' do context 'and log_udp_host is not set' do
let :params do let :params do
@@ -176,8 +159,10 @@ describe 'swift::proxy' do
:cors_allow_origin => 'http://foo.bar:1234,https://foo.bar', :cors_allow_origin => 'http://foo.bar:1234,https://foo.bar',
} }
end end
it_raises 'a Puppet::Error', /log_udp_port requires log_udp_host to be set/ it_raises 'a Puppet::Error', /log_udp_port requires log_udp_host to be set/
end end
context 'and log_udp_host is set' do context 'and log_udp_host is set' do
let :params do let :params do
{ {
@@ -198,39 +183,40 @@ describe 'swift::proxy' do
:cors_allow_origin => 'http://foo.bar:1234,https://foo.bar', :cors_allow_origin => 'http://foo.bar:1234,https://foo.bar',
} }
end end
let :pre_condition do let :pre_condition do
"class { memcached: max_memory => 1} "class { memcached: max_memory => 1}
class { swift: swift_hash_path_suffix => string } class { swift: swift_hash_path_suffix => string }
include ::swift::proxy::swauth" include ::swift::proxy::swauth"
end end
it { is_expected.to contain_swift_proxy_config('DEFAULT/bind_port').with_value('80')} it { should contain_swift_proxy_config('DEFAULT/bind_port').with_value('80') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/bind_ip').with_value('10.0.0.2')} it { should contain_swift_proxy_config('DEFAULT/bind_ip').with_value('10.0.0.2') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/workers').with_value('3')} it { should contain_swift_proxy_config('DEFAULT/workers').with_value('3') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/user').with_value('swift')} it { should contain_swift_proxy_config('DEFAULT/user').with_value('swift') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/log_name').with_value('swift-proxy-server')} it { should contain_swift_proxy_config('DEFAULT/log_name').with_value('swift-proxy-server') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/log_facility').with_value('LOG_LOCAL2')} it { should contain_swift_proxy_config('DEFAULT/log_facility').with_value('LOG_LOCAL2') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/log_level').with_value('DEBUG')} it { should contain_swift_proxy_config('DEFAULT/log_level').with_value('DEBUG') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/log_headers').with_value('False')} it { should contain_swift_proxy_config('DEFAULT/log_headers').with_value('False') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/log_address').with_value('/dev/log')} it { should contain_swift_proxy_config('DEFAULT/log_address').with_value('/dev/log') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/log_udp_host').with_value('127.0.0.1')} it { should contain_swift_proxy_config('DEFAULT/log_udp_host').with_value('127.0.0.1') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/log_udp_port').with_value('514')} it { should contain_swift_proxy_config('DEFAULT/log_udp_port').with_value('514') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/cors_allow_origin').with_value('http://foo.bar:1234,https://foo.bar')} it { should contain_swift_proxy_config('DEFAULT/cors_allow_origin').with_value('http://foo.bar:1234,https://foo.bar') }
it { is_expected.to contain_swift_proxy_config('DEFAULT/strict_cors_mode').with_value('true')} it { should contain_swift_proxy_config('DEFAULT/strict_cors_mode').with_value('true') }
it { is_expected.to contain_swift_proxy_config('pipeline:main/pipeline').with_value('swauth proxy-server')} it { should contain_swift_proxy_config('pipeline:main/pipeline').with_value('swauth proxy-server') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/use').with_value('egg:swift#proxy')} it { should contain_swift_proxy_config('app:proxy-server/use').with_value('egg:swift#proxy') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/set log_name').with_value('swift-proxy-server')} it { should contain_swift_proxy_config('app:proxy-server/set log_name').with_value('swift-proxy-server') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/set log_facility').with_value('LOG_LOCAL2')} it { should contain_swift_proxy_config('app:proxy-server/set log_facility').with_value('LOG_LOCAL2') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/set log_level').with_value('DEBUG')} it { should contain_swift_proxy_config('app:proxy-server/set log_level').with_value('DEBUG') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/set log_address').with_value('/dev/log')} it { should contain_swift_proxy_config('app:proxy-server/set log_address').with_value('/dev/log') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/log_handoffs').with_value('true')} it { should contain_swift_proxy_config('app:proxy-server/log_handoffs').with_value('true') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/allow_account_management').with_value('false')} it { should contain_swift_proxy_config('app:proxy-server/allow_account_management').with_value('false') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/account_autocreate').with_value('false')} it { should contain_swift_proxy_config('app:proxy-server/account_autocreate').with_value('false') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/sorting_method').with_value('affinity')} it { should contain_swift_proxy_config('app:proxy-server/sorting_method').with_value('affinity') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/read_affinity').with_value('r1z1=100, r1=200')} it { should contain_swift_proxy_config('app:proxy-server/read_affinity').with_value('r1z1=100, r1=200') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/write_affinity').with_value('r1')} it { should contain_swift_proxy_config('app:proxy-server/write_affinity').with_value('r1') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/write_affinity_node_count').with_value('2 * replicas')} it { should contain_swift_proxy_config('app:proxy-server/write_affinity_node_count').with_value('2 * replicas') }
it { is_expected.to contain_swift_proxy_config('app:proxy-server/node_timeout').with_value('20')} it { should contain_swift_proxy_config('app:proxy-server/node_timeout').with_value('20') }
end end
end end
@@ -238,7 +224,7 @@ describe 'swift::proxy' do
[:account_autocreate, :allow_account_management].each do |param| [:account_autocreate, :allow_account_management].each do |param|
it "should fail when #{param} is not passed a boolean" do it "should fail when #{param} is not passed a boolean" do
params[param] = 'false' params[param] = 'false'
expect { catalogue }.to raise_error(Puppet::Error, /is not a boolean/) should raise_error(Puppet::Error, /is not a boolean/)
end end
end end
@@ -249,17 +235,21 @@ describe 'swift::proxy' do
} }
end end
it "should fail if write_affinity_node_count is used without write_affinity" do it 'should fail if write_affinity_node_count is used without write_affinity' do
expect { catalogue }.to raise_error(Puppet::Error, /write_affinity_node_count requires write_affinity/) should raise_error(Puppet::Error, /write_affinity_node_count requires write_affinity/)
end
end end
end end
end end
end end
shared_examples_for 'swift-proxy-server' do shared_examples 'swift::proxy server' do
let :params do let :params do
{ :proxy_local_net_ip => '127.0.0.1' } {
:proxy_local_net_ip => '127.0.0.1'
}
end end
let :pre_condition do let :pre_condition do
"class { memcached: max_memory => 1} "class { memcached: max_memory => 1}
class { swift: swift_hash_path_suffix => string } class { swift: swift_hash_path_suffix => string }
@@ -271,36 +261,37 @@ describe 'swift::proxy' do
[{ :enabled => true, :manage_service => true }, [{ :enabled => true, :manage_service => true },
{ :enabled => false, :manage_service => true }].each do |param_hash| { :enabled => false, :manage_service => true }].each do |param_hash|
context "when service is_expected.to be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
before do before do
params.merge!(param_hash) params.merge!(param_hash)
end end
it 'configures swift-proxy-server service' do it 'configures swift-proxy-server service' do
is_expected.to contain_service('swift-proxy-server').with( should contain_service('swift-proxy-server').with(
:name => platform_params['swift-proxy-server'], :name => platform_params['swift-proxy-server'],
:ensure => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running' : 'stopped', :ensure => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running' : 'stopped',
:enable => param_hash[:enabled], :enable => param_hash[:enabled],
:provider => platform_params['service_provider'], :provider => nil,
:tag => 'swift-service', :tag => 'swift-service',
) )
end end
end end
end end
context 'with disabled service managing' do context 'with disabled service managing and service provider' do
before do before do
params.merge!({ params.merge!({
:manage_service => false, :manage_service => false,
:enabled => false }) :enabled => false,
:service_provider => 'swiftinit',
})
end end
it 'configures swift-proxy-server service' do it 'configures swift-proxy-server service' do
should contain_service('swift-proxy-server').with(
is_expected.to contain_service('swift-proxy-server').with(
:ensure => nil, :ensure => nil,
:name => platform_params['swift-proxy-server'], :name => 'swift-proxy-server',
:provider => platform_params['service_provider'], :provider => 'swiftinit',
:enable => false, :enable => false,
:hasstatus => true, :hasstatus => true,
) )
@@ -308,63 +299,25 @@ describe 'swift::proxy' do
end end
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
OSDefaults.get_facts({ }).each do |os,facts|
:operatingsystem => 'Ubuntu', context "on #{os}" do
:osfamily => 'Debian', let (:facts) do
:processorcount => 1, facts.merge(OSDefaults.get_facts())
})
end end
let :platform_params do let (:platform_params) do
{ 'swift-proxy-server' => 'swift-proxy', case facts[:osfamily]
'service_provider' => nil when 'Debian'
} { 'swift-proxy-server' => 'swift-proxy' }
end when 'RedHat'
it_configures 'swift-proxy-server' { 'swift-proxy-server' => 'openstack-swift-proxy' }
context 'on Debian platforms using swiftinit service provider' do
before do
params.merge!({ :service_provider => 'swiftinit' })
end
let :platform_params do
{ 'swift-proxy-server' => 'swift-proxy-server',
'service_provider' => 'swiftinit'
}
end
it_configures 'swift-proxy-server'
end end
end end
context 'on RedHat platforms' do it_behaves_like 'swift::proxy'
let :facts do it_behaves_like 'swift::proxy server'
OSDefaults.get_facts({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:processorcount => 1,
})
end
let :platform_params do
{
'swift-proxy-server' => 'openstack-swift-proxy',
}
end
it_configures 'swift-proxy-server'
context 'on Redhat platforms using swiftinit service provider' do
before do
params.merge!({ :service_provider => 'swiftinit' })
end
let :platform_params do
{ 'swift-proxy-server' => 'swift-proxy-server',
'service_provider' => 'swiftinit'
}
end
it_configures 'swift-proxy-server'
end end
end end
end end

View File

@@ -1,11 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::staticweb' do describe 'swift::proxy::staticweb' do
shared_examples 'swift::proxy::staticweb' do
let :facts do
{}
end
it { is_expected.to contain_swift_proxy_config('filter:staticweb/use').with_value('egg:swift#staticweb') } it { is_expected.to contain_swift_proxy_config('filter:staticweb/use').with_value('egg:swift#staticweb') }
describe "when overriding default parameters" do describe "when overriding default parameters" do
@@ -14,7 +10,20 @@ describe 'swift::proxy::staticweb' do
:url_base => 'https://www.example.com', :url_base => 'https://www.example.com',
} }
end end
it { is_expected.to contain_swift_proxy_config('filter:staticweb/url_base').with_value('https://www.example.com') } it { is_expected.to contain_swift_proxy_config('filter:staticweb/url_base').with_value('https://www.example.com') }
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 'swift::proxy::staticweb'
end
end
end end

View File

@@ -1,24 +1,16 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::swauth' do describe 'swift::proxy::swauth' do
shared_examples 'swift::proxy::swauth' do
let :facts do
{}
end
it { is_expected.to contain_package('python-swauth').with_ensure('present') } it { is_expected.to contain_package('python-swauth').with_ensure('present') }
it { is_expected.to contain_swift_proxy_config('filter:swauth/use').with_value('egg:swauth#swauth') } it { is_expected.to contain_swift_proxy_config('filter:swauth/use').with_value('egg:swauth#swauth') }
describe 'with defaults' do describe 'with defaults' do
it { is_expected.to contain_swift_proxy_config('filter:swauth/default_swift_cluster').with_value('local#127.0.0.1') } it { is_expected.to contain_swift_proxy_config('filter:swauth/default_swift_cluster').with_value('local#127.0.0.1') }
it { is_expected.to contain_swift_proxy_config('filter:swauth/super_admin_key').with_value('swauthkey') } it { is_expected.to contain_swift_proxy_config('filter:swauth/super_admin_key').with_value('swauthkey') }
end end
describe 'with overridden parameters' do describe 'with overridden parameters' do
let :params do let :params do
{:swauth_endpoint => '10.0.0.1', {:swauth_endpoint => '10.0.0.1',
:swauth_super_admin_key => 'foo', :swauth_super_admin_key => 'foo',
@@ -29,8 +21,19 @@ describe 'swift::proxy::swauth' do
it { is_expected.to contain_swift_proxy_config('filter:swauth/super_admin_key').with_value('foo') } it { is_expected.to contain_swift_proxy_config('filter:swauth/super_admin_key').with_value('foo') }
it { is_expected.to contain_package('python-swauth').with_ensure('latest') } it { is_expected.to contain_package('python-swauth').with_ensure('latest') }
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 'swift::proxy::swauth'
end
end
end end

View File

@@ -1,14 +1,19 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::swift3' do describe 'swift::proxy::swift3' do
shared_examples 'swift::proxy::swift3' do
let :facts do it { is_expected.to contain_swift_proxy_config('filter:swift3/use').with_value('egg:swift3#swift3') }
OSDefaults.get_facts({
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
})
end end
it { is_expected.to contain_swift_proxy_config('filter:swift3/use').with_value('egg:swift3#swift3') } 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 'swift::proxy::swift3'
end
end
end end

View File

@@ -1,6 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::tempauth' do describe 'swift::proxy::tempauth' do
shared_examples 'swift::proxy::tempauth' do
let :default_params do { let :default_params do {
'account_user_list' => [ 'account_user_list' => [
{ {
@@ -40,6 +41,7 @@ describe 'swift::proxy::tempauth' do
}, },
] ]
} end } end
it { is_expected.to contain_swift_proxy_config('filter:tempauth/user_admin_admin').with_value('admin .admin .reseller_admin') } it { is_expected.to contain_swift_proxy_config('filter:tempauth/user_admin_admin').with_value('admin .admin .reseller_admin') }
it { is_expected.to contain_swift_proxy_config('filter:tempauth/user_bar_foo').with_value('pass .reseller_admin') } it { is_expected.to contain_swift_proxy_config('filter:tempauth/user_bar_foo').with_value('pass .reseller_admin') }
end end
@@ -55,10 +57,10 @@ describe 'swift::proxy::tempauth' do
}, },
] ]
} end } end
it { is_expected.to contain_swift_proxy_config('filter:tempauth/user_admin_admin').with_value('admin') } it { is_expected.to contain_swift_proxy_config('filter:tempauth/user_admin_admin').with_value('admin') }
end end
context 'when undef params are set' do context 'when undef params are set' do
let :params do { let :params do {
'reseller_prefix' => 'auth', 'reseller_prefix' => 'auth',
@@ -82,4 +84,17 @@ describe 'swift::proxy::tempauth' do
end end
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 'swift::proxy::tempauth'
end
end
end end

View File

@@ -1,11 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::tempurl' do describe 'swift::proxy::tempurl' do
shared_examples 'swift::proxy::tempurl' do
let :facts do
{}
end
it { is_expected.to contain_swift_proxy_config('filter:tempurl/use').with_value('egg:swift#tempurl') } it { is_expected.to contain_swift_proxy_config('filter:tempurl/use').with_value('egg:swift#tempurl') }
['methods', ['methods',
@@ -51,4 +47,17 @@ describe 'swift::proxy::tempurl' do
end end
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 'swift::proxy::tempurl'
end
end
end end

View File

@@ -1,11 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::versioned_writes' do describe 'swift::proxy::versioned_writes' do
shared_examples 'swift::proxy::versioned_writes' do
let :facts do
{}
end
describe "when using default parameters" do describe "when using default parameters" do
it { is_expected.to contain_swift_proxy_config('filter:versioned_writes/use').with_value('egg:swift#versioned_writes') } it { is_expected.to contain_swift_proxy_config('filter:versioned_writes/use').with_value('egg:swift#versioned_writes') }
it { is_expected.to contain_swift_proxy_config('filter:versioned_writes/allow_versioned_writes').with_value('false') } it { is_expected.to contain_swift_proxy_config('filter:versioned_writes/allow_versioned_writes').with_value('false') }
@@ -17,7 +13,20 @@ describe 'swift::proxy::versioned_writes' do
:allow_versioned_writes => true, :allow_versioned_writes => true,
} }
end end
it { is_expected.to contain_swift_proxy_config('filter:versioned_writes/allow_versioned_writes').with_value('true') } it { is_expected.to contain_swift_proxy_config('filter:versioned_writes/allow_versioned_writes').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
it_configures 'swift::proxy::versioned_writes'
end
end
end end

View File

@@ -1,21 +1,14 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::ringbuilder' do describe 'swift::ringbuilder' do
let :facts do shared_examples 'swift::ringbuilder' do
OSDefaults.get_facts({
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:os_workers => 1,
:processorcount => 1,
})
end
describe 'when swift class is not included' do describe 'when swift class is not included' do
it 'should fail' do it 'should fail' do
expect { catalogue }.to raise_error(Puppet::Error) expect { catalogue }.to raise_error(Puppet::Error)
end end
end end
describe 'when swift class is included' do
describe 'when swift class is included' do
let :pre_condition do let :pre_condition do
"class { memcached: max_memory => 1} "class { memcached: max_memory => 1}
class { swift: swift_hash_path_suffix => string }" class { swift: swift_hash_path_suffix => string }"
@@ -38,7 +31,6 @@ describe 'swift::ringbuilder' do
end end
describe 'with parameter overrides' do describe 'with parameter overrides' do
let :params do let :params do
{:part_power => '19', {:part_power => '19',
:replicas => '3', :replicas => '3',
@@ -53,8 +45,8 @@ describe 'swift::ringbuilder' do
:min_part_hours => '2' :min_part_hours => '2'
)} )}
end end
end end
describe 'when specifying ring devices' do describe 'when specifying ring devices' do
let :pre_condition do let :pre_condition do
'class { memcached: max_memory => 1} 'class { memcached: max_memory => 1}
@@ -97,4 +89,17 @@ describe 'swift::ringbuilder' do
end end
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 'swift::ringbuilder'
end
end
end end

View File

@@ -1,24 +1,17 @@
require 'spec_helper' require 'spec_helper'
# LP1492636 - Cohabitation of compile matcher and webmock # LP1492636 - Cohabitation of compile matcher and webmock
WebMock.disable_net_connect!(:allow => "169.254.169.254") WebMock.disable_net_connect!(:allow => "169.254.169.254")
describe 'swift::ringserver' do describe 'swift::ringserver' do
shared_examples 'swift::ringserver' do
context 'when storage.pp was already included' do context 'when storage.pp was already included' do
let :pre_condition do let :pre_condition do
"class { 'swift::storage': storage_local_net_ip => '127.0.0.1' } "class { 'swift::storage': storage_local_net_ip => '127.0.0.1' }
class {'swift' : swift_hash_path_suffix => 'eee' } class {'swift' : swift_hash_path_suffix => 'eee' }
include swift::ringbuilder" include swift::ringbuilder"
end end
let :facts do
OSDefaults.get_facts({
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
})
end
let :params do let :params do
{ {
:local_net_ip => '127.0.0.1', :local_net_ip => '127.0.0.1',
@@ -40,24 +33,14 @@ describe 'swift::ringserver' do
'read_only' => 'true' 'read_only' => 'true'
}) })
end end
end end
context 'when storage.pp was not already included' do context 'when storage.pp was not already included' do
let :pre_condition do let :pre_condition do
"class {'swift' : swift_hash_path_suffix => 'eee' } "class {'swift' : swift_hash_path_suffix => 'eee' }
include swift::ringbuilder" include swift::ringbuilder"
end end
let :facts do
OSDefaults.get_facts({
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
})
end
let :params do let :params do
{ {
:local_net_ip => '127.0.0.1', :local_net_ip => '127.0.0.1',
@@ -83,7 +66,18 @@ describe 'swift::ringserver' do
'read_only' => 'true' 'read_only' => '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
it_configures 'swift::ringserver'
end
end
end end

View File

@@ -1,7 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'swift' do describe 'swift' do
shared_examples 'swift' do
let :params do let :params do
{ {
:swift_hash_path_suffix => 'string', :swift_hash_path_suffix => 'string',
@@ -9,17 +9,11 @@ describe 'swift' do
} }
end end
let :facts do
OSDefaults.get_facts({
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
})
end
describe 'when no swift hash is specified' do describe 'when no swift hash is specified' do
let :params do let :params do
{} {}
end end
it 'should raise an exception' do it 'should raise an exception' do
expect { catalogue }.to raise_error(Puppet::Error) expect { catalogue }.to raise_error(Puppet::Error)
end end
@@ -33,6 +27,7 @@ describe 'swift' do
:tag => 'swift-file', :tag => 'swift-file',
} }
end end
it {is_expected.to contain_user('swift')} it {is_expected.to contain_user('swift')}
it {is_expected.to contain_file('/etc/swift').with( it {is_expected.to contain_file('/etc/swift').with(
{:ensure => 'directory'}.merge(file_defaults) {:ensure => 'directory'}.merge(file_defaults)
@@ -47,14 +42,17 @@ describe 'swift' do
it {is_expected.to contain_file('/etc/swift/swift.conf').with( it {is_expected.to contain_file('/etc/swift/swift.conf').with(
{:ensure => 'file'}.merge(file_defaults) {:ensure => 'file'}.merge(file_defaults)
)} )}
it 'configures swift.conf' do it 'configures swift.conf' do
is_expected.to contain_swift_config( is_expected.to contain_swift_config(
'swift-hash/swift_hash_path_suffix').with_value('string') 'swift-hash/swift_hash_path_suffix').with_value('string')
end end
it 'configures swift.conf' do it 'configures swift.conf' do
is_expected.to contain_swift_config( is_expected.to contain_swift_config(
'swift-constraints/max_header_size').with_value('16384') 'swift-constraints/max_header_size').with_value('16384')
end end
it { is_expected.to contain_package('swift').with_ensure('present') it { is_expected.to contain_package('swift').with_ensure('present')
is_expected.to contain_package('swift').that_requires('Anchor[swift::install::begin]') is_expected.to contain_package('swift').that_requires('Anchor[swift::install::begin]')
is_expected.to contain_package('swift').that_notifies('Anchor[swift::install::end]')} is_expected.to contain_package('swift').that_notifies('Anchor[swift::install::end]')}
@@ -73,6 +71,7 @@ describe 'swift' do
{ :swift_hash_path_suffix => 'mysuffix', { :swift_hash_path_suffix => 'mysuffix',
:swift_hash_path_prefix => 'myprefix' } :swift_hash_path_prefix => 'myprefix' }
end end
it 'should configure swift.conf' do it 'should configure swift.conf' do
is_expected.to contain_swift_config( is_expected.to contain_swift_config(
'swift-hash/swift_hash_path_suffix').with_value('mysuffix') 'swift-hash/swift_hash_path_suffix').with_value('mysuffix')
@@ -87,5 +86,17 @@ describe 'swift' do
is_expected.to contain_package('swiftclient').with_ensure(params[:client_package_ensure]) is_expected.to contain_package('swiftclient').with_ensure(params[:client_package_ensure])
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 'swift'
end
end
end end

View File

@@ -12,8 +12,7 @@ describe 'swift::storage::account' do
:manage_service => true } :manage_service => true }
end end
shared_examples_for 'swift-storage-account' do shared_examples 'swift::storage::account' do
[{}, [{},
{:package_ensure => 'latest'} {:package_ensure => 'latest'}
].each do |param_set| ].each do |param_set|
@@ -39,7 +38,7 @@ describe 'swift::storage::account' do
:name => service_name, :name => service_name,
:ensure => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running' : 'stopped', :ensure => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running' : 'stopped',
:enable => param_hash[:enabled], :enable => param_hash[:enabled],
:provider => platform_params[:service_provider], :provider => nil,
:tag => 'swift-service', :tag => 'swift-service',
) )
end end
@@ -47,105 +46,63 @@ describe 'swift::storage::account' do
end end
end end
context 'with disabled service managing' do context 'with disabled service managing and service provider' do
before do before do
params.merge!({ params.merge!({
:manage_service => false, :manage_service => false,
:enabled => false }) :enabled => false,
:service_provider => 'swiftinit',
})
end end
it 'configures services' do it 'configures services' do
platform_params[:service_names].each do |service_alias, service_name|
{ 'swift-account-server' => 'swift-account-server',
'swift-account-replicator' => 'swift-account-replicator',
'swift-account-reaper' => 'swift-account-reaper',
'swift-account-auditor' => 'swift-account-auditor' }.each do |service_alias, service_name|
is_expected.to contain_service(service_alias).with( is_expected.to contain_service(service_alias).with(
:ensure => nil, :ensure => nil,
:name => service_name, :name => service_name,
:enable => false, :enable => false,
:tag => 'swift-service', :tag => 'swift-service',
:provider => 'swiftinit',
) )
end end
end end
end end
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
OSDefaults.get_facts({ }).each do |os,facts|
:operatingsystem => 'Ubuntu', context "on #{os}" do
:osfamily => 'Debian', let (:facts) do
}) facts.merge(OSDefaults.get_facts())
end end
let :platform_params do let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :service_names => { { :service_names => {
'swift-account-server' => 'swift-account', 'swift-account-server' => 'swift-account',
'swift-account-replicator' => 'swift-account-replicator', 'swift-account-replicator' => 'swift-account-replicator',
'swift-account-reaper' => 'swift-account-reaper', 'swift-account-reaper' => 'swift-account-reaper',
'swift-account-auditor' => 'swift-account-auditor' 'swift-account-auditor' => 'swift-account-auditor'
},
:service_provider => nil
} }
end
it_configures 'swift-storage-account'
context 'on Debian platforms using swiftinit service provider' do
before do
params.merge!({ :service_provider => 'swiftinit' })
end
let :platform_params do
{ :service_names => {
'swift-account-server' => 'swift-account-server',
'swift-account-replicator' => 'swift-account-replicator',
'swift-account-reaper' => 'swift-account-reaper',
'swift-account-auditor' => 'swift-account-auditor',
},
:service_provider => 'swiftinit'
} }
end when 'RedHat'
it_configures 'swift-storage-account'
end
end
context 'on RedHat platforms' do
let :facts do
OSDefaults.get_facts({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
})
end
let :platform_params do
{ :service_names => { { :service_names => {
'swift-account-server' => 'openstack-swift-account', 'swift-account-server' => 'openstack-swift-account',
'swift-account-replicator' => 'openstack-swift-account-replicator', 'swift-account-replicator' => 'openstack-swift-account-replicator',
'swift-account-reaper' => 'openstack-swift-account-reaper', 'swift-account-reaper' => 'openstack-swift-account-reaper',
'swift-account-auditor' => 'openstack-swift-account-auditor' 'swift-account-auditor' => 'openstack-swift-account-auditor'
}, }
} }
end end
it_configures 'swift-storage-account'
context 'on redhat using swiftinit service provider' do
before do
params.merge!({ :service_provider => 'swiftinit' })
end end
let :platform_params do it_configures 'swift::storage::account'
{ :service_names => {
'swift-account-server' => 'swift-account-server',
'swift-account-replicator' => 'swift-account-replicator',
'swift-account-reaper' => 'swift-account-reaper',
'swift-account-auditor' => 'swift-account-auditor',
},
:service_provider => 'swiftinit'
}
end
it_configures 'swift-storage-account'
end end
end end
end end

View File

@@ -1,14 +1,6 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::storage::all' do describe 'swift::storage::all' do
let :facts do
OSDefaults.get_facts({
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
})
end
let :pre_condition do let :pre_condition do
"class { 'swift': swift_hash_path_suffix => 'changeme' } "class { 'swift': swift_hash_path_suffix => 'changeme' }
swift::storage::filter::healthcheck { 'container': } swift::storage::filter::healthcheck { 'container': }
@@ -29,6 +21,7 @@ describe 'swift::storage::all' do
} }
end end
shared_examples 'swift::storage::all' do
describe 'when an internal network ip is not specified' do describe 'when an internal network ip is not specified' do
if Puppet::Util::Package.versioncmp(Puppet.version, '4.3.0') >= 0 if Puppet::Util::Package.versioncmp(Puppet.version, '4.3.0') >= 0
it_raises 'a Puppet::Error', /expects a value for parameter 'storage_local_net_ip'/ it_raises 'a Puppet::Error', /expects a value for parameter 'storage_local_net_ip'/
@@ -122,7 +115,6 @@ describe 'swift::storage::all' do
:use_chroot => 'no' :use_chroot => 'no'
} }
)} )}
end end
end end
@@ -156,14 +148,28 @@ describe 'swift::storage::all' do
end end
end end
describe "when installed on Debian" do describe "when specifying number of workers" do
let :facts do let :params do
OSDefaults.get_facts({ {
:operatingsystem => 'Debian', :storage_local_net_ip => '127.0.0.1',
:osfamily => 'Debian', :account_server_workers => '42',
}) :container_server_workers => '42',
:object_server_workers => '42',
}
end end
{'object' => '6000', 'container' => '6001', 'account' => '6002'}.each do |type,name|
it "should define worker count in the #{type} config file" do
is_expected.to contain_concat_fragment("swift-#{type}-#{name}").with_content(
/workers = 42/
)
end
end
end
end
shared_examples 'swift::storage::all debian' do
describe "when installed on Debian" do
[{ :storage_local_net_ip => '127.0.0.1' }, [{ :storage_local_net_ip => '127.0.0.1' },
{ {
:devices => '/tmp/node', :devices => '/tmp/node',
@@ -181,6 +187,7 @@ describe 'swift::storage::all' do
let :params do let :params do
param_set param_set
end end
['object', 'container', 'account'].each do |type| ['object', 'container', 'account'].each do |type|
it { is_expected.to contain_package("swift-#{type}").with_ensure('present') } it { is_expected.to contain_package("swift-#{type}").with_ensure('present') }
it { is_expected.to contain_service("swift-#{type}-server").with( it { is_expected.to contain_service("swift-#{type}-server").with(
@@ -200,24 +207,21 @@ describe 'swift::storage::all' do
end end
end end
end end
describe "when specifying number of workers" do
let :params do
{
:storage_local_net_ip => '127.0.0.1',
:account_server_workers => '42',
:container_server_workers => '42',
:object_server_workers => '42',
}
end end
{'object' => '6000', 'container' => '6001', 'account' => '6002'}.each do |type,name| on_supported_os({
it "should define worker count in the #{type} config file" do :supported_os => OSDefaults.get_supported_os
is_expected.to contain_concat_fragment("swift-#{type}-#{name}").with_content( }).each do |os,facts|
/workers = 42/ context "on #{os}" do
) let (:facts) do
end facts.merge(OSDefaults.get_facts())
end
end end
it_configures 'swift::storage::all'
if facts[:osfamily] == 'Debian'
it_configures 'swift::storage::all debian'
end
end
end
end end

View File

@@ -12,7 +12,7 @@ describe 'swift::storage::container' do
:manage_service => true } :manage_service => true }
end end
shared_examples_for 'swift-storage-container' do shared_examples 'swift::storage::container' do
[{}, [{},
{:package_ensure => 'latest'} {:package_ensure => 'latest'}
].each do |param_set| ].each do |param_set|
@@ -39,7 +39,7 @@ describe 'swift::storage::container' do
:name => service_name, :name => service_name,
:ensure => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running' : 'stopped', :ensure => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running' : 'stopped',
:enable => param_hash[:enabled], :enable => param_hash[:enabled],
:provider => platform_params[:service_provider], :provider => nil,
:tag => 'swift-service', :tag => 'swift-service',
) )
end end
@@ -47,78 +47,52 @@ describe 'swift::storage::container' do
end end
end end
context 'with disabled service managing' do context 'with disabled service managing and service provider' do
before do before do
params.merge!({ params.merge!({
:manage_service => false, :manage_service => false,
:enabled => false }) :enabled => false,
:service_provider => 'swiftinit',
})
end end
it 'configures services' do it 'configures services' do
platform_params[:service_names].each do |service_alias, service_name| { 'swift-container-server' => 'swift-container-server',
'swift-container-replicator' => 'swift-container-replicator',
'swift-container-updater' => 'swift-container-updater',
'swift-container-auditor' => 'swift-container-auditor',
'swift-container-sync' => 'swift-container-sync' }.each do |service_alias, service_name|
is_expected.to contain_service(service_alias).with( is_expected.to contain_service(service_alias).with(
:ensure => nil, :ensure => nil,
:name => service_name, :name => service_name,
:enable => false, :enable => false,
:tag => 'swift-service', :tag => 'swift-service',
:provider => 'swiftinit',
) )
end end
end end
end end
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
OSDefaults.get_facts({ }).each do |os,facts|
:osfamily => 'Debian', context "on #{os}" do
:operatingsystem => 'Ubuntu', let (:facts) do
}) facts.merge(OSDefaults.get_facts())
end end
let :platform_params do let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :service_names => { { :service_names => {
'swift-container-server' => 'swift-container', 'swift-container-server' => 'swift-container',
'swift-container-replicator' => 'swift-container-replicator', 'swift-container-replicator' => 'swift-container-replicator',
'swift-container-updater' => 'swift-container-updater', 'swift-container-updater' => 'swift-container-updater',
'swift-container-auditor' => 'swift-container-auditor' 'swift-container-auditor' => 'swift-container-auditor'
},
:service_provider => nil
} }
end
it_configures 'swift-storage-container'
context 'on debian using swiftinit service provider' do
before do
params.merge!({ :service_provider => 'swiftinit' })
end
let :platform_params do
{ :service_names => {
'swift-container-server' => 'swift-container-server',
'swift-container-replicator' => 'swift-container-replicator',
'swift-container-updater' => 'swift-container-updater',
'swift-container-auditor' => 'swift-container-auditor',
'swift-container-sync' => 'swift-container-sync'
},
:service_provider => 'swiftinit'
} }
end when 'RedHat'
it_configures 'swift-storage-container'
end
end
context 'on RedHat platforms' do
let :facts do
OSDefaults.get_facts({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
})
end
let :platform_params do
{ :service_names => { { :service_names => {
'swift-container-server' => 'openstack-swift-container', 'swift-container-server' => 'openstack-swift-container',
'swift-container-replicator' => 'openstack-swift-container-replicator', 'swift-container-replicator' => 'openstack-swift-container-replicator',
@@ -127,28 +101,9 @@ describe 'swift::storage::container' do
} }
} }
end end
it_configures 'swift-storage-container'
context 'on redhat using swiftinit service provider' do
before do
params.merge!({ :service_provider => 'swiftinit' })
end end
let :platform_params do it_configures 'swift::storage::container'
{ :service_names => {
'swift-container-server' => 'swift-container-server',
'swift-container-replicator' => 'swift-container-replicator',
'swift-container-updater' => 'swift-container-updater',
'swift-container-auditor' => 'swift-container-auditor',
'swift-container-sync' => 'swift-container-sync'
},
:service_provider => 'swiftinit'
}
end
it_configures 'swift-storage-container'
end end
end end
end end

View File

@@ -16,7 +16,7 @@ require 'spec_helper'
describe 'swift::storage::disks' do describe 'swift::storage::disks' do
shared_examples_for 'swift storage disks' do shared_examples 'swift::storage::disks' do
let :params do let :params do
{ {
:args => { :args => {
@@ -44,7 +44,7 @@ describe 'swift::storage::disks' do
facts.merge!(OSDefaults.get_facts()) facts.merge!(OSDefaults.get_facts())
end end
it_configures 'swift storage disks' it_configures 'swift::storage::disks'
end end
end end

View File

@@ -16,7 +16,7 @@ require 'spec_helper'
describe 'swift::storage::loopbacks' do describe 'swift::storage::loopbacks' do
shared_examples_for 'swift storage loopbacks' do shared_examples 'swift::storage::loopbacks' do
let :params do let :params do
{ {
:args => { :args => {
@@ -44,7 +44,7 @@ describe 'swift::storage::loopbacks' do
facts.merge!(OSDefaults.get_facts()) facts.merge!(OSDefaults.get_facts())
end end
it_configures 'swift storage loopbacks' it_configures 'swift::storage::loopbacks'
end end
end end

View File

@@ -13,8 +13,7 @@ describe 'swift::storage::object' do
:manage_service => true } :manage_service => true }
end end
shared_examples_for 'swift-storage-object' do shared_examples 'swift::storage::object' do
[{}, [{},
{ :package_ensure => 'latest' } { :package_ensure => 'latest' }
].each do |param_set| ].each do |param_set|
@@ -40,7 +39,7 @@ describe 'swift::storage::object' do
:name => service_name, :name => service_name,
:ensure => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running' : 'stopped', :ensure => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running' : 'stopped',
:enable => param_hash[:enabled], :enable => param_hash[:enabled],
:provider => platform_params[:service_provider], :provider => nil,
:tag => 'swift-service', :tag => 'swift-service',
) )
end end
@@ -48,80 +47,53 @@ describe 'swift::storage::object' do
end end
end end
context 'with disabled service managing' do context 'with disabled service managing and service provider' do
before do before do
params.merge!({ params.merge!({
:manage_service => false, :manage_service => false,
:enabled => false }) :enabled => false,
:service_provider => 'swiftinit',
})
end end
it 'configures services' do it 'configures services' do
platform_params[:service_names].each do |service_alias, service_name| { 'swift-object-server' => 'swift-object-server',
'swift-object-reconstructor' => 'swift-object-reconstructor',
'swift-object-replicator' => 'swift-object-replicator',
'swift-object-updater' => 'swift-object-updater',
'swift-object-auditor' => 'swift-object-auditor' }.each do |service_alias, service_name|
is_expected.to contain_service(service_alias).with( is_expected.to contain_service(service_alias).with(
:ensure => nil, :ensure => nil,
:name => service_name, :name => service_name,
:enable => false, :enable => false,
:tag => 'swift-service', :tag => 'swift-service',
:provider => 'swiftinit',
) )
end end
end end
end end
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
OSDefaults.get_facts({ }).each do |os,facts|
:operatingsystem => 'Ubuntu', context "on #{os}" do
:osfamily => 'Debian', let (:facts) do
}) facts.merge(OSDefaults.get_facts())
end end
let :platform_params do let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :service_names => { { :service_names => {
'swift-object-server' => 'swift-object', 'swift-object-server' => 'swift-object',
'swift-object-reconstructor' => 'swift-object-reconstructor', 'swift-object-reconstructor' => 'swift-object-reconstructor',
'swift-object-replicator' => 'swift-object-replicator', 'swift-object-replicator' => 'swift-object-replicator',
'swift-object-updater' => 'swift-object-updater', 'swift-object-updater' => 'swift-object-updater',
'swift-object-auditor' => 'swift-object-auditor' 'swift-object-auditor' => 'swift-object-auditor'
},
:service_provider => nil
} }
end
it_configures 'swift-storage-object'
context 'on debian using swiftinit service provider' do
before do
params.merge!({ :service_provider => 'swiftinit' })
end
let :platform_params do
{ :service_names => {
'swift-object-server' => 'swift-object-server',
'swift-object-reconstructor' => 'swift-object-reconstructor',
'swift-object-replicator' => 'swift-object-replicator',
'swift-object-updater' => 'swift-object-updater',
'swift-object-auditor' => 'swift-object-auditor',
},
:service_provider => 'swiftinit'
} }
end when 'RedHat'
it_configures 'swift-storage-object'
end
end
context 'on RedHat platforms' do
let :facts do
OSDefaults.get_facts({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
})
end
let :platform_params do
{ :service_names => { { :service_names => {
'swift-object-server' => 'openstack-swift-object', 'swift-object-server' => 'openstack-swift-object',
'swift-object-reconstructor' => 'openstack-swift-object-reconstructor', 'swift-object-reconstructor' => 'openstack-swift-object-reconstructor',
@@ -131,27 +103,9 @@ describe 'swift::storage::object' do
} }
} }
end end
it_configures 'swift-storage-object'
context 'on redhat using swiftinit service provider' do
before do
params.merge!({ :service_provider => 'swiftinit' })
end end
let :platform_params do it_configures 'swift::storage::object'
{ :service_names => {
'swift-object-server' => 'swift-object-server',
'swift-object-reconstructor' => 'swift-object-reconstructor',
'swift-object-replicator' => 'swift-object-replicator',
'swift-object-updater' => 'swift-object-updater',
'swift-object-auditor' => 'swift-object-auditor',
},
:service_provider => 'swiftinit'
}
end
it_configures 'swift-storage-object'
end end
end end
end end

View File

@@ -1,13 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::storage' do describe 'swift::storage' do
let :facts do shared_examples 'swift::storage' do
OSDefaults.get_facts({
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
})
end
describe 'when required classes are specified' do describe 'when required classes are specified' do
let :pre_condition do let :pre_condition do
"class { 'swift': swift_hash_path_suffix => 'changeme' }" "class { 'swift': swift_hash_path_suffix => 'changeme' }"
@@ -27,6 +21,7 @@ describe 'swift::storage' do
} }
)} )}
end end
describe 'when local net ip is not specified' do describe 'when local net ip is not specified' do
if Puppet::Util::Package.versioncmp(Puppet.version, '4.3.0') >= 0 if Puppet::Util::Package.versioncmp(Puppet.version, '4.3.0') >= 0
it_raises 'a Puppet::Error', /expects a value for parameter 'storage_local_net_ip'/ it_raises 'a Puppet::Error', /expects a value for parameter 'storage_local_net_ip'/
@@ -35,9 +30,23 @@ describe 'swift::storage' do
end end
end end
end end
describe 'when the dependencies are not specified' do describe 'when the dependencies are not specified' do
it 'should fail' do it 'should fail' do
expect { catalogue }.to raise_error(Puppet::Error) expect { catalogue }.to raise_error(Puppet::Error)
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 'swift::storage'
end
end
end end

View File

@@ -6,8 +6,8 @@ describe 'swift::test_file' do
{:password => 'foo'} {:password => 'foo'}
end end
shared_examples 'swift::test_file' do
describe 'with defaults' do describe 'with defaults' do
let :params do let :params do
default_params default_params
end end
@@ -21,11 +21,9 @@ describe 'swift::test_file' do
] ]
) )
end end
end end
describe 'when overridding' do describe 'when overridding' do
let :params do let :params do
default_params.merge({ default_params.merge({
:auth_server => '127.0.0.2', :auth_server => '127.0.0.2',
@@ -44,6 +42,18 @@ describe 'swift::test_file' do
] ]
) )
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 'swift::test_file'
end
end end
end end

View File

@@ -1,6 +1,21 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::xfs' do describe 'swift::xfs' do
shared_examples 'swift::xfs' do
['xfsprogs', 'parted'].each do |present_package| ['xfsprogs', 'parted'].each do |present_package|
it { is_expected.to contain_package(present_package).with_ensure('present') } it { is_expected.to contain_package(present_package).with_ensure('present') }
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 'swift::xfs'
end
end
end end

View File

@@ -1,15 +1,25 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::proxy::tempauth_account' do describe 'swift::proxy::tempauth_account' do
shared_examples 'swift::proxy::tempauth_account' do
let :title do let :title do
' user_admin_admin, admin .admin .reseller_admin' ' user_admin_admin, admin .admin .reseller_admin'
end end
describe 'when passing in a string containing "user_<account>_<user>, <key> .<group1> .<groupx>"' do describe 'when passing in a string containing "user_<account>_<user>, <key> .<group1> .<groupx>"' do
it { should contain_swift_proxy_config('filter:tempauth/user_admin_admin').with_value('admin .admin .reseller_admin') }
it { is_expected.to contain_swift_proxy_config('filter:tempauth/user_admin_admin').with_value('admin .admin .reseller_admin') } 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 'swift::proxy::tempauth_acount'
end
end
end end

View File

@@ -1,13 +1,16 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::ringbuilder::create' do
describe 'swift::ringbuilder::create' do
let :default_params do let :default_params do
{:part_power => 18, {
:part_power => 18,
:replicas => 3, :replicas => 3,
:min_part_hours => 24, :min_part_hours => 24,
:user => 'swift'} :user => 'swift'
}
end end
shared_examples 'swift::ringbuilder::create' do
describe 'with allowed titles' do describe 'with allowed titles' do
['object', 'container', 'account'].each do |type| ['object', 'container', 'account'].each do |type|
describe "when title is #{type}" do describe "when title is #{type}" do
@@ -21,8 +24,7 @@ describe 'swift::ringbuilder::create' do
:min_part_hours => 2, :min_part_hours => 2,
:user => 'root'}].each do |param_set| :user => 'root'}].each do |param_set|
describe "when #{param_set == {} ? "using default" : "specifying"} class parame describe "when #{param_set == {} ? "using default" : "specifying"} class parame ters" do
ters" do
let :param_hash do let :param_hash do
default_params.merge(param_set) default_params.merge(param_set)
end end
@@ -31,24 +33,36 @@ describe 'swift::ringbuilder::create' do
param_set param_set
end end
it { is_expected.to contain_exec("create_#{type}").with( it { should contain_exec("create_#{type}").with(
{:command => "swift-ring-builder /etc/swift/#{type}.builder create #{param_hash[:part_power]} #{param_hash[:replicas]} #{param_hash[:min_part_hours]}", :command => "swift-ring-builder /etc/swift/#{type}.builder create #{param_hash[:part_power]} #{param_hash[:replicas]} #{param_hash[:min_part_hours]}",
:path => ['/usr/bin'], :path => ['/usr/bin'],
:user => param_hash[:user], :user => param_hash[:user],
:creates => "/etc/swift/#{type}.builder" } :creates => "/etc/swift/#{type}.builder",
)} )}
end end
end end
end end
end end
end end
describe 'with an invalid title' do describe 'with an invalid title' do
let :title do let :title do
'invalid' 'invalid'
end end
it 'should raise an error' do
expect { catalogue }.to raise_error(Puppet::Error) it { should raise_error(Puppet::Error) }
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 'swift::ringbuilder::create'
end
end
end end

View File

@@ -6,21 +6,12 @@ describe 'swift::ringbuilder::policy_ring' do
"1" "1"
end end
let :facts do shared_examples 'swift::ringbuilder::policy_ring' do
OSDefaults.get_facts({
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:os_workers => 1,
:processorcount => 1,
})
end
describe 'when swift class is not included' do describe 'when swift class is not included' do
it 'should fail' do it { should raise_error(Puppet::Error) }
expect { catalogue }.to raise_error(Puppet::Error)
end end
end
describe 'when swift class is included and policy is >= 1' do
describe 'when swift class is included and policy is >= 1' do
let :pre_condition do let :pre_condition do
"class { memcached: max_memory => 1} "class { memcached: max_memory => 1}
class { swift: swift_hash_path_suffix => string }" class { swift: swift_hash_path_suffix => string }"
@@ -39,7 +30,6 @@ describe 'swift::ringbuilder::policy_ring' do
end end
describe 'with parameter overrides' do describe 'with parameter overrides' do
let :params do let :params do
{:part_power => '19', {:part_power => '19',
:replicas => '3', :replicas => '3',
@@ -52,7 +42,6 @@ describe 'swift::ringbuilder::policy_ring' do
:replicas => '3', :replicas => '3',
:min_part_hours => '2' :min_part_hours => '2'
)} )}
end end
describe 'when specifying ring devices' do describe 'when specifying ring devices' do
@@ -63,7 +52,6 @@ describe 'swift::ringbuilder::policy_ring' do
zone => 1, zone => 1,
weight => 1, weight => 1,
}' }'
end end
it 'should set up all of the correct dependencies' do it 'should set up all of the correct dependencies' do
@@ -76,4 +64,17 @@ describe 'swift::ringbuilder::policy_ring' do
end end
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 'swift::ringbuilder::policy_ring'
end
end
end end

View File

@@ -1,11 +1,14 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::ringbuilder::rebalance' do describe 'swift::ringbuilder::rebalance' do
shared_examples 'swift::ringbuilder::rebalance' do
describe 'with allowed titles' do describe 'with allowed titles' do
['object', 'container', 'account'].each do |type| ['object', 'container', 'account'].each do |type|
describe "when title is #{type}" do describe "when title is #{type}" do
let :title do let :title do
type type
end end
it { is_expected.to contain_exec("rebalance_#{type}").with( it { is_expected.to contain_exec("rebalance_#{type}").with(
{:command => "swift-ring-builder /etc/swift/#{type}.builder rebalance", {:command => "swift-ring-builder /etc/swift/#{type}.builder rebalance",
:path => ['/usr/bin'], :path => ['/usr/bin'],
@@ -14,37 +17,57 @@ describe 'swift::ringbuilder::rebalance' do
end end
end end
end end
describe 'with valid seed' do describe 'with valid seed' do
let :params do let :params do
{ :seed => '999' } { :seed => '999' }
end end
let :title do let :title do
'object' 'object'
end end
it { is_expected.to contain_exec("rebalance_object").with( it { is_expected.to contain_exec("rebalance_object").with(
{:command => "swift-ring-builder /etc/swift/object.builder rebalance 999", {:command => "swift-ring-builder /etc/swift/object.builder rebalance 999",
:path => ['/usr/bin'], :path => ['/usr/bin'],
:refreshonly => true} :refreshonly => true}
)} )}
end end
describe 'with an invalid seed' do describe 'with an invalid seed' do
let :title do let :title do
'object' 'object'
end end
let :params do let :params do
{ :seed => 'invalid' } { :seed => 'invalid' }
end end
it 'should raise an error' do
expect { catalogue }.to raise_error(Puppet::Error)
end
end
describe 'with an invalid title' do
let :title do
'invalid'
end
it 'should raise an error' do it 'should raise an error' do
expect { catalogue }.to raise_error(Puppet::Error) expect { catalogue }.to raise_error(Puppet::Error)
end end
end end
describe 'with an invalid title' do
let :title do
'invalid'
end
it 'should raise an error' do
expect { catalogue }.to raise_error(Puppet::Error)
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 'swift::ringbuilder::rebalance'
end
end
end end

View File

@@ -16,6 +16,7 @@ describe 'swift::storage::disk' do
} }
end end
shared_examples 'swift::storage::disk' do
it { is_expected.to contain_exec("create_partition_label-sdb").with( it { is_expected.to contain_exec("create_partition_label-sdb").with(
:command => "parted -s #{params[:base_dir]}/sdb mklabel gpt #{params[:ext_args]}", :command => "parted -s #{params[:base_dir]}/sdb mklabel gpt #{params[:ext_args]}",
:path => ["/usr/bin/", "/sbin", "/bin"], :path => ["/usr/bin/", "/sbin", "/bin"],
@@ -30,5 +31,17 @@ describe 'swift::storage::disk' do
:subscribe => 'Exec[create_partition_label-sdb]', :subscribe => 'Exec[create_partition_label-sdb]',
:loopback => false :loopback => false
) } ) }
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 'swift::storage::disk'
end
end
end end

View File

@@ -5,15 +5,24 @@ describe 'swift::storage::filter::healthcheck' do
'dummy' 'dummy'
end end
let :facts do shared_examples 'swift::storage::filter::healthcheck' do
{} it 'should build the fragment with correct content' do
end
it 'should build the fragment with correct content' do
is_expected.to contain_concat_fragment('swift_healthcheck_dummy').with_content(' is_expected.to contain_concat_fragment('swift_healthcheck_dummy').with_content('
[filter:healthcheck] [filter:healthcheck]
use = egg:swift#healthcheck use = egg:swift#healthcheck
') ')
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 'swift::storage::filter::healthcheck'
end
end
end end

View File

@@ -5,10 +5,7 @@ describe 'swift::storage::filter::recon' do
'dummy' 'dummy'
end end
let :facts do shared_examples 'swift::storage::filter::recon' do
{}
end
describe 'when passing default parameters' do describe 'when passing default parameters' do
it 'should build the fragment with correct content' do it 'should build the fragment with correct content' do
is_expected.to contain_concat_fragment('swift_recon_dummy').with_content(' is_expected.to contain_concat_fragment('swift_recon_dummy').with_content('
@@ -25,9 +22,22 @@ recon_cache_path = /var/cache/swift
:cache_path => '/some/other/path' :cache_path => '/some/other/path'
} }
end end
it 'should build the fragment with correct content' do it 'should build the fragment with correct content' do
is_expected.to contain_concat_fragment('swift_recon_dummy').with_content(/recon_cache_path = \/some\/other\/path/) is_expected.to contain_concat_fragment('swift_recon_dummy').with_content(/recon_cache_path = \/some\/other\/path/)
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 'swift::storage::filter::recon'
end
end
end end

View File

@@ -1,18 +1,10 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::storage::generic' do describe 'swift::storage::generic' do
let :title do let :title do
'account' 'account'
end end
let :facts do
OSDefaults.get_facts({
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
})
end
let :pre_condition do let :pre_condition do
"class { 'swift': swift_hash_path_suffix => 'foo' } "class { 'swift': swift_hash_path_suffix => 'foo' }
class { 'swift::storage': storage_local_net_ip => '10.0.0.1' }" class { 'swift::storage': storage_local_net_ip => '10.0.0.1' }"
@@ -24,17 +16,18 @@ describe 'swift::storage::generic' do
:manage_service => true } :manage_service => true }
end end
shared_examples 'swift::storage::generic' do
describe 'with an invalid title' do describe 'with an invalid title' do
let :title do let :title do
'foo' 'foo'
end end
it_raises 'a Puppet::Error', /does not match/ it_raises 'a Puppet::Error', /does not match/
end end
shared_examples_for 'swift-storage-generic' do
%w(account object container).each do |t| %w(account object container).each do |t|
[{}, [{},
{ :package_ensure => 'latest' } { :package_ensure => 'latest', :service_provider => 'swiftinit' }
].each do |param_set| ].each do |param_set|
describe "when #{param_set == {} ? 'using default' : 'specifying'} class parameters" do describe "when #{param_set == {} ? 'using default' : 'specifying'} class parameters" do
before do before do
@@ -45,11 +38,29 @@ describe 'swift::storage::generic' do
t t
end end
let :swiftinit_platform do
{
'swift-account-server' => 'swift-account-server',
'swift-account-replicator' => 'swift-account-replicator',
'swift-account-auditor' => 'swift-account-auditor',
'swift-container-server' => 'swift-container-server',
'swift-container-replicator' => 'swift-container-replicator',
'swift-container-auditor' => 'swift-container-auditor',
'swift-object-server' => 'swift-object-server',
'swift-object-replicator' => 'swift-object-replicator',
'swift-object-auditor' => 'swift-object-auditor',
}
end
[{ :enabled => true, :manage_service => true }, [{ :enabled => true, :manage_service => true },
{ :enabled => false, :manage_service => true }].each do |param_hash_manage| { :enabled => false, :manage_service => true }].each do |param_hash_manage|
context "when service is_expected.to be #{param_hash_manage[:enabled] ? 'enabled' : 'disabled'}" do context "when service is_expected.to be #{param_hash_manage[:enabled] ? 'enabled' : 'disabled'}" do
before do before do
params.merge!(param_hash_manage) params.merge!(param_hash_manage)
if param_set[:service_provider] == 'swiftinit'
platform_params.merge!(swiftinit_platform)
end
end end
it do it do
@@ -59,33 +70,37 @@ describe 'swift::storage::generic' do
:notify => ['Anchor[swift::install::end]'] :notify => ['Anchor[swift::install::end]']
) )
end end
it do it do
is_expected.to contain_service("swift-#{t}-server").with( is_expected.to contain_service("swift-#{t}-server").with(
:name => platform_params["swift-#{t}-server"], :name => platform_params["swift-#{t}-server"],
:ensure => (param_hash_manage[:manage_service] && param_hash_manage[:enabled]) ? 'running' : 'stopped', :ensure => (param_hash_manage[:manage_service] && param_hash_manage[:enabled]) ? 'running' : 'stopped',
:enable => param_hash_manage[:enabled], :enable => param_hash_manage[:enabled],
:provider => platform_params['service_provider'], :provider => param_set[:service_provider],
:tag => 'swift-service' :tag => 'swift-service'
) )
end end
it do it do
is_expected.to contain_service("swift-#{t}-replicator").with( is_expected.to contain_service("swift-#{t}-replicator").with(
:name => platform_params["swift-#{t}-replicator"], :name => platform_params["swift-#{t}-replicator"],
:ensure => (param_hash_manage[:manage_service] && param_hash_manage[:enabled]) ? 'running' : 'stopped', :ensure => (param_hash_manage[:manage_service] && param_hash_manage[:enabled]) ? 'running' : 'stopped',
:enable => param_hash_manage[:enabled], :enable => param_hash_manage[:enabled],
:provider => platform_params['service_provider'], :provider => param_set[:service_provider],
:tag => 'swift-service' :tag => 'swift-service'
) )
end end
it do it do
is_expected.to contain_service("swift-#{t}-auditor").with( is_expected.to contain_service("swift-#{t}-auditor").with(
:name => platform_params["swift-#{t}-auditor"], :name => platform_params["swift-#{t}-auditor"],
:ensure => (param_hash_manage[:manage_service] && param_hash_manage[:enabled]) ? 'running' : 'stopped', :ensure => (param_hash_manage[:manage_service] && param_hash_manage[:enabled]) ? 'running' : 'stopped',
:enable => param_hash_manage[:enabled], :enable => param_hash_manage[:enabled],
:provider => platform_params['service_provider'], :provider => param_set[:service_provider],
:tag => 'swift-service' :tag => 'swift-service'
) )
end end
it do it do
is_expected.to contain_file("/etc/swift/#{t}-server/").with( is_expected.to contain_file("/etc/swift/#{t}-server/").with(
:ensure => 'directory', :ensure => 'directory',
@@ -98,16 +113,19 @@ describe 'swift::storage::generic' do
end end
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
OSDefaults.get_facts({ }).each do |os,facts|
:operatingsystem => 'Ubuntu', context "on #{os}" do
:osfamily => 'Debian', let (:facts) do
}) facts.merge(OSDefaults.get_facts())
end end
let :platform_params do let(:platform_params) do
{ 'swift-account-server' => 'swift-account', case facts[:osfamily]
when 'Debian'
{
'swift-account-server' => 'swift-account',
'swift-account-replicator' => 'swift-account-replicator', 'swift-account-replicator' => 'swift-account-replicator',
'swift-account-auditor' => 'swift-account-auditor', 'swift-account-auditor' => 'swift-account-auditor',
'swift-container-server' => 'swift-container', 'swift-container-server' => 'swift-container',
@@ -116,45 +134,10 @@ describe 'swift::storage::generic' do
'swift-object-server' => 'swift-object', 'swift-object-server' => 'swift-object',
'swift-object-replicator' => 'swift-object-replicator', 'swift-object-replicator' => 'swift-object-replicator',
'swift-object-auditor' => 'swift-object-auditor', 'swift-object-auditor' => 'swift-object-auditor',
'service_provider' => nil
} }
end when 'RedHat'
{
it_configures 'swift-storage-generic' 'swift-account-server' => 'openstack-swift-account',
context 'on Debian platforms using swiftinit service provider' do
before do
params.merge!(:service_provider => 'swiftinit')
end
let :platform_params do
{ 'swift-account-server' => 'swift-account-server',
'swift-account-replicator' => 'swift-account-replicator',
'swift-account-auditor' => 'swift-account-auditor',
'swift-container-server' => 'swift-container-server',
'swift-container-replicator' => 'swift-container-replicator',
'swift-container-auditor' => 'swift-container-auditor',
'swift-object-server' => 'swift-object-server',
'swift-object-replicator' => 'swift-object-replicator',
'swift-object-auditor' => 'swift-object-auditor',
'service_provider' => 'swiftinit',
}
end
it_configures 'swift-storage-generic'
end
end
context 'on Redhat platforms' do
let :facts do
OSDefaults.get_facts({
:operatingsystem => 'Redhat',
:osfamily => 'Redhat',
})
end
let :platform_params do
{ 'swift-account-server' => 'openstack-swift-account',
'swift-account-replicator' => 'openstack-swift-account-replicator', 'swift-account-replicator' => 'openstack-swift-account-replicator',
'swift-account-auditor' => 'openstack-swift-account-auditor', 'swift-account-auditor' => 'openstack-swift-account-auditor',
'swift-container-server' => 'openstack-swift-container', 'swift-container-server' => 'openstack-swift-container',
@@ -165,29 +148,9 @@ describe 'swift::storage::generic' do
'swift-object-auditor' => 'openstack-swift-object-auditor', 'swift-object-auditor' => 'openstack-swift-object-auditor',
} }
end end
it_configures 'swift-storage-generic'
context 'on Redhat platforms using swiftinit service provider' do
before do
params.merge!(:service_provider => 'swiftinit')
end end
let :platform_params do it_configures 'swift::storage::generic'
{ 'swift-account-server' => 'swift-account-server',
'swift-account-replicator' => 'swift-account-replicator',
'swift-account-auditor' => 'swift-account-auditor',
'swift-container-server' => 'swift-container-server',
'swift-container-replicator' => 'swift-container-replicator',
'swift-container-auditor' => 'swift-container-auditor',
'swift-object-server' => 'swift-object-server',
'swift-object-replicator' => 'swift-object-replicator',
'swift-object-auditor' => 'swift-object-auditor',
'service_provider' => 'swiftinit',
}
end
it_configures 'swift-storage-generic'
end end
end end
end end

View File

@@ -7,12 +7,25 @@ describe 'swift::storage::loopback' do
'dans_disk' 'dans_disk'
end end
shared_examples 'swift::storage::loopback' do
it { is_expected.to contain_swift__storage__xfs('dans_disk').with( it { is_expected.to contain_swift__storage__xfs('dans_disk').with(
:device => '/srv/loopback-device/dans_disk', :device => '/srv/loopback-device/dans_disk',
:mnt_base_dir => '/srv/node', :mnt_base_dir => '/srv/node',
:byte_size => '1024', :byte_size => '1024',
:subscribe => 'Exec[create_partition-dans_disk]', :subscribe => 'Exec[create_partition-dans_disk]',
:loopback => true :loopback => true
) } )}
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 'swift::storage::loopback'
end
end
end end

View File

@@ -1,4 +1,5 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::storage::mount' do describe 'swift::storage::mount' do
# TODO add unit tests # TODO add unit tests
@@ -6,6 +7,7 @@ describe 'swift::storage::mount' do
'dans_mount_point' 'dans_mount_point'
end end
shared_examples 'swift::storage::mount' do
describe 'with defaults params' do describe 'with defaults params' do
let :params do let :params do
{ {
@@ -19,11 +21,9 @@ describe 'swift::storage::mount' do
:fstype => 'xfs', :fstype => 'xfs',
:options => 'noatime,nodiratime,nobarrier,logbufs=8', :options => 'noatime,nodiratime,nobarrier,logbufs=8',
)} )}
end end
describe 'when mounting a loopback device' do describe 'when mounting a loopback device' do
let :params do let :params do
{ {
:device => '/dev/sda', :device => '/dev/sda',
@@ -35,7 +35,6 @@ describe 'swift::storage::mount' do
:device => '/dev/sda', :device => '/dev/sda',
:options => 'noatime,nodiratime,nobarrier,loop,logbufs=8' :options => 'noatime,nodiratime,nobarrier,loop,logbufs=8'
)} )}
end end
describe 'when mounting a loopback device on selinux system' do describe 'when mounting a loopback device on selinux system' do
@@ -56,6 +55,18 @@ describe 'swift::storage::mount' do
:path => ['/usr/sbin', '/sbin'], :path => ['/usr/sbin', '/sbin'],
:refreshonly => true} :refreshonly => 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
it_configures 'swift::storage::mount'
end
end end
end end

View File

@@ -1,15 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::storage::node' do describe 'swift::storage::node' do
shared_examples 'swift::storage::node' do
let :facts do
OSDefaults.get_facts({
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:os_workers => 1,
})
end
describe 'with valid preconditons should contain ring devices' do describe 'with valid preconditons should contain ring devices' do
let :params do let :params do
{ {
@@ -30,11 +22,11 @@ describe 'swift::storage::node' do
it { is_expected.to contain_ring_object_device("127.0.0.1:6010/1") } it { is_expected.to contain_ring_object_device("127.0.0.1:6010/1") }
it { is_expected.to contain_ring_container_device("127.0.0.1:6011/1") } it { is_expected.to contain_ring_container_device("127.0.0.1:6011/1") }
it { is_expected.to contain_ring_account_device("127.0.0.1:6012/1") } it { is_expected.to contain_ring_account_device("127.0.0.1:6012/1") }
end end
context 'when zone is not a number' do context 'when zone is not a number' do
let(:title) { '1' } let(:title) { '1' }
let :params do let :params do
{ :zone => 'invalid', { :zone => 'invalid',
:mnt_base_dir => '/srv/node' } :mnt_base_dir => '/srv/node' }
@@ -65,4 +57,17 @@ describe 'swift::storage::node' do
it { is_expected.to contain_ring_container_device("127.0.0.1:6011/1") } it { is_expected.to contain_ring_container_device("127.0.0.1:6011/1") }
it { is_expected.to contain_ring_account_device("127.0.0.1:6012/1") } it { is_expected.to contain_ring_account_device("127.0.0.1:6012/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 'swift::storage::node'
end
end
end end

View File

@@ -1,14 +1,6 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::storage::server' do describe 'swift::storage::server' do
let :facts do
OSDefaults.get_facts({
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:os_workers => 1,
})
end
let :pre_condition do let :pre_condition do
"class { 'swift': swift_hash_path_suffix => 'foo' } "class { 'swift': swift_hash_path_suffix => 'foo' }
class { 'swift::storage': storage_local_net_ip => '10.0.0.1' } class { 'swift::storage': storage_local_net_ip => '10.0.0.1' }
@@ -20,6 +12,7 @@ describe 'swift::storage::server' do
swift::storage::filter::recon { 'account': } swift::storage::filter::recon { 'account': }
" "
end end
let :default_params do let :default_params do
{ {
:devices => '/srv/node', :devices => '/srv/node',
@@ -32,21 +25,22 @@ describe 'swift::storage::server' do
} }
end end
shared_examples 'swift::storage::server' do
describe 'with an invalid title' do describe 'with an invalid title' do
let :params do let :params do
{:storage_local_net_ip => '127.0.0.1', {:storage_local_net_ip => '127.0.0.1',
:type => 'object'} :type => 'object'}
end end
let :title do let :title do
'foo' 'foo'
end end
it_raises 'a Puppet::Error', /does not match/ it_raises 'a Puppet::Error', /does not match/
end end
['account', 'object', 'container'].each do |t| ['account', 'object', 'container'].each do |t|
describe "for type #{t}" do describe "for type #{t}" do
let :title do let :title do
'8000' '8000'
end end
@@ -54,6 +48,7 @@ describe 'swift::storage::server' do
let :req_params do let :req_params do
{:storage_local_net_ip => '10.0.0.1', :type => t} {:storage_local_net_ip => '10.0.0.1', :type => t}
end end
let :params do let :params do
req_params req_params
end end
@@ -78,6 +73,7 @@ describe 'swift::storage::server' do
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^#{k.to_s}\s*=\s*#{v.is_a?(Array) ? v.join(' ') : v}\s*$/) } it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^#{k.to_s}\s*=\s*#{v.is_a?(Array) ? v.join(' ') : v}\s*$/) }
end end
end end
describe "when pipeline is passed an array" do describe "when pipeline is passed an array" do
let :params do req_params.merge({:pipeline => ['healthcheck','recon']}) end let :params do req_params.merge({:pipeline => ['healthcheck','recon']}) end
it { is_expected.to contain_concat__fragment("swift-#{t}-#{title}").with( it { is_expected.to contain_concat__fragment("swift-#{t}-#{title}").with(
@@ -85,6 +81,7 @@ describe 'swift::storage::server' do
:before => ["Swift::Storage::Filter::Healthcheck[#{t}]", "Swift::Storage::Filter::Recon[#{t}]",] :before => ["Swift::Storage::Filter::Healthcheck[#{t}]", "Swift::Storage::Filter::Recon[#{t}]",]
)} )}
end end
describe "when pipeline is not passed an array" do describe "when pipeline is not passed an array" do
let :params do req_params.merge({:pipeline => 'not an array'}) end let :params do req_params.merge({:pipeline => 'not an array'}) end
it_raises 'a Puppet::Error', /is not an Array/ it_raises 'a Puppet::Error', /is not an Array/
@@ -94,6 +91,7 @@ describe 'swift::storage::server' do
let :params do req_params.merge({:replicator_concurrency => 42}) end let :params do req_params.merge({:replicator_concurrency => 42}) end
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/\[#{t}-replicator\]\nconcurrency\s*=\s*42\s*$/m) } it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/\[#{t}-replicator\]\nconcurrency\s*=\s*42\s*$/m) }
end end
if t != 'account' if t != 'account'
describe "when updater_concurrency is set" do describe "when updater_concurrency is set" do
let :params do req_params.merge({:updater_concurrency => 73}) end let :params do req_params.merge({:updater_concurrency => 73}) end
@@ -105,12 +103,14 @@ describe 'swift::storage::server' do
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/\[#{t}-reaper\]\nconcurrency\s*=\s*4682\s*$/m) } it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/\[#{t}-reaper\]\nconcurrency\s*=\s*4682\s*$/m) }
end end
end end
if t == 'container' if t == 'container'
describe "when allow_versioning is set" do describe "when allow_versioning is set" do
let :params do req_params.merge({ :allow_versions => false, }) end let :params do req_params.merge({ :allow_versions => false, }) end
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/\[app:container-server\]\nallow_versions\s*=\s*false\s*$/m) } it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/\[app:container-server\]\nallow_versions\s*=\s*false\s*$/m) }
end end
end end
describe "when log_udp_port is set" do describe "when log_udp_port is set" do
context 'and log_udp_host is not set' do context 'and log_udp_host is not set' do
let :params do req_params.merge({ :log_udp_port => 514}) end let :params do req_params.merge({ :log_udp_port => 514}) end
@@ -136,6 +136,7 @@ describe 'swift::storage::server' do
end end
it { is_expected.to contain_concat("/etc/swift/#{t}-server.conf").that_comes_before("Swift_#{t}_config[foo/bar]") } it { is_expected.to contain_concat("/etc/swift/#{t}-server.conf").that_comes_before("Swift_#{t}_config[foo/bar]") }
end end
describe "when log_requests is turned off" do describe "when log_requests is turned off" do
let :params do req_params.merge({:log_requests => false}) end let :params do req_params.merge({:log_requests => false}) end
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_requests\s*=\s*false\s*$/) } it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_requests\s*=\s*false\s*$/) }
@@ -170,10 +171,23 @@ describe 'swift::storage::server' do
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_level\s*=\s*INFO\s*$/) } it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_level\s*=\s*INFO\s*$/) }
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_address\s*=\s*\/dev\/log\s*$/) } it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_address\s*=\s*\/dev\/log\s*$/) }
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_requests\s*=\s*true\s*$/) } it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_requests\s*=\s*true\s*$/) }
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^workers\s*=\s*1\s*$/) } it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^workers\s*=\s*2\s*$/) }
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^concurrency\s*=\s*1\s*$/) } it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^concurrency\s*=\s*1\s*$/) }
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^pipeline\s*=\s*#{t}-server\s*$/) } it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^pipeline\s*=\s*#{t}-server\s*$/) }
end end
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 'swift::storage::server'
end
end
end end

View File

@@ -1,9 +1,11 @@
require 'spec_helper' require 'spec_helper'
describe 'swift::storage::xfs' do describe 'swift::storage::xfs' do
let :title do let :title do
'foo' 'foo'
end end
shared_examples 'swift::storage::xfs' do
describe 'when a device is specified' do describe 'when a device is specified' do
let :default_params do let :default_params do
{ {
@@ -43,8 +45,20 @@ describe 'swift::storage::xfs' do
:mnt_base_dir => param_hash[:mnt_base_dir], :mnt_base_dir => param_hash[:mnt_base_dir],
:loopback => param_hash[:loopback], :loopback => param_hash[:loopback],
)} )}
end end
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 'swift::storage::xfs'
end
end
end end