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