Commit 5373adcb authored by Štěpán Balážik's avatar Štěpán Balážik Committed by Petr Špaček

add command line option to set number of retries

--retries defaults to 3
parent c09c4076
......@@ -106,6 +106,8 @@ def rpls(paths):
def pytest_addoption(parser):
parser.addoption("--config", action="append", help="path to Deckard configuration .yaml file")
parser.addoption("--scenarios", action="append", help="directory with .rpl files")
parser.addoption("--retries", action="store", help=("number of retries per"
"test when Deckard is under load"))
def pytest_generate_tests(metafunc):
......@@ -128,7 +130,11 @@ def pytest_generate_tests(metafunc):
if 'rpl_path' in metafunc.fixturenames:
paths = metafunc.config.option.scenarios
metafunc.parametrize("rpl_path", rpls(paths), ids=str)
if 'max_retries' in metafunc.fixturenames:
max_retries = metafunc.config.option.retries
if max_retries is None:
max_retries = 3
metafunc.parametrize("max_retries", [max_retries], ids=str)
def check_log_level_xdist(level):
if level < logging.ERROR:
......@@ -35,7 +35,7 @@ logging.getLogger("augeas").setLevel(logging.ERROR)
def run_test(path, qmin, config, retries=0):
def run_test(path, qmin, config, max_retries, retries=0):
set_coverage_env(path, qmin)
del os.environ["SOCKET_WRAPPER_DIR"]
......@@ -44,24 +44,24 @@ def run_test(path, qmin, config, retries=0):
deckard.process_file(path, qmin, config)
except deckard.DeckardUnderLoadError as e:
if retries < 3:
if retries < max_retries:
logging.error("Deckard under load. Retrying…")
# Exponential backoff
time.sleep((2 ** (retries + 1)) + (random.randint(0, 1000) / 1000))
run_test(path, qmin, config, retries + 1)
time.sleep((2 ** retries) + random.random())
run_test(path, qmin, config, max_retries, retries + 1)
raise e
def test_passes_qmin_on(scenario):
def test_passes_qmin_on(scenario, max_retries):
if scenario.qmin is True or scenario.qmin is None:
run_test(scenario.path, True, scenario.config)
run_test(scenario.path, True, scenario.config, max_retries)
pytest.skip("Query minimization is off in test config")
def test_passes_qmin_off(scenario):
def test_passes_qmin_off(scenario, max_retries):
if scenario.qmin is False or scenario.qmin is None:
run_test(scenario.path, False, scenario.config)
run_test(scenario.path, False, scenario.config, max_retries)
pytest.skip("Query minimization is on in test config")
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment