summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric Ollivier <cedric.ollivier@orange.com>2018-05-07 16:42:51 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-05-07 16:42:51 +0000
commit062513f302369a8d48394edb0b1a75df660fee20 (patch)
tree190ded300c4e2b74552c83d504b5e883dfe2f860
parent601781b8020c267618bb7bfe3fc4cbe2bedc40b3 (diff)
parente1e1317226b4022b6e77ae7ddcc9a1ef9d8ccbd2 (diff)
Merge "Improve ssh timeout in vping_ssh"
-rw-r--r--functest/opnfv_tests/openstack/vping/vping_ssh.py24
1 files 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)