Repository: cloudstack Updated Branches: refs/heads/master b73fe3251 -> 0c77b2007
CLOUDSTACK-7223: Wait for system VM agent state to be up before verification Signed-off-by: Santhosh Edukulla <santhosh.eduku...@gmail.com> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/0c77b200 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/0c77b200 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/0c77b200 Branch: refs/heads/master Commit: 0c77b2007e3918b10a8de560b2f63bd0f0f2cbdd Parents: b73fe32 Author: John Dilley <john.dil...@citrix.com> Authored: Mon Aug 4 14:48:43 2014 +0000 Committer: Santhosh Edukulla <santhosh.eduku...@gmail.com> Committed: Mon Aug 4 20:28:56 2014 +0530 ---------------------------------------------------------------------- test/integration/smoke/test_ssvm.py | 69 +++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c77b200/test/integration/smoke/test_ssvm.py ---------------------------------------------------------------------- diff --git a/test/integration/smoke/test_ssvm.py b/test/integration/smoke/test_ssvm.py index ac4079e..5713569 100644 --- a/test/integration/smoke/test_ssvm.py +++ b/test/integration/smoke/test_ssvm.py @@ -50,6 +50,25 @@ class TestSSVMs(cloudstackTestCase): raise Exception("Warning: Exception during cleanup : %s" % e) return + def waitForSystemVMAgent(self, vmname): + timeout = self.services["timeout"] + + while True: + list_host_response = list_hosts( + self.apiclient, + name=vmname + ) + + if list_host_response and list_host_response[0].state == 'Up': + break + + if timeout == 0: + raise Exception("Timed out waiting for SSVM agent to be Up") + + time.sleep(self.services["sleep"]) + timeout = timeout - 1 + + @attr(tags = ["advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="false") def test_01_list_sec_storage_vm(self): """Test List secondary storage VMs @@ -517,9 +536,6 @@ class TestSSVMs(cloudstackTestCase): cmd.id = ssvm.id self.apiclient.stopSystemVm(cmd) - # Sleep to ensure that VM is in proper state - time.sleep(self.services["sleep"]) - timeout = self.services["timeout"] while True: list_ssvm_response = list_ssvms( @@ -529,7 +545,7 @@ class TestSSVMs(cloudstackTestCase): if isinstance(list_ssvm_response, list): if list_ssvm_response[0].state == 'Running': break - elif timeout == 0: + if timeout == 0: raise Exception("List SSVM call failed!") time.sleep(self.services["sleep"]) @@ -547,6 +563,9 @@ class TestSSVMs(cloudstackTestCase): 'Running', "Check whether SSVM is running or not" ) + # Wait for the agent to be up + self.waitForSystemVMAgent(ssvm_response.name) + # Call above tests to ensure SSVM is properly running self.test_01_list_sec_storage_vm() self.test_03_ssvm_internals() @@ -593,9 +612,6 @@ class TestSSVMs(cloudstackTestCase): cmd.id = cpvm.id self.apiclient.stopSystemVm(cmd) - # Sleep to ensure that VM is in proper state - time.sleep(self.services["sleep"]) - timeout = self.services["timeout"] while True: list_cpvm_response = list_ssvms( @@ -605,7 +621,7 @@ class TestSSVMs(cloudstackTestCase): if isinstance(list_cpvm_response, list): if list_cpvm_response[0].state == 'Running': break - elif timeout == 0: + if timeout == 0: raise Exception("List CPVM call failed!") time.sleep(self.services["sleep"]) @@ -620,6 +636,10 @@ class TestSSVMs(cloudstackTestCase): 'Running', "Check whether CPVM is running or not" ) + + # Wait for the agent to be up + self.waitForSystemVMAgent(cpvm_response.name) + # Call above tests to ensure CPVM is properly running self.test_02_list_cpvm_vm() self.test_04_cpvm_internals() @@ -670,9 +690,6 @@ class TestSSVMs(cloudstackTestCase): cmd.id = ssvm_response.id self.apiclient.rebootSystemVm(cmd) - # Sleep to ensure that VM is in proper state - time.sleep(self.services["sleep"]) - timeout = self.services["timeout"] while True: list_ssvm_response = list_ssvms( @@ -682,7 +699,7 @@ class TestSSVMs(cloudstackTestCase): if isinstance(list_ssvm_response, list): if list_ssvm_response[0].state == 'Running': break - elif timeout == 0: + if timeout == 0: raise Exception("List SSVM call failed!") time.sleep(self.services["sleep"]) @@ -707,6 +724,10 @@ class TestSSVMs(cloudstackTestCase): old_private_ip, "Check Private IP after reboot with that of before reboot" ) + + # Wait for the agent to be up + self.waitForSystemVMAgent(ssvm_response.name) + #Call to verify cloud process is running self.test_03_ssvm_internals() return @@ -756,9 +777,6 @@ class TestSSVMs(cloudstackTestCase): cmd.id = cpvm_response.id self.apiclient.rebootSystemVm(cmd) - # Sleep to ensure that VM is in proper state - time.sleep(self.services["sleep"]) - timeout = self.services["timeout"] while True: list_cpvm_response = list_ssvms( @@ -768,7 +786,7 @@ class TestSSVMs(cloudstackTestCase): if isinstance(list_cpvm_response, list): if list_cpvm_response[0].state == 'Running': break - elif timeout == 0: + if timeout == 0: raise Exception("List CPVM call failed!") time.sleep(self.services["sleep"]) @@ -794,6 +812,9 @@ class TestSSVMs(cloudstackTestCase): old_private_ip, "Check Private IP after reboot with that of before reboot" ) + # Wait for the agent to be up + self.waitForSystemVMAgent(cpvm_response.name) + #Call to verify cloud process is running self.test_04_cpvm_internals() return @@ -830,9 +851,6 @@ class TestSSVMs(cloudstackTestCase): cmd.id = ssvm_response.id self.apiclient.destroySystemVm(cmd) - # Sleep to ensure that VM is in proper state - time.sleep(self.services["sleep"]) - timeout = self.services["timeout"] while True: list_ssvm_response = list_ssvms( @@ -843,7 +861,7 @@ class TestSSVMs(cloudstackTestCase): if isinstance(list_ssvm_response, list): if list_ssvm_response[0].state == 'Running': break - elif timeout == 0: + if timeout == 0: raise Exception("List SSVM call failed!") time.sleep(self.services["sleep"]) @@ -876,6 +894,9 @@ class TestSSVMs(cloudstackTestCase): "Check whether SSVM has public IP field" ) + # Wait for the agent to be up + self.waitForSystemVMAgent(ssvm_response.name) + #Call to verify cloud process is running self.test_03_ssvm_internals() return @@ -911,9 +932,6 @@ class TestSSVMs(cloudstackTestCase): cmd.id = cpvm_response.id self.apiclient.destroySystemVm(cmd) - # Sleep to ensure that VM is in proper state - time.sleep(self.services["sleep"]) - timeout = self.services["timeout"] while True: list_cpvm_response = list_ssvms( @@ -924,7 +942,7 @@ class TestSSVMs(cloudstackTestCase): if isinstance(list_cpvm_response, list): if list_cpvm_response[0].state == 'Running': break - elif timeout == 0: + if timeout == 0: raise Exception("List CPVM call failed!") time.sleep(self.services["sleep"]) @@ -957,6 +975,9 @@ class TestSSVMs(cloudstackTestCase): "Check whether CPVM has public IP field" ) + # Wait for the agent to be up + self.waitForSystemVMAgent(cpvm_response.name) + #Call to verify cloud process is running self.test_04_cpvm_internals() return