Rerun test in a single thread if multi-thread failed

Sometimes multi-threaded connectivity tests fail, and we
don't really know the root cause for that.
With this patch, we'll rerun a test in a single thread in
case it failed.

Change-Id: I1f8c61b3d5a384e7c9a9e1101b2d3d8cc984324e
This commit is contained in:
Yossi Boaron 2019-01-23 12:03:42 +02:00
parent a37f46e781
commit fc53fd0457
1 changed files with 12 additions and 5 deletions

View File

@ -656,12 +656,19 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest):
threads=threads,
fn_timeout=request_timeout)
def _run_threaded_and_assert(self, fn, predicate, repetitions=100,
threads=8, fn_timeout=1):
def _run_threaded_and_assert(
self, fn, predicate, repetitions=100, threads=8, fn_timeout=1,
retry_repetitions=10):
tp = pool.ThreadPool(processes=threads)
results = [tp.apply_async(fn) for _ in range(repetitions)]
resps = [result.get(timeout=fn_timeout) for result in results]
predicate(self, resps)
try:
results = [tp.apply_async(fn) for _ in range(repetitions)]
resps = [result.get(timeout=fn_timeout) for result in results]
predicate(self, resps)
except Exception as e:
LOG.info("Multi threaded test failed with Exception:%s. "
"Retry with single thread", e)
resps = [fn() for _ in range(retry_repetitions)]
predicate(self, resps)
@classmethod
def verify_lbaas_endpoints_configured(cls, ep_name, pod_num,