vmfloaty 1.1.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/vmfloaty/abs.rb +58 -61
- data/lib/vmfloaty/http.rb +2 -6
- data/lib/vmfloaty/logger.rb +19 -3
- data/lib/vmfloaty/nonstandard_pooler.rb +3 -2
- data/lib/vmfloaty/pooler.rb +20 -25
- data/lib/vmfloaty/service.rb +5 -5
- data/lib/vmfloaty/utils.rb +66 -62
- data/lib/vmfloaty/version.rb +1 -2
- data/lib/vmfloaty.rb +64 -50
- data/spec/spec_helper.rb +30 -5
- data/spec/vmfloaty/abs/auth_spec.rb +26 -17
- data/spec/vmfloaty/abs_spec.rb +52 -43
- data/spec/vmfloaty/auth_spec.rb +23 -13
- data/spec/vmfloaty/nonstandard_pooler_spec.rb +32 -31
- data/spec/vmfloaty/pooler_spec.rb +29 -26
- data/spec/vmfloaty/service_spec.rb +10 -10
- data/spec/vmfloaty/ssh_spec.rb +3 -3
- data/spec/vmfloaty/utils_spec.rb +178 -161
- metadata +19 -13
data/spec/vmfloaty/utils_spec.rb
CHANGED
@@ -36,13 +36,14 @@ describe Utils do
|
|
36
36
|
|
37
37
|
it 'formats a result from vmpooler into a hash of os to hostnames' do
|
38
38
|
result = Utils.standardize_hostnames(JSON.parse(@vmpooler_response_body))
|
39
|
-
expect(result).to eq('centos-7-x86_64'
|
40
|
-
'ubuntu-1610-x86_64' => ['gdoy8q3nckuob0i.delivery.mycompany.net',
|
39
|
+
expect(result).to eq('centos-7-x86_64' => ['dlgietfmgeegry2.delivery.mycompany.net'],
|
40
|
+
'ubuntu-1610-x86_64' => ['gdoy8q3nckuob0i.delivery.mycompany.net',
|
41
|
+
'ctnktsd0u11p9tm.delivery.mycompany.net'])
|
41
42
|
end
|
42
43
|
|
43
44
|
it 'formats a result from the nonstandard pooler into a hash of os to hostnames' do
|
44
45
|
result = Utils.standardize_hostnames(JSON.parse(@nonstandard_response_body))
|
45
|
-
expect(result).to eq('solaris-10-sparc'
|
46
|
+
expect(result).to eq('solaris-10-sparc' => ['sol10-10.delivery.mycompany.net', 'sol10-11.delivery.mycompany.net'],
|
46
47
|
'ubuntu-16.04-power8' => ['power8-ubuntu16.04-6.delivery.mycompany.net'])
|
47
48
|
end
|
48
49
|
end
|
@@ -50,12 +51,12 @@ describe Utils do
|
|
50
51
|
describe '#format_host_output' do
|
51
52
|
before :each do
|
52
53
|
@vmpooler_results = {
|
53
|
-
'centos-7-x86_64'
|
54
|
-
'ubuntu-1610-x86_64' => ['gdoy8q3nckuob0i.delivery.mycompany.net', 'ctnktsd0u11p9tm.delivery.mycompany.net']
|
54
|
+
'centos-7-x86_64' => ['dlgietfmgeegry2.delivery.mycompany.net'],
|
55
|
+
'ubuntu-1610-x86_64' => ['gdoy8q3nckuob0i.delivery.mycompany.net', 'ctnktsd0u11p9tm.delivery.mycompany.net']
|
55
56
|
}
|
56
57
|
@nonstandard_results = {
|
57
|
-
'solaris-10-sparc'
|
58
|
-
'ubuntu-16.04-power8' => ['power8-ubuntu16.04-6.delivery.mycompany.net']
|
58
|
+
'solaris-10-sparc' => ['sol10-10.delivery.mycompany.net', 'sol10-11.delivery.mycompany.net'],
|
59
|
+
'ubuntu-16.04-power8' => ['power8-ubuntu16.04-6.delivery.mycompany.net']
|
59
60
|
}
|
60
61
|
@vmpooler_output = <<~OUT.chomp
|
61
62
|
- dlgietfmgeegry2.delivery.mycompany.net (centos-7-x86_64)
|
@@ -98,23 +99,23 @@ describe Utils do
|
|
98
99
|
describe '#get_service_config' do
|
99
100
|
before :each do
|
100
101
|
@default_config = {
|
101
|
-
'url'
|
102
|
-
'user'
|
103
|
-
'token' => 'default-token'
|
102
|
+
'url' => 'http://default.url',
|
103
|
+
'user' => 'first.last.default',
|
104
|
+
'token' => 'default-token'
|
104
105
|
}
|
105
106
|
@services_config = {
|
106
107
|
'services' => {
|
107
108
|
'vm' => {
|
108
|
-
'url'
|
109
|
-
'user'
|
110
|
-
'token' => 'vmpooler-token'
|
109
|
+
'url' => 'http://vmpooler.url',
|
110
|
+
'user' => 'first.last.vmpooler',
|
111
|
+
'token' => 'vmpooler-token'
|
111
112
|
},
|
112
113
|
'ns' => {
|
113
|
-
'url'
|
114
|
-
'user'
|
115
|
-
'token' => 'nspooler-token'
|
116
|
-
}
|
117
|
-
}
|
114
|
+
'url' => 'http://nspooler.url',
|
115
|
+
'user' => 'first.last.nspooler',
|
116
|
+
'token' => 'nspooler-token'
|
117
|
+
}
|
118
|
+
}
|
118
119
|
}
|
119
120
|
end
|
120
121
|
|
@@ -126,26 +127,26 @@ describe Utils do
|
|
126
127
|
|
127
128
|
it 'allows selection by configured service key' do
|
128
129
|
config = @default_config.merge @services_config
|
129
|
-
options = MockOptions.new(:
|
130
|
+
options = MockOptions.new(service: 'ns')
|
130
131
|
expect(Utils.get_service_config(config, options)).to include @services_config['services']['ns']
|
131
132
|
end
|
132
133
|
|
133
134
|
it 'uses top-level service config values as defaults when configured service values are missing' do
|
134
135
|
config = @default_config.merge @services_config
|
135
136
|
config['services']['vm'].delete 'url'
|
136
|
-
options = MockOptions.new(:
|
137
|
+
options = MockOptions.new(service: 'vm')
|
137
138
|
expect(Utils.get_service_config(config, options)['url']).to eq 'http://default.url'
|
138
139
|
end
|
139
140
|
|
140
141
|
it "raises an error if passed a service name that hasn't been configured" do
|
141
142
|
config = @default_config.merge @services_config
|
142
|
-
options = MockOptions.new(:
|
143
|
+
options = MockOptions.new(service: 'none')
|
143
144
|
expect { Utils.get_service_config(config, options) }.to raise_error ArgumentError
|
144
145
|
end
|
145
146
|
|
146
147
|
it 'prioritizes values passed as command line options over configuration options' do
|
147
148
|
config = @default_config
|
148
|
-
options = MockOptions.new(:
|
149
|
+
options = MockOptions.new(url: 'http://alternate.url', token: 'alternate-token')
|
149
150
|
expected = config.merge('url' => 'http://alternate.url', 'token' => 'alternate-token')
|
150
151
|
expect(Utils.get_service_config(config, options)).to include expected
|
151
152
|
end
|
@@ -182,15 +183,15 @@ describe Utils do
|
|
182
183
|
{
|
183
184
|
'template' => 'ubuntu-1604-x86_64',
|
184
185
|
'lifetime' => 12,
|
185
|
-
'running'
|
186
|
-
'state'
|
187
|
-
'ip'
|
188
|
-
'domain'
|
186
|
+
'running' => 9.66,
|
187
|
+
'state' => 'running',
|
188
|
+
'ip' => '127.0.0.1',
|
189
|
+
'domain' => domain
|
189
190
|
}
|
190
191
|
end
|
191
192
|
|
192
193
|
it 'outputs fqdn for host' do
|
193
|
-
expect(
|
194
|
+
expect($stdout).to receive(:puts).with(fqdn)
|
194
195
|
|
195
196
|
subject
|
196
197
|
end
|
@@ -201,17 +202,17 @@ describe Utils do
|
|
201
202
|
let(:hostname) { 'sol11-9.delivery.mycompany.net' }
|
202
203
|
let(:host_data) do
|
203
204
|
{
|
204
|
-
'fqdn'
|
205
|
-
'os_triple'
|
206
|
-
'reserved_by_user'
|
207
|
-
'reserved_for_reason'
|
208
|
-
'hours_left_on_reservation' => 35.89
|
205
|
+
'fqdn' => hostname,
|
206
|
+
'os_triple' => 'solaris-11-sparc',
|
207
|
+
'reserved_by_user' => 'first.last',
|
208
|
+
'reserved_for_reason' => '',
|
209
|
+
'hours_left_on_reservation' => 35.89
|
209
210
|
}
|
210
211
|
end
|
211
212
|
let(:fqdn) { hostname } # for nspooler these are the same
|
212
213
|
|
213
214
|
it 'outputs fqdn for host' do
|
214
|
-
expect(
|
215
|
+
expect($stdout).to receive(:puts).with(fqdn)
|
215
216
|
|
216
217
|
subject
|
217
218
|
end
|
@@ -231,19 +232,19 @@ describe Utils do
|
|
231
232
|
{
|
232
233
|
'hostname' => fqdn,
|
233
234
|
'type' => template,
|
234
|
-
'enging' => 'vmpooler'
|
235
|
-
}
|
235
|
+
'enging' => 'vmpooler'
|
236
|
+
}
|
236
237
|
],
|
237
238
|
'request' => {
|
238
239
|
'job' => {
|
239
|
-
'id' => hostname
|
240
|
+
'id' => hostname
|
240
241
|
}
|
241
|
-
}
|
242
|
+
}
|
242
243
|
}
|
243
244
|
end
|
244
245
|
|
245
246
|
it 'outputs fqdn for host' do
|
246
|
-
expect(
|
247
|
+
expect($stdout).to receive(:puts).with(fqdn)
|
247
248
|
|
248
249
|
subject
|
249
250
|
end
|
@@ -275,18 +276,18 @@ describe Utils do
|
|
275
276
|
hostname => {
|
276
277
|
'template' => 'ubuntu-1604-x86_64',
|
277
278
|
'lifetime' => 12,
|
278
|
-
'running'
|
279
|
-
'state'
|
280
|
-
'ip'
|
281
|
-
'domain'
|
279
|
+
'running' => 9.66,
|
280
|
+
'state' => 'running',
|
281
|
+
'ip' => '127.0.0.1',
|
282
|
+
'domain' => domain
|
282
283
|
}
|
283
284
|
}
|
284
285
|
end
|
285
286
|
|
286
|
-
let(:default_output) { "- #{fqdn} (ubuntu-1604-x86_64, 9.66/12 hours)" }
|
287
|
+
let(:default_output) { "- #{fqdn} (running, ubuntu-1604-x86_64, 9.66/12 hours)" }
|
287
288
|
|
288
289
|
it 'prints output with host fqdn, template and duration info' do
|
289
|
-
expect(
|
290
|
+
expect($stdout).to receive(:puts).with(default_output)
|
290
291
|
|
291
292
|
subject
|
292
293
|
end
|
@@ -298,22 +299,22 @@ describe Utils do
|
|
298
299
|
hostname => {
|
299
300
|
'template' => 'redhat-7-x86_64',
|
300
301
|
'lifetime' => 48,
|
301
|
-
'running'
|
302
|
-
'state'
|
303
|
-
'tags'
|
302
|
+
'running' => 7.67,
|
303
|
+
'state' => 'running',
|
304
|
+
'tags' => {
|
304
305
|
'user' => 'bob',
|
305
|
-
'role' => 'agent'
|
306
|
+
'role' => 'agent'
|
306
307
|
},
|
307
|
-
'ip'
|
308
|
-
'domain'
|
308
|
+
'ip' => '127.0.0.1',
|
309
|
+
'domain' => domain
|
309
310
|
}
|
310
311
|
}
|
311
312
|
end
|
312
313
|
|
313
314
|
it 'prints output with host fqdn, template, duration info, and tags' do
|
314
|
-
output = "- #{fqdn} (redhat-7-x86_64, 7.67/48 hours, user: bob, role: agent)"
|
315
|
+
output = "- #{fqdn} (running, redhat-7-x86_64, 7.67/48 hours, user: bob, role: agent)"
|
315
316
|
|
316
|
-
expect(
|
317
|
+
expect($stdout).to receive(:puts).with(output)
|
317
318
|
|
318
319
|
subject
|
319
320
|
end
|
@@ -323,7 +324,7 @@ describe Utils do
|
|
323
324
|
let(:print_to_stderr) { true }
|
324
325
|
|
325
326
|
it 'outputs to stderr instead of stdout' do
|
326
|
-
expect(
|
327
|
+
expect($stderr).to receive(:puts).with(default_output)
|
327
328
|
|
328
329
|
subject
|
329
330
|
end
|
@@ -337,11 +338,11 @@ describe Utils do
|
|
337
338
|
let(:response_body) do
|
338
339
|
{
|
339
340
|
hostname => {
|
340
|
-
'fqdn'
|
341
|
-
'os_triple'
|
342
|
-
'reserved_by_user'
|
343
|
-
'reserved_for_reason'
|
344
|
-
'hours_left_on_reservation' => 35.89
|
341
|
+
'fqdn' => hostname,
|
342
|
+
'os_triple' => 'solaris-11-sparc',
|
343
|
+
'reserved_by_user' => 'first.last',
|
344
|
+
'reserved_for_reason' => '',
|
345
|
+
'hours_left_on_reservation' => 35.89
|
345
346
|
}
|
346
347
|
}
|
347
348
|
end
|
@@ -349,7 +350,7 @@ describe Utils do
|
|
349
350
|
let(:default_output) { "- #{hostname} (solaris-11-sparc, 35.89h remaining)" }
|
350
351
|
|
351
352
|
it 'prints output with host, template, and time remaining' do
|
352
|
-
expect(
|
353
|
+
expect($stdout).to receive(:puts).with(default_output)
|
353
354
|
|
354
355
|
subject
|
355
356
|
end
|
@@ -358,11 +359,11 @@ describe Utils do
|
|
358
359
|
let(:response_body) do
|
359
360
|
{
|
360
361
|
hostname => {
|
361
|
-
'fqdn'
|
362
|
-
'os_triple'
|
363
|
-
'reserved_by_user'
|
364
|
-
'reserved_for_reason'
|
365
|
-
'hours_left_on_reservation' => 35.89
|
362
|
+
'fqdn' => hostname,
|
363
|
+
'os_triple' => 'solaris-11-sparc',
|
364
|
+
'reserved_by_user' => 'first.last',
|
365
|
+
'reserved_for_reason' => 'testing',
|
366
|
+
'hours_left_on_reservation' => 35.89
|
366
367
|
}
|
367
368
|
}
|
368
369
|
end
|
@@ -370,7 +371,7 @@ describe Utils do
|
|
370
371
|
it 'prints output with host, template, time remaining, and reason' do
|
371
372
|
output = '- sol11-9.delivery.mycompany.net (solaris-11-sparc, 35.89h remaining, reason: testing)'
|
372
373
|
|
373
|
-
expect(
|
374
|
+
expect($stdout).to receive(:puts).with(output)
|
374
375
|
|
375
376
|
subject
|
376
377
|
end
|
@@ -380,7 +381,7 @@ describe Utils do
|
|
380
381
|
let(:print_to_stderr) { true }
|
381
382
|
|
382
383
|
it 'outputs to stderr instead of stdout' do
|
383
|
-
expect(
|
384
|
+
expect($stderr).to receive(:puts).with(default_output)
|
384
385
|
|
385
386
|
subject
|
386
387
|
end
|
@@ -392,7 +393,7 @@ describe Utils do
|
|
392
393
|
|
393
394
|
let(:hostname) { '1597952189390' }
|
394
395
|
let(:fqdn) { 'example-noun.delivery.mycompany.net' }
|
395
|
-
let(:fqdn_hostname) {'example-noun'}
|
396
|
+
let(:fqdn_hostname) { 'example-noun' }
|
396
397
|
let(:template) { 'ubuntu-1604-x86_64' }
|
397
398
|
|
398
399
|
# This seems to be the miminal stub response from ABS for the current output
|
@@ -404,14 +405,14 @@ describe Utils do
|
|
404
405
|
{
|
405
406
|
'hostname' => fqdn,
|
406
407
|
'type' => template,
|
407
|
-
'engine' => 'vmpooler'
|
408
|
-
}
|
408
|
+
'engine' => 'vmpooler'
|
409
|
+
}
|
409
410
|
],
|
410
411
|
'request' => {
|
411
412
|
'job' => {
|
412
|
-
'id' => hostname
|
413
|
+
'id' => hostname
|
413
414
|
}
|
414
|
-
}
|
415
|
+
}
|
415
416
|
}
|
416
417
|
}
|
417
418
|
end
|
@@ -420,47 +421,58 @@ describe Utils do
|
|
420
421
|
let(:domain) { 'delivery.mycompany.net' }
|
421
422
|
let(:response_body_vmpooler) do
|
422
423
|
{
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
424
|
+
fqdn_hostname => {
|
425
|
+
'template' => template,
|
426
|
+
'lifetime' => 48,
|
427
|
+
'running' => 7.67,
|
428
|
+
'state' => 'running',
|
429
|
+
'tags' => {
|
430
|
+
'user' => 'bob',
|
431
|
+
'role' => 'agent'
|
432
|
+
},
|
433
|
+
'ip' => '127.0.0.1',
|
434
|
+
'domain' => domain
|
435
|
+
}
|
435
436
|
}
|
436
437
|
end
|
437
438
|
|
438
439
|
before(:each) do
|
439
440
|
allow(Utils).to receive(:get_vmpooler_service_config).and_return({
|
440
|
-
|
441
|
-
|
442
|
-
|
441
|
+
'url' => 'http://vmpooler.example.com',
|
442
|
+
'token' => 'krypto-knight'
|
443
|
+
})
|
443
444
|
allow(service).to receive(:query)
|
444
|
-
|
445
|
-
|
445
|
+
.with(anything, fqdn_hostname)
|
446
|
+
.and_return(response_body_vmpooler)
|
446
447
|
end
|
447
448
|
|
448
449
|
let(:default_output_first_line) { "- [JobID:#{hostname}] <allocated>" }
|
449
450
|
let(:default_output_second_line) { " - #{fqdn} (#{template})" }
|
450
451
|
|
451
452
|
it 'prints output with job id, host, and template' do
|
452
|
-
expect(
|
453
|
-
expect(
|
453
|
+
expect($stdout).to receive(:puts).with(default_output_first_line)
|
454
|
+
expect($stdout).to receive(:puts).with(default_output_second_line)
|
454
455
|
|
455
456
|
subject
|
456
457
|
end
|
457
458
|
|
458
459
|
it 'prints more information when vmpooler_fallback is set output with job id, host, template, lifetime, user and role' do
|
459
|
-
fallback = {'vmpooler_fallback' => 'vmpooler'}
|
460
|
+
fallback = { 'vmpooler_fallback' => 'vmpooler' }
|
461
|
+
service.config.merge! fallback
|
462
|
+
default_output_second_line = " - #{fqdn} (running, #{template}, 7.67/48 hours, user: bob, role: agent)"
|
463
|
+
expect($stdout).to receive(:puts).with(default_output_first_line)
|
464
|
+
expect($stdout).to receive(:puts).with(default_output_second_line)
|
465
|
+
|
466
|
+
subject
|
467
|
+
end
|
468
|
+
|
469
|
+
it 'prints in red when destroyed' do
|
470
|
+
fallback = { 'vmpooler_fallback' => 'vmpooler' }
|
460
471
|
service.config.merge! fallback
|
461
|
-
|
462
|
-
|
463
|
-
expect(
|
472
|
+
response_body_vmpooler[fqdn_hostname]['state'] = 'destroyed'
|
473
|
+
default_output_second_line_red = " - #{fqdn} (destroyed, #{template}, 7.67/48 hours, user: bob, role: agent)".red
|
474
|
+
expect($stdout).to receive(:puts).with(default_output_first_line)
|
475
|
+
expect($stdout).to receive(:puts).with(default_output_second_line_red)
|
464
476
|
|
465
477
|
subject
|
466
478
|
end
|
@@ -469,8 +481,8 @@ describe Utils do
|
|
469
481
|
let(:print_to_stderr) { true }
|
470
482
|
|
471
483
|
it 'outputs to stderr instead of stdout' do
|
472
|
-
expect(
|
473
|
-
expect(
|
484
|
+
expect($stderr).to receive(:puts).with(default_output_first_line)
|
485
|
+
expect($stderr).to receive(:puts).with(default_output_second_line)
|
474
486
|
|
475
487
|
subject
|
476
488
|
end
|
@@ -483,34 +495,34 @@ describe Utils do
|
|
483
495
|
let(:hostname) { '1597952189390' }
|
484
496
|
let(:fqdn) { 'this-noun.delivery.mycompany.net' }
|
485
497
|
let(:fqdn_ns) { 'that-noun.delivery.mycompany.net' }
|
486
|
-
let(:fqdn_hostname) {'this-noun'}
|
487
|
-
let(:fqdn_ns_hostname) {'that-noun'}
|
498
|
+
let(:fqdn_hostname) { 'this-noun' }
|
499
|
+
let(:fqdn_ns_hostname) { 'that-noun' }
|
488
500
|
let(:template) { 'ubuntu-1604-x86_64' }
|
489
501
|
let(:template_ns) { 'solaris-10-sparc' }
|
490
502
|
|
491
503
|
# This seems to be the miminal stub response from ABS for the current output
|
492
504
|
let(:response_body) do
|
493
505
|
{
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
},
|
506
|
+
hostname => {
|
507
|
+
'state' => 'allocated',
|
508
|
+
'allocated_resources' => [
|
509
|
+
{
|
510
|
+
'hostname' => fqdn,
|
511
|
+
'type' => template,
|
512
|
+
'engine' => 'vmpooler'
|
513
|
+
},
|
514
|
+
{
|
515
|
+
'hostname' => fqdn_ns,
|
516
|
+
'type' => template_ns,
|
517
|
+
'engine' => 'nspooler'
|
518
|
+
}
|
519
|
+
],
|
520
|
+
'request' => {
|
521
|
+
'job' => {
|
522
|
+
'id' => hostname
|
523
|
+
}
|
513
524
|
}
|
525
|
+
}
|
514
526
|
}
|
515
527
|
end
|
516
528
|
|
@@ -518,29 +530,29 @@ describe Utils do
|
|
518
530
|
let(:domain) { 'delivery.mycompany.net' }
|
519
531
|
let(:response_body_vmpooler) do
|
520
532
|
{
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
+
fqdn_hostname => {
|
534
|
+
'template' => template,
|
535
|
+
'lifetime' => 48,
|
536
|
+
'running' => 7.67,
|
537
|
+
'state' => 'running',
|
538
|
+
'tags' => {
|
539
|
+
'user' => 'bob',
|
540
|
+
'role' => 'agent'
|
541
|
+
},
|
542
|
+
'ip' => '127.0.0.1',
|
543
|
+
'domain' => domain
|
544
|
+
}
|
533
545
|
}
|
534
546
|
end
|
535
547
|
|
536
548
|
before(:each) do
|
537
549
|
allow(Utils).to receive(:get_vmpooler_service_config).and_return({
|
538
|
-
|
539
|
-
|
550
|
+
'url' => 'http://vmpooler.example.com',
|
551
|
+
'token' => 'krypto-knight'
|
540
552
|
})
|
541
553
|
allow(service).to receive(:query)
|
542
|
-
|
543
|
-
|
554
|
+
.with(anything, fqdn_hostname)
|
555
|
+
.and_return(response_body_vmpooler)
|
544
556
|
end
|
545
557
|
|
546
558
|
let(:default_output_first_line) { "- [JobID:#{hostname}] <allocated>" }
|
@@ -548,9 +560,9 @@ describe Utils do
|
|
548
560
|
let(:default_output_third_line) { " - #{fqdn_ns} (#{template_ns})" }
|
549
561
|
|
550
562
|
it 'prints output with job id, host, and template' do
|
551
|
-
expect(
|
552
|
-
expect(
|
553
|
-
expect(
|
563
|
+
expect($stdout).to receive(:puts).with(default_output_first_line)
|
564
|
+
expect($stdout).to receive(:puts).with(default_output_second_line)
|
565
|
+
expect($stdout).to receive(:puts).with(default_output_third_line)
|
554
566
|
|
555
567
|
subject
|
556
568
|
end
|
@@ -559,9 +571,9 @@ describe Utils do
|
|
559
571
|
let(:print_to_stderr) { true }
|
560
572
|
|
561
573
|
it 'outputs to stderr instead of stdout' do
|
562
|
-
expect(
|
563
|
-
expect(
|
564
|
-
expect(
|
574
|
+
expect($stderr).to receive(:puts).with(default_output_first_line)
|
575
|
+
expect($stderr).to receive(:puts).with(default_output_second_line)
|
576
|
+
expect($stderr).to receive(:puts).with(default_output_third_line)
|
565
577
|
|
566
578
|
subject
|
567
579
|
end
|
@@ -575,54 +587,59 @@ describe Utils do
|
|
575
587
|
config = {
|
576
588
|
'user' => 'foo',
|
577
589
|
'services' => {
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
590
|
+
'myabs' => {
|
591
|
+
'url' => 'http://abs.com',
|
592
|
+
'token' => 'krypto-night',
|
593
|
+
'type' => 'abs'
|
594
|
+
}
|
583
595
|
}
|
584
596
|
}
|
585
597
|
allow(Conf).to receive(:read_config).and_return(config)
|
586
|
-
expect
|
598
|
+
expect do
|
599
|
+
Utils.get_vmpooler_service_config(config['services']['myabs']['vmpooler_fallback'])
|
600
|
+
end.to raise_error(ArgumentError)
|
587
601
|
end
|
588
602
|
it 'returns an error if the vmpooler_fallback is setup but cannot be found' do
|
589
603
|
config = {
|
590
604
|
'user' => 'foo',
|
591
605
|
'services' => {
|
592
606
|
'myabs' => {
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
607
|
+
'url' => 'http://abs.com',
|
608
|
+
'token' => 'krypto-night',
|
609
|
+
'type' => 'abs',
|
610
|
+
'vmpooler_fallback' => 'myvmpooler'
|
597
611
|
}
|
598
612
|
}
|
599
613
|
}
|
600
614
|
allow(Conf).to receive(:read_config).and_return(config)
|
601
|
-
expect
|
615
|
+
expect do
|
616
|
+
Utils.get_vmpooler_service_config(config['services']['myabs']['vmpooler_fallback'])
|
617
|
+
end.to raise_error(ArgumentError,
|
618
|
+
/myvmpooler/)
|
602
619
|
end
|
603
620
|
it 'returns the vmpooler_fallback config' do
|
604
621
|
config = {
|
605
622
|
'user' => 'foo',
|
606
623
|
'services' => {
|
607
624
|
'myabs' => {
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
625
|
+
'url' => 'http://abs.com',
|
626
|
+
'token' => 'krypto-night',
|
627
|
+
'type' => 'abs',
|
628
|
+
'vmpooler_fallback' => 'myvmpooler'
|
612
629
|
},
|
613
630
|
'myvmpooler' => {
|
614
|
-
|
615
|
-
|
631
|
+
'url' => 'http://vmpooler.com',
|
632
|
+
'token' => 'krypto-knight'
|
616
633
|
}
|
617
634
|
}
|
618
635
|
}
|
619
636
|
allow(Conf).to receive(:read_config).and_return(config)
|
620
637
|
expect(Utils.get_vmpooler_service_config(config['services']['myabs']['vmpooler_fallback'])).to include({
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
638
|
+
'url' => 'http://vmpooler.com',
|
639
|
+
'token' => 'krypto-knight',
|
640
|
+
'user' => 'foo',
|
641
|
+
'type' => 'vmpooler'
|
642
|
+
})
|
626
643
|
end
|
627
644
|
end
|
628
645
|
end
|