with driver.Metacluster() as metacluster: cluster = driver.Cluster(metacluster) executable_path, command_prefix, serve_options = scenario_common.parse_mode_flags(opts) print "Starting cluster..." files1 = driver.Files(metacluster, db_path = "db-first", log_path = "create-output-first", executable_path = executable_path, command_prefix = command_prefix) process1 = driver.Process(cluster, files1, log_path = "serve-output-first", executable_path = executable_path, command_prefix = command_prefix, extra_options = serve_options) process1.wait_until_started_up() print "Creating namespace..." http1 = http_admin.ClusterAccess([("localhost", process1.http_port)]) dc = http1.add_datacenter() http1.move_server_to_datacenter(files1.machine_name, dc) ns = scenario_common.prepare_table_for_workload(opts, http1, primary = dc) http1.wait_until_blueprint_satisfied(ns) workload_ports_1 = scenario_common.get_workload_ports(opts, ns, [process1]) workload_runner.run(opts["protocol"], opts["workload1"], workload_ports_1, opts["timeout"]) print "Bringing up new server..." files2 = driver.Files(metacluster, db_path = "db-second", log_path = "create-output-second", executable_path = executable_path, command_prefix = command_prefix) process2 = driver.Process(cluster, files2, log_path = "serve-output-second", executable_path = executable_path, command_prefix = command_prefix, extra_options = serve_options) process2.wait_until_started_up() http1.update_cluster_data(3) http1.move_server_to_datacenter(files2.machine_name, dc) http1.set_namespace_affinities(ns, {dc: 1}) http1.check_no_issues()
driver.Files(metacluster, db_path = "db-%d" % i, log_path = "create-output-%d" % i, executable_path = executable_path, command_prefix = command_prefix), log_path = "serve-output-%d" % i, executable_path = executable_path, command_prefix = command_prefix, extra_options = serve_options) for i in xrange(opts["num-nodes"])] for process in processes: process.wait_until_started_up() print "Creating table..." http = http_admin.ClusterAccess([("localhost", p.http_port) for p in processes]) primary_dc = http.add_datacenter() secondary_dc = http.add_datacenter() machines = http.machines.keys() http.move_server_to_datacenter(machines[0], primary_dc) http.move_server_to_datacenter(machines[1], secondary_dc) ns = scenario_common.prepare_table_for_workload(http, primary = primary_dc) http.wait_until_blueprint_satisfied(ns) cluster.check() http.check_no_issues() workload_ports = scenario_common.get_workload_ports(ns, processes) with workload_runner.SplitOrContinuousWorkload(opts, workload_ports) as workload: workload.run_before() cluster.check() http.check_no_issues() http.move_table_to_datacenter(ns, secondary_dc) http.wait_until_blueprint_satisfied(ns) rdb_workload_common.wait_for_table(host=workload_ports.host, port=workload_ports.rdb_port, table=workload_ports.table_name) cluster.check()
executable_path=executable_path, command_prefix=command_prefix, extra_options=serve_options) primary.wait_until_started_up() secondary.wait_until_started_up() print "Creating namespace..." http = http_admin.ClusterAccess([("localhost", secondary.http_port)]) primary_dc = http.add_datacenter() http.move_server_to_datacenter(primary.files.machine_name, primary_dc) secondary_dc = http.add_datacenter() http.move_server_to_datacenter(secondary.files.machine_name, secondary_dc) ns = scenario_common.prepare_table_for_workload(opts, http, primary=primary_dc, affinities={ primary_dc: 0, secondary_dc: 1 }) http.set_namespace_ack_expectations(ns, {secondary_dc: 1}) http.wait_until_blueprint_satisfied(ns) cluster.check() http.check_no_issues() workload_ports = scenario_common.get_workload_ports(opts, ns, [secondary]) with workload_runner.SplitOrContinuousWorkload(opts, opts["protocol"], workload_ports) as workload: workload.run_before() cluster.check() http.check_no_issues() print "Killing the primary..."
primary = driver.Process(cluster, primary_files, log_path = "serve-output-1", executable_path = executable_path, command_prefix = command_prefix, extra_options = serve_options) secondary_files = driver.Files(metacluster, db_path = "db-2", log_path = "create-output-2", executable_path = executable_path, command_prefix = command_prefix) secondary = driver.Process(cluster, secondary_files, log_path = "serve-output-2", executable_path = executable_path, command_prefix = command_prefix, extra_options = serve_options) primary.wait_until_started_up() secondary.wait_until_started_up() print "Creating namespace..." http = http_admin.ClusterAccess([("localhost", secondary.http_port)]) primary_dc = http.add_datacenter() http.move_server_to_datacenter(primary.files.machine_name, primary_dc) secondary_dc = http.add_datacenter() http.move_server_to_datacenter(secondary.files.machine_name, secondary_dc) ns = scenario_common.prepare_table_for_workload(opts, http, primary = primary_dc, affinities = {primary_dc: 0, secondary_dc: 1}) http.set_namespace_ack_expectations(ns, {secondary_dc: 1}) http.wait_until_blueprint_satisfied(ns) cluster.check() http.check_no_issues() workload_ports = scenario_common.get_workload_ports(opts, ns, [secondary]) with workload_runner.SplitOrContinuousWorkload(opts, opts["protocol"], workload_ports) as workload: workload.run_before() cluster.check() http.check_no_issues() print "Killing the primary..." primary.close() http.declare_machine_dead(primary.files.machine_name) http.move_namespace_to_datacenter(ns, secondary_dc) http.set_namespace_affinities(ns, {secondary_dc: 0})
print "Starting cluster..." files = driver.Files(metacluster, log_path="create-output", executable_path=executable_path, command_prefix=command_prefix) process = driver.Process(cluster, files, executable_path=executable_path, command_prefix=command_prefix, extra_options=serve_options) process.wait_until_started_up() print "Creating namespace..." http = http_admin.ClusterAccess([("localhost", process.http_port)]) dc = http.add_datacenter() http.move_server_to_datacenter(http.machines.keys()[0], dc) ns = scenario_common.prepare_table_for_workload(opts, http, primary=dc) http.wait_until_blueprint_satisfied(ns) workload_ports = scenario_common.get_workload_ports(opts, ns, [process]) workload_runner.run(opts["protocol"], opts["workload1"], workload_ports, opts["timeout"]) print "Restarting server..." process.check_and_stop() process2 = driver.Process(cluster, files, executable_path=executable_path, command_prefix=command_prefix, extra_options=serve_options) process2.wait_until_started_up() http.wait_until_blueprint_satisfied(ns) workload_runner.run(opts["protocol"], opts["workload2"], workload_ports, opts["timeout"])
log_path = "serve_output-%d" % i, executable_path = executable_path, command_prefix = command_prefix, extra_options = serve_options) for i in xrange(opts["sequence"].peak())] primary_process.wait_until_started_up() for replica_process in replica_processes: replica_process.wait_until_started_up() print "Creating namespace..." http = http_admin.ClusterAccess([("localhost", p.http_port) for p in [primary_process] + replica_processes]) primary_dc = http.add_datacenter() http.move_server_to_datacenter(primary_process.files.machine_name, primary_dc) replica_dc = http.add_datacenter() for replica_process in replica_processes: http.move_server_to_datacenter(replica_process.files.machine_name, replica_dc) ns = scenario_common.prepare_table_for_workload(opts, http, primary = primary_dc, affinities = {primary_dc: 0, replica_dc: opts["sequence"].initial}) http.wait_until_blueprint_satisfied(ns) cluster.check() http.check_no_issues() workload_ports = scenario_common.get_workload_ports(opts, ns, [primary_process] + replica_processes) with workload_runner.SplitOrContinuousWorkload(opts, opts["protocol"], workload_ports) as workload: workload.run_before() cluster.check() http.check_no_issues() workload.check() current = opts["sequence"].initial for i, s in enumerate(opts["sequence"].steps): if i != 0: workload.run_between() print "Changing the number of secondaries from %d to %d..." % (current, current + s)
executable_path = executable_path, command_prefix = command_prefix, extra_options = serve_options) files2 = driver.Files(metacluster, db_path = "db-2", log_path = "create-output-2", executable_path = executable_path, command_prefix = command_prefix) process2 = driver.Process(cluster, files2, log_path = "serve-output-2", executable_path = executable_path, command_prefix = command_prefix, extra_options = serve_options) process1.wait_until_started_up() process2.wait_until_started_up() print "Creating table..." http = http_admin.ClusterAccess([("localhost", p.http_port) for p in [process1, process2]]) dc1 = http.add_datacenter() http.move_server_to_datacenter(process1.files.machine_name, dc1) dc2 = http.add_datacenter() http.move_server_to_datacenter(process2.files.machine_name, dc2) ns = scenario_common.prepare_table_for_workload(http, primary = dc1, affinities = {dc1: 0, dc2: 1}) http.wait_until_blueprint_satisfied(ns) cluster.check() http.check_no_issues() workload_ports = scenario_common.get_workload_ports(ns, [process1, process2]) with workload_runner.SplitOrContinuousWorkload(opts, workload_ports) as workload: workload.run_before() cluster.check() http.check_no_issues() workload.check() print "Changing the primary..." http.set_table_affinities(ns, {dc1: 1, dc2: 1}) http.move_table_to_datacenter(ns, dc2) http.set_table_affinities(ns, {dc1: 1, dc2: 0}) http.wait_until_blueprint_satisfied(ns)
print "Creating table..." http = http_admin.ClusterAccess([ ("localhost", p.http_port) for p in [primary_process] + replica_processes ]) primary_dc = http.add_datacenter() http.move_server_to_datacenter(primary_process.files.machine_name, primary_dc) replica_dc = http.add_datacenter() for replica_process in replica_processes: http.move_server_to_datacenter(replica_process.files.machine_name, replica_dc) ns = scenario_common.prepare_table_for_workload( http, primary=primary_dc, affinities={ primary_dc: 0, replica_dc: opts["sequence"].initial }) http.wait_until_blueprint_satisfied(ns) cluster.check() http.check_no_issues() workload_ports = scenario_common.get_workload_ports( ns, [primary_process] + replica_processes) with workload_runner.SplitOrContinuousWorkload(opts, workload_ports) as workload: workload.run_before() cluster.check() http.check_no_issues() workload.check()
executable_path = executable_path, command_prefix = command_prefix, extra_options = serve_options) files2 = driver.Files(metacluster, db_path = "db-2", log_path = "create-output-2", executable_path = executable_path, command_prefix = command_prefix) process2 = driver.Process(cluster, files2, log_path = "serve-output-2", executable_path = executable_path, command_prefix = command_prefix, extra_options = serve_options) process1.wait_until_started_up() process2.wait_until_started_up() print "Creating namespace..." http = http_admin.ClusterAccess([("localhost", p.http_port) for p in [process1, process2]]) dc1 = http.add_datacenter() http.move_server_to_datacenter(process1.files.machine_name, dc1) dc2 = http.add_datacenter() http.move_server_to_datacenter(process2.files.machine_name, dc2) ns = scenario_common.prepare_table_for_workload(opts, http, primary = dc1, affinities = {dc1: 0, dc2: 1}) http.wait_until_blueprint_satisfied(ns) cluster.check() http.check_no_issues() workload_ports = scenario_common.get_workload_ports(opts, ns, [process1, process2]) with workload_runner.SplitOrContinuousWorkload(opts, opts["protocol"], workload_ports) as workload: workload.run_before() cluster.check() http.check_no_issues() workload.check() print "Changing the primary..." http.set_namespace_affinities(ns, {dc1: 1, dc2: 1}) http.move_namespace_to_datacenter(ns, dc2) http.set_namespace_affinities(ns, {dc1: 1, dc2: 0}) http.wait_until_blueprint_satisfied(ns)
executable_path = executable_path, command_prefix = command_prefix), log_path = "serve-output-%d" % i, executable_path = executable_path, command_prefix = command_prefix, extra_options = serve_options) for i in xrange(opts["num-nodes"])] for process in processes: process.wait_until_started_up() print "Creating table..." http = http_admin.ClusterAccess([("localhost", p.http_port) for p in processes]) primary_dc = http.add_datacenter() secondary_dc = http.add_datacenter() machines = http.machines.keys() http.move_server_to_datacenter(machines[0], primary_dc) http.move_server_to_datacenter(machines[1], primary_dc) http.move_server_to_datacenter(machines[2], secondary_dc) ns = scenario_common.prepare_table_for_workload(http, primary = primary_dc, affinities = {primary_dc.uuid: 1, secondary_dc.uuid: 1}) shard_boundaries = set(random.sample(candidate_shard_boundaries, opts["sequence"].initial)) print "Split points are:", list(shard_boundaries) http.change_table_shards(ns, adds = list(shard_boundaries)) http.wait_until_blueprint_satisfied(ns) cluster.check() workload_ports = scenario_common.get_workload_ports(ns, processes) with workload_runner.SplitOrContinuousWorkload(opts, workload_ports) as workload: workload.run_before() cluster.check() for i, (num_adds, num_removes) in enumerate(opts["sequence"].steps): if i != 0: workload.run_between() adds = set(random.sample(candidate_shard_boundaries - shard_boundaries, num_adds)) removes = set(random.sample(shard_boundaries, num_removes))