summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLan Qi song <lqslan@cn.ibm.com>2015-05-05 16:16:59 +0800
committerLan Qi song <lqslan@cn.ibm.com>2015-05-06 13:55:56 +0800
commitcba98483b21c4e35d771977ac9bee25bece73634 (patch)
tree94048d883d1d08408d73ac0eb5ae2aa23391ec6a /spec
parentcb7a11a2c42c9a2a133b2f33d2cc1ddf0b1f3b2a (diff)
Add support for cinder-backup service
Notes
Notes (review): Verified+2: Jenkins Workflow+1: Mark Vanderwiel <vanderwl@us.ibm.com> Code-Review+2: Ma Wen Cheng <wenchma@cn.ibm.com> Submitted-by: Jenkins Submitted-at: Wed, 06 May 2015 13:11:05 +0000 Reviewed-on: https://review.openstack.org/180076 Project: stackforge/cookbook-openstack-block-storage Branch: refs/heads/master
Diffstat (limited to 'spec')
-rw-r--r--spec/backup-redhat_spec.rb48
-rw-r--r--spec/backup-suse_spec.rb43
-rw-r--r--spec/backup_spec.rb80
-rw-r--r--spec/cinder_common_spec.rb44
4 files changed, 215 insertions, 0 deletions
diff --git a/spec/backup-redhat_spec.rb b/spec/backup-redhat_spec.rb
new file mode 100644
index 0000000..de27e26
--- /dev/null
+++ b/spec/backup-redhat_spec.rb
@@ -0,0 +1,48 @@
1# encoding: UTF-8
2#
3# Cookbook Name:: openstack-block-storage
4
5require_relative 'spec_helper'
6
7describe 'openstack-block-storage::backup' do
8 describe 'redhat' do
9 let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
10 let(:node) { runner.node }
11 let(:chef_run) { runner.converge(described_recipe) }
12
13 include_context 'block-storage-stubs'
14
15 describe 'enable cinder backup service' do
16 before do
17 node.set['openstack']['block-storage']['backup']['enabled'] = true
18 end
19
20 it 'starts cinder backup' do
21 expect(chef_run).to start_service 'openstack-cinder-backup'
22 end
23
24 it 'starts cinder backup on boot' do
25 expect(chef_run).to enable_service 'openstack-cinder-backup'
26 end
27
28 it 'upgrades mysql python package' do
29 expect(chef_run).to upgrade_package 'MySQL-python'
30 end
31
32 it 'upgrades db2 python packages if explicitly told' do
33 node.set['openstack']['db']['block-storage']['service_type'] = 'db2'
34
35 ['python-ibm-db', 'python-ibm-db-sa'].each do |pkg|
36 expect(chef_run).to upgrade_package pkg
37 end
38 end
39
40 it 'upgrades postgresql python packages if explicitly told' do
41 node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
42
43 expect(chef_run).to upgrade_package 'python-psycopg2'
44 expect(chef_run).not_to upgrade_package 'MySQL-python'
45 end
46 end
47 end
48end
diff --git a/spec/backup-suse_spec.rb b/spec/backup-suse_spec.rb
new file mode 100644
index 0000000..8ee21c4
--- /dev/null
+++ b/spec/backup-suse_spec.rb
@@ -0,0 +1,43 @@
1# encoding: UTF-8
2#
3# Cookbook Name:: openstack-block-storage
4
5require_relative 'spec_helper'
6
7describe 'openstack-block-storage::backup' do
8 describe 'suse' do
9 let(:runner) { ChefSpec::SoloRunner.new(SUSE_OPTS) }
10 let(:node) { runner.node }
11 let(:chef_run) { runner.converge(described_recipe) }
12
13 include_context 'block-storage-stubs'
14
15 describe 'enable cinder backup service' do
16 before do
17 node.set['openstack']['block-storage']['backup']['enabled'] = true
18 end
19 it 'upgrades cinder backup package' do
20 expect(chef_run).to upgrade_package 'openstack-cinder-backup'
21 end
22
23 it 'starts cinder backup' do
24 expect(chef_run).to start_service 'openstack-cinder-backup'
25 end
26
27 it 'starts cinder backup on boot' do
28 expect(chef_run).to enable_service 'openstack-cinder-backup'
29 end
30
31 it 'upgrades mysql python package' do
32 expect(chef_run).to upgrade_package 'python-mysql'
33 end
34
35 it 'upgrades postgresql python packages if explicitly told' do
36 node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
37
38 expect(chef_run).to upgrade_package 'python-psycopg2'
39 expect(chef_run).not_to upgrade_package 'python-mysql'
40 end
41 end
42 end
43end
diff --git a/spec/backup_spec.rb b/spec/backup_spec.rb
new file mode 100644
index 0000000..0dffd0f
--- /dev/null
+++ b/spec/backup_spec.rb
@@ -0,0 +1,80 @@
1# encoding: UTF-8
2#
3# Cookbook Name:: openstack-block-storage
4
5require_relative 'spec_helper'
6
7describe 'openstack-block-storage::backup' do
8 describe 'ubuntu' do
9 let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
10 let(:node) { runner.node }
11 let(:chef_run) { runner.converge(described_recipe) }
12
13 include_context 'block-storage-stubs'
14
15 describe 'enable cinder backup service' do
16 before do
17 node.set['openstack']['block-storage']['backup']['enabled'] = true
18 end
19 it 'upgrades cinder backup package' do
20 expect(chef_run).to upgrade_package 'cinder-backup'
21 end
22
23 it 'starts cinder backup' do
24 expect(chef_run).to start_service 'cinder-backup'
25 end
26
27 it 'starts cinder backup on boot' do
28 expect(chef_run).to enable_service 'cinder-backup'
29 end
30
31 it 'subscribes to the template change' do
32 expect(chef_run.service('cinder-backup')).to subscribe_to('template[/etc/cinder/cinder.conf]')
33 end
34
35 it 'upgrades mysql python package' do
36 expect(chef_run).to upgrade_package 'python-mysqldb'
37 end
38
39 it 'upgrades postgresql python packages if explicitly told' do
40 node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
41
42 expect(chef_run).to upgrade_package 'python-psycopg2'
43 expect(chef_run).not_to upgrade_package 'python-mysqldb'
44 end
45 end
46
47 describe 'disable cinder backup service' do
48 before do
49 node.set['openstack']['block-storage']['backup']['enabled'] = false
50 end
51 it 'not to upgrades cinder backup package' do
52 expect(chef_run).not_to upgrade_package 'cinder-backup'
53 end
54
55 it 'not to starts cinder backup' do
56 expect(chef_run).not_to start_service 'cinder-backup'
57 end
58
59 it 'not to starts cinder backup on boot' do
60 expect(chef_run).not_to enable_service 'cinder-backup'
61 end
62
63 it 'not to subscribes to the template change' do
64 expect(chef_run.service('cinder-backup')).not_to subscribe_to('template[/etc/cinder/cinder.conf]')
65 end
66
67 it 'not to upgrades mysql python package' do
68 expect(chef_run).not_to upgrade_package 'python-mysqldb'
69 end
70
71 it 'not to upgrades postgresql python packages if explicitly told' do
72 node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
73
74 expect(chef_run).not_to upgrade_package 'python-psycopg2'
75 expect(chef_run).not_to upgrade_package 'python-mysqldb'
76 end
77 end
78
79 end
80end
diff --git a/spec/cinder_common_spec.rb b/spec/cinder_common_spec.rb
index 8ed5454..385c80c 100644
--- a/spec/cinder_common_spec.rb
+++ b/spec/cinder_common_spec.rb
@@ -180,6 +180,50 @@ describe 'openstack-block-storage::cinder-common' do
180 end 180 end
181 end 181 end
182 182
183 context 'backup swift backend contents' do
184 before do
185 node.set['openstack']['block-storage']['backup']['enabled'] = true
186 node.set['openstack']['block-storage']['backup']['driver'] = 'cinder.backup.drivers.swift'
187 end
188
189 it 'has default attributes' do
190 %w(swift_catalog_info=object-store:swift:publicURL
191 backup_swift_auth=per_user
192 backup_swift_auth_version=1
193 backup_swift_container=volumebackups
194 backup_swift_object_size=52428800
195 backup_swift_block_size=32768
196 backup_swift_retry_attempts=3
197 backup_swift_retry_backoff=2
198 backup_swift_enable_progress_timer=True).each do |attr|
199 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr}$/)
200 end
201 end
202
203 it 'has override attributes' do
204 %w(url
205 auth
206 auth_version
207 tenant
208 user
209 key
210 container
211 object_size
212 block_size
213 retry_attempts
214 retry_backoff
215 enable_progress_timer).each do |attr|
216 node.set['openstack']['block-storage']['backup']['swift'][attr] = "backup_swift_#{attr}"
217 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^backup_swift_#{attr}=backup_swift_#{attr}$/)
218 end
219 end
220
221 it 'has a custom catalog_info' do
222 node.set['openstack']['block-storage']['backup']['swift']['catalog_info'] = 'swift_catalog_info'
223 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^swift_catalog_info=swift_catalog_info$/)
224 end
225 end
226
183 context 'rdb driver' do 227 context 'rdb driver' do
184 # FIXME(galstrom21): this block needs to check all of the default 228 # FIXME(galstrom21): this block needs to check all of the default
185 # rdb_* configuration options 229 # rdb_* configuration options