Sha256: 8c9d2620567b8320d41285efb305f2d38783db3ddd7970b88fb1da26446120fa

Contents?: true

Size: 1.86 KB

Versions: 30

Compression:

Stored size: 1.86 KB

Contents

require 'spec_helper'

module Beaker
  describe Vsphere do

    before :each do
      MockVsphereHelper.set_config( fog_file_contents )
      MockVsphereHelper.set_vms( make_hosts() )
      stub_const( "VsphereHelper", MockVsphereHelper )
    end

    describe "#provision" do

      it 'provisions hosts' do 
        MockVsphereHelper.powerOff
        vsphere = Beaker::Vsphere.new( make_hosts(), make_opts )

        vsphere.provision

        hosts =  vsphere.instance_variable_get( :@hosts )
        hosts.each do |host|
          expect( MockVsphereHelper.find_vm( host.name ).powerState ) == "poweredOn"
        end
        
      end

      it 'raises an error if a vm is missing in Vsphere' do
        MockVsphereHelper.powerOff
        hosts = make_hosts()
        hosts[0][:vmname] = 'unknown'
        vsphere = Beaker::Vsphere.new( hosts, make_opts )

        expect{ vsphere.provision }.to raise_error

      end

      it 'raises an error if a vm does not have a given snapshot name' do
        MockVsphereHelper.powerOff
        hosts = make_hosts()
        hosts[0]["snapshot"] = 'unknown'
        vsphere = Beaker::Vsphere.new( hosts, make_opts )

        expect{ vsphere.provision }.to raise_error

      end

    end

    describe "#cleanup" do

      it "cleans up" do
        MockVsphereHelper.powerOn
        vsphere = Beaker::Vsphere.new( make_hosts(), make_opts )
        vsphere.cleanup

        hosts =  vsphere.instance_variable_get( :@hosts )
        hosts.each do |host|
          expect( MockVsphereHelper.find_vm( host.name ).powerState ) == "poweredOff"
        end
      end

      it 'raises an error if a vm is missing in Vsphere' do
        MockVsphereHelper.powerOn
        hosts = make_hosts()
        hosts[0][:vmname] = 'unknown'
        vsphere = Beaker::Vsphere.new( hosts, make_opts )

        expect{ vsphere.cleanup }.to raise_error

      end

    end

  end

end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
beaker-1.21.0 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.20.1 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.20.0 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.19.1 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.19.0 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.18.0 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.17.7 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.17.6 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.17.5 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.17.4 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.17.3 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.17.2 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.17.1 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.17.0 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.16.0 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.15.0 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.14.1 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.14.0 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.13.1 spec/beaker/hypervisor/vsphere_spec.rb
beaker-1.13.0 spec/beaker/hypervisor/vsphere_spec.rb