Files
puppet-cinder/spec/classes/cinder_volume_rbd_spec.rb
Sebastien Badia 4224fdd12e spec: updates for rspec-puppet 2.x and rspec 3.x
This patch aim to update our specs test in order to work with the

rspec-puppet release 2.0.0, in the mean time, we update rspec syntax
in order to be prepared for rspec 3.x move.

In details:

  * Use shared_examples "a Puppet::Error" for puppet::error tests
  * Convert 'should' keyword to 'is_expected.to' (prepare rspec 3.x)
  * Fix spec tests for rspec-puppet 2.0.0
  * Upgrade and pin rspec-puppet from 1.0.1 to 2.0.0
  * Clean Gemfile (remove over-specificication of runtime deps of puppetlabs_spec_helper)

Change-Id: Id5b428fb518f40cf92cd27078d36f19b6d60226b
Card: https://trello.com/c/eHXc1Ryd/4-investigate-the-necessary-change-to-be-rspec-puppet-2-0-0-compliant
2015-03-11 17:58:49 +01:00

82 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 => '0123456789',
:rbd_ceph_conf => '/foo/boo/zoo/ceph.conf',
:rbd_flatten_volume_from_snapshot => true,
:volume_tmp_dir => '/foo/tmp',
: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_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
context 'with rbd_secret_uuid disabled' do
let(:params) { req_params.merge!({:rbd_secret_uuid => false}) }
it { is_expected.to contain_cinder_config('DEFAULT/rbd_secret_uuid').with_ensure('absent') }
end
context 'with volume_tmp_dir disabled' do
let(:params) { req_params.merge!({:volume_tmp_dir => false}) }
it { is_expected.to contain_cinder_config('DEFAULT/volume_tmp_dir').with_ensure('absent') }
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