2 # Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
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
10 # http://www.apache.org/licenses/LICENSE-2.0
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
18 # Unit tests for cinder::backup class
23 describe 'cinder::backup' do
25 let :default_params do
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' }
37 shared_examples_for 'cinder backup' do
39 default_params.merge(params)
42 it { should contain_class('cinder::params') }
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],
50 should contain_package('cinder-backup').with_before(/Cinder_config\[.+\]/)
51 should contain_package('cinder-backup').with_before(/Service\[cinder-backup\]/)
55 it 'ensure cinder backup service is running' do
56 should contain_service('cinder-backup').with('hasstatus' => true)
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])
66 context 'when overriding backup_name_template' do
68 params.merge!(:backup_name_template => 'foo-bar-%s')
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])
76 context 'on Debian platforms' do
78 { :osfamily => 'Debian' }
81 let :platform_params do
82 { :backup_package => 'cinder-backup',
83 :backup_service => 'cinder-backup' }
86 it_configures 'cinder backup'
89 context 'on RedHat platforms' do
91 { :osfamily => 'RedHat' }
94 let :platform_params do
95 { :backup_service => 'cinder-backup' }
98 it_configures 'cinder backup'