summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJens Rosenboom <j.rosenboom@x-ion.de>2017-03-29 08:18:27 +0000
committerJens Rosenboom <j.rosenboom@x-ion.de>2017-03-30 14:34:15 +0000
commita3ba8685a71257a9ad0e26141d3b324cc55a7208 (patch)
treea0e5c56df269537ff26aeff80291f677741c89bc /spec
parent8421080468d27739d38cc9a6e029e2e0df82cd99 (diff)
Make cinder work for Ocata
- cinder-api now runs under apache2 and no longer as systemd service - cinder-volume needs explicit backend configuration - don't install deprecated cinder v1 API endpoints - clean up some config options To be added in a follow-up: - Make backend configuration more flexible - Replace distro provided wsgi setup with our custom one Change-Id: I77ac294fd8e1cd4e6bc39667ddfdea21c4daed8a
Notes
Notes (review): Code-Review+2: Christoph Albers <c.albers@x-ion.de> Code-Review+2: Samuel Cassiba <s@cassiba.com> Workflow+1: Samuel Cassiba <s@cassiba.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Sat, 01 Apr 2017 15:09:19 +0000 Reviewed-on: https://review.openstack.org/451246 Project: openstack/cookbook-openstack-block-storage Branch: refs/heads/master
Diffstat (limited to 'spec')
-rw-r--r--spec/api-redhat_spec.rb4
-rw-r--r--spec/api_spec.rb18
-rw-r--r--spec/cinder_common_spec.rb107
-rw-r--r--spec/identity_registration_spec.rb25
-rw-r--r--spec/spec_helper.rb9
5 files changed, 19 insertions, 144 deletions
diff --git a/spec/api-redhat_spec.rb b/spec/api-redhat_spec.rb
index 290f03b..d0ef802 100644
--- a/spec/api-redhat_spec.rb
+++ b/spec/api-redhat_spec.rb
@@ -26,9 +26,5 @@ describe 'openstack-block-storage::api' do
26 expect(chef_run).to upgrade_package 'python-psycopg2' 26 expect(chef_run).to upgrade_package 'python-psycopg2'
27 expect(chef_run).not_to upgrade_package 'MySQL-python' 27 expect(chef_run).not_to upgrade_package 'MySQL-python'
28 end 28 end
29
30 it 'starts cinder api on boot' do
31 expect(chef_run).to enable_service 'openstack-cinder-api'
32 end
33 end 29 end
34end 30end
diff --git a/spec/api_spec.rb b/spec/api_spec.rb
index 19471b4..0233a84 100644
--- a/spec/api_spec.rb
+++ b/spec/api_spec.rb
@@ -12,16 +12,12 @@ describe 'openstack-block-storage::api' do
12 12
13 include_context 'block-storage-stubs' 13 include_context 'block-storage-stubs'
14 include_examples 'common-logging' 14 include_examples 'common-logging'
15 include_examples 'creates_cinder_conf', 'service[cinder-api]', 'cinder', 'cinder' 15 include_examples 'creates_cinder_conf', 'service[cinder-apache2]', 'cinder', 'cinder'
16 16
17 it 'upgrades cinder api packages' do 17 it 'upgrades cinder api packages' do
18 expect(chef_run).to upgrade_package('cinder-api') 18 expect(chef_run).to upgrade_package('cinder-api')
19 end 19 end
20 20
21 it 'starts cinder api on boot' do
22 expect(chef_run).to enable_service('cinder-api')
23 end
24
25 it 'upgrades mysql python package' do 21 it 'upgrades mysql python package' do
26 expect(chef_run).to upgrade_package('python-mysqldb') 22 expect(chef_run).to upgrade_package('python-mysqldb')
27 end 23 end
@@ -33,18 +29,6 @@ describe 'openstack-block-storage::api' do
33 expect(chef_run).not_to upgrade_package('python-mysqldb') 29 expect(chef_run).not_to upgrade_package('python-mysqldb')
34 end 30 end
35 31
36 describe '/var/cache/cinder/api' do
37 let(:dir) { chef_run.directory('/var/cache/cinder/api') }
38
39 it 'should create the directory' do
40 expect(chef_run).to create_directory(dir.name).with(
41 owner: 'cinder',
42 group: 'cinder',
43 mode: 00700
44 )
45 end
46 end
47
48 it 'runs db migrations' do 32 it 'runs db migrations' do
49 expect(chef_run).to run_execute('cinder-manage db sync').with(user: 'cinder', group: 'cinder') 33 expect(chef_run).to run_execute('cinder-manage db sync').with(user: 'cinder', group: 'cinder')
50 end 34 end
diff --git a/spec/cinder_common_spec.rb b/spec/cinder_common_spec.rb
index 59a0843..d912040 100644
--- a/spec/cinder_common_spec.rb
+++ b/spec/cinder_common_spec.rb
@@ -51,33 +51,30 @@ describe 'openstack-block-storage::cinder-common' do
51 end 51 end
52 52
53 context 'keystone authtoken attributes with default values' do 53 context 'keystone authtoken attributes with default values' do
54 it 'sets memcached server(s)' do 54 it 'does not set memcached server(s)' do
55 expect(chef_run).not_to render_file(file.name).with_content(/^memcached_servers = $/) 55 expect(chef_run).not_to render_file(file.name).with_content(/^memcached_servers = $/)
56 end 56 end
57 57
58 it 'sets memcache security strategy' do 58 it 'does not set memcache security strategy' do
59 expect(chef_run).not_to render_file(file.name).with_content(/^memcache_security_strategy = $/) 59 expect(chef_run).not_to render_file(file.name).with_content(/^memcache_security_strategy = $/)
60 end 60 end
61 61
62 it 'sets memcache secret key' do 62 it 'does not set memcache secret key' do
63 expect(chef_run).not_to render_file(file.name).with_content(/^memcache_secret_key = $/) 63 expect(chef_run).not_to render_file(file.name).with_content(/^memcache_secret_key = $/)
64 end 64 end
65 65
66 it 'sets cafile' do 66 it 'does not set cafile' do
67 expect(chef_run).not_to render_file(file.name).with_content(/^cafile = $/) 67 expect(chef_run).not_to render_file(file.name).with_content(/^cafile = $/)
68 end 68 end
69 end 69 end
70 70
71 context 'keystone authtoken attributes' do 71 context 'keystone authtoken attributes' do
72 it 'has signing_dir' do
73 node.set['openstack']['block-storage']['conf']['keystone_authtoken']['signing_dir'] = 'auth_cache_dir'
74
75 expect(chef_run).to render_file(file.name).with_content(/^signing_dir = auth_cache_dir$/)
76 end
77
78 context 'endpoint related' do 72 context 'endpoint related' do
79 it 'has auth_uri' do 73 it 'has auth_uri' do
80 expect(chef_run).to render_file(file.name).with_content(%r{^auth_url = http://127.0.0.1:5000/v3$}) 74 expect(chef_run).to render_config_file(file.name).with_section_content('keystone_authtoken', %r{^auth_uri = http://127.0.0.1:5000/v3$})
75 end
76 it 'has auth_url' do
77 expect(chef_run).to render_config_file(file.name).with_section_content('keystone_authtoken', %r{^auth_url = http://127.0.0.1:35357/v3$})
81 end 78 end
82 end 79 end
83 80
@@ -85,43 +82,13 @@ describe 'openstack-block-storage::cinder-common' do
85 expect(chef_run).not_to render_file(file.name).with_content(/^auth_version = v2.0$/) 82 expect(chef_run).not_to render_file(file.name).with_content(/^auth_version = v2.0$/)
86 end 83 end
87 84
88 it 'has an admin tenant name' do
89 node.set['openstack']['block-storage']['conf']['keystone_authtoken']['admin_tenant_name'] = 'tenant_name'
90
91 expect(chef_run).to render_file(file.name).with_content(/^admin_tenant_name = tenant_name$/)
92 end
93
94 it 'has an admin user' do
95 node.set['openstack']['block-storage']['conf']['keystone_authtoken']['admin_user'] = 'username'
96
97 expect(chef_run).to render_file(file.name).with_content(/^admin_user = username$/)
98 end
99
100 it 'has an admin password' do 85 it 'has an admin password' do
101 # (fgimenez) the get_password mocking is set in spec/spec_helper.rb 86 # (fgimenez) the get_password mocking is set in spec/spec_helper.rb
102 expect(chef_run).to render_file(file.name).with_content(/^password = cinder-pass$/) 87 expect(chef_run).to render_config_file(file.name).with_section_content('keystone_authtoken', /^password = cinder-pass$/)
103 end 88 end
104 end 89 end
105 90
106 context 'template contents' do 91 context 'template contents' do
107 context 'commonly named attributes' do
108 %w(debug verbose host notification_driver
109 osapi_volume_worker control_exchange).each do |attr_key|
110 it "has a #{attr_key} attribute" do
111 node.set['openstack']['block-storage']['conf']['DEFAULT'][attr_key] = "#{attr_key}_value"
112
113 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr_key} = #{attr_key}_value$/)
114 end
115 end
116 end
117
118 context 'backup swift backend contents' do
119 before do
120 node.set['openstack']['block-storage']['backup']['enabled'] = true
121 node.set['openstack']['block-storage']['backup']['driver'] = 'cinder.backup.drivers.swift'
122 end
123 end
124
125 it 'has a lock_path attribute' do 92 it 'has a lock_path attribute' do
126 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_concurrency', %r{^lock_path = /var/lib/cinder/tmp}) 93 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_concurrency', %r{^lock_path = /var/lib/cinder/tmp})
127 end 94 end
@@ -151,50 +118,22 @@ describe 'openstack-block-storage::cinder-common' do
151 .with_section_content('database', /^connection = sql_connection_value$/) 118 .with_section_content('database', /^connection = sql_connection_value$/)
152 end 119 end
153 120
154 it 'has a slave db connection attribute' do 121 it 'has a glance_api_servers attribute' do
155 allow_any_instance_of(Chef::Recipe).to receive(:db_uri) 122 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', %r{^glance_api_servers = http://127.0.0.1:9292$})
156 .and_return('sql_connection_value')
157
158 expect(chef_run).to render_config_file(file.name)
159 .with_section_content('database', /^connection = sql_connection_value$/)
160 end
161
162 it 'has a volume_driver attribute' do
163 node.set['openstack']['block-storage']['conf']['DEFAULT']['volume_driver'] = 'volume_driver_value'
164 expect(chef_run).to render_file(file.name).with_content(/^volume_driver = volume_driver_value$/)
165 end
166
167 it 'has a state_path attribute' do
168 node.set['openstack']['block-storage']['conf']['DEFAULT']['state_path'] = 'state_path_value'
169 expect(chef_run).to render_file(file.name).with_content(/^state_path = state_path_value$/)
170 end
171
172 context 'glance endpoint' do
173 it 'has a glance_api_servers attribute' do
174 expect(chef_run).to render_file(file.name).with_content(%r{^glance_api_servers = http://127.0.0.1:9292$})
175 end
176
177 it 'has a glance host attribute' do
178 expect(chef_run).to render_file(file.name).with_content(/^glance_host = 127.0.0.1$/)
179 end
180
181 it 'has a glance port attribute' do
182 expect(chef_run).to render_file(file.name).with_content(/^glance_port = 9292$/)
183 end
184 end 123 end
185 124
186 context 'cinder endpoint' do 125 context 'cinder endpoint' do
187 it 'has osapi_volume_listen set' do 126 it 'has osapi_volume_listen set' do
188 expect(chef_run).to render_file(file.name).with_content(/^osapi_volume_listen = 127.0.0.1$/) 127 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^osapi_volume_listen = 127.0.0.1$/)
189 end 128 end
190 129
191 it 'has osapi_volume_listen_port set' do 130 it 'has osapi_volume_listen_port set' do
192 expect(chef_run).to render_file(file.name).with_content(/^osapi_volume_listen_port = 8776$/) 131 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^osapi_volume_listen_port = 8776$/)
193 end 132 end
194 end 133 end
195 it 'has default transport_url/AMQP options set' do 134 it 'has default transport_url/AMQP options set' do
196 [%r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$}].each do |line| 135 [%r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$}].each do |line|
197 expect(chef_run).to render_file(file.name).with_content(line) 136 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line)
198 end 137 end
199 end 138 end
200 139
@@ -204,22 +143,10 @@ describe 'openstack-block-storage::cinder-common' do
204 node.set['openstack']['mq']['block-storage']['rabbit']['ha'] = false 143 node.set['openstack']['mq']['block-storage']['rabbit']['ha'] = false
205 end 144 end
206 145
207 %w(host port).each do |attr|
208 it "has rabbit_#{attr} attribute" do
209 node.set['openstack']['block-storage']['conf']['oslo_messaging_rabbit']["rabbit_#{attr}"] = "rabbit_#{attr}_value"
210 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_#{attr} = rabbit_#{attr}_value$/)
211 end
212 end
213
214 it 'does not have a rabbit_hosts attribute' do 146 it 'does not have a rabbit_hosts attribute' do
215 expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_hosts = /) 147 expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_hosts = /)
216 end 148 end
217 end 149 end
218
219 it 'has rabbit_virtual_host' do
220 node.set['openstack']['block-storage']['conf']['oslo_messaging_rabbit']['rabbit_virtual_host'] = 'vhost_value'
221 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_virtual_host = vhost_value$/)
222 end
223 end 150 end
224 151
225 context 'lvm settings' do 152 context 'lvm settings' do
@@ -243,11 +170,6 @@ describe 'openstack-block-storage::cinder-common' do
243 end 170 end
244 end 171 end
245 172
246 it 'has volume_driver attribute' do
247 node.set['openstack']['block-storage']['conf']['DEFAULT']['volume_driver'] = 'volume_driver_value'
248 expect(chef_run).to render_file(file.name).with_content(/^volume_driver = volume_driver_value$/)
249 end
250
251 context 'netapp ISCSI settings' do 173 context 'netapp ISCSI settings' do
252 before do 174 before do
253 node.set['openstack']['block-storage']['conf']['DEFAULT']['volume_driver'] = 'cinder.volume.drivers.netapp.NetAppISCSIDriver' 175 node.set['openstack']['block-storage']['conf']['DEFAULT']['volume_driver'] = 'cinder.volume.drivers.netapp.NetAppISCSIDriver'
@@ -293,6 +215,7 @@ describe 'openstack-block-storage::cinder-common' do
293 end 215 end
294 end 216 end
295 end 217 end
218
296 it do 219 it do
297 expect(chef_run).to run_ruby_block("delete all attributes in node['openstack']['block-storage']['conf_secrets']") 220 expect(chef_run).to run_ruby_block("delete all attributes in node['openstack']['block-storage']['conf_secrets']")
298 end 221 end
diff --git a/spec/identity_registration_spec.rb b/spec/identity_registration_spec.rb
index 6a8def2..162f994 100644
--- a/spec/identity_registration_spec.rb
+++ b/spec/identity_registration_spec.rb
@@ -60,22 +60,6 @@ describe 'openstack-block-storage::identity_registration' do
60 ) 60 )
61 end 61 end
62 end 62 end
63 %w(admin internal public).each do |interface|
64 it "#{interface} with different service type/name and registers v1 endpoint" do
65 node.set['openstack']['block-storage']['service_name'] = 'cinder'
66 node.set['openstack']['block-storage']['service_type'] = 'volume'
67
68 expect(chef_run).to create_openstack_endpoint(
69 'volume'
70 ).with(
71 service_name: 'cinder',
72 # interface: interface,
73 url: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
74 region: 'RegionOne',
75 connection_params: connection_params
76 )
77 end
78 end
79 63
80 it 'with custom region override' do 64 it 'with custom region override' do
81 node.set['openstack']['block-storage']['region'] = 'volumeRegion' 65 node.set['openstack']['block-storage']['region'] = 'volumeRegion'
@@ -116,14 +100,5 @@ describe 'openstack-block-storage::identity_registration' do
116 connection_params: connection_params 100 connection_params: connection_params
117 ) 101 )
118 end 102 end
119
120 it 'registers cinder v1 volume service' do
121 expect(chef_run).to create_openstack_service(
122 'cinder'
123 ).with(
124 connection_params: connection_params,
125 type: 'volume'
126 )
127 end
128 end 103 end
129end 104end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 1242590..029cfa8 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -32,9 +32,6 @@ shared_context 'block-storage-stubs' do
32 .with('db', anything) 32 .with('db', anything)
33 .and_return('') 33 .and_return('')
34 allow_any_instance_of(Chef::Recipe).to receive(:get_password) 34 allow_any_instance_of(Chef::Recipe).to receive(:get_password)
35 .with('token', 'openstack_identity_bootstrap_token')
36 .and_return('bootstrap-token')
37 allow_any_instance_of(Chef::Recipe).to receive(:get_password)
38 .with('token', 'rbd_secret_uuid') 35 .with('token', 'rbd_secret_uuid')
39 .and_return('b0ff3bba-e07b-49b1-beed-09a45552b1ad') 36 .and_return('b0ff3bba-e07b-49b1-beed-09a45552b1ad')
40 allow_any_instance_of(Chef::Recipe).to receive(:get_password) 37 allow_any_instance_of(Chef::Recipe).to receive(:get_password)
@@ -111,14 +108,14 @@ shared_examples 'creates_cinder_conf' do |service, user, group, action = :restar
111 108
112 it do 109 it do
113 [ 110 [
114 /^auth_type = v3password$/, 111 /^auth_type = password$/,
115 /^region_name = RegionOne$/, 112 /^region_name = RegionOne$/,
116 /^username = cinder/, 113 /^username = cinder/,
117 /^project_name = service$/, 114 /^project_name = service$/,
118 /^user_domain_name = Default/, 115 /^user_domain_name = Default/,
119 /^project_domain_name = Default/, 116 /^project_domain_name = Default/,
120 %r{^signing_dir = /var/cache/cinder/api$}, 117 %r{^auth_uri = http://127.0.0.1:5000/v3$},
121 %r{^auth_url = http://127.0.0.1:5000/v3$}, 118 %r{^auth_url = http://127.0.0.1:35357/v3$},
122 /^password = cinder-pass$/ 119 /^password = cinder-pass$/
123 ].each do |line| 120 ].each do |line|
124 expect(chef_run).to render_config_file(file.name) 121 expect(chef_run).to render_config_file(file.name)