(BKR-1181) Separate Vcloud into its own library

This commit is contained in:
Rishi Javia 2017-08-04 11:35:17 -07:00 committed by Kevin Imber
parent cba871a5af
commit f7273ae4f2
4 changed files with 1 additions and 320 deletions

View file

@ -1,79 +0,0 @@
require 'spec_helper'
module Beaker
describe Vcloud do
before :each do
MockVsphereHelper.set_config( fog_file_contents )
MockVsphereHelper.set_vms( make_hosts() )
stub_const( "VsphereHelper", MockVsphereHelper )
stub_const( "Net", MockNet )
json = double( 'json' )
allow( json ).to receive( :parse ) do |arg|
arg
end
stub_const( "JSON", json )
allow( Socket ).to receive( :getaddrinfo ).and_return( true )
end
describe "#provision" do
it 'instantiates vmpooler if pooling api is provided' do
opts = make_opts
opts[:pooling_api] = 'testpool'
hypervisor = Beaker::Vcloud.new( make_hosts, opts)
expect( hypervisor.class ).to be Beaker::Vmpooler
end
it 'provisions hosts and add them to the pool' do
MockVsphereHelper.powerOff
opts = make_opts
opts[:pooling_api] = nil
opts[:datacenter] = 'testdc'
vcloud = Beaker::Vcloud.new( make_hosts, opts )
allow( vcloud ).to receive( :require ).and_return( true )
allow( vcloud ).to receive( :sleep ).and_return( true )
vcloud.provision
hosts = vcloud.instance_variable_get( :@hosts )
hosts.each do | host |
name = host['vmhostname']
vm = MockVsphereHelper.find_vm( name )
expect( vm.toolsRunningStatus ).to be === "guestToolsRunning"
end
end
end
describe "#cleanup" do
it "cleans up hosts not in the pool" do
MockVsphereHelper.powerOn
opts = make_opts
opts[:pooling_api] = nil
opts[:datacenter] = 'testdc'
vcloud = Beaker::Vcloud.new( make_hosts, opts )
allow( vcloud ).to receive( :require ).and_return( true )
allow( vcloud ).to receive( :sleep ).and_return( true )
vcloud.provision
vcloud.cleanup
hosts = vcloud.instance_variable_get( :@hosts )
vm_names = hosts.map {|h| h['vmhostname'] }.compact
vm_names.each do | name |
vm = MockVsphereHelper.find_vm( name )
expect( vm.runtime.powerState ).to be === "poweredOff"
end
end
end
end
end

View file

@ -2,7 +2,6 @@ require 'simplecov'
require 'rspec/its'
require 'beaker'
require 'beaker/hypervisor/vmpooler'
require 'beaker/hypervisor/vcloud'
# setup & require beaker's spec_helper.rb
beaker_gem_spec = Gem::Specification.find_by_name('beaker')
@ -14,4 +13,4 @@ require File.join(beaker_spec_path, 'spec_helper.rb')
RSpec.configure do |config|
config.include TestFileHelpers
config.include HostHelpers
end
end