Sha256: b431d45b55c4bd80d34f67ffe3bcaf34ffee6a32316e47af3d443feb83b207e9

Contents?: true

Size: 1.82 KB

Versions: 82

Compression:

Stored size: 1.82 KB

Contents

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 'provisions hosts and add them to the pool' do
        MockVsphereHelper.powerOff

        opts = make_opts
        opts[:pooling_api] = nil

        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

        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

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
beaker-2.16.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.15.1 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.15.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.14.1 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.14.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.13.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.12.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.11.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.10.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.9.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.8.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.7.1 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.7.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.6.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.5.1 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.5.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.4.1 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.4.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.3.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-2.2.0 spec/beaker/hypervisor/vcloud_spec.rb