
Few weeks ago, a patchset[1] that aims to treat the value '<SERVICE
DEFAULT>' of a parameter as if ensure => absent has been merged.
The final objective of this patch was to make our manifests lighter to
read and write by avoiding the pattern
if $var { value => $var } else { ensure => absent }
This commit brings this feature to the puppet-cinder module and remains
backward compatible with what was in place before.
This commit switches a part of the module, another commit will switch the
other part (init.pp/paste).
The split in reviews aims to offer :
* easier readability on this one
* the other review might needs other change as well - not a drop in
replacement, contrary to this one so it is simpler to split it.
[1]
b554d30aaf
Change-Id: I005096625a9ea7d069893e4a3d64aa31e074378e
83 lines
3.0 KiB
Ruby
83 lines
3.0 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe 'cinder::volume::rbd' do
|
|
let :req_params do
|
|
{
|
|
:rbd_pool => 'volumes',
|
|
:rbd_user => 'test',
|
|
:rbd_secret_uuid => '<SERVICE DEFAULT>',
|
|
:rbd_ceph_conf => '/foo/boo/zoo/ceph.conf',
|
|
:rbd_flatten_volume_from_snapshot => true,
|
|
:volume_tmp_dir => '<SERVICE DEFAULT>',
|
|
:rbd_max_clone_depth => '0',
|
|
}
|
|
end
|
|
|
|
it { is_expected.to contain_class('cinder::params') }
|
|
|
|
let :params do
|
|
req_params
|
|
end
|
|
|
|
let :facts do
|
|
{:osfamily => 'Debian'}
|
|
end
|
|
|
|
describe 'rbd volume driver' do
|
|
it 'configure rbd volume driver' do
|
|
is_expected.to contain_cinder_config('DEFAULT/volume_driver').with_value('cinder.volume.drivers.rbd.RBDDriver')
|
|
|
|
is_expected.to contain_cinder_config('DEFAULT/rbd_ceph_conf').with_value(req_params[:rbd_ceph_conf])
|
|
is_expected.to contain_cinder_config('DEFAULT/rbd_flatten_volume_from_snapshot').with_value(req_params[:rbd_flatten_volume_from_snapshot])
|
|
is_expected.to contain_cinder_config('DEFAULT/volume_tmp_dir').with_value(req_params[:volume_tmp_dir])
|
|
is_expected.to contain_cinder_config('DEFAULT/rbd_max_clone_depth').with_value(req_params[:rbd_max_clone_depth])
|
|
is_expected.to contain_cinder_config('DEFAULT/rbd_pool').with_value(req_params[:rbd_pool])
|
|
is_expected.to contain_cinder_config('DEFAULT/rbd_user').with_value(req_params[:rbd_user])
|
|
is_expected.to contain_cinder_config('DEFAULT/rbd_secret_uuid').with_value(req_params[:rbd_secret_uuid])
|
|
is_expected.to contain_cinder_config('DEFAULT/host').with_value('rbd:'"#{req_params[:rbd_pool]}")
|
|
is_expected.to contain_file('/etc/init/cinder-volume.override').with(:ensure => 'present')
|
|
is_expected.to contain_file_line('set initscript env').with(
|
|
:line => /env CEPH_ARGS=\"--id test\"/,
|
|
:path => '/etc/init/cinder-volume.override',
|
|
:notify => 'Service[cinder-volume]')
|
|
end
|
|
|
|
end
|
|
|
|
describe 'rbd volume driver with additional configuration' do
|
|
before :each do
|
|
params.merge!({:extra_options => {'rbd_backend/param1' => {'value' => 'value1'}}})
|
|
end
|
|
it 'configure rbd volume with additional configuration' do
|
|
is_expected.to contain_cinder__backend__rbd('DEFAULT').with({
|
|
:extra_options => {'rbd_backend/param1' => {'value' => 'value1'}}
|
|
})
|
|
end
|
|
end
|
|
|
|
describe 'with RedHat' do
|
|
let :facts do
|
|
{ :osfamily => 'RedHat' }
|
|
end
|
|
|
|
let :params do
|
|
req_params
|
|
end
|
|
|
|
it 'should ensure that the cinder-volume sysconfig file is present' do
|
|
is_expected.to contain_file('/etc/sysconfig/openstack-cinder-volume').with(
|
|
:ensure => 'present'
|
|
)
|
|
end
|
|
|
|
it 'should configure RedHat init override' do
|
|
is_expected.to contain_file_line('set initscript env').with(
|
|
:line => /export CEPH_ARGS=\"--id test\"/,
|
|
:path => '/etc/sysconfig/openstack-cinder-volume',
|
|
:notify => 'Service[cinder-volume]')
|
|
end
|
|
end
|
|
|
|
end
|
|
|