1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Improve ansible-test retries.

This commit is contained in:
Matt Clay 2018-03-21 21:31:03 -07:00
parent fcd75bbc5a
commit ee596743d1

View file

@ -5,8 +5,7 @@ from __future__ import absolute_import, print_function
import os import os
import pipes import pipes
import tempfile import tempfile
import time
from time import sleep
import lib.pytar import lib.pytar
@ -50,13 +49,12 @@ class ManageWindowsCI(object):
env = ansible_environment(self.core_ci.args) env = ansible_environment(self.core_ci.args)
cmd = ['ansible', '-m', 'win_ping', '-i', '%s,' % name, name, '-e', ' '.join(extra_vars)] cmd = ['ansible', '-m', 'win_ping', '-i', '%s,' % name, name, '-e', ' '.join(extra_vars)]
for _ in range(1, 120): for dummy in range(1, 120):
try: try:
intercept_command(self.core_ci.args, cmd, 'ping', env=env) intercept_command(self.core_ci.args, cmd, 'ping', env=env)
return return
except SubprocessError: except SubprocessError:
sleep(10) time.sleep(10)
continue
raise ApplicationError('Timeout waiting for %s/%s instance %s.' % raise ApplicationError('Timeout waiting for %s/%s instance %s.' %
(self.core_ci.platform, self.core_ci.version, self.core_ci.instance_id)) (self.core_ci.platform, self.core_ci.version, self.core_ci.instance_id))
@ -92,13 +90,12 @@ class ManageNetworkCI(object):
name, name,
] ]
for _ in range(1, 90): for dummy in range(1, 90):
try: try:
intercept_command(self.core_ci.args, cmd, 'ping', env=env) intercept_command(self.core_ci.args, cmd, 'ping', env=env)
return return
except SubprocessError: except SubprocessError:
sleep(10) time.sleep(10)
continue
raise ApplicationError('Timeout waiting for %s/%s instance %s.' % raise ApplicationError('Timeout waiting for %s/%s instance %s.' %
(self.core_ci.platform, self.core_ci.version, self.core_ci.instance_id)) (self.core_ci.platform, self.core_ci.version, self.core_ci.instance_id))
@ -144,13 +141,12 @@ class ManagePosixCI(object):
def wait(self): def wait(self):
"""Wait for instance to respond to SSH.""" """Wait for instance to respond to SSH."""
for _ in range(1, 90): for dummy in range(1, 90):
try: try:
self.ssh('id') self.ssh('id')
return return
except SubprocessError: except SubprocessError:
sleep(10) time.sleep(10)
continue
raise ApplicationError('Timeout waiting for %s/%s instance %s.' % raise ApplicationError('Timeout waiting for %s/%s instance %s.' %
(self.core_ci.platform, self.core_ci.version, self.core_ci.instance_id)) (self.core_ci.platform, self.core_ci.version, self.core_ci.instance_id))
@ -209,6 +205,13 @@ class ManagePosixCI(object):
:type src: str :type src: str
:type dst: str :type dst: str
""" """
for dummy in range(1, 3):
try:
run_command(self.core_ci.args, run_command(self.core_ci.args,
['scp'] + self.ssh_args + ['scp'] + self.ssh_args +
['-P', str(self.core_ci.connection.port), '-q', '-r', src, dst]) ['-P', str(self.core_ci.connection.port), '-q', '-r', src, dst])
return
except SubprocessError:
time.sleep(10)
raise ApplicationError('Failed transfer: %s -> %s' % (src, dst))