diff --git a/test/integration/smoke/test_deploy_virtio_scsi_vm.py b/test/integration/smoke/test_deploy_virtio_scsi_vm.py index df54c4307a9..89690977121 100644 --- a/test/integration/smoke/test_deploy_virtio_scsi_vm.py +++ b/test/integration/smoke/test_deploy_virtio_scsi_vm.py @@ -96,6 +96,7 @@ class TestDeployVirtioSCSIVM(cloudstackTestCase): cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.pod = get_pod(cls.apiclient, cls.zone.id) cls.services['mode'] = cls.zone.networktype + cls.cleanup = [] if cls.hypervisor.lower() not in ['kvm']: cls.hypervisorNotSupported = True return diff --git a/test/integration/smoke/test_hostha_kvm.py b/test/integration/smoke/test_hostha_kvm.py index a4de07e2298..cd4a2d412a4 100644 --- a/test/integration/smoke/test_hostha_kvm.py +++ b/test/integration/smoke/test_hostha_kvm.py @@ -274,9 +274,12 @@ class TestHAKVM(cloudstackTestCase): Tests Enable HA when host is in Maintenance mode, should be Ineligible """ self.logger.debug("Starting test_hostha_enable_ha_when_host_in_maintenance") - + self.logger.debug("Pausing to wait for VMs to have finished starting") + time.sleep(300) + # Enable HA self.configureAndEnableHostHa() + # Prepare for maintenance Host self.setHostToMaintanance(self.host.id) diff --git a/test/integration/smoke/test_vm_life_cycle.py b/test/integration/smoke/test_vm_life_cycle.py index 32e917444c0..b7a996f1d72 100644 --- a/test/integration/smoke/test_vm_life_cycle.py +++ b/test/integration/smoke/test_vm_life_cycle.py @@ -940,6 +940,23 @@ class TestSecuredVmMigration(cloudstackTestCase): vm_response = VirtualMachine.list(self.apiclient, id=vm.id)[0] self.assertEqual(vm_response.hostid, dest_host.id, "Check destination host ID of migrated VM") + def waitUntilHostInState(self, hostId, state="Up", interval=5, retries=20): + while retries > -1: + print("Waiting for host: %s to be %s. %s retries left." % (hostId, state, retries)) + time.sleep(interval) + host = Host.list( + self.apiclient, + hostid=hostId, + type='Routing' + )[0] + if host.state != state: + if retries >= 0: + retries = retries - 1 + continue + else: + print("Host %s now showing as %s" % (hostId, state)) + return + def unsecure_host(self, host): SshClient(host.ipaddress, port=22, user=self.hostConfig["username"], passwd=self.hostConfig["password"]) \ .execute("rm -f /etc/cloudstack/agent/cloud* && \ @@ -947,9 +964,10 @@ class TestSecuredVmMigration(cloudstackTestCase): sed -i 's/listen_tcp.*/listen_tcp=1/g' /etc/libvirt/libvirtd.conf && \ sed -i '/.*_file=.*/d' /etc/libvirt/libvirtd.conf && \ service libvirtd restart && \ + sleep 30 && \ service cloudstack-agent restart") - - time.sleep(10) + print("Unsecuring Host: %s" % (host.name)) + self.waitUntilHostInState(hostId=host.id, state="Up") self.check_connection(host=host, secured='false') return host @@ -961,6 +979,8 @@ class TestSecuredVmMigration(cloudstackTestCase): self.apiclient.provisionCertificate(cmd) for host in self.hosts: + print("Securing Host %s" % host.name) + self.waitUntilHostInState(hostId=host.id, state="Up") self.check_connection(secured='true', host=host) def deploy_vm(self, origin_host): @@ -1011,6 +1031,7 @@ class TestSecuredVmMigration(cloudstackTestCase): vm = self.deploy_vm(src_host) self.cleanup.append(vm) + self.debug("Securing Host(s)") dest_host = self.get_target_host(secured='true', virtualmachineid=vm.id) self.migrate_and_check(vm, src_host, dest_host) diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py index 29e61f94bb3..5fe2ea7dbac 100755 --- a/tools/marvin/marvin/lib/base.py +++ b/tools/marvin/marvin/lib/base.py @@ -623,22 +623,34 @@ class VirtualMachine: return VirtualMachine(virtual_machine.__dict__, services) # program ssh access over NAT via PF - if mode.lower() == 'advanced': - cls.access_ssh_over_nat( - apiclient, - services, - virtual_machine, - allow_egress=allow_egress, - networkid=cmd.networkids[0] if cmd.networkids else None) - elif mode.lower() == 'basic': - if virtual_machine.publicip is not None: - # EIP/ELB (netscaler) enabled zone - vm_ssh_ip = virtual_machine.publicip - else: - # regular basic zone with security group - vm_ssh_ip = virtual_machine.nic[0].ipaddress - virtual_machine.ssh_ip = vm_ssh_ip - virtual_machine.public_ip = vm_ssh_ip + retries = 5 + interval = 30 + while retries > 0: + time.sleep(interval) + try: + if mode.lower() == 'advanced': + cls.access_ssh_over_nat( + apiclient, + services, + virtual_machine, + allow_egress=allow_egress, + networkid=cmd.networkids[0] if cmd.networkids else None) + elif mode.lower() == 'basic': + if virtual_machine.publicip is not None: + # EIP/ELB (netscaler) enabled zone + vm_ssh_ip = virtual_machine.publicip + else: + # regular basic zone with security group + vm_ssh_ip = virtual_machine.nic[0].ipaddress + virtual_machine.ssh_ip = vm_ssh_ip + virtual_machine.public_ip = vm_ssh_ip + break + except Exception as e: + if retries >= 0: + retries = retries - 1 + continue + raise Exception( + "The following exception appeared while programming ssh access - %s" % e) return VirtualMachine(virtual_machine.__dict__, services)