0636344c0a72f8a677e1f5964618f41e41449789
[mirror/dsa-puppet.git] / 3rdparty / modules / cinder / spec / defines / cinder_backend_rbd_spec.rb
1 require 'spec_helper'
2
3 describe 'cinder::backend::rbd' do
4
5   let(:title) {'rbd-ssd'}
6
7   let :req_params do
8     {
9       :volume_backend_name              => 'rbd-ssd',
10       :rbd_pool                         => 'volumes',
11       :glance_api_version               => '2',
12       :rbd_user                         => 'test',
13       :rbd_secret_uuid                  => '0123456789',
14       :rbd_ceph_conf                    => '/foo/boo/zoo/ceph.conf',
15       :rbd_flatten_volume_from_snapshot => true,
16       :volume_tmp_dir                   => '/foo/tmp',
17       :rbd_max_clone_depth              => '0'
18     }
19   end
20
21   it { should contain_class('cinder::params') }
22
23   let :params do
24     req_params
25   end
26
27   let :facts do
28     {:osfamily => 'Debian'}
29   end
30
31   describe 'rbd backend volume driver' do
32     it 'configure rbd volume driver' do
33       should contain_cinder_config("#{req_params[:volume_backend_name]}/volume_backend_name").with_value(req_params[:volume_backend_name])
34       should contain_cinder_config("#{req_params[:volume_backend_name]}/volume_driver").with_value('cinder.volume.drivers.rbd.RBDDriver')
35       should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_ceph_conf").with_value(req_params[:rbd_ceph_conf])
36       should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_flatten_volume_from_snapshot").with_value(req_params[:rbd_flatten_volume_from_snapshot])
37       should contain_cinder_config("#{req_params[:volume_backend_name]}/volume_tmp_dir").with_value(req_params[:volume_tmp_dir])
38       should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_max_clone_depth").with_value(req_params[:rbd_max_clone_depth])
39       should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_pool").with_value(req_params[:rbd_pool])
40       should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_user").with_value(req_params[:rbd_user])
41       should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_secret_uuid").with_value(req_params[:rbd_secret_uuid])
42       should contain_file('/etc/init/cinder-volume.override').with(:ensure => 'present')
43       should contain_file_line('set initscript env').with(
44         :line    => /env CEPH_ARGS=\"--id test\"/,
45         :path    => '/etc/init/cinder-volume.override',
46         :notify  => 'Service[cinder-volume]')
47     end
48
49     context 'with rbd_secret_uuid disabled' do
50       let(:params) { req_params.merge!({:rbd_secret_uuid => false}) }
51       it { should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_secret_uuid").with_ensure('absent') }
52     end
53
54     context 'with volume_tmp_dir disabled' do
55       let(:params) { req_params.merge!({:volume_tmp_dir => false}) }
56       it { should contain_cinder_config("#{req_params[:volume_backend_name]}/volume_tmp_dir").with_ensure('absent') }
57     end
58
59     context 'with another RBD backend' do
60       let :pre_condition do
61         "cinder::backend::rbd { 'ceph2':
62            rbd_pool => 'volumes2',
63            rbd_user => 'test'
64          }"
65       end
66       it { should contain_cinder_config("#{req_params[:volume_backend_name]}/volume_driver").with_value('cinder.volume.drivers.rbd.RBDDriver') }
67       it { should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_pool").with_value(req_params[:rbd_pool]) }
68       it { should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_user").with_value(req_params[:rbd_user]) }
69       it { should contain_cinder_config("ceph2/volume_driver").with_value('cinder.volume.drivers.rbd.RBDDriver') }
70       it { should contain_cinder_config("ceph2/rbd_pool").with_value('volumes2') }
71       it { should contain_cinder_config("ceph2/rbd_user").with_value('test') }
72     end
73   end
74
75   describe 'with RedHat' do
76     let :facts do
77         { :osfamily => 'RedHat' }
78     end
79
80     let :params do
81       req_params
82     end
83
84     it 'should ensure that the cinder-volume sysconfig file is present' do
85       should contain_file('/etc/sysconfig/openstack-cinder-volume').with(
86         :ensure => 'present'
87       )
88     end
89
90     it 'should configure RedHat init override' do
91       should contain_file_line('set initscript env').with(
92         :line    => /export CEPH_ARGS=\"--id test\"/,
93         :path    => '/etc/sysconfig/openstack-cinder-volume',
94         :notify  => 'Service[cinder-volume]')
95     end
96   end
97
98 end