| 1 |
# |
| 2 |
# Copyright (C) 2014 Catalyst IT Limited. |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
# you may not use this file except in compliance with the License. |
| 6 |
# You may obtain a copy of the License at |
| 7 |
# |
| 8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
# See the License for the specific language governing permissions and |
| 14 |
# limitations under the License. |
| 15 |
# |
| 16 |
# Author: Ricardo Rocha <[email protected]> |
| 17 |
# |
| 18 |
require 'spec_helper' |
| 19 |
|
| 20 |
describe 'ceph::rgw' do |
| 21 |
let :pre_condition do |
| 22 |
'include ceph::params' |
| 23 |
end |
| 24 |
|
| 25 |
shared_examples 'ceph::rgw on Ubuntu 14.04' do |
| 26 |
before do |
| 27 |
facts.merge!( :operatingsystem => 'Ubuntu', |
| 28 |
:operatingsystemrelease => '14.04', |
| 29 |
:service_provider => 'upstart' ) |
| 30 |
end |
| 31 |
|
| 32 |
context 'activated with default params' do |
| 33 |
let :title do |
| 34 |
'radosgw.gateway' |
| 35 |
end |
| 36 |
|
| 37 |
it { should contain_package('radosgw').with('ensure' => 'installed') } |
| 38 |
it { should contain_ceph_config('client.radosgw.gateway/user').with_value('www-data') } |
| 39 |
it { should contain_ceph_config('client.radosgw.gateway/host').with_value('myhost') } |
| 40 |
it { should contain_ceph_config('client.radosgw.gateway/keyring').with_value('/etc/ceph/ceph.client.radosgw.gateway.keyring') } |
| 41 |
it { should contain_ceph_config('client.radosgw.gateway/log_file').with_value('/var/log/ceph/radosgw.log') } |
| 42 |
it { should contain_ceph_config('client.radosgw.gateway/rgw_dns_name').with_value('myhost.domain') } |
| 43 |
it { should contain_ceph_config('client.radosgw.gateway/rgw_swift_url').with_value('http://myhost.domain:7480') } |
| 44 |
|
| 45 |
it { should contain_file('/var/lib/ceph/radosgw').with( |
| 46 |
:ensure => 'directory', |
| 47 |
:mode => '0755', |
| 48 |
:selinux_ignore_defaults => true, |
| 49 |
)} |
| 50 |
|
| 51 |
it { should contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway').with( |
| 52 |
:ensure => 'directory', |
| 53 |
:owner => 'root', |
| 54 |
:group => 'root', |
| 55 |
:mode => '0750', |
| 56 |
:selinux_ignore_defaults => true, |
| 57 |
)} |
| 58 |
|
| 59 |
it { should contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway/done') } |
| 60 |
it { should contain_service('radosgw-radosgw.gateway') } |
| 61 |
end |
| 62 |
|
| 63 |
context 'activated with custom params' do |
| 64 |
let :title do |
| 65 |
'radosgw.custom' |
| 66 |
end |
| 67 |
|
| 68 |
let :params do |
| 69 |
{ |
| 70 |
:pkg_radosgw => 'pkgradosgw', |
| 71 |
:rgw_ensure => 'stopped', |
| 72 |
:rgw_enable => false, |
| 73 |
:rgw_data => "/var/lib/ceph/radosgw/ceph-radosgw.custom", |
| 74 |
:user => 'wwwuser', |
| 75 |
:keyring_path => "/etc/ceph/ceph.radosgw.custom.keyring", |
| 76 |
:log_file => '/var/log/ceph/mylogfile.log', |
| 77 |
:rgw_dns_name => 'mydns.hostname', |
| 78 |
:rgw_swift_url => 'https://mydns.hostname:443' |
| 79 |
} |
| 80 |
end |
| 81 |
|
| 82 |
it { should contain_package('pkgradosgw').with('ensure' => 'installed') } |
| 83 |
|
| 84 |
it { should contain_ceph_config('client.radosgw.custom/host').with_value('myhost') } |
| 85 |
it { should contain_ceph_config('client.radosgw.custom/keyring').with_value('/etc/ceph/ceph.radosgw.custom.keyring') } |
| 86 |
it { should contain_ceph_config('client.radosgw.custom/log_file').with_value('/var/log/ceph/mylogfile.log') } |
| 87 |
it { should contain_ceph_config('client.radosgw.custom/user').with_value('wwwuser') } |
| 88 |
it { should contain_ceph_config('client.radosgw.custom/rgw_dns_name').with_value('mydns.hostname') } |
| 89 |
it { should contain_ceph_config('client.radosgw.custom/rgw_swift_url').with_value('https://mydns.hostname:443') } |
| 90 |
|
| 91 |
it { should contain_file('/var/lib/ceph/radosgw/ceph-radosgw.custom').with( |
| 92 |
:ensure => 'directory', |
| 93 |
:owner => 'root', |
| 94 |
:group => 'root', |
| 95 |
:mode => '0750', |
| 96 |
:selinux_ignore_defaults => true, |
| 97 |
)} |
| 98 |
|
| 99 |
it { should_not contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway/done') } |
| 100 |
it { should contain_service('radosgw-radosgw.custom').with('ensure' => 'stopped' ) } |
| 101 |
end |
| 102 |
end |
| 103 |
|
| 104 |
shared_examples 'ceph::rgw on Ubuntu 16.04' do |
| 105 |
before do |
| 106 |
facts.merge!( :operatingsystem => 'Ubuntu', |
| 107 |
:operatingsystemrelease => '16.04', |
| 108 |
:service_provider => 'systemd' ) |
| 109 |
end |
| 110 |
|
| 111 |
context 'activated with default params' do |
| 112 |
let :title do |
| 113 |
'radosgw.gateway' |
| 114 |
end |
| 115 |
|
| 116 |
it { should contain_package('radosgw').with('ensure' => 'installed') } |
| 117 |
it { should contain_ceph_config('client.radosgw.gateway/user').with_value('www-data') } |
| 118 |
it { should contain_ceph_config('client.radosgw.gateway/host').with_value('myhost') } |
| 119 |
it { should contain_ceph_config('client.radosgw.gateway/keyring').with_value('/etc/ceph/ceph.client.radosgw.gateway.keyring') } |
| 120 |
it { should contain_ceph_config('client.radosgw.gateway/log_file').with_value('/var/log/ceph/radosgw.log') } |
| 121 |
|
| 122 |
it { should contain_file('/var/lib/ceph/radosgw').with( |
| 123 |
:ensure => 'directory', |
| 124 |
:mode => '0755', |
| 125 |
:selinux_ignore_defaults => true, |
| 126 |
)} |
| 127 |
|
| 128 |
it { should contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway').with( |
| 129 |
:ensure => 'directory', |
| 130 |
:owner => 'root', |
| 131 |
:group => 'root', |
| 132 |
:mode => '0750', |
| 133 |
:selinux_ignore_defaults => true, |
| 134 |
)} |
| 135 |
|
| 136 |
it { should contain_service('radosgw-radosgw.gateway') } |
| 137 |
end |
| 138 |
|
| 139 |
context 'activated with custom params' do |
| 140 |
let :title do |
| 141 |
'radosgw.custom' |
| 142 |
end |
| 143 |
|
| 144 |
let :params do |
| 145 |
{ |
| 146 |
:pkg_radosgw => 'pkgradosgw', |
| 147 |
:rgw_ensure => 'stopped', |
| 148 |
:rgw_enable => false, |
| 149 |
:rgw_data => '/var/lib/ceph/radosgw/ceph-radosgw.custom', |
| 150 |
:user => 'wwwuser', |
| 151 |
:keyring_path => '/etc/ceph/ceph.radosgw.custom.keyring', |
| 152 |
:log_file => '/var/log/ceph/mylogfile.log', |
| 153 |
} |
| 154 |
end |
| 155 |
|
| 156 |
it { should contain_package('pkgradosgw').with('ensure' => 'installed') } |
| 157 |
|
| 158 |
it { should contain_ceph_config('client.radosgw.custom/host').with_value('myhost') } |
| 159 |
it { should contain_ceph_config('client.radosgw.custom/keyring').with_value('/etc/ceph/ceph.radosgw.custom.keyring') } |
| 160 |
it { should contain_ceph_config('client.radosgw.custom/log_file').with_value('/var/log/ceph/mylogfile.log') } |
| 161 |
it { should contain_ceph_config('client.radosgw.custom/user').with_value('wwwuser') } |
| 162 |
|
| 163 |
it { should contain_file('/var/lib/ceph/radosgw/ceph-radosgw.custom').with( |
| 164 |
:ensure => 'directory', |
| 165 |
:owner => 'root', |
| 166 |
:group => 'root', |
| 167 |
:mode => '0750', |
| 168 |
:selinux_ignore_defaults => true, |
| 169 |
)} |
| 170 |
|
| 171 |
it { should_not contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway/done') } |
| 172 |
it { should contain_service('radosgw-radosgw.custom').with('ensure' => 'stopped' ) } |
| 173 |
end |
| 174 |
end |
| 175 |
|
| 176 |
shared_examples 'ceph::rgw on RedHat' do |
| 177 |
before do |
| 178 |
facts.merge!( :operatingsystem => 'RedHat', |
| 179 |
:operatingsystemrelease => '7.2', |
| 180 |
:operatingsystemmajrelease => '7' ) |
| 181 |
end |
| 182 |
|
| 183 |
context 'activated with default params' do |
| 184 |
let :title do |
| 185 |
'radosgw.gateway' |
| 186 |
end |
| 187 |
|
| 188 |
it { should contain_package('ceph-radosgw').with('ensure' => 'installed') } |
| 189 |
it { should contain_ceph_config('client.radosgw.gateway/user').with_value('apache') } |
| 190 |
it { should contain_ceph_config('client.radosgw.gateway/host').with_value('myhost') } |
| 191 |
it { should contain_ceph_config('client.radosgw.gateway/keyring').with_value('/etc/ceph/ceph.client.radosgw.gateway.keyring') } |
| 192 |
it { should contain_ceph_config('client.radosgw.gateway/log_file').with_value('/var/log/ceph/radosgw.log') } |
| 193 |
|
| 194 |
it { should contain_file('/var/lib/ceph/radosgw').with( |
| 195 |
:ensure => 'directory', |
| 196 |
:mode => '0755', |
| 197 |
:selinux_ignore_defaults => true, |
| 198 |
)} |
| 199 |
|
| 200 |
it { should contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway').with( |
| 201 |
:ensure => 'directory', |
| 202 |
:owner => 'root', |
| 203 |
:group => 'root', |
| 204 |
:mode => '0750', |
| 205 |
:selinux_ignore_defaults => true, |
| 206 |
)} |
| 207 |
|
| 208 |
it { should contain_service('radosgw-radosgw.gateway') } |
| 209 |
end |
| 210 |
|
| 211 |
context 'activated with custom params' do |
| 212 |
let :title do |
| 213 |
'radosgw.custom' |
| 214 |
end |
| 215 |
|
| 216 |
let :params do |
| 217 |
{ |
| 218 |
:pkg_radosgw => 'pkgradosgw', |
| 219 |
:rgw_ensure => 'stopped', |
| 220 |
:rgw_enable => false, |
| 221 |
:rgw_data => "/var/lib/ceph/radosgw/ceph-radosgw.custom", |
| 222 |
:user => 'wwwuser', |
| 223 |
:keyring_path => "/etc/ceph/ceph.radosgw.custom.keyring", |
| 224 |
:log_file => '/var/log/ceph/mylogfile.log', |
| 225 |
} |
| 226 |
end |
| 227 |
|
| 228 |
it { should contain_package('pkgradosgw').with('ensure' => 'installed') } |
| 229 |
|
| 230 |
it { should contain_ceph_config('client.radosgw.custom/host').with_value('myhost') } |
| 231 |
it { should contain_ceph_config('client.radosgw.custom/keyring').with_value('/etc/ceph/ceph.radosgw.custom.keyring') } |
| 232 |
it { should contain_ceph_config('client.radosgw.custom/log_file').with_value('/var/log/ceph/mylogfile.log') } |
| 233 |
it { should contain_ceph_config('client.radosgw.custom/user').with_value('wwwuser') } |
| 234 |
|
| 235 |
it { should contain_file('/var/lib/ceph/radosgw/ceph-radosgw.custom').with( |
| 236 |
:ensure => 'directory', |
| 237 |
:owner => 'root', |
| 238 |
:group => 'root', |
| 239 |
:mode => '0750', |
| 240 |
:selinux_ignore_defaults => true, |
| 241 |
)} |
| 242 |
|
| 243 |
it { should contain_service('radosgw-radosgw.custom').with('ensure' => 'stopped' ) } |
| 244 |
end |
| 245 |
end |
| 246 |
|
| 247 |
on_supported_os({ |
| 248 |
:supported_os => OSDefaults.get_supported_os |
| 249 |
}).each do |os,facts| |
| 250 |
context "on #{os}" do |
| 251 |
let (:facts) do |
| 252 |
facts.merge!(OSDefaults.get_facts( :concat_basedir => '/var/lib/puppet/concat', |
| 253 |
:fqdn => 'myhost.domain', |
| 254 |
:hostname => 'myhost' )) |
| 255 |
end |
| 256 |
|
| 257 |
if facts[:operatingsystem] == 'Ubuntu' |
| 258 |
it_behaves_like 'ceph::rgw on Ubuntu 14.04' |
| 259 |
it_behaves_like 'ceph::rgw on Ubuntu 16.04' |
| 260 |
end |
| 261 |
|
| 262 |
if facts[:osfamily] == 'RedHat' |
| 263 |
it_behaves_like 'ceph::rgw on RedHat' |
| 264 |
end |
| 265 |
end |
| 266 |
end |
| 267 |
end |