summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorChristoph Albers <c.albers@x-ion.de>2016-08-31 15:33:25 +0200
committerChristoph Albers <c.albers@x-ion.de>2016-09-30 10:58:23 +0200
commit49d23da16764c499abde28d670ab8f0a4d6025e8 (patch)
tree5395c49940a7f29fdfc59616f2053b0ce1d8453a /spec
parentddad81bf9b1a46cc71bc35c6ecd9f580caa73ec5 (diff)
use_cookbook-openstackclient/identity_v3
- Now use cookbook-openstackclient to create endpoints role service and user - added domain creation and access granting - added values to work with identity_v3 - rewrote specs to work again - added needed keystone_authtoken attributes - updated README Change-Id: I2f339055883354c6a8a77daa7967ff279c4d18d9 Depends-On: I0f8955f05de9b33711c54b9a198f45018cceb8e1 Depends-On: If7b4d6e563081a0be9957353d73ef61a9688df56
Notes
Notes (review): Code-Review+2: Jan Klare <j.klare@cloudbau.de> Code-Review+2: Samuel Cassiba <s@cassiba.com> Workflow+1: Samuel Cassiba <s@cassiba.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Tue, 11 Oct 2016 16:09:33 +0000 Reviewed-on: https://review.openstack.org/363696 Project: openstack/cookbook-openstack-block-storage Branch: refs/heads/master
Diffstat (limited to 'spec')
-rw-r--r--spec/cinder_common_spec.rb6
-rw-r--r--spec/identity_registration_spec.rb198
-rw-r--r--spec/spec_helper.rb8
3 files changed, 88 insertions, 124 deletions
diff --git a/spec/cinder_common_spec.rb b/spec/cinder_common_spec.rb
index a224659..8e65abf 100644
--- a/spec/cinder_common_spec.rb
+++ b/spec/cinder_common_spec.rb
@@ -77,13 +77,11 @@ describe 'openstack-block-storage::cinder-common' do
77 77
78 context 'endpoint related' do 78 context 'endpoint related' do
79 it 'has auth_uri' do 79 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/v2.0$}) 80 expect(chef_run).to render_file(file.name).with_content(%r{^auth_url = http://127.0.0.1:5000/v3$})
81 end 81 end
82 end 82 end
83 83
84 it 'has no auth_version when auth_version is v2.0' do 84 it do
85 node.set['openstack']['block-storage']['api']['auth']['version'] = 'v2.0'
86
87 expect(chef_run).not_to render_file(file.name).with_content(/^auth_version = v2.0$/) 85 expect(chef_run).not_to render_file(file.name).with_content(/^auth_version = v2.0$/)
88 end 86 end
89 87
diff --git a/spec/identity_registration_spec.rb b/spec/identity_registration_spec.rb
index 35b79ea..6a8def2 100644
--- a/spec/identity_registration_spec.rb
+++ b/spec/identity_registration_spec.rb
@@ -12,153 +12,117 @@ describe 'openstack-block-storage::identity_registration' do
12 12
13 include_context 'block-storage-stubs' 13 include_context 'block-storage-stubs'
14 14
15 it 'registers service tenant' do 15 connection_params = {
16 expect(chef_run).to create_tenant_openstack_identity_register( 16 openstack_auth_url: 'http://127.0.0.1:35357/v3/auth/tokens',
17 'Register Service Tenant' 17 openstack_username: 'admin',
18 openstack_api_key: 'emc_test_pass',
19 openstack_project_name: 'admin',
20 openstack_domain_name: 'default'
21 }
22 service_name = 'cinderv2'
23 service_type = 'volumev2'
24 service_user = 'cinder'
25 url = 'http://127.0.0.1:8776/v2/%(tenant_id)s'
26 region = 'RegionOne'
27 project_name = 'service'
28 role_name = 'service'
29 password = 'cinder-pass'
30 domain_name = 'Default'
31
32 it "registers #{project_name} Project" do
33 expect(chef_run).to create_openstack_project(
34 project_name
18 ).with( 35 ).with(
19 auth_uri: 'http://127.0.0.1:35357/v2.0', 36 connection_params: connection_params
20 bootstrap_token: 'bootstrap-token',
21 tenant_name: 'service',
22 tenant_description: 'Service Tenant'
23 ) 37 )
24 end 38 end
25 39
26 it 'registers cinder v2 volume service' do 40 it "registers #{service_name} service" do
27 expect(chef_run).to create_service_openstack_identity_register( 41 expect(chef_run).to create_openstack_service(
28 'Register Cinder V2 Volume Service' 42 service_name
29 ).with( 43 ).with(
30 auth_uri: 'http://127.0.0.1:35357/v2.0', 44 connection_params: connection_params,
31 bootstrap_token: 'bootstrap-token', 45 type: service_type
32 service_name: 'cinderv2',
33 service_type: 'volumev2',
34 service_description: 'Cinder Volume Service V2',
35 endpoint_region: 'RegionOne',
36 endpoint_adminurl: 'http://127.0.0.1:8776/v2/%(tenant_id)s',
37 endpoint_internalurl: 'http://127.0.0.1:8776/v2/%(tenant_id)s',
38 endpoint_publicurl: 'http://127.0.0.1:8776/v2/%(tenant_id)s'
39 ) 46 )
40 end 47 end
41 48
42 context 'registers v2 volume endpoint' do 49 context "registers #{service_name} endpoint" do
43 it 'with default values' do 50 %w(admin internal public).each do |interface|
44 expect(chef_run).to create_endpoint_openstack_identity_register( 51 it "#{interface} endpoint with default values" do
45 'Register Cinder V2 Volume Endpoint' 52 expect(chef_run).to create_openstack_endpoint(
46 ).with( 53 service_type
47 auth_uri: 'http://127.0.0.1:35357/v2.0', 54 ).with(
48 bootstrap_token: 'bootstrap-token', 55 service_name: service_name,
49 service_name: 'cinderv2', 56 # interface: interface,
50 service_type: 'volumev2', 57 url: url,
51 service_description: 'Cinder Volume Service V2', 58 region: region,
52 endpoint_region: 'RegionOne', 59 connection_params: connection_params
53 endpoint_adminurl: 'http://127.0.0.1:8776/v2/%(tenant_id)s', 60 )
54 endpoint_internalurl: 'http://127.0.0.1:8776/v2/%(tenant_id)s', 61 end
55 endpoint_publicurl: 'http://127.0.0.1:8776/v2/%(tenant_id)s'
56 )
57 end
58
59 it 'with all different URLs' do
60 admin_url = 'https://admin.host:123/admin_path'
61 internal_url = 'http://internal.host:456/internal_path'
62 public_url = 'https://public.host:789/public_path'
63
64 node.set['openstack']['endpoints']['internal']['block-storage']['uri'] = internal_url
65 node.set['openstack']['endpoints']['admin']['block-storage']['uri'] = admin_url
66 node.set['openstack']['endpoints']['public']['block-storage']['uri'] = public_url
67
68 expect(chef_run).to create_endpoint_openstack_identity_register(
69 'Register Cinder V2 Volume Endpoint'
70 ).with(
71 auth_uri: 'http://127.0.0.1:35357/v2.0',
72 bootstrap_token: 'bootstrap-token',
73 service_name: 'cinderv2',
74 service_type: 'volumev2',
75 service_description: 'Cinder Volume Service V2',
76 endpoint_region: 'RegionOne',
77 endpoint_adminurl: admin_url,
78 endpoint_internalurl: internal_url,
79 endpoint_publicurl: public_url
80 )
81 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'
82 67
83 it 'with different service type/name' do 68 expect(chef_run).to create_openstack_endpoint(
84 node.set['openstack']['block-storage']['service_name'] = 'cinder' 69 'volume'
85 node.set['openstack']['block-storage']['service_type'] = 'volume' 70 ).with(
86 71 service_name: 'cinder',
87 expect(chef_run).to create_endpoint_openstack_identity_register( 72 # interface: interface,
88 'Register Cinder V2 Volume Endpoint' 73 url: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
89 ).with( 74 region: 'RegionOne',
90 auth_uri: 'http://127.0.0.1:35357/v2.0', 75 connection_params: connection_params
91 bootstrap_token: 'bootstrap-token', 76 )
92 service_name: 'cinder', 77 end
93 service_type: 'volume',
94 service_description: 'Cinder Volume Service V2',
95 endpoint_region: 'RegionOne',
96 endpoint_adminurl: 'http://127.0.0.1:8776/v2/%(tenant_id)s',
97 endpoint_internalurl: 'http://127.0.0.1:8776/v2/%(tenant_id)s',
98 endpoint_publicurl: 'http://127.0.0.1:8776/v2/%(tenant_id)s'
99 )
100 end 78 end
101 79
102 it 'with custom region override' do 80 it 'with custom region override' do
103 node.set['openstack']['block-storage']['region'] = 'volumeRegion' 81 node.set['openstack']['block-storage']['region'] = 'volumeRegion'
104 expect(chef_run).to create_endpoint_openstack_identity_register( 82 expect(chef_run).to create_openstack_endpoint(
105 'Register Cinder V2 Volume Endpoint' 83 service_type
106 ).with(endpoint_region: 'volumeRegion') 84 ).with(region: 'volumeRegion')
107 end 85 end
108 end 86 end
109 87
110 it 'registers service user' do 88 it 'registers service user' do
111 expect(chef_run).to create_user_openstack_identity_register( 89 expect(chef_run).to create_openstack_user(
112 'Register Cinder Service User' 90 service_user
113 ).with( 91 ).with(
114 auth_uri: 'http://127.0.0.1:35357/v2.0', 92 project_name: project_name,
115 bootstrap_token: 'bootstrap-token', 93 role_name: role_name,
116 tenant_name: 'service', 94 password: password,
117 user_name: 'cinder', 95 connection_params: connection_params
118 user_pass: 'cinder-pass',
119 user_enabled: true
120 ) 96 )
121 end 97 end
122 98
123 it 'grants service role to service user for service tenant' do 99 it do
124 expect(chef_run).to grant_role_openstack_identity_register( 100 expect(chef_run).to grant_domain_openstack_user(
125 'Grant service Role to Cinder Service User for Cinder Service Tenant' 101 service_user
126 ).with( 102 ).with(
127 auth_uri: 'http://127.0.0.1:35357/v2.0', 103 domain_name: domain_name,
128 bootstrap_token: 'bootstrap-token', 104 role_name: role_name,
129 tenant_name: 'service', 105 connection_params: connection_params
130 user_name: 'cinder',
131 role_name: 'service'
132 ) 106 )
133 end 107 end
108
134 it do 109 it do
135 expect(chef_run).to create_service_openstack_identity_register( 110 expect(chef_run).to grant_role_openstack_user(
136 'Register Cinder V1 Volume Service' 111 service_user
137 ).with( 112 ).with(
138 auth_uri: 'http://127.0.0.1:35357/v2.0', 113 project_name: project_name,
139 bootstrap_token: 'bootstrap-token', 114 role_name: role_name,
140 service_name: 'cinder', 115 password: password,
141 service_type: 'volume', 116 connection_params: connection_params
142 service_description: 'Cinder Volume Service V1',
143 endpoint_region: 'RegionOne',
144 endpoint_adminurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
145 endpoint_internalurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
146 endpoint_publicurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s'
147 ) 117 )
148 end 118 end
149 it do 119
150 expect(chef_run).to create_endpoint_openstack_identity_register( 120 it 'registers cinder v1 volume service' do
151 'Register Cinder V1 Volume Endpoint' 121 expect(chef_run).to create_openstack_service(
122 'cinder'
152 ).with( 123 ).with(
153 auth_uri: 'http://127.0.0.1:35357/v2.0', 124 connection_params: connection_params,
154 bootstrap_token: 'bootstrap-token', 125 type: 'volume'
155 service_name: 'cinder',
156 service_type: 'volume',
157 service_description: 'Cinder Volume Service V1',
158 endpoint_region: 'RegionOne',
159 endpoint_adminurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
160 endpoint_internalurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
161 endpoint_publicurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s'
162 ) 126 )
163 end 127 end
164 end 128 end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 9b80925..0876859 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -108,12 +108,14 @@ shared_examples 'creates_cinder_conf' do |service, user, group, action = :restar
108 108
109 it do 109 it do
110 [ 110 [
111 /^auth_type = v2password$/, 111 /^auth_type = v3password$/,
112 /^region_name = RegionOne$/, 112 /^region_name = RegionOne$/,
113 /^username = cinder/, 113 /^username = cinder/,
114 /^tenant_name = service$/, 114 /^project_name = service$/,
115 /^user_domain_name = Default/,
116 /^project_domain_name = Default/,
115 %r{^signing_dir = /var/cache/cinder/api$}, 117 %r{^signing_dir = /var/cache/cinder/api$},
116 %r{^auth_url = http://127.0.0.1:5000/v2.0$}, 118 %r{^auth_url = http://127.0.0.1:5000/v3$},
117 /^password = cinder-pass$/ 119 /^password = cinder-pass$/
118 ].each do |line| 120 ].each do |line|
119 expect(chef_run).to render_config_file(file.name) 121 expect(chef_run).to render_config_file(file.name)