Sha256: 7c7a4dea20af285a8e342be8c8ec80c34b7ef79565f5b22f637cd88cc14ccf23

Contents?: true

Size: 1.99 KB

Versions: 3

Compression:

Stored size: 1.99 KB

Contents

require "#{File.dirname(__FILE__)}/../spec_helper"

describe "VM Life cycle" do

  before(:all) do
   user="admin@internal"
    password="123123"
    hostname = "ovirt.sat.lab.tlv.redhat.com"
    port = "8080"
    url = "http://#{hostname}:#{port}/api"
    @blank_template_id = "00000000-0000-0000-0000-000000000000"
    @client = ::OVIRT::Client.new(user, password, url)
  end

  context 'basic vm and templates operations' do

    before(:all) do
      name = 'vm-'+Time.now.to_i.to_s
      params = {}
      params[:name] = name
      params[:cluster_name] = "test"
      @vm = @client.create_vm(params)
      @client.add_volume(@vm.id)
      @client.add_interface(@vm.id)
      while @client.vm(@vm.id).status !~ /down/i do
      end
    end

    after(:all) do
      @client.destroy_vm(@vm.id)
    end

    it "test_should_create_template" do
      template_name = "test_template"
      template = @client.create_template(:vm => @vm.id, :name => template_name, :description => "test_template")
      template.class.to_s.should eql("OVIRT::Template")
      while @client.vm(@vm.id).status !~ /down/i do
      end
      @client.destroy_template(template.id)
    end

    it "test_should_return_a_template" do
      @client.template(@blank_template_id).id.should eql(@blank_template_id)
    end

    it "test_should_return_a_vm" do
      @client.vm(@vm.id).id.should eql(@vm.id)
    end

    it "test_should_start_and_stop_vm" do
      @client.vm_action(@vm.id, :start)
      @client.vm_action(@vm.id, :shutdown)
    end

    it "test_should_destroy_vm" do
      name = 'd-'+Time.now.to_i.to_s
      params = {}
      params[:name] = name
      params[:cluster_name] = "test"
      vm = @client.create_vm(params)
      @client.destroy_vm(vm.id)
    end

    it "test_should_create_a_vm" do
      name = 'c-'+Time.now.to_i.to_s
      params = {}
      params[:name] = name
      params[:cluster_name] = "test"
      vm = @client.create_vm(params)
      vm.class.to_s.should eql("OVIRT::VM")
      @client.destroy_vm(vm.id)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rbovirt-0.0.6 spec/integration/vm_crud_spec.rb
rbovirt-0.0.5 spec/integration/vm_crud_spec.rb
rbovirt-0.0.4 spec/integration/vm_crud_spec.rb