Sha256: ef9fb536888f2ca81c11aff0a94a20c39f2341b304604e8a7d17873bd8e00447

Contents?: true

Size: 1.75 KB

Versions: 17

Compression:

Stored size: 1.75 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 = mock( 'json' )
      json.stub( :parse ) do |arg| 
        arg
      end
      stub_const( "JSON", json )
      Socket.stub( :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 )
        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 |
          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 )
        vcloud.stub( :require ).and_return( true )
        vcloud.stub( :sleep ).and_return( true )
        vcloud.provision
        vcloud.cleanup

        hosts = vcloud.instance_variable_get( :@vcloud_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

17 entries across 17 versions & 1 rubygems

Version Path
beaker-1.8.1 spec/beaker/hypervisor/vcloud_spec.rb
beaker-1.8.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-1.7.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-1.6.2 spec/beaker/hypervisor/vcloud_spec.rb
beaker-1.6.1 spec/beaker/hypervisor/vcloud_spec.rb
beaker-1.6.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-1.5.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-1.4.1 spec/beaker/hypervisor/vcloud_spec.rb
beaker-1.4.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-1.3.2 spec/beaker/hypervisor/vcloud_spec.rb
beaker-1.3.1 spec/beaker/hypervisor/vcloud_spec.rb
beaker-1.3.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-1.2.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-1.1.0 spec/beaker/hypervisor/vcloud_spec.rb
beaker-1.0.1 spec/beaker/hypervisor/vcloud_spec.rb
beaker-1.0.1.pre spec/beaker/hypervisor/vcloud_spec.rb
beaker-1.0.0 spec/beaker/hypervisor/vcloud_spec.rb