mirror of
https://github.com/puppetlabs/vmpooler-provider-gce.git
synced 2026-01-25 19:18:40 -05:00
Update spec tests for new dns settings
This commit is contained in:
parent
38064771aa
commit
1aaa6711b5
3 changed files with 17 additions and 23 deletions
|
|
@ -1,9 +0,0 @@
|
||||||
MockDNS = Struct.new(
|
|
||||||
# https://rubydoc.info/gems/google-cloud-dns/0.35.1/Google/Cloud/Dns
|
|
||||||
:change, :credentials, :project, :record, :zone,
|
|
||||||
keyword_init: true
|
|
||||||
) do
|
|
||||||
def zone(zone)
|
|
||||||
self.zone = zone
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
@ -10,7 +10,6 @@ require 'vmpooler'
|
||||||
require 'redis'
|
require 'redis'
|
||||||
require 'vmpooler/metrics'
|
require 'vmpooler/metrics'
|
||||||
require 'computeservice_helper'
|
require 'computeservice_helper'
|
||||||
require 'dnsservice_helper'
|
|
||||||
|
|
||||||
def project_root_dir
|
def project_root_dir
|
||||||
File.dirname(File.dirname(__FILE__))
|
File.dirname(File.dirname(__FILE__))
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,11 @@ describe 'Vmpooler::PoolManager::Provider::Gce' do
|
||||||
:config:
|
:config:
|
||||||
max_tries: 3
|
max_tries: 3
|
||||||
retry_factor: 10
|
retry_factor: 10
|
||||||
|
:dns_configs:
|
||||||
|
:gcp-clouddns:
|
||||||
|
project: vmpooler-test
|
||||||
|
domain: vmpooler.example.com
|
||||||
|
dns_zone_resource_name: vmpooler-example-com
|
||||||
:providers:
|
:providers:
|
||||||
:gce:
|
:gce:
|
||||||
connection_pool_timeout: 1
|
connection_pool_timeout: 1
|
||||||
|
|
@ -32,6 +37,7 @@ describe 'Vmpooler::PoolManager::Provider::Gce' do
|
||||||
timeout: 10
|
timeout: 10
|
||||||
ready_ttl: 1440
|
ready_ttl: 1440
|
||||||
provider: 'gce'
|
provider: 'gce'
|
||||||
|
dns_config: 'gcp-clouddns'
|
||||||
machine_type: 'zones/#{zone}/machineTypes/e2-micro'
|
machine_type: 'zones/#{zone}/machineTypes/e2-micro'
|
||||||
EOT
|
EOT
|
||||||
)
|
)
|
||||||
|
|
@ -51,8 +57,6 @@ EOT
|
||||||
|
|
||||||
subject { Vmpooler::PoolManager::Provider::Gce.new(config, logger, metrics, redis_connection_pool, 'gce', provider_options) }
|
subject { Vmpooler::PoolManager::Provider::Gce.new(config, logger, metrics, redis_connection_pool, 'gce', provider_options) }
|
||||||
|
|
||||||
before(:each) { allow(subject).to receive(:dns).and_return(MockDNS.new()) }
|
|
||||||
|
|
||||||
describe '#name' do
|
describe '#name' do
|
||||||
it 'should be gce' do
|
it 'should be gce' do
|
||||||
expect(subject.name).to eq('gce')
|
expect(subject.name).to eq('gce')
|
||||||
|
|
@ -61,7 +65,6 @@ EOT
|
||||||
|
|
||||||
describe '#manual tests live' do
|
describe '#manual tests live' do
|
||||||
context 'in itsysops' do
|
context 'in itsysops' do
|
||||||
before(:each) { allow(subject).to receive(:dns).and_call_original }
|
|
||||||
let(:vmname) { "instance-31" }
|
let(:vmname) { "instance-31" }
|
||||||
let(:project) { 'vmpooler-test' }
|
let(:project) { 'vmpooler-test' }
|
||||||
let(:config) { YAML.load(<<~EOT
|
let(:config) { YAML.load(<<~EOT
|
||||||
|
|
@ -69,14 +72,17 @@ EOT
|
||||||
:config:
|
:config:
|
||||||
max_tries: 3
|
max_tries: 3
|
||||||
retry_factor: 10
|
retry_factor: 10
|
||||||
|
:dns_configs:
|
||||||
|
:gcp-clouddns:
|
||||||
|
project: vmpooler-test
|
||||||
|
domain: vmpooler.example.com
|
||||||
|
dns_zone_resource_name: vmpooler-example-com
|
||||||
:providers:
|
:providers:
|
||||||
:gce:
|
:gce:
|
||||||
connection_pool_timeout: 1
|
connection_pool_timeout: 1
|
||||||
project: '#{project}'
|
project: '#{project}'
|
||||||
zone: '#{zone}'
|
zone: '#{zone}'
|
||||||
network_name: 'projects/itsysopsnetworking/global/networks/shared1'
|
network_name: 'projects/itsysopsnetworking/global/networks/shared1'
|
||||||
dns_zone_resource_name: 'vmpooler-test-puppet-net'
|
|
||||||
domain: 'vmpooler-test.puppet.net'
|
|
||||||
:pools:
|
:pools:
|
||||||
- name: '#{poolname}'
|
- name: '#{poolname}'
|
||||||
alias: [ 'mockpool' ]
|
alias: [ 'mockpool' ]
|
||||||
|
|
@ -85,6 +91,7 @@ EOT
|
||||||
timeout: 10
|
timeout: 10
|
||||||
ready_ttl: 1440
|
ready_ttl: 1440
|
||||||
provider: 'gce'
|
provider: 'gce'
|
||||||
|
dns_config: 'gcp-clouddns'
|
||||||
subnetwork_name: 'projects/itsysopsnetworking/regions/us-west1/subnetworks/vmpooler-test'
|
subnetwork_name: 'projects/itsysopsnetworking/regions/us-west1/subnetworks/vmpooler-test'
|
||||||
machine_type: 'zones/#{zone}/machineTypes/e2-micro'
|
machine_type: 'zones/#{zone}/machineTypes/e2-micro'
|
||||||
disk_type: 'pd-ssd'
|
disk_type: 'pd-ssd'
|
||||||
|
|
@ -92,10 +99,6 @@ EOT
|
||||||
) }
|
) }
|
||||||
skip 'gets a vm' do
|
skip 'gets a vm' do
|
||||||
result = subject.create_vm(poolname, vmname)
|
result = subject.create_vm(poolname, vmname)
|
||||||
#result = subject.destroy_vm(poolname, vmname)
|
|
||||||
# subject.get_vm(poolname, vmname)
|
|
||||||
subject.dns_teardown({'name' => vmname})
|
|
||||||
# subject.dns_setup({'name' => vmname, 'ip' => '1.2.3.5'})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -267,7 +270,6 @@ EOT
|
||||||
result = MockResult.new
|
result = MockResult.new
|
||||||
result.status = 'DONE'
|
result.status = 'DONE'
|
||||||
allow(connection).to receive(:insert_instance).and_return(result)
|
allow(connection).to receive(:insert_instance).and_return(result)
|
||||||
allow(subject).to receive(:dns_setup).and_return(true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return a hash' do
|
it 'should return a hash' do
|
||||||
|
|
@ -314,7 +316,6 @@ EOT
|
||||||
result.status = 'DONE'
|
result.status = 'DONE'
|
||||||
allow(subject).to receive(:wait_for_operation).and_return(result)
|
allow(subject).to receive(:wait_for_operation).and_return(result)
|
||||||
allow(connection).to receive(:delete_instance).and_return(result)
|
allow(connection).to receive(:delete_instance).and_return(result)
|
||||||
allow(subject).to receive(:dns_teardown).and_return(true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return true' do
|
it 'should return true' do
|
||||||
|
|
@ -349,7 +350,11 @@ EOT
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#vm_ready?' do
|
describe '#vm_ready?' do
|
||||||
let(:domain) { nil }
|
let(:domain) { 'vmpooler.example.com' }
|
||||||
|
before(:each) do
|
||||||
|
allow(subject).to receive(:domain).and_return('vmpooler.example.com')
|
||||||
|
end
|
||||||
|
|
||||||
context 'When a VM is ready' do
|
context 'When a VM is ready' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
expect(subject).to receive(:open_socket).with(vmname, domain)
|
expect(subject).to receive(:open_socket).with(vmname, domain)
|
||||||
|
|
@ -586,7 +591,6 @@ EOT
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
allow(subject).to receive(:connect_to_gce).and_return(connection)
|
allow(subject).to receive(:connect_to_gce).and_return(connection)
|
||||||
allow(subject).to receive(:dns_teardown).and_return(true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with empty allowlist' do
|
context 'with empty allowlist' do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue