#!/usr/bin/env python # Copyright 2010-2014 RethinkDB, all rights reserved. '''Start two servers, with data on only one kill and remove the second and verify that the primary continues''' import sys, os, time startTime = time.time() sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, 'common'))) import driver, scenario_common, utils, vcoptparse, workload_runner op = vcoptparse.OptParser() op["workload"] = vcoptparse.PositionalArg() scenario_common.prepare_option_parser_mode_flags(op) opts = op.parse(sys.argv) _, command_prefix, serve_options = scenario_common.parse_mode_flags(opts) numNodes = 2 r = utils.import_python_driver() dbName, tableName = utils.get_test_db_table() print("Starting cluster of %d servers (%.2fs)" % (numNodes, time.time() - startTime)) with driver.Cluster(initial_servers=numNodes, output_folder='.', wait_until_ready=True, command_prefix=command_prefix, extra_options=serve_options) as cluster: print("Establishing ReQL Connection (%.2fs)" % (time.time() - startTime)) database_server = cluster[0] access_server = cluster[1] conn = r.connect(host=database_server.host, port=database_server.driver_port)
peak = current = self.initial for step in self.steps: current += step peak = max(current, peak) return peak def __repr__(self): return str(self.initial) + "".join( ("+" if s > 0 else "-") + str(abs(x)) for x in self.steps) op = vcoptparse.OptParser() workload_runner.prepare_option_parser_for_split_or_continuous_workload( op, allow_between=True) scenario_common.prepare_option_parser_mode_flags(op) op["sequence"] = vcoptparse.PositionalArg(converter=ReplicaSequence) opts = op.parse(sys.argv) _, command_prefix, serve_options = scenario_common.parse_mode_flags(opts) r = utils.import_python_driver() dbName, tableName = utils.get_test_db_table() numReplicas = opts["sequence"].peak() print('Starting cluster (%.2fs)' % (time.time() - startTime)) with driver.Cluster(output_folder='.') as cluster: print('Starting primary server (%.2fs)' % (time.time() - startTime)) primary_files = driver.Files(cluster.metacluster, db_path="db-primary",