From e1e1317226b4022b6e77ae7ddcc9a1ef9d8ccbd2 Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Mon, 7 May 2018 16:02:00 +0200 Subject: Improve ssh timeout in vping_ssh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It seems that 10s is not enough for Fuel. Change-Id: I46d3d2c9091946befb0e056a8c8cc56c59087471 Signed-off-by: Cédric Ollivier --- functest/opnfv_tests/openstack/vping/vping_ssh.py | 24 +++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/functest/opnfv_tests/openstack/vping/vping_ssh.py b/functest/opnfv_tests/openstack/vping/vping_ssh.py index 8cc251d1d..933779ec1 100644 --- a/functest/opnfv_tests/openstack/vping/vping_ssh.py +++ b/functest/opnfv_tests/openstack/vping/vping_ssh.py @@ -97,13 +97,25 @@ class VPingSSH(vping_base.VPingBase): return testcase.TestCase.EX_RUN_ERROR def _do_vping(self): - time.sleep(10) self.ssh.set_missing_host_key_policy(paramiko.client.AutoAddPolicy()) - self.ssh.connect( - self.vm2.public_v4, - username=getattr(config.CONF, 'openstack_image_user'), - key_filename=self.key_filename, - timeout=getattr(config.CONF, 'vping_vm_ssh_connect_timeout')) + for loop in range(6): + try: + self.ssh.connect( + self.vm2.public_v4, + username=getattr(config.CONF, 'openstack_image_user'), + key_filename=self.key_filename, + timeout=getattr( + config.CONF, 'vping_vm_ssh_connect_timeout')) + break + except Exception: # pylint: disable=broad-except + self.logger.info( + "try %s: cannot connect to %s", loop + 1, + self.vm2.public_v4) + time.sleep(10) + else: + self.logger.error("cannot connect to %s", self.vm2.public_v4) + return False + self.logger.debug("ssh: %s", self.ssh) (_, stdout, _) = self.ssh.exec_command( 'ping -c 1 ' + self.vm1.private_v4) -- cgit 1.2.3-korg