APIS = {'pony': CMD_PONY, 'python': CMD_PYTHON, 'python3': CMD_PYTHON3} # If resilience is on, add --run-with-resilience to commands import os if os.environ.get("resilience") == 'on': for a in APIS: APIS[a] += ' --run-with-resilience' ############## # Test spec(s) ############## AUTOSCALE_TEST_NAME_FMT = 'test_autoscale_{api}_{ops}' ################# # Autoscale tests ################# OPS = [Grow(1), Grow(4), Shrink(1), Shrink(4)] # Programmatically create the tests, do the name mangling, and place them # in the global scope for pytest to find for api, cmd in APIS.items(): for o1 in OPS: for o2 in OPS: if o1 == o2: TC.create(AUTOSCALE_TEST_NAME_FMT, api, cmd, [o1]) else: TC.create(AUTOSCALE_TEST_NAME_FMT, api, cmd, [o1, Wait(2), o2])
RESILIENCE_TEST_NAME_FMT = 'test_resilience_{api}_{source_type}_{source_number}_{ops}' ################## # Resilience Tests ################## SOURCE_TYPES = ['alo'] SOURCE_NAME = 'Detector' SOURCE_NUMBERS = [1] RESILIENCE_SEQS = [ # wait, grow1, wait, shrink1, wait, crash2, wait, recover [ Wait(2), Grow(1), Wait(2), Shrink(1), Wait(2), Crash(2), Wait(2), Recover(2), Wait(5) ], # crash1, recover1 [Wait(2), Crash(1), Wait(2), Recover(1), Wait(5)], # crash2, recover2 [Wait(2), Crash(2), Wait(2),
def test_auto4(): command = 'multi_partition_detector --depth 1' ops = [Grow(4)] _test_resilience(command, ops, validate_output=True)
def test_auto15(): command = 'multi_partition_detector --depth 1' ops = [Shrink(4), Wait(2), Grow(4)] _test_resilience(command, ops, validate_output=True)
def test_grow1_shrink1_crash2_wait2_recover2(): command = 'multi_partition_detector --depth 1 --internal-source' ops = [Wait(2), Grow(1), Wait(2), Shrink(1), Wait(2), Crash(2), Wait(2), Recover(2)] _test_resilience(command, ops, validate_output=True, sources=0)