1) # Number of servers in the cluster opts['duration'] = vcoptparse.IntFlag( '--duration', 900) # Time to perform fuzzing in seconds opts['progress'] = vcoptparse.BoolFlag( '--progress', False) # Write messages every 10 seconds with the time remaining opts['threads'] = vcoptparse.IntFlag( '--threads', 16) # Number of client threads to run (not counting changefeeds) opts['changefeeds'] = vcoptparse.BoolFlag( '--changefeeds', False) # Whether or not to use changefeeds opts['kill'] = vcoptparse.BoolFlag( '--kill', False ) # Randomly kill and revive servers during fuzzing - will produce a lot of noise parsed_opts = opts.parse(sys.argv) _, command_prefix, serve_options = scenario_common.parse_mode_flags( parsed_opts) r = utils.import_python_driver() dbName, tableName = utils.get_test_db_table() server_names = list(string.ascii_lowercase[:parsed_opts['servers']]) system_tables = [ 'table_config', 'server_config', 'db_config', 'cluster_config', 'table_status', 'server_status', 'current_issues', 'jobs', 'stats', 'logs', '_debug_table_status' ] # Global data used by query generators, and a lock to make it thread-safe data_lock = threading.Lock() dbs = set()
#!/usr/bin/env python # Copyright 2014-2015 RethinkDB, all rights reserved. """The `interface.db_config` test checks that the special `rethinkdb.db_config` table behaves as expected.""" import os, sys sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, 'common'))) import driver, scenario_common, utils, vcoptparse r = utils.import_python_driver() op = vcoptparse.OptParser() scenario_common.prepare_option_parser_mode_flags(op) _, command_prefix, serve_options = scenario_common.parse_mode_flags(op.parse(sys.argv)) utils.print_with_time("Starting server") with driver.Process(name='./a', command_prefix=command_prefix, extra_options=serve_options, wait_until_ready=True) as server: utils.print_with_time("Establishing ReQL connection") conn = r.connect(host=server.host, port=server.driver_port) utils.print_with_time("Starting tests") res = list(r.db("rethinkdb").table("db_config").run(conn)) assert res == [], res res = r.db_create("foo").run(conn) assert res["dbs_created"] == 1 assert len(res["config_changes"]) == 1 assert res["config_changes"][0]["old_val"] is None assert res["config_changes"][0]["new_val"] == r.db("foo").config().run(conn)
workingValue -= 1 elif char == '+': workingValue += 1 else: raise ValueError('Got a bad step value: %s' % repr(char)) assert char in ('-', '+') returnValue += (workingValue,) return returnValue op = vcoptparse.OptParser() scenario_common.prepare_option_parser_mode_flags(op) workload_runner.prepare_option_parser_for_split_or_continuous_workload(op, allow_between = True) op["num-nodes"] = vcoptparse.IntFlag("--num-nodes", 3) op["sequence"] = vcoptparse.ValueFlag("--sequence", converter=sequence_from_string, default=(2, 3)) opts = op.parse(sys.argv) _, command_prefix, serve_options = scenario_common.parse_mode_flags(opts) class Rebalance(rdb_unittest.RdbTestCase): '''Change the number of shards on a table.''' # keep the same number of replicas as nodes so we don't have to backfill constantly replicas = opts["num-nodes"] shards = 1 server_command_prefix = command_prefix server_extra_options = serve_options def test_workload(self): connServer = self.cluster[0]
# Copyright 2010-2012 RethinkDB, all rights reserved. import sys, os, time sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, 'common'))) import http_admin, driver, workload_runner, scenario_common from vcoptparse import * op = OptParser() scenario_common.prepare_option_parser_mode_flags(op) op["workload1"] = PositionalArg() op["workload2"] = PositionalArg() op["timeout"] = IntFlag("--timeout", 600) opts = op.parse(sys.argv) 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)
import sys, os, time sys.path.append( os.path.abspath( os.path.join(os.path.dirname(__file__), os.path.pardir, 'common'))) import http_admin, driver, workload_runner, scenario_common from vcoptparse import * op = OptParser() workload_runner.prepare_option_parser_for_split_or_continuous_workload(op) 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) primary_files = driver.Files(metacluster, db_path="db-1", log_path="create-output-1", executable_path=executable_path, command_prefix=command_prefix) 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,
#!/usr/bin/env python # Copyright 2015-2016 RethinkDB, all rights reserved. import os, sys, time sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, 'common'))) import driver, scenario_common, utils, vcoptparse op = vcoptparse.OptParser() scenario_common.prepare_option_parser_mode_flags(op) _, command_prefix, server_options = scenario_common.parse_mode_flags(op.parse(sys.argv)) r = utils.import_python_driver() with driver.Cluster(initial_servers=["a", "b"], output_folder='.', command_prefix=command_prefix, extra_options=server_options) as cluster: utils.print_with_time("Establishing ReQl connections") conn = r.connect(host=cluster[0].host, port=cluster[0].driver_port) utils.print_with_time("Creating a table") r.db_create("test").run(conn) res = r.table_create("test", replicas=2).run(conn) table_uuid = res["config_changes"][0]["new_val"]["id"] r.table("test").wait(wait_for="all_replicas_ready").run(conn) r.table("test").insert(r.range(1000).map({"value": r.row})).run(conn) assert os.path.exists(os.path.join(cluster[0].data_path, table_uuid)) assert os.path.exists(os.path.join(cluster[1].data_path, table_uuid)) utils.print_with_time("Removing one replica")