def parse_mode_flags(parsed_opts): mode = parsed_opts["mode"] if parsed_opts["valgrind"]: assert parsed_opts["wrapper"] is None command_prefix = ["valgrind"] for valgrind_option in shlex.split(parsed_opts["valgrind-options"]): command_prefix.append(valgrind_option) # Make sure we use the valgrind build # this assumes that the 'valgrind' substring goes at the end of the specific build string if "valgrind" not in mode and mode != "": mode = mode + "-valgrind" elif parsed_opts["wrapper"] is not None: command_prefix = shlex.split(parsed_opts["wrapper"]) else: command_prefix = [] return driver.find_rethinkdb_executable(mode), command_prefix, shlex.split(parsed_opts["serve-flags"])
with driver.Metacluster() as metacluster: cluster = driver.Cluster(metacluster) print "Starting cluster..." num_nodes = 2 files = [ driver.Files(metacluster, db_path="db-%d" % i, log_path="create-output-%d" % i) for i in xrange(num_nodes) ] processes = [ driver.Process(cluster, files[i], log_path="serve-output-%d" % i, executable_path=driver.find_rethinkdb_executable()) for i in xrange(num_nodes) ] time.sleep(3) print "Creating table..." http = http_admin.ClusterAccess([("localhost", p.http_port) for p in processes]) db = http.add_database("test") dc = http.add_datacenter() for machine_id in http.machines: http.move_server_to_datacenter(machine_id, dc) ns = http.add_namespace(protocol="rdb", primary=dc, name="stress", database=db) time.sleep(3)
rethinkdb_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir)) sys.path.append(os.path.join(rethinkdb_root, "test", "common")) import http_admin, driver from vcoptparse import * with driver.Metacluster() as metacluster: cluster = driver.Cluster(metacluster) print "Starting cluster..." num_nodes = 2 files = [driver.Files(metacluster, db_path = "db-%d" % i, log_path = "create-output-%d" % i) for i in xrange(num_nodes)] processes = [driver.Process( cluster, files[i], log_path = "serve-output-%d" % i, executable_path = driver.find_rethinkdb_executable()) for i in xrange(num_nodes)] time.sleep(3) print "Creating table..." http = http_admin.ClusterAccess([("localhost", p.http_port) for p in processes]) db = http.add_database("test") dc = http.add_datacenter() for machine_id in http.machines: http.move_server_to_datacenter(machine_id, dc) ns = http.add_namespace(protocol = "memcached", primary = dc, name = "stress", database = db) time.sleep(3) host, port = driver.get_namespace_host(ns.port, processes) cluster.check() print "Increasing replication factor..." http.set_namespace_affinities(ns, {dc: 1})
with driver.Metacluster() as metacluster: cluster = driver.Cluster(metacluster) print "Starting cluster..." num_nodes = 2 files = [ driver.Files(metacluster, db_path="db-%d" % i, log_path="create-output-%d" % i) for i in xrange(num_nodes) ] processes = [ driver.Process( cluster, files[i], log_path="serve-output-%d" % i, executable_path=driver.find_rethinkdb_executable("debug")) for i in xrange(num_nodes) ] time.sleep(3) print "Creating table..." http = http_admin.ClusterAccess([("localhost", p.http_port) for p in processes]) db = http.add_database("test") dc = http.add_datacenter() for machine_id in http.machines: http.move_server_to_datacenter(machine_id, dc) ns = http.add_namespace(protocol="rdb", primary=dc, name="stress", database=db) time.sleep(3)
rethinkdb_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir)) sys.path.append(os.path.join(rethinkdb_root, "test", "common")) import http_admin, driver from vcoptparse import * with driver.Metacluster() as metacluster: cluster = driver.Cluster(metacluster) print "Starting cluster..." num_nodes = 2 files = [driver.Files(metacluster, db_path = "db-%d" % i, log_path = "create-output-%d" % i) for i in xrange(num_nodes)] processes = [driver.Process( cluster, files[i], log_path = "serve-output-%d" % i, executable_path = driver.find_rethinkdb_executable("debug")) for i in xrange(num_nodes)] time.sleep(3) print "Creating table..." http = http_admin.ClusterAccess([("localhost", p.http_port) for p in processes]) db = http.add_database("test") dc = http.add_datacenter() for machine_id in http.machines: http.move_server_to_datacenter(machine_id, dc) ns = http.add_namespace(protocol = "rdb", primary = dc, name = "stress", database = db) time.sleep(3) host, port = driver.get_namespace_host(ns.port, processes) cluster.check() print "Increasing replication factor..." http.set_namespace_affinities(ns, {dc: 1})
from vcoptparse import * from termcolor import colored, cprint op = OptParser() op["num-nodes"] = IntFlag("--num-nodes", 3) op["num-shards"] = IntFlag("--num-shards", 2) op["mode"] = StringFlag("--mode", "debug") op["tests"] = ManyPositionalArgs() op["timeout"] = IntFlag("--timeout", 600) op["images"] = StringFlag("--images", "./casper-results") opts = op.parse(sys.argv) with driver.Metacluster() as metacluster: cluster = driver.Cluster(metacluster) print "Starting cluster..." executable_path = driver.find_rethinkdb_executable(opts["mode"]) processes = [driver.Process(cluster, driver.Files(metacluster, db_path = "db-%d" % i, log_path = "create-output-%d" % i), executable_path = executable_path, log_path = "serve-output-%d" % i) for i in xrange(opts["num-nodes"])] for process in processes: process.wait_until_started_up() tests = [os.path.abspath(test) for test in opts["tests"]] process = processes[0] for test in tests: import socket; print socket.gethostname() # Build command with arguments for casperjs test cl = ['casperjs', '--rdb-server=http://localhost:%d' % process.http_port,
op["workload"] = PositionalArg() op["timeout"] = IntFlag("--timeout", 600) op["fast-workload"] = BoolFlag("--fast-workload") scenario_common.prepare_option_parser_mode_flags(op) opts = op.parse(sys.argv) with driver.Metacluster() as metacluster: print "Starting cluster..." cluster = driver.Cluster(metacluster) executable_path, command_prefix, serve_options = scenario_common.parse_mode_flags(opts) files1 = driver.Files(metacluster, db_path = "db-1", log_path = "create-output-1", executable_path = executable_path, command_prefix = command_prefix) files2 = driver.Files(metacluster, db_path = "db-2", log_path = "create-output-2", executable_path = executable_path, command_prefix = command_prefix) if opts["fast-workload"]: print "Fast workload mode--starting processes in release mode." process1 = driver.Process(cluster, files1, log_path = "serve-output-1-fast", executable_path = driver.find_rethinkdb_executable("release")) process2 = driver.Process(cluster, files2, log_path = "serve-output-2-fast", executable_path = driver.find_rethinkdb_executable("release")) else: process1 = driver.Process(cluster, files1, log_path = "serve-output-1", executable_path = executable_path, command_prefix = command_prefix, extra_options = serve_options) 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]]) dc = http.add_datacenter() http.move_server_to_datacenter(process1.files.machine_name, dc) http.move_server_to_datacenter(process2.files.machine_name, dc)
# Copyright 2010-2012 RethinkDB, all rights reserved. import sys, os, time, tempfile rethinkdb_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir)) sys.path.append(os.path.join(rethinkdb_root, "test", "common")) import http_admin, driver from vcoptparse import * with driver.Metacluster() as metacluster: cluster = driver.Cluster(metacluster) print "Starting cluster..." num_nodes = 2 files = [driver.Files(metacluster, db_path="db-%d" % i, log_path="create-output-%d" % i) for i in xrange(num_nodes)] processes = [ driver.Process( cluster, files[i], log_path="serve-output-%d" % i, executable_path=driver.find_rethinkdb_executable("debug") ) for i in xrange(num_nodes) ] time.sleep(10) print "Creating namespace..." http = http_admin.ClusterAccess([("localhost", p.http_port) for p in processes]) dc = http.add_datacenter() for machine_id in http.machines: http.move_server_to_datacenter(machine_id, dc) ns = http.add_namespace(protocol="memcached", primary=dc) time.sleep(10) cluster.check() print "Splitting into two shards..." http.add_namespace_shard(ns, "t")
db_path="db-1", log_path="create-output-1", executable_path=executable_path, command_prefix=command_prefix, ) files2 = driver.Files( metacluster, db_path="db-2", log_path="create-output-2", executable_path=executable_path, command_prefix=command_prefix, ) if opts["fast-workload"]: print "Fast workload mode--starting processes in release mode." process1 = driver.Process( cluster, files1, log_path="serve-output-1-fast", executable_path=driver.find_rethinkdb_executable("release") ) process2 = driver.Process( cluster, files2, log_path="serve-output-2-fast", executable_path=driver.find_rethinkdb_executable("release") ) else: process1 = driver.Process( cluster, files1, log_path="serve-output-1", executable_path=executable_path, command_prefix=command_prefix, extra_options=serve_options, ) process2 = driver.Process( cluster,
db_path="db-1", log_path="create-output-1", executable_path=executable_path, command_prefix=command_prefix) files2 = driver.Files(metacluster, db_path="db-2", log_path="create-output-2", executable_path=executable_path, command_prefix=command_prefix) if opts["fast-workload"]: print "Fast workload mode--starting processes in release mode." process1 = driver.Process( cluster, files1, log_path="serve-output-1-fast", executable_path=driver.find_rethinkdb_executable("release")) process2 = driver.Process( cluster, files2, log_path="serve-output-2-fast", executable_path=driver.find_rethinkdb_executable("release")) else: process1 = driver.Process(cluster, files1, log_path="serve-output-1", executable_path=executable_path, command_prefix=command_prefix, extra_options=serve_options) process2 = driver.Process(cluster, files2, log_path="serve-output-2",