try again, with puppetforge modules, correctly included now
[mirror/dsa-puppet.git] / 3rdparty / modules / cinder / spec / classes / cinder_backup_ceph_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::ceph class
19 #
20
21 require 'spec_helper'
22
23 describe 'cinder::backup::ceph' do
24
25   let :default_params do
26     { :backup_ceph_conf         => '/etc/ceph/ceph.conf',
27       :backup_ceph_user         => 'cinder',
28       :backup_ceph_chunk_size   => '134217728',
29       :backup_ceph_pool         => 'backups',
30       :backup_ceph_stripe_unit  => '0',
31       :backup_ceph_stripe_count => '0' }
32   end
33
34   let :params do
35     {}
36   end
37
38   shared_examples_for 'cinder backup with ceph' do
39     let :p do
40       default_params.merge(params)
41     end
42
43     it 'configures cinder.conf' do
44       should contain_cinder_config('DEFAULT/backup_driver').with_value('cinder.backup.drivers.ceph')
45       should contain_cinder_config('DEFAULT/backup_ceph_conf').with_value(p[:backup_ceph_conf])
46       should contain_cinder_config('DEFAULT/backup_ceph_user').with_value(p[:backup_ceph_user])
47       should contain_cinder_config('DEFAULT/backup_ceph_chunk_size').with_value(p[:backup_ceph_chunk_size])
48       should contain_cinder_config('DEFAULT/backup_ceph_pool').with_value(p[:backup_ceph_pool])
49       should contain_cinder_config('DEFAULT/backup_ceph_stripe_unit').with_value(p[:backup_ceph_stripe_unit])
50       should contain_cinder_config('DEFAULT/backup_ceph_stripe_count').with_value(p[:backup_ceph_stripe_count])
51     end
52
53     context 'when overriding default parameters' do
54       before :each do
55         params.merge!(:backup_ceph_conf => '/tmp/ceph.conf')
56         params.merge!(:backup_ceph_user => 'toto')
57         params.merge!(:backup_ceph_chunk_size => '123')
58         params.merge!(:backup_ceph_pool => 'foo')
59         params.merge!(:backup_ceph_stripe_unit => '56')
60         params.merge!(:backup_ceph_stripe_count => '67')
61       end
62       it 'should replace default parameters with new values' do
63         should contain_cinder_config('DEFAULT/backup_ceph_conf').with_value(p[:backup_ceph_conf])
64         should contain_cinder_config('DEFAULT/backup_ceph_user').with_value(p[:backup_ceph_user])
65         should contain_cinder_config('DEFAULT/backup_ceph_chunk_size').with_value(p[:backup_ceph_chunk_size])
66         should contain_cinder_config('DEFAULT/backup_ceph_pool').with_value(p[:backup_ceph_pool])
67         should contain_cinder_config('DEFAULT/backup_ceph_stripe_unit').with_value(p[:backup_ceph_stripe_unit])
68         should contain_cinder_config('DEFAULT/backup_ceph_stripe_count').with_value(p[:backup_ceph_stripe_count])
69       end
70     end
71   end
72
73   context 'on Debian platforms' do
74     let :facts do
75       { :osfamily => 'Debian' }
76     end
77
78     it_configures 'cinder backup with ceph'
79   end
80
81   context 'on RedHat platforms' do
82     let :facts do
83       { :osfamily => 'RedHat' }
84     end
85
86     it_configures 'cinder backup with ceph'
87   end
88
89 end