2015-09-10 15:51:52 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'swift::objectexpirer' do
|
|
|
|
|
|
|
|
let :default_params do
|
|
|
|
{ :manage_service => true,
|
|
|
|
:enabled => true,
|
|
|
|
:package_ensure => 'present',
|
2021-01-26 21:08:48 +09:00
|
|
|
:pipeline => ['catch_errors', 'proxy-logging', 'cache', 'proxy-server'],
|
2022-08-22 21:32:20 +09:00
|
|
|
:auto_create_account_prefix => '<SERVICE DEFAULT>',
|
|
|
|
:concurrency => '<SERVICE DEFAULT>',
|
|
|
|
:expiring_objects_account_name => '<SERVICE DEFAULT>',
|
|
|
|
:interval => '<SERVICE DEFAULT>',
|
|
|
|
:process => '<SERVICE DEFAULT>',
|
|
|
|
:processes => '<SERVICE DEFAULT>',
|
|
|
|
:reclaim_age => '<SERVICE DEFAULT>',
|
|
|
|
:recon_cache_path => '<SERVICE DEFAULT>',
|
|
|
|
:report_interval => '<SERVICE DEFAULT>',
|
2018-05-04 14:20:57 -04:00
|
|
|
:log_facility => 'LOG_LOCAL2',
|
|
|
|
:log_level => 'INFO',
|
2021-01-08 14:05:06 +01:00
|
|
|
:memcache_servers => ['127.0.0.1:11211'],
|
|
|
|
:cache_tls_enabled => false,
|
|
|
|
}
|
2015-09-10 15:51:52 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
let :params do
|
|
|
|
{}
|
|
|
|
end
|
|
|
|
|
2016-09-27 17:50:21 +10:00
|
|
|
let :pre_condition do
|
|
|
|
'class { "memcached": max_memory => 1 }'
|
|
|
|
end
|
2015-09-10 15:51:52 +02:00
|
|
|
|
2018-05-17 00:13:44 +02:00
|
|
|
shared_examples 'swift::object::expirer' do
|
2015-09-10 15:51:52 +02:00
|
|
|
let (:p) { default_params.merge!(params) }
|
|
|
|
|
2016-09-27 17:50:21 +10:00
|
|
|
context 'with defaults' do
|
|
|
|
it 'configures object-expirer.conf' do
|
|
|
|
is_expected.to contain_swift_object_expirer_config(
|
|
|
|
'pipeline:main/pipeline').with_value(p[:pipeline].join(' '))
|
|
|
|
is_expected.to contain_swift_object_expirer_config(
|
|
|
|
'object-expirer/auto_create_account_prefix').with_value(p[:auto_create_account_prefix])
|
|
|
|
is_expected.to contain_swift_object_expirer_config(
|
|
|
|
'object-expirer/concurrency').with_value(p[:concurrency])
|
|
|
|
is_expected.to contain_swift_object_expirer_config(
|
|
|
|
'object-expirer/expiring_objects_account_name').with_value(p[:expiring_objects_account_name])
|
|
|
|
is_expected.to contain_swift_object_expirer_config(
|
|
|
|
'object-expirer/interval').with_value(p[:interval])
|
|
|
|
is_expected.to contain_swift_object_expirer_config(
|
|
|
|
'object-expirer/process').with_value(p[:process])
|
|
|
|
is_expected.to contain_swift_object_expirer_config(
|
|
|
|
'object-expirer/processes').with_value(p[:processes])
|
|
|
|
is_expected.to contain_swift_object_expirer_config(
|
|
|
|
'object-expirer/reclaim_age').with_value(p[:reclaim_age])
|
|
|
|
is_expected.to contain_swift_object_expirer_config(
|
|
|
|
'object-expirer/recon_cache_path').with_value(p[:recon_cache_path])
|
|
|
|
is_expected.to contain_swift_object_expirer_config(
|
|
|
|
'object-expirer/report_interval').with_value(p[:report_interval])
|
2018-05-04 14:20:57 -04:00
|
|
|
is_expected.to contain_swift_object_expirer_config(
|
|
|
|
'object-expirer/log_level').with_value(p[:log_level])
|
|
|
|
is_expected.to contain_swift_object_expirer_config(
|
|
|
|
'object-expirer/log_facility').with_value(p[:log_facility])
|
2021-01-26 21:08:48 +09:00
|
|
|
is_expected.to contain_swift_object_expirer_config(
|
|
|
|
'filter:cache/memcache_servers').with_value(p[:memcache_servers])
|
2016-09-27 17:50:21 +10:00
|
|
|
end
|
2015-09-10 15:51:52 +02:00
|
|
|
|
2016-09-27 17:50:21 +10:00
|
|
|
it 'configures object-expirer service' do
|
|
|
|
is_expected.to contain_service('swift-object-expirer').with(
|
|
|
|
:ensure => (p[:manage_service] && p[:enabled]) ? 'running' : 'stopped',
|
|
|
|
:name => platform_params[:service_name],
|
|
|
|
:provider => platform_params[:service_provider],
|
|
|
|
:enable => p[:enabled]
|
|
|
|
)
|
|
|
|
end
|
2015-09-10 15:51:52 +02:00
|
|
|
end
|
|
|
|
|
2022-06-27 16:56:49 +05:30
|
|
|
context 'when overriding parameters' do
|
2016-09-27 17:50:21 +10:00
|
|
|
before do
|
|
|
|
params.merge!(
|
|
|
|
:interval => '600',
|
|
|
|
:reclaim_age => '10000',
|
|
|
|
:concurrency => '3',
|
|
|
|
)
|
|
|
|
end
|
2015-09-10 15:51:52 +02:00
|
|
|
end
|
|
|
|
|
2021-01-26 21:08:48 +09:00
|
|
|
context 'when cache is not included in pipeline' do
|
2015-09-10 15:51:52 +02:00
|
|
|
before do
|
|
|
|
params.merge!(
|
2021-01-26 21:08:48 +09:00
|
|
|
:pipeline => ['catch_errors', 'proxy-logging', 'proxy-server'],
|
2015-09-10 15:51:52 +02:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2021-01-26 21:08:48 +09:00
|
|
|
it 'should not configure memcache servers' do
|
2022-04-06 10:37:58 +09:00
|
|
|
is_expected.to contain_swift_object_expirer_config(
|
|
|
|
'filter:cache/memcache_servers').with_ensure('absent')
|
2016-09-27 17:50:21 +10:00
|
|
|
end
|
2015-09-10 15:51:52 +02:00
|
|
|
end
|
2015-11-03 16:35:36 -05:00
|
|
|
|
2016-09-27 17:50:21 +10:00
|
|
|
context 'when using swiftinit service provider' do
|
2015-11-03 16:35:36 -05:00
|
|
|
before do
|
|
|
|
params.merge!({ :service_provider => 'swiftinit' })
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
platform_params.merge!({ :service_provider => 'swiftinit' })
|
|
|
|
end
|
|
|
|
end
|
2015-09-10 15:51:52 +02:00
|
|
|
end
|
|
|
|
|
2016-09-27 17:50:21 +10:00
|
|
|
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
|
2015-09-10 15:51:52 +02:00
|
|
|
|
2016-09-27 17:50:21 +10:00
|
|
|
let(:platform_params) do
|
2023-03-02 12:49:54 +09:00
|
|
|
case facts[:os]['family']
|
2016-09-27 17:50:21 +10:00
|
|
|
when 'Debian'
|
|
|
|
{ :service_name => 'swift-object-expirer',
|
|
|
|
:service_provider => nil }
|
|
|
|
when 'RedHat'
|
|
|
|
{ :service_name => 'openstack-swift-object-expirer',
|
|
|
|
:service_provider => nil }
|
2015-09-10 15:51:52 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-17 00:13:44 +02:00
|
|
|
it_configures 'swift::object::expirer'
|
2015-09-10 15:51:52 +02:00
|
|
|
end
|
2015-11-03 16:35:36 -05:00
|
|
|
|
2015-09-10 15:51:52 +02:00
|
|
|
end
|
|
|
|
end
|