memcached (openstack) is no longer in use
[mirror/dsa-puppet.git] / 3rdparty / modules / cinder / spec / classes / cinder_backup_swift_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::swift class
19 #
20
21 require 'spec_helper'
22
23 describe 'cinder::backup::swift' do
24
25   let :default_params do
26     { :backup_swift_url            => 'http://localhost:8080/v1/AUTH_',
27       :backup_swift_container      => 'volumes_backup',
28       :backup_swift_object_size    => '52428800',
29       :backup_swift_retry_attempts => '3',
30       :backup_swift_retry_backoff  => '2' }
31   end
32
33   let :params do
34     {}
35   end
36
37   shared_examples_for 'cinder backup with swift' do
38     let :p do
39       default_params.merge(params)
40     end
41
42     it 'configures cinder.conf' do
43       should contain_cinder_config('DEFAULT/backup_driver').with_value('cinder.backup.drivers.swift')
44       should contain_cinder_config('DEFAULT/backup_swift_url').with_value(p[:backup_swift_url])
45       should contain_cinder_config('DEFAULT/backup_swift_container').with_value(p[:backup_swift_container])
46       should contain_cinder_config('DEFAULT/backup_swift_object_size').with_value(p[:backup_swift_object_size])
47       should contain_cinder_config('DEFAULT/backup_swift_retry_attempts').with_value(p[:backup_swift_retry_attempts])
48       should contain_cinder_config('DEFAULT/backup_swift_retry_backoff').with_value(p[:backup_swift_retry_backoff])
49     end
50
51     context 'when overriding default parameters' do
52       before :each do
53         params.merge!(:backup_swift_url => 'https://controller2:8080/v1/AUTH_')
54         params.merge!(:backup_swift_container => 'toto')
55         params.merge!(:backup_swift_object_size => '123')
56         params.merge!(:backup_swift_retry_attempts => '99')
57         params.merge!(:backup_swift_retry_backoff => '56')
58       end
59       it 'should replace default parameters with new values' do
60         should contain_cinder_config('DEFAULT/backup_swift_url').with_value(p[:backup_swift_url])
61         should contain_cinder_config('DEFAULT/backup_swift_container').with_value(p[:backup_swift_container])
62         should contain_cinder_config('DEFAULT/backup_swift_object_size').with_value(p[:backup_swift_object_size])
63         should contain_cinder_config('DEFAULT/backup_swift_retry_attempts').with_value(p[:backup_swift_retry_attempts])
64         should contain_cinder_config('DEFAULT/backup_swift_retry_backoff').with_value(p[:backup_swift_retry_backoff])
65       end
66     end
67   end
68
69   context 'on Debian platforms' do
70     let :facts do
71       { :osfamily => 'Debian' }
72     end
73
74     it_configures 'cinder backup with swift'
75   end
76
77   context 'on RedHat platforms' do
78     let :facts do
79       { :osfamily => 'RedHat' }
80     end
81
82     it_configures 'cinder backup with swift'
83   end
84
85 end