two_phase_workloads = [
    ("$RETHINKDB/test/memcached_workloads/many_keys.py $HOST:$PORT --phase w",
     "$RETHINKDB/test/memcached_workloads/many_keys.py $HOST:$PORT --phase r",
     'many-keys'),
    ("$RETHINKDB/test/memcached_workloads/multi_serial_mix.py $HOST:$PORT --save values",
     "$RETHINKDB/test/memcached_workloads/multi_serial_mix.py $HOST:$PORT --load values",
     'multi-serial-mix'),
    ]

n_phase_workloads = [
    ("$RETHINKDB/bench/stress-client/stress -s sockmemcached,$HOST:$PORT -w 0/0/1/0 -d 10000q",
     "true",
     "true",
     'stress'),
    ("$RETHINKDB/test/memcached_workloads/serial_mix.py $HOST:$PORT --save values",
     "$RETHINKDB/test/memcached_workloads/serial_mix.py $HOST:$PORT --load values --save values",
     "$RETHINKDB/test/memcached_workloads/serial_mix.py $HOST:$PORT --load values",
     'serial-mix'),
    ("$RETHINKDB/test/memcached_workloads/multi_serial_mix.py $HOST:$PORT --save values",
     "$RETHINKDB/test/memcached_workloads/multi_serial_mix.py $HOST:$PORT --load values --save values",
     "$RETHINKDB/test/memcached_workloads/multi_serial_mix.py $HOST:$PORT --load values",
     'multi-serial-mix'),
    ]

two_phase_scenarios = {
    'rebalance': "$RETHINKDB/test/scenarios/rebalance.py --workload-before '%(before)s' --workload-after '%(after)s'",
    'relocate-namespace': "$RETHINKDB/test/scenarios/relocate_namespace.py --workload-before '%(before)s' --workload-after '%(after)s'",
    'change-primary': "$RETHINKDB/test/scenarios/change_primary.py --workload-before '%(before)s' --workload-after '%(after)s'",
    'failover': "$RETHINKDB/test/scenarios/failover_to_secondary.py --workload-before '%(before)s' --workload-after '%(after)s'",
    'add-secondary': "$RETHINKDB/test/scenarios/more_or_less_secondaries.py 1+1 --workload-before '%(before)s' --workload-after '%(after)s'",
    'remove-secondary': "$RETHINKDB/test/scenarios/more_or_less_secondaries.py 1-1 --workload-before '%(before)s' --workload-after '%(after)s'",
    'kill-secondary': "$RETHINKDB/test/scenarios/kill_secondary.py --workload-before '%(before)s' --workload-after '%(after)s'",
    'transfer': "$RETHINKDB/test/scenarios/transfer.py '%(before)s' '%(after)s'",
    'restart': "$RETHINKDB/test/scenarios/restart.py '%(before)s' '%(after)s'",
    }

n_phase_scenarios = {
    'more-or-less': "$RETHINKDB/test/scenarios/more_or_less_secondaries.py 2+1-1+1-1+1-1+1-1+1-1 --workload-before '%(before)s' --workload-after '%(after)s' --workload-between '%(between)s'",
    'rebalance-1': "$RETHINKDB/test/scenarios/rebalance.py --sequence 2,++,--,+-,+-,+++,--+,---- --workload-before '%(before)s' --workload-after '%(after)s' --workload-between '%(between)s'",
    'rebalance-2': "$RETHINKDB/test/scenarios/rebalance.py --sequence 32,++++++++++++++++++++++++++++++++,--------------------------------,++++++++++++++++----------------,++++++++++++++++----------------,++++++++++++++++++++++++++++++++++++++++++++++++,--------------------------------++++++++++++++++,---------------------------------------------------------------- --workload-before '%(before)s' --workload-after '%(after)s' --workload-between '%(between)s'",
    }

for sname, scenario in two_phase_scenarios.items():
    for before, after, wname in two_phase_workloads:
        generate_test(
            scenario % {"before": before, "after": after},
            name = sname + '-' + wname
            )
    for before, between, after, wname in n_phase_workloads:
        generate_test(
            scenario % {"before": before, "after": after},
            name = sname + '-' + wname
            )

for sname, scenario in n_phase_scenarios.items():
    for before, between, after, wname in n_phase_workloads:
        generate_test(
            scenario % {"before": before, "between": between, "after": after},
            name = sname + '-' + wname
            )
