Skip to content

Commit f3f0db8

Browse files
committed
Tests: Add retry for assert stopped
service stop is a backgrounded process, so it hasn't necessary completed when we check assertStopped. Add 10s retry. This will hopefully address the intermittant OSError not raised automation issue. Testing: test_control
1 parent c70a652 commit f3f0db8

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

tests/product/base_product_case.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,14 @@ def expected_stop(self, running=None, not_running=None):
357357

358358
def assert_stopped(self, process_per_host):
359359
for host, pid in process_per_host:
360-
self.assertRaisesRegexp(OSError,
361-
'No such process',
362-
self.cluster.exec_cmd_on_host,
363-
host, 'kill -0 %s' % pid)
360+
self.retry(lambda:
361+
self.assertRaisesRegexp(OSError,
362+
'No such process',
363+
self.cluster.exec_cmd_on_host,
364+
host,
365+
'kill -0 %s' % pid),
366+
retry_timeout=10,
367+
retry_interval=2)
364368

365369
def get_process_per_host(self, output_lines):
366370
process_per_host = []
@@ -409,17 +413,18 @@ def escape_for_regex(self, expected):
409413
expected = expected.replace('+', '\+')
410414
return expected
411415

412-
def retry(self, method_to_check):
416+
def retry(self, method_to_check, retry_timeout=RETRY_TIMEOUT,
417+
retry_interval=RETRY_INTERVAL):
413418
time_spent_waiting = 0
414-
while time_spent_waiting <= RETRY_TIMEOUT:
419+
while time_spent_waiting <= retry_timeout:
415420
try:
416421
result = method_to_check()
417422
# No exception thrown, success
418423
return result
419424
except (AssertionError, PrestoError, OSError):
420425
pass
421-
sleep(RETRY_INTERVAL)
422-
time_spent_waiting += RETRY_INTERVAL
426+
sleep(retry_interval)
427+
time_spent_waiting += retry_interval
423428
return method_to_check()
424429

425430
def down_node_connection_error(self, host):

0 commit comments

Comments
 (0)