From 1951b0cba7f9d15eae917634fe0dab3c63f7b3b2 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 20 Dec 2023 16:47:23 +0530 Subject: [PATCH 1/4] test: additional check to ensure hosts are left in up state Signed-off-by: Abhishek Kumar --- test/integration/smoke/test_vm_life_cycle.py | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/integration/smoke/test_vm_life_cycle.py b/test/integration/smoke/test_vm_life_cycle.py index a9a554e19ad1..5c555f2e73cc 100644 --- a/test/integration/smoke/test_vm_life_cycle.py +++ b/test/integration/smoke/test_vm_life_cycle.py @@ -1011,8 +1011,36 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): + cls.ensure_all_hosts_are_up() super(TestSecuredVmMigration, cls).tearDownClass() + @classmethod + def ensure_all_hosts_are_up(cls): + hosts = Host.list( + cls.apiclient, + zoneid=cls.zone.id, + type='Routing', + hypervisor='KVM' + ) + for host in hosts: + if host.state != "Up": + SshClient(host.ipaddress, port=22, user=cls.hostConfig["username"], passwd=cls.hostConfig["password"]) \ + .execute("service cloudstack-agent stop ; \ + sleep 10 ; \ + service cloudstack-agent start") + interval = 5 + retries = 10 + while retries > -1: + time.sleep(interval) + restarted_host = Host.list( + cls.apiclient, + hostid=host.id, + type='Routing' + )[0] + if restarted_host.state == state: + break + retries = retries - 1 + def setUp(self): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() From 29b05e402173544fb231be9325c6b8161c89ec47 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 20 Dec 2023 19:04:59 +0530 Subject: [PATCH 2/4] Update test/integration/smoke/test_vm_life_cycle.py --- test/integration/smoke/test_vm_life_cycle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/smoke/test_vm_life_cycle.py b/test/integration/smoke/test_vm_life_cycle.py index 5c555f2e73cc..a75125a51538 100644 --- a/test/integration/smoke/test_vm_life_cycle.py +++ b/test/integration/smoke/test_vm_life_cycle.py @@ -1037,7 +1037,7 @@ def ensure_all_hosts_are_up(cls): hostid=host.id, type='Routing' )[0] - if restarted_host.state == state: + if restarted_host.state == 'Up': break retries = retries - 1 From fdf2af3e1aa67b7615aedf615339a6ece60e944a Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 20 Dec 2023 19:06:09 +0530 Subject: [PATCH 3/4] Update test/integration/smoke/test_vm_life_cycle.py --- test/integration/smoke/test_vm_life_cycle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/smoke/test_vm_life_cycle.py b/test/integration/smoke/test_vm_life_cycle.py index a75125a51538..58b9620ae5f2 100644 --- a/test/integration/smoke/test_vm_life_cycle.py +++ b/test/integration/smoke/test_vm_life_cycle.py @@ -1037,7 +1037,7 @@ def ensure_all_hosts_are_up(cls): hostid=host.id, type='Routing' )[0] - if restarted_host.state == 'Up': + if restarted_host.state == "Up": break retries = retries - 1 From b4c74d31e60bf9e40cfe5e38859704e2645974de Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 21 Dec 2023 14:19:32 +0530 Subject: [PATCH 4/4] fix non-kvm Signed-off-by: Abhishek Kumar --- test/integration/smoke/test_vm_life_cycle.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/integration/smoke/test_vm_life_cycle.py b/test/integration/smoke/test_vm_life_cycle.py index 58b9620ae5f2..6c824c1fe7d3 100644 --- a/test/integration/smoke/test_vm_life_cycle.py +++ b/test/integration/smoke/test_vm_life_cycle.py @@ -1011,7 +1011,8 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - cls.ensure_all_hosts_are_up() + if cls.hypervisor.lower() in ["kvm"]: + cls.ensure_all_hosts_are_up() super(TestSecuredVmMigration, cls).tearDownClass() @classmethod