1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
require 'spec_helper'
describe 'swift::storage::generic' do
let :title do
'account'
end
let :pre_condition do
"class { 'swift': swift_hash_path_suffix => 'foo' }
class { 'swift::storage': storage_local_net_ip => '10.0.0.1' }"
end
let :params do
{ :package_ensure => 'present',
:enabled => true,
:manage_service => true }
end
shared_examples 'swift::storage::generic' do
describe 'with an invalid title' do
let :title do
'foo'
end
it { should raise_error(Puppet::Error) }
end
%w(account object container).each do |t|
[{},
{ :package_ensure => 'latest', :service_provider => 'swiftinit' }
].each do |param_set|
describe "when #{param_set == {} ? 'using default' : 'specifying'} class parameters" do
before do
params.merge!(param_set)
end
let :title do
t
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 => false, :manage_service => true }].each do |param_hash_manage|
context "when service is_expected.to be #{param_hash_manage[:enabled] ? 'enabled' : 'disabled'}" do
before do
params.merge!(param_hash_manage)
if param_set[:service_provider] == 'swiftinit'
platform_params.merge!(swiftinit_platform)
end
end
it do
is_expected.to contain_package("swift-#{t}").with(
:ensure => params[:package_ensure],
:tag => ['openstack', 'swift-package'],
:notify => ['Anchor[swift::install::end]']
)
end
it do
is_expected.to contain_service("swift-#{t}-server").with(
:name => platform_params["swift-#{t}-server"],
:ensure => (param_hash_manage[:manage_service] && param_hash_manage[:enabled]) ? 'running' : 'stopped',
:enable => param_hash_manage[:enabled],
:provider => param_set[:service_provider],
:tag => ['swift-service', "swift-#{t}-service"],
)
end
it do
is_expected.to contain_service("swift-#{t}-replicator").with(
:name => platform_params["swift-#{t}-replicator"],
:ensure => (param_hash_manage[:manage_service] && param_hash_manage[:enabled]) ? 'running' : 'stopped',
:enable => param_hash_manage[:enabled],
:provider => param_set[:service_provider],
:tag => ['swift-service', "swift-#{t}-service"],
)
end
it do
is_expected.to contain_service("swift-#{t}-auditor").with(
:name => platform_params["swift-#{t}-auditor"],
:ensure => (param_hash_manage[:manage_service] && param_hash_manage[:enabled]) ? 'running' : 'stopped',
:enable => param_hash_manage[:enabled],
:provider => param_set[:service_provider],
:tag => ['swift-service', "swift-#{t}-service"],
)
end
it do
is_expected.to contain_file("/etc/swift/#{t}-server/").with(
:ensure => 'directory',
)
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
let(:platform_params) do
case facts[:os]['family']
when 'Debian'
{
'swift-account-server' => 'swift-account',
'swift-account-replicator' => 'swift-account-replicator',
'swift-account-auditor' => 'swift-account-auditor',
'swift-container-server' => 'swift-container',
'swift-container-replicator' => 'swift-container-replicator',
'swift-container-auditor' => 'swift-container-auditor',
'swift-object-server' => 'swift-object',
'swift-object-replicator' => 'swift-object-replicator',
'swift-object-auditor' => 'swift-object-auditor',
}
when 'RedHat'
{
'swift-account-server' => 'openstack-swift-account',
'swift-account-replicator' => 'openstack-swift-account-replicator',
'swift-account-auditor' => 'openstack-swift-account-auditor',
'swift-container-server' => 'openstack-swift-container',
'swift-container-replicator' => 'openstack-swift-container-replicator',
'swift-container-auditor' => 'openstack-swift-container-auditor',
'swift-object-server' => 'openstack-swift-object',
'swift-object-replicator' => 'openstack-swift-object-replicator',
'swift-object-auditor' => 'openstack-swift-object-auditor',
}
end
end
it_configures 'swift::storage::generic'
end
end
end
|