From f8f2338d886a39502fc19a71ac288690e1b03ff8 Mon Sep 17 00:00:00 2001 From: Umer Khan Date: Tue, 7 Jun 2016 10:34:56 -0700 Subject: [PATCH] int-test: remove unnecessary wait and add more logging info. - Since chairman is gone and host document is updated with AZ, we don't need sleep/wait. - Adding logging in case of vm creation failure. Change-Id: I73963f7ab24791a4f5f0e84406ade128d57ed190 --- .../availability_zone_spec.rb | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/ruby/integration_tests/spec/availabilityzone/availability_zone_spec.rb b/ruby/integration_tests/spec/availabilityzone/availability_zone_spec.rb index c7aa15fc87..81e52e23ef 100644 --- a/ruby/integration_tests/spec/availabilityzone/availability_zone_spec.rb +++ b/ruby/integration_tests/spec/availabilityzone/availability_zone_spec.rb @@ -38,20 +38,22 @@ expect(host).to_not be_nil expect(host.address).to_not be_nil - # To be on safe side, wait few sec and let agent register with chairman for updated availability zone - sleep_time = 5 - sleep(sleep_time) + # create VMs in specific availability zone + for i in 1..3 + vm_name = random_name("vm-#{i}-") + begin + vm = create_vm(@seeder.project!, name: vm_name, affinities: [{id: availability_zone.id, kind: "availabilityZone"}]) + rescue EsxCloud::Error => e + host_service = EsxCloud::Dcp::CloudStore::HostFactory.get_host host.id + fail "Create VM failed. Host: #{host.id} HostState: #{host_service["agentState"]} Error: #{e}" + end - # create VMs in specific availability zone - for i in 1..3 - vm_name = random_name("vm-#{i}-") - vm = create_vm(@seeder.project!, name: vm_name, affinities: [{id: availability_zone.id, kind: "availabilityZone"}]) - expect(vm).to_not be_nil - expect(vm.name).to eq(vm_name) - expect(vm.host).to eq(host.address) + expect(vm).to_not be_nil + expect(vm.name).to eq(vm_name) + expect(vm.host).to eq(host.address) - vm.delete - end + vm.delete + end end it "set host's availability zone again should fail" do