Sha256: b3e66a2c576d84d0ae6694724df1257f90307c4db4f00897465615c5cf1541f2

Contents?: true

Size: 1.47 KB

Versions: 5

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper'

module Beaker
  describe VcloudPooled do

    before :each do
      vms = make_hosts()
      MockVsphereHelper.set_config( fog_file_contents )
      MockVsphereHelper.set_vms( vms )
      stub_const( "VsphereHelper", MockVsphereHelper )
      stub_const( "Net", MockNet )
      JSON.stub( :parse ) do |arg|
        arg
      end
      Socket.stub( :getaddrinfo ).and_return( true )
    end

    describe "#provision" do

      it 'provisions hosts from the pool' do 

        vcloud = Beaker::VcloudPooled.new( make_hosts, make_opts )
        vcloud.stub( :require ).and_return( true )
        vcloud.stub( :sleep ).and_return( true )
        vcloud.provision

        hosts = vcloud.instance_variable_get( :@vcloud_hosts )
        hosts.each do | host |
          expect( host['vmhostname'] ).to be === 'pool'
        end
        
      end

    end

    describe "#cleanup" do

      it "cleans up hosts in the pool" do
        MockVsphereHelper.powerOn

        vcloud = Beaker::VcloudPooled.new( make_hosts, make_opts )
        vcloud.stub( :require ).and_return( true )
        vcloud.stub( :sleep ).and_return( true )
        vcloud.provision
        vcloud.cleanup

        hosts = vcloud.instance_variable_get( :@vcloud_hosts )
        hosts.each do | host |
          name = host.name
          vm = MockVsphereHelper.find_vm( name )
          expect( vm.runtime.powerState ).to be === "poweredOn" #handed back to the pool, stays on
        end
      end


    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
beaker-1.2.0 spec/beaker/hypervisor/vcloud_pooled_spec.rb
beaker-1.1.0 spec/beaker/hypervisor/vcloud_pooled_spec.rb
beaker-1.0.1 spec/beaker/hypervisor/vcloud_pooled_spec.rb
beaker-1.0.1.pre spec/beaker/hypervisor/vcloud_pooled_spec.rb
beaker-1.0.0 spec/beaker/hypervisor/vcloud_pooled_spec.rb