Merge "Rerun test in a single thread if multi-thread failed"

This commit is contained in:
Zuul 2019-02-07 18:55:17 +00:00 committed by Gerrit Code Review
commit c31364ff06
1 changed files with 12 additions and 5 deletions

View File

@ -660,12 +660,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,