kitchen-vra 2.4.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/vra_spec.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  #
3
4
  # Author:: Chef Partner Engineering (<partnereng@chef.io>)
4
5
  # Copyright:: Copyright (c) 2015 Chef Software, Inc.
@@ -17,33 +18,33 @@
17
18
  # limitations under the License.
18
19
  #
19
20
 
20
- require 'spec_helper'
21
- require 'kitchen/driver/vra'
22
- require 'kitchen/provisioner/dummy'
23
- require 'kitchen/transport/dummy'
24
- require 'kitchen/verifier/dummy'
21
+ require "spec_helper"
22
+ require "kitchen/driver/vra"
23
+ require "kitchen/provisioner/dummy"
24
+ require "kitchen/transport/dummy"
25
+ require "kitchen/verifier/dummy"
25
26
 
26
27
  describe Kitchen::Driver::Vra do
27
28
  let(:logged_output) { StringIO.new }
28
29
  let(:logger) { Logger.new(logged_output) }
29
- let(:platform) { Kitchen::Platform.new(name: 'fake_platform') }
30
+ let(:platform) { Kitchen::Platform.new(name: "fake_platform") }
30
31
  let(:transport) { Kitchen::Transport::Dummy.new }
31
32
  let(:driver) { Kitchen::Driver::Vra.new(config) }
32
33
 
33
34
  let(:config) do
34
35
  {
35
- base_url: 'https://vra.corp.local',
36
- username: 'myuser',
37
- password: 'mypassword',
38
- tenant: 'mytenant',
39
- verify_ssl: true,
40
- cpus: 2,
41
- memory: 2048,
42
- requested_for: 'override_user@corp.local',
43
- notes: 'some notes',
44
- subtenant_id: '160b473a-0ec9-473d-8156-28dd96c0b6b7',
45
- lease_days: 5,
46
- use_dns: false
36
+ base_url: "https://vra.corp.local",
37
+ username: "myuser",
38
+ password: "mypassword",
39
+ tenant: "mytenant",
40
+ project_id: "6ba69375-79d5-42c3-a099-7d32739f71a7",
41
+ image_mapping: "VRA-nc-lnx-ce8.4-Docker",
42
+ flavor_mapping: "Small",
43
+ verify_ssl: true,
44
+ subtenant_id: "160b473a-0ec9-473d-8156-28dd96c0b6b7",
45
+ use_dns: false,
46
+ deployment_name: "test-instance",
47
+ version: 1,
47
48
  }
48
49
  end
49
50
 
@@ -52,28 +53,28 @@ describe Kitchen::Driver::Vra do
52
53
  logger: logger,
53
54
  transport: transport,
54
55
  platform: platform,
55
- to_str: 'instance_str')
56
+ to_str: "instance_str")
56
57
  end
57
58
 
58
59
  before do
59
60
  allow(driver).to receive(:instance).and_return(instance)
60
61
  end
61
62
 
62
- it 'driver API version is 2' do
63
+ it "driver API version is 2" do
63
64
  expect(driver.diagnose_plugin[:api_version]).to eq(2)
64
65
  end
65
66
 
66
- describe '#name' do
67
- it 'has an overridden name' do
68
- expect(driver.name).to eq('vRA')
67
+ describe "#name" do
68
+ it "has an overridden name" do
69
+ expect(driver.name).to eq("vRA")
69
70
  end
70
71
  end
71
72
 
72
- describe '#create' do
73
- context 'when the server is already created' do
74
- let(:state) { { resource_id: '48959518-6a0d-46e1-8415-3749696b65f4' } }
73
+ describe "#create" do
74
+ context "when the server is already created" do
75
+ let(:state) { { deployment_id: "48959518-6a0d-46e1-8415-3749696b65f4" } }
75
76
 
76
- it 'does not submit a catalog request' do
77
+ it "does not submit a catalog request" do
77
78
  expect(driver).not_to receive(:request_server)
