mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
tabling this PR for the next sprint
This commit is contained in:
parent
e5c477254f
commit
66eb598e4e
4 changed files with 76 additions and 20 deletions
|
|
@ -368,7 +368,15 @@ module Vmpooler
|
|||
else
|
||||
fqdn = hostname
|
||||
end
|
||||
dns_ip, dns_available = check_dns_available(fqdn)
|
||||
|
||||
# skip dns check if the provider is set to skip_dns_check_before_creating_vm
|
||||
provider = get_provider_for_pool(pool_name)
|
||||
if config[:providers] && config[:providers][provider.name.to_sym] && config[:providers][provider.name.to_sym]['skip_dns_check_before_creating_vm']
|
||||
dns_available = true
|
||||
else
|
||||
dns_ip, dns_available = check_dns_available(fqdn)
|
||||
end
|
||||
|
||||
break if hostname_available && dns_available
|
||||
|
||||
hostname_retries += 1
|
||||
|
|
|
|||
|
|
@ -125,7 +125,6 @@ describe Vmpooler::API::V2 do
|
|||
expected = {
|
||||
"ok": true,
|
||||
"request_id": uuid,
|
||||
"domain": domain
|
||||
}
|
||||
expect(last_response.body).to eq(JSON.pretty_generate(expected))
|
||||
end
|
||||
|
|
|
|||
|
|
@ -24,10 +24,15 @@ describe Vmpooler::API::V2 do
|
|||
'site_name' => 'test pooler',
|
||||
'vm_lifetime_auth' => 2
|
||||
},
|
||||
providers: {
|
||||
vsphere: {'domain' => 'one.example.com'},
|
||||
gce: {'domain' => 'two.example.com'},
|
||||
foo: {'domain' => 'three.example.com'}
|
||||
},
|
||||
pools: [
|
||||
{'name' => 'pool1', 'size' => 5, 'domain' => 'one.example.com'},
|
||||
{'name' => 'pool2', 'size' => 10, 'domain' => 'two.example.com'},
|
||||
{'name' => 'pool3', 'size' => 10, 'domain' => 'three.example.com'}
|
||||
{'name' => 'pool1', 'size' => 5, 'provider' => 'vsphere'},
|
||||
{'name' => 'pool2', 'size' => 10, 'provider' => 'gce'},
|
||||
{'name' => 'pool3', 'size' => 10, 'provider' => 'foo'}
|
||||
],
|
||||
statsd: { 'prefix' => 'stats_prefix'},
|
||||
alias: { 'poolone' => ['pool1'] },
|
||||
|
|
@ -80,8 +85,7 @@ describe Vmpooler::API::V2 do
|
|||
ok: true,
|
||||
pool1: {
|
||||
hostname: "#{vmname}.one.example.com"
|
||||
},
|
||||
domain: 'one.example.com'
|
||||
}
|
||||
}
|
||||
|
||||
expect(last_response.body).to eq(JSON.pretty_generate(expected))
|
||||
|
|
@ -99,8 +103,7 @@ describe Vmpooler::API::V2 do
|
|||
ok: true,
|
||||
poolone: {
|
||||
hostname: "#{vmname}.one.example.com"
|
||||
},
|
||||
domain: 'one.example.com'
|
||||
}
|
||||
}
|
||||
|
||||
expect(last_response.body).to eq(JSON.pretty_generate(expected))
|
||||
|
|
@ -150,7 +153,6 @@ describe Vmpooler::API::V2 do
|
|||
pool1: {
|
||||
hostname: "#{vmname}.one.example.com"
|
||||
},
|
||||
domain: 'two.example.com',
|
||||
pool2: {
|
||||
hostname: 'qrstuvwxyz012345.two.example.com'
|
||||
}
|
||||
|
|
@ -253,8 +255,7 @@ describe Vmpooler::API::V2 do
|
|||
ok: true,
|
||||
"pool1": {
|
||||
"hostname": "1abcdefghijklmnop.one.example.com"
|
||||
},
|
||||
domain: 'one.example.com'
|
||||
}
|
||||
}
|
||||
|
||||
expect(last_response.body).to eq(JSON.pretty_generate(expected))
|
||||
|
|
@ -355,8 +356,7 @@ describe Vmpooler::API::V2 do
|
|||
ok: true,
|
||||
pool1: {
|
||||
hostname: "2#{vmname}.one.example.com"
|
||||
},
|
||||
domain: 'one.example.com'
|
||||
}
|
||||
}
|
||||
|
||||
expect(last_response.body).to eq(JSON.pretty_generate(expected))
|
||||
|
|
@ -381,8 +381,7 @@ describe Vmpooler::API::V2 do
|
|||
ok: true,
|
||||
pool1: {
|
||||
hostname: 'abcdefghijklmnop.one.example.com'
|
||||
},
|
||||
domain: 'one.example.com'
|
||||
}
|
||||
}
|
||||
expect(last_response.body).to eq(JSON.pretty_generate(expected))
|
||||
|
||||
|
|
@ -408,8 +407,7 @@ describe Vmpooler::API::V2 do
|
|||
ok: true,
|
||||
pool1: {
|
||||
hostname: 'abcdefghijklmnop.one.example.com'
|
||||
},
|
||||
domain: 'one.example.com'
|
||||
}
|
||||
}
|
||||
expect(last_response.body).to eq(JSON.pretty_generate(expected))
|
||||
|
||||
|
|
@ -430,8 +428,7 @@ describe Vmpooler::API::V2 do
|
|||
ok: true,
|
||||
pool1: {
|
||||
hostname: 'abcdefghijklmnop.one.example.com'
|
||||
},
|
||||
domain: 'one.example.com'
|
||||
}
|
||||
}
|
||||
expect(last_response.body).to eq(JSON.pretty_generate(expected))
|
||||
|
||||
|
|
|
|||
|
|
@ -869,6 +869,58 @@ EOT
|
|||
end
|
||||
end
|
||||
|
||||
describe '#find_unique_hostname' do
|
||||
# it should return the hostname
|
||||
before do
|
||||
allow(subject).to receive(:generate_and_check_hostname).and_return(["spicy-proton", true])
|
||||
allow(subject).to receive(:get_provider_for_pool).and_return(provider)
|
||||
end
|
||||
|
||||
context 'with a setting to skip dns check' do
|
||||
let(:config) {
|
||||
YAML.load(<<-EOT
|
||||
---
|
||||
:providers:
|
||||
:mock_provider:
|
||||
skip_dns_check_before_creating_vm: true
|
||||
:pools:
|
||||
- name: '#{pool}'
|
||||
size: 1
|
||||
EOT
|
||||
)
|
||||
}
|
||||
it 'should skip the dns check' do
|
||||
#method is skipped
|
||||
expect(subject).not_to receive(:check_dns_available)
|
||||
expect(subject.find_unique_hostname(pool)).to eq("spicy-proton")
|
||||
end
|
||||
end
|
||||
context 'without the setting to skip dns check' do
|
||||
let(:config) {
|
||||
YAML.load(<<-EOT
|
||||
---
|
||||
:providers:
|
||||
:mock_provider:
|
||||
:pools:
|
||||
- name: '#{pool}'
|
||||
size: 1
|
||||
EOT
|
||||
)
|
||||
}
|
||||
it 'should run the dns check and pass' do
|
||||
#method is skipped
|
||||
expect(subject).to receive(:check_dns_available).and_return(["1.1.1.1",true])
|
||||
expect(subject.find_unique_hostname(pool)).to eq("spicy-proton")
|
||||
end
|
||||
|
||||
it 'should run the dns check and fail' do
|
||||
#method is skipped
|
||||
allow(subject).to receive(:check_dns_available).and_return(["1.1.1.1",false]).exactly(3).times
|
||||
expect{subject.find_unique_hostname(pool)}.to raise_error(RuntimeError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#_clone_vm' do
|
||||
let (:pool_object) { { 'name' => pool } }
|
||||
let (:redis_ttl) { 1 }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue