0f632ccb3f1716808b4e2529382efc3328b9c719
[mirror/dsa-puppet.git] / 3rdparty / modules / cinder / spec / classes / cinder_backup_spec.rb
1 #
2 # Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
3 #
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
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 cinder::backup class
19 #
20
21 require 'spec_helper'
22
23 describe 'cinder::backup' do
24
25   let :default_params do
26     { :enable               => true,
27       :backup_topic         => 'cinder-backup',
28       :backup_manager       => 'cinder.backup.manager.BackupManager',
29       :backup_api_class     => 'cinder.backup.api.API',
30       :backup_name_template => 'backup-%s' }
31   end
32
33   let :params do
34     {}
35   end
36
37   shared_examples_for 'cinder backup' do
38     let :p do
39       default_params.merge(params)
40     end
41
42     it { should contain_class('cinder::params') }
43
44     it 'installs cinder backup package' do
45       if platform_params.has_key?(:backup_package)
46         should contain_package('cinder-backup').with(
47           :name   => platform_params[:backup_package],
48           :ensure => 'present'
49         )
50         should contain_package('cinder-backup').with_before(/Cinder_config\[.+\]/)
51         should contain_package('cinder-backup').with_before(/Service\[cinder-backup\]/)
52       end
53     end
54
55     it 'ensure cinder backup service is running' do
56       should contain_service('cinder-backup').with('hasstatus' => true)
57     end
58
59     it 'configures cinder.conf' do
60       should contain_cinder_config('DEFAULT/backup_topic').with_value(p[:backup_topic])
61       should contain_cinder_config('DEFAULT/backup_manager').with_value(p[:backup_manager])
62       should contain_cinder_config('DEFAULT/backup_api_class').with_value(p[:backup_api_class])
63       should contain_cinder_config('DEFAULT/backup_name_template').with_value(p[:backup_name_template])
64     end
65
66     context 'when overriding backup_name_template' do
67       before :each do
68         params.merge!(:backup_name_template => 'foo-bar-%s')
69       end
70       it 'should replace default parameter with new value' do
71         should contain_cinder_config('DEFAULT/backup_name_template').with_value(p[:backup_name_template])
72       end
73     end
74   end
75
76   context 'on Debian platforms' do
77     let :facts do
78       { :osfamily => 'Debian' }
79     end
80
81     let :platform_params do
82       { :backup_package => 'cinder-backup',
83         :backup_service => 'cinder-backup' }
84     end
85
86     it_configures 'cinder backup'
87   end
88
89   context 'on RedHat platforms' do
90     let :facts do
91       { :osfamily => 'RedHat' }
92     end
93
94     let :platform_params do
95       { :backup_service => 'cinder-backup' }
96     end
97
98     it_configures 'cinder backup'
99   end
100
101 end