|
4 | 4 | require 'vmfloaty/ssh'
|
5 | 5 |
|
6 | 6 | class ServiceStub
|
7 |
| - def retrieve(_verbose, os_types, _use_token) |
| 7 | + def retrieve(_verbose, os_types, _use_token, ondemand) |
8 | 8 | if os_types.keys[0] == 'abs_host_string'
|
9 | 9 | return {
|
10 | 10 | os_types.keys[0] => { 'hostname' => ['abs-hostname.delivery.puppetlabs.net'] },
|
11 | 11 | 'ok' => true
|
12 | 12 | }
|
13 |
| - end |
14 | 13 |
|
15 |
| - { |
16 |
| - os_types.keys[0] => { 'hostname' => 'vmpooler-hostname' }, |
17 |
| - 'domain' => 'delivery.puppetlabs.net', |
18 |
| - 'ok' => true |
19 |
| - } |
| 14 | + elsif os_types.keys[0] == 'vmpooler_api_v2_host_string' |
| 15 | + return { |
| 16 | + os_types.keys[0] => { 'hostname' => ['vmpooler-v2-hostname.delivery.puppetlabs.net'] }, |
| 17 | + 'ok' => true |
| 18 | + } |
| 19 | + |
| 20 | + else |
| 21 | + return { |
| 22 | + os_types.keys[0] => { 'hostname' => 'vmpooler-v1-hostname' }, |
| 23 | + 'domain' => 'delivery.puppetlabs.net', |
| 24 | + 'ok' => true |
| 25 | + } |
| 26 | + end |
20 | 27 | end
|
21 | 28 |
|
22 | 29 | def type
|
23 | 30 | return 'abs' if os_types == 'abs_host_string'
|
24 |
| - return 'vmpooler' if os_types == 'vmpooler_host_string' |
| 31 | + return 'vmpooler' if os_types == 'vmpooler_api_v1_host_string' || os_types == 'vmpooler_api_v2_host_string' |
| 32 | + end |
| 33 | + |
| 34 | + def wait_for_request(verbose, requestid) |
| 35 | + return true |
25 | 36 | end
|
26 | 37 | end
|
27 | 38 |
|
28 | 39 | describe Ssh do
|
29 | 40 | before :each do
|
30 | 41 | end
|
31 | 42 |
|
32 |
| - it 'gets a hostname string for abs' do |
33 |
| - verbose = false |
34 |
| - service = ServiceStub.new |
35 |
| - host_os = 'abs_host_string' |
36 |
| - use_token = false |
37 |
| - cmd = Ssh.command_string(verbose, service, host_os, use_token) |
38 |
| - expect(cmd).to match(/ssh [email protected]/) |
| 43 | + context "for pooled requests" do |
| 44 | + it 'gets a hostname string for abs' do |
| 45 | + verbose = false |
| 46 | + service = ServiceStub.new |
| 47 | + host_os = 'abs_host_string' |
| 48 | + use_token = false |
| 49 | + cmd = Ssh.command_string(verbose, service, host_os, use_token) |
| 50 | + expect(cmd).to match(/ssh [email protected]/) |
| 51 | + end |
| 52 | + |
| 53 | + it 'gets a hostname string for vmpooler api v1' do |
| 54 | + verbose = true |
| 55 | + service = ServiceStub.new |
| 56 | + host_os = 'vmpooler_api_v1_host_string' |
| 57 | + use_token = false |
| 58 | + cmd = Ssh.command_string(verbose, service, host_os, use_token) |
| 59 | + expect(cmd).to match(/ssh [email protected]/) |
| 60 | + end |
| 61 | + |
| 62 | + it 'gets a hostname string for vmpooler api v2' do |
| 63 | + verbose = false |
| 64 | + service = ServiceStub.new |
| 65 | + host_os = 'vmpooler_api_v2_host_string' |
| 66 | + use_token = false |
| 67 | + cmd = Ssh.command_string(verbose, service, host_os, use_token) |
| 68 | + expect(cmd).to match(/ssh [email protected]/) |
| 69 | + end |
39 | 70 | end
|
40 | 71 |
|
41 |
| - it 'gets a hostname string for vmpooler' do |
42 |
| - verbose = false |
43 |
| - service = ServiceStub.new |
44 |
| - host_os = 'vmpooler_host_string' |
45 |
| - use_token = false |
46 |
| - cmd = Ssh.command_string(verbose, service, host_os, use_token) |
47 |
| - expect(cmd).to match(/ssh [email protected]/) |
| 72 | + context "for ondemend requests" do |
| 73 | + let(:service) { ServiceStub.new } |
| 74 | + let(:url) { 'http://pooler.example.com' } |
| 75 | + |
| 76 | + it 'gets a hostname string for abs' do |
| 77 | + verbose = false |
| 78 | + host_os = 'abs_host_string' |
| 79 | + use_token = false |
| 80 | + ondemand = true |
| 81 | + response = {'abs_host_string' => { 'hostname' => ['abs-hostname.delivery.puppetlabs.net']}} |
| 82 | + allow(service).to receive(:url) |
| 83 | + allow(service).to receive(:check_ondemandvm).and_return(response) |
| 84 | + cmd = Ssh.command_string(verbose, service, host_os, use_token, ondemand) |
| 85 | + expect(cmd).to match(/ssh [email protected]/) |
| 86 | + end |
| 87 | + |
| 88 | + it 'gets a hostname string for abs' do |
| 89 | + verbose = false |
| 90 | + host_os = 'vmpooler_api_v1_host_string' |
| 91 | + use_token = false |
| 92 | + ondemand = true |
| 93 | + response = {'vmpooler_api_v1_host_string' => { 'hostname' => ['vmpooler_api_v1_host_string.delivery.puppetlabs.net']}} |
| 94 | + allow(service).to receive(:url) |
| 95 | + allow(service).to receive(:check_ondemandvm).and_return(response) |
| 96 | + cmd = Ssh.command_string(verbose, service, host_os, use_token, ondemand) |
| 97 | + expect(cmd).to match(/ssh root@vmpooler_api_v1_host_string.delivery.puppetlabs.net/) |
| 98 | + end |
| 99 | + |
| 100 | + it 'gets a hostname string for abs' do |
| 101 | + verbose = false |
| 102 | + host_os = 'vmpooler_api_v2_host_string' |
| 103 | + use_token = false |
| 104 | + ondemand = true |
| 105 | + response = {'vmpooler_api_v2_host_string' => { 'hostname' => ['vmpooler_api_v2_host_string.delivery.puppetlabs.net']}} |
| 106 | + allow(service).to receive(:url) |
| 107 | + allow(service).to receive(:check_ondemandvm).and_return(response) |
| 108 | + cmd = Ssh.command_string(verbose, service, host_os, use_token, ondemand) |
| 109 | + expect(cmd).to match(/ssh root@vmpooler_api_v2_host_string.delivery.puppetlabs.net/) |
| 110 | + end |
48 | 111 | end
|
49 | 112 | end
|
0 commit comments