Debian Codegraph @

spec/classes/nova_compute_rbd_spec.rb

raw
1 #
2 # Copyright (C) 2014 eNovance SAS <[email protected]>
3 #
4 # Author: Emilien Macchi <[email protected]>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
7 # not use this file except in compliance with the License. You may obtain
8 # a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 # License for the specific language governing permissions and limitations
16 # under the License.
17 #
18 # Unit tests for nova::compute::rbd class
19 #
20
21 require 'spec_helper'
22
23 describe 'nova::compute::rbd' do
24
25 let :params do
26 { :libvirt_rbd_user => 'nova' }
27 end
28
29 shared_examples_for 'nova::compute::rbd' do
30
31 it { is_expected.to contain_class('nova::params') }
32
33 it 'configure nova.conf with default parameters' do
34 is_expected.to contain_nova_config('libvirt/rbd_secret_uuid').with_ensure('absent')
35 is_expected.to contain_nova_config('libvirt/images_rbd_pool').with_value('rbd')
36 is_expected.to contain_nova_config('libvirt/images_rbd_ceph_conf').with_value('/etc/ceph/ceph.conf')
37 is_expected.to contain_nova_config('libvirt/rbd_user').with_value('nova')
38 is_expected.to contain_nova_config('libvirt/images_rbd_glance_store_name').with_value('<SERVICE DEFAULT>')
39 is_expected.to contain_nova_config('libvirt/images_rbd_glance_copy_poll_interval').with_value('<SERVICE DEFAULT>')
40 is_expected.to contain_nova_config('libvirt/images_rbd_glance_copy_timeout').with_value('<SERVICE DEFAULT>')
41 is_expected.to contain_nova_config('libvirt/rbd_connect_timeout').with_value('<SERVICE DEFAULT>')
42 is_expected.to contain_nova_config('libvirt/rbd_destroy_volume_retry_interval').with_value('<SERVICE DEFAULT>')
43 is_expected.to contain_nova_config('libvirt/rbd_destroy_volume_retries').with_value('<SERVICE DEFAULT>')
44 end
45
46 it 'installs client package' do
47 is_expected.to contain_package('ceph-common').with(
48 'name' => platform_params[:ceph_common_package],
49 'ensure' => 'installed',
50 )
51 end
52
53 context 'when overriding default parameters' do
54 before :each do
55 params.merge!(
56 :libvirt_rbd_user => 'joe',
57 :libvirt_images_rbd_pool => 'AnotherPool',
58 :libvirt_images_rbd_ceph_conf => '/tmp/ceph.conf',
59 :libvirt_images_rbd_glance_store_name => 'glance_rbd_store',
60 :libvirt_images_rbd_glance_copy_poll_interval => 30,
61 :libvirt_images_rbd_glance_copy_timeout => 300,
62 :libvirt_rbd_connect_timeout => 5,
63 :libvirt_rbd_destroy_volume_retry_interval => 5,
64 :libvirt_rbd_destroy_volume_retries => 12,
65 )
66 end
67
68 it 'configure nova.conf with overridden parameters' do
69 is_expected.to contain_nova_config('libvirt/images_rbd_pool').with_value('AnotherPool')
70 is_expected.to contain_nova_config('libvirt/images_rbd_ceph_conf').with_value('/tmp/ceph.conf')
71 is_expected.to contain_nova_config('libvirt/rbd_user').with_value('joe')
72 is_expected.to contain_nova_config('libvirt/images_rbd_glance_store_name').with_value('glance_rbd_store')
73 is_expected.to contain_nova_config('libvirt/images_rbd_glance_copy_poll_interval').with_value(30)
74 is_expected.to contain_nova_config('libvirt/images_rbd_glance_copy_timeout').with_value(300)
75 is_expected.to contain_nova_config('libvirt/rbd_connect_timeout').with_value(5)
76 is_expected.to contain_nova_config('libvirt/rbd_destroy_volume_retry_interval').with_value(5)
77 is_expected.to contain_nova_config('libvirt/rbd_destroy_volume_retries').with_value(12)
78 end
79 end
80
81 context 'when using cephx' do
82 before do
83 params.merge!(
84 :libvirt_rbd_secret_uuid => '4f515eff-47e4-425c-b24d-9c6adc56401c',
85 :libvirt_rbd_secret_key => 'AQBHCbtT6APDHhAA5W00cBchwkQjh3dkKsyPjw==',
86 )
87 end
88
89 it { is_expected.to contain_nova__compute__libvirt__secret_ceph('4f515eff-47e4-425c-b24d-9c6adc56401c').with(
90 :uuid => '4f515eff-47e4-425c-b24d-9c6adc56401c',
91 :value => 'AQBHCbtT6APDHhAA5W00cBchwkQjh3dkKsyPjw==',
92 )}
93 end
94
95 context 'when using cephx but disabling ephemeral storage' do
96 before do
97 params.merge!(
98 :libvirt_rbd_secret_uuid => '4f515eff-47e4-425c-b24d-9c6adc56401c',
99 :libvirt_rbd_secret_key => 'AQBHCbtT6APDHhAA5W00cBchwkQjh3dkKsyPjw==',
100 :ephemeral_storage => false
101 )
102 end
103
104 it 'should only set user and secret_uuid in nova.conf ' do
105 is_expected.to contain_nova_config('libvirt/images_rbd_pool').with_ensure('absent')
106 is_expected.to contain_nova_config('libvirt/images_rbd_ceph_conf').with_ensure('absent')
107 is_expected.to contain_nova_config('libvirt/images_rbd_glance_store_name').with_ensure('absent')
108 is_expected.to contain_nova_config('libvirt/images_rbd_glance_copy_poll_interval').with_ensure('absent')
109 is_expected.to contain_nova_config('libvirt/images_rbd_glance_copy_timeout').with_ensure('absent')
110 is_expected.to contain_nova_config('libvirt/rbd_connect_timeout').with_ensure('absent')
111 is_expected.to contain_nova_config('libvirt/rbd_destroy_volume_retry_interval').with_ensure('absent')
112 is_expected.to contain_nova_config('libvirt/rbd_destroy_volume_retries').with_ensure('absent')
113 is_expected.to contain_nova_config('libvirt/rbd_user').with_value('nova')
114 is_expected.to contain_nova_config('libvirt/rbd_secret_uuid').with_value('4f515eff-47e4-425c-b24d-9c6adc56401c')
115 end
116
117 it { is_expected.to contain_nova__compute__libvirt__secret_ceph('4f515eff-47e4-425c-b24d-9c6adc56401c').with(
118 :uuid => '4f515eff-47e4-425c-b24d-9c6adc56401c',
119 :value => 'AQBHCbtT6APDHhAA5W00cBchwkQjh3dkKsyPjw==',
120 )}
121 end
122
123 context 'when not managing ceph client' do
124 before :each do
125 params.merge!(
126 :manage_ceph_client => false
127 )
128 end
129
130 it { is_expected.to_not contain_package('ceph-common') }
131 end
132 end
133
134 shared_examples_for 'nova::compute::rbd in Debian' do
135 it 'should install the qemu-block-extra package' do
136 is_expected.to contain_package('qemu-block-extra').with(
137 :ensure => 'present',
138 :tag => ['openstack', 'nova-support-package'],
139 )
140 end
141 end
142
143 shared_examples_for 'nova::compute::rbd in RedHat' do
144 it 'should not install the qemu-block-extra package' do
145 is_expected.to_not contain_package('qemu-block-extra')
146 end
147 end
148
149 on_supported_os({
150 :supported_os => OSDefaults.get_supported_os
151 }).each do |os,facts|
152 context "on #{os}" do
153 let (:facts) do
154 facts.merge!(OSDefaults.get_facts())
155 end
156
157 let (:platform_params) do
158 case facts[:os]['family']
159 when 'Debian'
160 { :ceph_common_package => 'ceph-common' }
161 when 'RedHat'
162 { :ceph_common_package => 'ceph-common' }
163 end
164 end
165 it_configures 'nova::compute::rbd'
166 if facts[:os]['family'] == 'Debian'
167 it_configures "nova::compute::rbd in #{facts[:os]['family']}"
168 end
169 end
170 end
171
172 end