78
79
  driver.create(state)
79
80
  end
@@ -81,10 +82,10 @@ describe Kitchen::Driver::Vra do
81
82
 
82
83
  let(:state) { {} }
83
84
  let(:resource) do
84
- double('server1',
85
- id: 'e8706351-cf4c-4c12-acb7-c90cc683b22c',
86
- name: 'server1',
87
- ip_addresses: [ '1.2.3.4' ],
85
+ double("server1",
86
+ deployment_id: "e8706351-cf4c-4c12-acb7-c90cc683b22c",
87
+ name: "test-server",
88
+ ip_address: "1.2.3.4",
88
89
  vm?: true)
89
90
  end
90
91
 
@@ -93,91 +94,91 @@ describe Kitchen::Driver::Vra do
93
94
  allow(driver).to receive(:wait_for_server)
94
95
  end
95
96
 
96
- it 'requests the server' do
97
+ it "requests the server" do
97
98
  expect(driver).to receive(:request_server).and_return(resource)
98
99
  driver.create(state)
99
100
  end
100
101
 
101
- it 'sets the server ID in the state hash' do
102
+ it "sets the server ID in the state hash" do
102
103
  driver.create(state)
103
- expect(state[:resource_id]).to eq('e8706351-cf4c-4c12-acb7-c90cc683b22c')
104
+ expect(state[:deployment_id]).to eq("e8706351-cf4c-4c12-acb7-c90cc683b22c")
104
105
  end
105
106
 
106
- it 'sets the hostname in the state hash' do
107
- allow(driver).to receive(:hostname_for).and_return('test_hostname')
107
+ it "sets the hostname in the state hash" do
108
+ allow(driver).to receive(:hostname_for).and_return("test_hostname")
108
109
  driver.create(state)
109
- expect(state[:hostname]).to eq('test_hostname')
110
+ expect(state[:hostname]).to eq("test_hostname")
110
111
  end
111
112
 
112
- it 'waits for the server to be ready' do
113
+ it "waits for the server to be ready" do
113
114
  expect(driver).to receive(:wait_for_server)
114
115
  driver.create(state)
115
116
  end
116
117
  end
117
118
 
118
- describe '#hostname_for' do
119
+ describe "#hostname_for" do
119
120
  let(:server) do
120
- double('server',
121
- id: 'test_id',
122
- name: 'test_hostname',
123
- ip_addresses: [ '1.2.3.4' ],
121
+ double("server",
122
+ deployment_id: "test_id",
123
+ name: "test_hostname",
124
+ ip_address: "1.2.3.4",
124
125
  vm?: true)
125
126
  end
126
127
 
127
- context 'when use_dns is true and dns_suffix is defined' do
128
+ context "when use_dns is true and dns_suffix is defined" do
128
129
  let(:config) do
129
130
  {
130
131
  use_dns: true,
131
- dns_suffix: 'my.com'
132
+ dns_suffix: "my.com",
132
133
  }
133
134
  end
134
135
 
135
- it 'returns the server name with suffix appended' do
136
- expect(driver.hostname_for(server)).to eq('test_hostname.my.com')
136
+ it "returns the server name with suffix appended" do
137
+ expect(driver.hostname_for(server)).to eq("test_hostname.my.com")
137
138
  end
138
139
  end
139
140
 
140
- context 'when use_dns is true' do
141
+ context "when use_dns is true" do
141
142
  let(:config) { { use_dns: true } }
142
143
 
143
- it 'raises an exception if the server name is nil' do
144
+ it "raises an exception if the server name is nil" do
144
145
  allow(server).to receive(:name).and_return(nil)
145
146
  expect { driver.hostname_for(server) }.to raise_error(RuntimeError)
146
147
  end
147
148
 
148
- it 'returns the server name' do
149
- expect(driver.hostname_for(server)).to eq('test_hostname')
149
+ it "returns the server name" do
150
+ expect(driver.hostname_for(server)).to eq("test_hostname")
150
151
  end
151
152
  end
152
153
 
153
- context 'when use_dns is false' do
154
- it 'falls back to the server name if no IP address exists' do
155
- allow(server).to receive(:ip_addresses).and_return([])
154
+ context "when use_dns is false" do
155
+ it "falls back to the server name if no IP address exists" do
156
+ allow(server).to receive(:ip_address).and_return(nil)
156
157
  expect(driver).to receive(:warn)
157
- expect(driver.hostname_for(server)).to eq('test_hostname')
158
+ expect(driver.hostname_for(server)).to eq("test_hostname")
158
159
  end
159
160
 
160
- it 'returns the IP address if it exists' do
161
- expect(driver.hostname_for(server)).to eq('1.2.3.4')
161
+ it "returns the IP address if it exists" do
162
+ expect(driver.hostname_for(server)).to eq("1.2.3.4")
162
163
  end
163
164
  end
164
165
  end
165
166
 
166
- describe '#request_server' do
167
- let(:submitted_request) { double('submitted_request') }
168
- let(:catalog_request) { double('catalog_request') }
167
+ describe "#request_server" do
168
+ let(:submitted_request) { double("submitted_request") }
169
+ let(:catalog_request) { double("catalog_request") }
169
170
  let(:resource1) do
170
- double('server1',
171
- id: 'e8706351-cf4c-4c12-acb7-c90cc683b22c',
172
- name: 'server1',
173
- ip_addresses: [ '1.2.3.4' ],
171
+ double("server1",
172
+ id: "e8706351-cf4c-4c12-acb7-c90cc683b22c",
173
+ name: "server1",
174
+ ip_address: "1.2.3.4",
174
175
  vm?: true)
175
176
  end
176
177
  let(:resource2) do
177
- double('server2',
178
- id: '9e2364cf-7af4-4b85-93fd-1f03ee2ac865',
179
- name: 'server2',
180
- ip_addresses: [ '4.3.2.1' ],
178
+ double("server2",
179
+ id: "9e2364cf-7af4-4b85-93fd-1f03ee2ac865",
180
+ name: "server2",
181
+ ip_address: "4.3.2.1",
181
182
  vm?: true)
182
183
  end
183
184
  let(:resources) { [resource1] }
@@ -185,63 +186,63 @@ describe Kitchen::Driver::Vra do
185
186
  before do
186
187
  allow(driver).to receive(:catalog_request).and_return(catalog_request)
187
188
  allow(catalog_request).to receive(:submit).and_return(submitted_request)
188
- allow(submitted_request).to receive(:id).and_return('74e26af9-2d2f-4889-a472-95dbcedb70b8')
189
+ allow(submitted_request).to receive(:id).and_return("74e26af9-2d2f-4889-a472-95dbcedb70b8")
189
190
  allow(submitted_request).to receive(:resources).and_return(resources)
190
191
  allow(submitted_request).to receive(:failed?).and_return(false)
191
192
  allow(driver).to receive(:wait_for_request).with(submitted_request)
192
193
  end
193
194
 
194
- it 'submits a catalog request' do
195
+ it "submits a catalog request" do
195
196
  expect(driver.catalog_request).to receive(:submit).and_return(submitted_request)
196
197
  driver.request_server
197
198
  end
198
199
 
199
- it 'waits for the request to complete' do
200
+ it "waits for the request to complete" do
200
201
  expect(driver).to receive(:wait_for_request).with(submitted_request)
201
202
  driver.request_server
202
203
  end
203
204
 
204
- it 'raises an exception if the request failed' do
205
+ it "raises an exception if the request failed" do
205
206
  allow(submitted_request).to receive(:failed?).and_return(true)
206
- allow(submitted_request).to receive(:completion_details).and_return('it failed')
207
+ allow(submitted_request).to receive(:completion_details).and_return("it failed")
207
208
  expect { driver.request_server }.to raise_error(RuntimeError)
208
209
  end
209
210
 
210
- describe 'getting the server from the request' do
211
- context 'when only one server is returned' do
212
- it 'does not raise an exception' do
211
+ describe "getting the server from the request" do
212
+ context "when only one server is returned" do
213
+ it "does not raise an exception" do
213
214
  expect { driver.request_server }.not_to raise_error
214
215
  end
215
216
  end
216
217
 
217
- context 'when multiple servers are returned' do
218
- it 'raises an exception' do
218
+ context "when multiple servers are returned" do
219
+ it "raises an exception" do
219
220
  allow(submitted_request).to receive(:resources).and_return([ resource1, resource2 ])
220
221
  expect { driver.request_server }.to raise_error(RuntimeError)
221
222
  end
222
223
  end
223
224
 
224
- context 'when no servers are returned' do
225
- it 'raises an exception' do
225
+ context "when no servers are returned" do
226
+ it "raises an exception" do
226
227
  allow(submitted_request).to receive(:resources).and_return([])
227
228
  expect { driver.request_server }.to raise_error(RuntimeError)
228
229
  end
229
230
  end
230
231
  end
231
232
 
232
- it 'returns the the single server resource object' do
233
+ it "returns the the single server resource object" do
233
234
  expect(driver.request_server).to eq(resource1)
234
235
  end
235
236
  end
236
237
 
237
- describe '#wait_for_server' do
238
+ describe "#wait_for_server" do
238
239
  let(:connection) { instance.transport.connection(state) }
239
240
  let(:state) { {} }
240
241
  let(:resource1) do
241
- double('server1',
242
- id: 'test_id',
243
- name: 'server1',
244
- ip_addresses: [ '1.2.3.4' ],
242
+ double("server1",
243
+ id: "test_id",
244
+ name: "server1",
245
+ ip_address: "1.2.3.4",
245
246
  vm?: true)
246
247
  end
247
248
 
@@ -252,58 +253,58 @@ describe Kitchen::Driver::Vra do
252
253
  allow(driver).to receive(:error)
253
254
  end
254
255
 
255
- it 'waits for the server to be ready' do
256
+ it "waits for the server to be ready" do
256
257
  expect(connection).to receive(:wait_until_ready)
257
258
  driver.wait_for_server(state, resource1)
258
259
  end
259
260
 
260
- context 'when an exception is caught and retries is 0' do
261
+ context "when an exception is caught and retries is 0" do
261
262
  let(:config) { { server_ready_retries: 0 } }
262
263
 
263
- it 'does not sleep and raises an exception' do
264
+ it "does not sleep and raises an exception" do
264
265
  allow(connection).to receive(:wait_until_ready).and_raise(Timeout::Error)
265
266
  expect(driver).not_to receive(:sleep)
266
- expect(driver).to receive(:error).with('Retries exceeded. Destroying server...')
267
+ expect(driver).to receive(:error).with("Retries exceeded. Destroying server...")
267
268
  expect { driver.wait_for_server(state, resource1) }.to raise_error(Timeout::Error)
268
269
  end
269
270
  end
270
271
 
271
- context 'when retries is 1 and it errors out twice' do
272
+ context "when retries is 1 and it errors out twice" do
272
273
  let(:config) { { server_ready_retries: 1 } }
273
274
 
274
- it 'displays a warning, sleeps once, retries, errors, destroys, and raises' do
275
+ it "displays a warning, sleeps once, retries, errors, destroys, and raises" do
275
276
  expect(connection).to receive(:wait_until_ready).twice.and_raise(Timeout::Error)
276
- expect(driver).to receive(:warn).once.with('Sleeping 5 seconds and retrying...')
277
+ expect(driver).to receive(:warn).once.with("Sleeping 5 seconds and retrying...")
277
278
  expect(driver).to receive(:sleep).once.with(5)
278
- expect(driver).to receive(:error).with('Retries exceeded. Destroying server...')
279
+ expect(driver).to receive(:error).with("Retries exceeded. Destroying server...")
279
280
  expect(driver).to receive(:destroy).with(state)
280
281
  expect { driver.wait_for_server(state, resource1) }.to raise_error(Timeout::Error)
281
282
  end
282
283
  end
283
284
 
284
- context 'when retries is 2 and it errors out all 3 times' do
285
+ context "when retries is 2 and it errors out all 3 times" do
285
286
  let(:config) { { server_ready_retries: 2 } }
286
287
 
287
- it 'displays 2 warnings, sleeps twice, retries, errors, destroys, and raises' do
288
+ it "displays 2 warnings, sleeps twice, retries, errors, destroys, and raises" do
288
289
  expect(connection).to receive(:wait_until_ready).exactly(3).times.and_raise(Timeout::Error)
289
- expect(driver).to receive(:warn).once.with('Sleeping 5 seconds and retrying...')
290
- expect(driver).to receive(:warn).once.with('Sleeping 10 seconds and retrying...')
290
+ expect(driver).to receive(:warn).once.with("Sleeping 5 seconds and retrying...")
291
+ expect(driver).to receive(:warn).once.with("Sleeping 10 seconds and retrying...")
291
292
  expect(driver).to receive(:sleep).once.with(5)
292
293
  expect(driver).to receive(:sleep).once.with(10)
293
- expect(driver).to receive(:error).with('Retries exceeded. Destroying server...')
294
+ expect(driver).to receive(:error).with("Retries exceeded. Destroying server...")
294
295
  expect(driver).to receive(:destroy).with(state)
295
296
  expect { driver.wait_for_server(state, resource1) }.to raise_error(Timeout::Error)
296
297
  end
297
298
  end
298
299
 
299
- context 'when retries is 5, it errors out the first 2 tries, but works on the 3rd' do
300
+ context "when retries is 5, it errors out the first 2 tries, but works on the 3rd" do
300
301
  let(:config) { { server_ready_retries: 5 } }
301
302
 
302
- it 'displays 2 warnings, sleeps twice, retries, but does not destroy or raise' do
303
+ it "displays 2 warnings, sleeps twice, retries, but does not destroy or raise" do
303
304
  expect(connection).to receive(:wait_until_ready).twice.and_raise(Timeout::Error)
304
305
  expect(connection).to receive(:wait_until_ready).once.and_return(true)
305
- expect(driver).to receive(:warn).once.with('Sleeping 5 seconds and retrying...')
306
- expect(driver).to receive(:warn).once.with('Sleeping 10 seconds and retrying...')
306
+ expect(driver).to receive(:warn).once.with("Sleeping 5 seconds and retrying...")
307
+ expect(driver).to receive(:warn).once.with("Sleeping 10 seconds and retrying...")
307
308
  expect(driver).to receive(:sleep).once.with(5)
308
309
  expect(driver).to receive(:sleep).once.with(10)
309
310
  expect(driver).not_to receive(:error)
@@ -312,10 +313,10 @@ describe Kitchen::Driver::Vra do
312
313
  end
313
314
  end
314
315
 
315
- context 'when retries is 7, always erroring' do
316
+ context "when retries is 7, always erroring" do
316
317
  let(:config) { { server_ready_retries: 8 } }
317
318
 
318
- it 'caps the delays at 30 seconds' do
319
+ it "caps the delays at 30 seconds" do
319
320
  expect(connection).to receive(:wait_until_ready).exactly(9).times.and_raise(Timeout::Error)
320
321
  expect(driver).to receive(:sleep).once.with(5)
321
322
  expect(driver).to receive(:sleep).once.with(10)
@@ -328,144 +329,135 @@ describe Kitchen::Driver::Vra do
328
329
  end
329
330
  end
330
331
 
331
- describe '#destroy' do
332
- let(:resource_id) { '8c1a833a-5844-4100-b58c-9cab3543c958' }
333
- let(:state) { { resource_id: resource_id } }
334
- let(:vra_client) { double('vra_client') }
335
- let(:resources) { double('resources') }
336
- let(:destroy_request) { double('destroy_request') }
332
+ describe "#destroy" do
333
+ let(:deployment_id) { "8c1a833a-5844-4100-b58c-9cab3543c958" }
334
+ let(:state) { { deployment_id: deployment_id } }
335
+ let(:vra_client) { double("vra_client") }
336
+ let(:deployments) { double("resources") }
337
+ let(:destroy_request) { double("destroy_request") }
337
338
  let(:resource) do
338
- double('server1',
339
- id: resource_id,
340
- name: 'server1',
341
- ip_addresses: [ '5.6.7.8' ],
339
+ double("server1",
340
+ deployment_id: deployment_id,
341
+ name: "server1",
342
+ ip_address: "5.6.7.8",
342
343
  vm?: true)
343
344
  end
344
345
 
345
346
  before do
346
347
  allow(driver).to receive(:vra_client).and_return(vra_client)
347
348
  allow(driver).to receive(:wait_for_request).with(destroy_request)
348
- allow(vra_client).to receive(:resources).and_return(resources)
349
- allow(resources).to receive(:by_id).and_return(resource)
349
+ allow(vra_client).to receive(:deployments).and_return(deployments)
350
+ allow(deployments).to receive(:by_id).and_return(resource)
350
351
  allow(resource).to receive(:destroy).and_return(destroy_request)
351
- allow(destroy_request).to receive(:id).and_return('6da65982-7c33-4e6e-b346-fdf4bcbf01ab')
352
+ allow(destroy_request).to receive(:id).and_return("6da65982-7c33-4e6e-b346-fdf4bcbf01ab")
352
353
  end
353
354
 
354
- context 'when the resource is not created' do
355
+ context "when the resource is not created" do
355
356
  let(:state) { {} }
356
- it 'does not look up the resource if no resource ID exists' do
357
- expect(vra_client.resources).not_to receive(:by_id)
357
+ it "does not look up the resource if no resource ID exists" do
358
+ expect(vra_client.deployments).not_to receive(:by_id)
358
359
  driver.destroy(state)
359
360
  end
360
361
  end
361
362
 
362
- it 'looks up the resource record' do
363
- expect(vra_client.resources).to receive(:by_id).with(resource_id).and_return(resource)
363
+ it "looks up the resource record" do
364
+ expect(vra_client.deployments).to receive(:by_id).with(deployment_id).and_return(resource)
364
365
  driver.destroy(state)
365
366
  end
366
367
 
367
- context 'when the resource record cannot be found' do
368
- it 'does not raise an exception' do
369
- allow(vra_client.resources).to receive(:by_id).with(resource_id).and_raise(Vra::Exception::NotFound)
368
+ context "when the resource record cannot be found" do
369
+ it "does not raise an exception" do
370
+ allow(vra_client.deployments).to receive(:by_id).with(deployment_id).and_raise(Vra::Exception::NotFound)
370
371
  expect { driver.destroy(state) }.not_to raise_error
371
372
  end
372
373
  end
373
374
 
374
- describe 'creating the destroy request' do
375
- context 'when the destroy method or server is not found' do
376
- it 'does not raise an exception' do
375
+ describe "creating the destroy request" do
376
+ context "when the destroy method or server is not found" do
377
+ it "does not raise an exception" do
377
378
  allow(resource).to receive(:destroy).and_raise(Vra::Exception::NotFound)
378
379
  expect { driver.destroy(state) }.not_to raise_error
379
380
  end
380
381
  end
381
382
 
382
- it 'calls #destroy on the server' do
383
+ it "calls #destroy on the server" do
383
384
  expect(resource).to receive(:destroy).and_return(destroy_request)
384
385
  driver.destroy(state)
385
386
  end
386
387
  end
387
388
 
388
- it 'waits for the destroy request to succeed' do
389
+ it "waits for the destroy request to succeed" do
389
390
  expect(driver).to receive(:wait_for_request).with(destroy_request)
390
391
  driver.destroy(state)
391
392
  end
392
393
  end
393
394
 
394
- describe '#catalog_request' do
395
- let(:catalog_request) { double('catalog_request') }
396
- let(:vra_client) { double('vra_client') }
397
- let(:catalog) { double('catalog') }
395
+ describe "#catalog_request" do
396
+ let(:catalog_request) { double("catalog_request") }
397
+ let(:vra_client) { double("vra_client") }
398
+ let(:catalog) { double("catalog") }
398
399
  before do
399
400
  allow(driver).to receive(:vra_client).and_return(vra_client)
400
401
  allow(vra_client).to receive(:catalog).and_return(catalog)
401
402
  allow(catalog).to receive(:request).and_return(catalog_request)
402
- [ :cpus=, :memory=, :requested_for=, :lease_days=, :notes=, :subtenant_id=, :set_parameter ].each do |method|
403
+ %i{subtenant_id= set_parameter}.each do |method|
403
404
  allow(catalog_request).to receive(method)
404
405
  end
405
406
  end
406
407
 
407
- it 'creates a catalog_request' do
408
+ it "creates a catalog_request" do
408
409
  expect(vra_client.catalog).to receive(:request).and_return(catalog_request)
409
410
  driver.catalog_request
410
411
  end
411
412
 
412
- it 'sets all the standard parameters on the request' do
413
- expect(catalog_request).to receive(:cpus=).with(config[:cpus])
414
- expect(catalog_request).to receive(:memory=).with(config[:memory])
415
- expect(catalog_request).to receive(:requested_for=).with(config[:requested_for])
416
- expect(catalog_request).to receive(:lease_days=).with(config[:lease_days])
417
- expect(catalog_request).to receive(:notes=).with(config[:notes])
418
- expect(catalog_request).to receive(:subtenant_id=).with(config[:subtenant_id])
419
- driver.catalog_request
420
- end
421
-
422
- context 'when option parameters are not supplied' do
413
+ context "when option parameters are not supplied" do
423
414
  let(:config) do
424
415
  {
425
- base_url: 'https://vra.corp.local',
426
- username: 'myuser',
427
- password: 'mypassword',
428
- tenant: 'mytenant',
429
- verify_ssl: true,
430
- cpus: 2,
431
- memory: 2048,
432
- requested_for: 'override_user@corp.local'
416
+ base_url: "https://vra.corp.local",
417
+ username: "myuser",
418
+ password: "mypassword",
419
+ tenant: "mytenant",
420
+ verify_ssl: true,
421
+ project_id: "6ba69375-79d5-42c3-a099-7d32739f71a7",
422
+ image_mapping: "VRA-nc-lnx-ce8.4-Docker",
423
+ flavor_mapping: "Small",
424
+ version: 1,
433
425
  }
434
426
  end
435
427
 
436
- it 'does not attempt to set params on the catalog_request' do
437
- expect(catalog_request).not_to receive(:lease_days=)
438
- expect(catalog_request).not_to receive(:notes=)
428
+ it "does not attempt to set params on the catalog_request" do
439
429
  expect(catalog_request).not_to receive(:subtenant_id=)
440
430
  driver.catalog_request
441
431
  end
442
432
  end
443
433
 
444
- context 'when extra parameters are set' do
434
+ context "when extra parameters are set" do
445
435
  let(:config) do
446
436
  {
447
- base_url: 'https://vra.corp.local',
448
- username: 'myuser',
449
- password: 'mypassword',
450
- tenant: 'mytenant',
451
- verify_ssl: true,
452
- cpus: 2,
453
- memory: 2048,
454
- extra_parameters: { 'key1' => { type: 'string', value: 'value1' },
455
- 'key2' => { type: 'integer', value: 123 } }
437
+ base_url: "https://vra.corp.local",
438
+ username: "myuser",
439
+ password: "mypassword",
440
+ tenant: "mytenant",
441
+ verify_ssl: true,
442
+ project_id: "6ba69375-79d5-42c3-a099-7d32739f71a7",
443
+ image_mapping: "VRA-nc-lnx-ce8.4-Docker",
444
+ flavor_mapping: "Small",
445
+ version: 1,
446
+ extra_parameters: { "key1" => { type: "string", value: "value1" },
447
+ "key2" => { type: "integer", value: 123 } },
456
448
  }
457
449
  end
458
450
 
459
- it 'sets extra parmeters' do
460
- expect(catalog_request).to receive(:set_parameter).with('key1', 'string', 'value1')
461
- expect(catalog_request).to receive(:set_parameter).with('key2', 'integer', 123)
451
+ it "sets extra parmeters" do
452
+ expect(catalog_request).to receive(:set_parameters).with("key1", type: "string", value: "value1")
453
+ expect(catalog_request).to receive(:set_parameters).with("key2", type: "integer", value: 123)
462
454
  driver.catalog_request
463
455
  end
464
456
  end
465
457
  end
466
458
 
467
- describe '#vra_client' do
468
- it 'sets up a client object' do
459
+ describe "#vra_client" do
460
+ it "sets up a client object" do
469
461
  expect(Vra::Client).to receive(:new).with(base_url: config[:base_url],
470
462
  username: config[:username],
471
463
  password: config[:password],
@@ -475,15 +467,15 @@ describe Kitchen::Driver::Vra do
475
467
  end
476
468
  end
477
469
 
478
- describe '#wait_for_request' do
470
+ describe "#wait_for_request" do
479
471
  before do
480
472
  # don't actually sleep
481
473
  allow(driver).to receive(:sleep)
482
474
  end
483
475
 
484
- context 'when the requests completes normally, 3 loops' do
485
- it 'only refreshes the request 3 times' do
486
- request = double('request')
476
+ context "when the requests completes normally, 3 loops" do
477
+ it "only refreshes the request 3 times" do
478
+ request = double("request")
487
479
  allow(request).to receive(:status)
488
480
  allow(request).to receive(:completed?).exactly(3).times.and_return(false, false, true)
489
481
  expect(request).to receive(:refresh).exactly(3).times
@@ -492,9 +484,9 @@ describe Kitchen::Driver::Vra do
492
484
  end
493
485
  end
494
486
 
495
- context 'when the request is completed on the first loop' do
496
- it 'only refreshes the request 1 time' do
497
- request = double('request')
487
+ context "when the request is completed on the first loop" do
488
+ it "only refreshes the request 1 time" do
489
+ request = double("request")
498
490
  allow(request).to receive(:status)
499
491
  allow(request).to receive(:completed?).once.and_return(true)
500
492
  expect(request).to receive(:refresh).once
@@ -503,17 +495,17 @@ describe Kitchen::Driver::Vra do
503
495
  end
504
496
  end
505
497
 
506
- context 'when the timeout is exceeded' do
507
- it 'prints a warning and exits' do
508
- request = double('request')
498
+ context "when the timeout is exceeded" do
499
+ it "prints a warning and exits" do
500
+ request = double("request")
509
501
  allow(Timeout).to receive(:timeout).and_raise(Timeout::Error)
510
502
  expect { driver.wait_for_request(request) }.to raise_error(Timeout::Error)
511
503
  end
512
504
  end
513
505
 
514
- context 'when a non-timeout exception is raised' do
515
- it 'raises the original exception' do
516
- request = double('request')
506
+ context "when a non-timeout exception is raised" do
507
+ it "raises the original exception" do
508
+ request = double("request")
517
509
  allow(request).to receive(:refresh).and_raise(RuntimeError)
518
510
  expect { driver.wait_for_request(request) }.to raise_error(RuntimeError)
519
511
  end