def main(cmdline_options): topology = vttest_pb2.VTTestTopology() if cmdline_options.proto_topo: # Text-encoded proto topology object, just parse it. topology = text_format.Parse(cmdline_options.proto_topo, topology) if not topology.cells: topology.cells.append('test') else: cells = [] keyspaces = [] shard_counts = [] if cmdline_options.cells: cells = cmdline_options.cells.split(',') if cmdline_options.keyspaces: keyspaces = cmdline_options.keyspaces.split(',') if cmdline_options.num_shards: shard_counts = [ int(x) for x in cmdline_options.num_shards.split(',') ] for cell in cells: topology.cells.append(cell) for keyspace, num_shards in zip(keyspaces, shard_counts): ks = topology.keyspaces.add(name=keyspace) for shard in sharding_utils.get_shard_names(num_shards): ks.shards.add(name=shard) ks.replica_count = cmdline_options.replica_count ks.rdonly_count = cmdline_options.rdonly_count environment.base_port = cmdline_options.port init_data_opts = None if cmdline_options.initialize_with_random_data: init_data_opts = init_data_options.InitDataOptions() init_data_opts.rng_seed = cmdline_options.rng_seed init_data_opts.min_table_shard_size = cmdline_options.min_table_shard_size init_data_opts.max_table_shard_size = cmdline_options.max_table_shard_size init_data_opts.null_probability = cmdline_options.null_probability with local_database.LocalDatabase( topology, cmdline_options.schema_dir, cmdline_options.mysql_only, init_data_opts, web_dir=cmdline_options.web_dir, web_dir2=cmdline_options.web_dir2, default_schema_dir=cmdline_options.default_schema_dir, extra_my_cnf=os.path.join(os.environ['VTTOP'], 'config/mycnf/vtcombo.cnf')) as local_db: print json.dumps(local_db.config()) sys.stdout.flush() try: raw_input() except EOFError: sys.stderr.write( 'WARNING: %s: No empty line was received on stdin.' ' Instead, stdin was closed and the cluster will be shut down now.' ' Make sure to send the empty line instead to proactively shutdown' ' the local cluster. For example, did you forget the shutdown in' ' your test\'s tearDown()?\n' % os.path.basename(__file__))
def setUpClass(cls): """Set up two keyspaces: one unsharded, one with two shards.""" topology = vttest_pb2.VTTestTopology() topology.cells.append('test') topology.cells.append('test2') keyspace = topology.keyspaces.add(name='test_keyspace') keyspace.replica_count = 2 keyspace.rdonly_count = 2 keyspace.shards.add(name='-80') keyspace.shards.add(name='80-') keyspace2 = topology.keyspaces.add(name='test_keyspace2') keyspace2.shards.add(name='0') keyspace2.replica_count = 2 keyspace2.rdonly_count = 1 cls.driver = environment.create_webdriver() port = environment.reserve_ports(1) vttest_environment.base_port = port environment.reset_mysql_flavor() cls.db = local_database.LocalDatabase( topology, os.path.join(environment.vttop, 'test/vttest_schema'), False, None, web_dir=os.path.join(environment.vttop, 'web/vtctld'), default_schema_dir=os.path.join( environment.vttop, 'test/vttest_schema/default'), web_dir2=os.path.join(environment.vttop, 'web/vtctld2/app')) cls.db.setup() cls.vtctld_addr = 'http://localhost:%d' % cls.db.config()['port'] utils.pause('Paused test after vtcombo was started.\n' 'For manual testing, connect to vtctld: %s' % cls.vtctld_addr)
def main(cmdline_options): topology = vttest_pb2.VTTestTopology() if cmdline_options.proto_topo: # Text-encoded proto topology object, just parse it. topology = text_format.Parse(cmdline_options.proto_topo, topology) environment.base_port = cmdline_options.port init_data_opts = None if cmdline_options.initialize_with_random_data: init_data_opts = init_data_options.InitDataOptions() init_data_opts.rng_seed = cmdline_options.rng_seed init_data_opts.min_table_shard_size = cmdline_options.min_table_shard_size init_data_opts.max_table_shard_size = cmdline_options.max_table_shard_size init_data_opts.null_probability = cmdline_options.null_probability with local_database.LocalDatabase( topology, cmdline_options.schema_dir, cmdline_options.vschema, cmdline_options.mysql_only, init_data_opts, web_dir=cmdline_options.web_dir) as local_db: print json.dumps(local_db.config()) sys.stdout.flush() try: raw_input() except EOFError: sys.stderr.write( 'WARNING: %s: No empty line was received on stdin.' ' Instead, stdin was closed and the cluster will be shut down now.' ' Make sure to send the empty line instead to proactively shutdown' ' the local cluster. For example, did you forget the shutdown in' ' your test\'s tearDown()?\n' % os.path.basename(__file__))
def main(port, topology, schema_dir, vschema, mysql_only, web_dir=None): shards = [] for shard in topology.split(','): m = shard_exp.match(shard) if m: shards.append( vt_processes.ShardInfo(m.group(1), m.group(2), m.group(3))) else: sys.stderr.write('invalid --shard flag format: %s\n' % shard) sys.exit(1) environment.base_port = port with local_database.LocalDatabase(shards, schema_dir, vschema, mysql_only, web_dir=web_dir) as local_db: print json.dumps(local_db.config()) sys.stdout.flush() try: raw_input() except EOFError: sys.stderr.write( 'WARNING: %s: No empty line was received on stdin.' ' Instead, stdin was closed and the cluster will be shut down now.' ' Make sure to send the empty line instead to proactively shutdown' ' the local cluster. For example, did you forget the shutdown in' ' your test\'s tearDown()?\n' % os.path.basename(__file__))
def main(cmdline_options): topology = vttest_pb2.VTTestTopology() if cmdline_options.topology: # old style topology, will disappear soon. Build a new style # topology from it. keyspaces = {} for shard in cmdline_options.topology.split(','): m = shard_exp.match(shard) if not m: sys.stderr.write('invalid --shard flag format: %s\n' % shard) sys.exit(1) keyspace = m.group(1) shard_name = m.group(2) db_name = m.group(3) if keyspace not in keyspaces: kpb = topology.keyspaces.add(name=keyspace) keyspaces[keyspace] = kpb keyspaces[keyspace].shards.add(name=shard_name, db_name_override=db_name) elif cmdline_options.proto_topo: # new style topology, just parse it as text topology = text_format.Parse(cmdline_options.proto_topo, topology) environment.base_port = cmdline_options.port init_data_opts = None if cmdline_options.initialize_with_random_data: init_data_opts = init_data_options.InitDataOptions() init_data_opts.rng_seed = cmdline_options.rng_seed init_data_opts.min_table_shard_size = cmdline_options.min_table_shard_size init_data_opts.max_table_shard_size = cmdline_options.max_table_shard_size init_data_opts.null_probability = cmdline_options.null_probability with local_database.LocalDatabase( topology, cmdline_options.schema_dir, cmdline_options.vschema, cmdline_options.mysql_only, init_data_opts, web_dir=cmdline_options.web_dir) as local_db: print json.dumps(local_db.config()) sys.stdout.flush() try: raw_input() except EOFError: sys.stderr.write( 'WARNING: %s: No empty line was received on stdin.' ' Instead, stdin was closed and the cluster will be shut down now.' ' Make sure to send the empty line instead to proactively shutdown' ' the local cluster. For example, did you forget the shutdown in' ' your test\'s tearDown()?\n' % os.path.basename(__file__))
def setUpClass(cls): """Set up two keyspaces: one unsharded, one with two shards.""" topology = vttest_pb2.VTTestTopology() topology.cells.append('test') topology.cells.append('test2') keyspace = topology.keyspaces.add(name='test_keyspace') keyspace.replica_count = 2 keyspace.rdonly_count = 2 keyspace.shards.add(name='-80') keyspace.shards.add(name='80-') keyspace2 = topology.keyspaces.add(name='test_keyspace2') keyspace2.shards.add(name='0') keyspace2.replica_count = 2 keyspace2.rdonly_count = 1 if os.environ.get('CI') == 'true' and os.environ.get( 'TRAVIS') == 'true': username = os.environ['SAUCE_USERNAME'] access_key = os.environ['SAUCE_ACCESS_KEY'] capabilities = {} capabilities['tunnel-identifier'] = os.environ['TRAVIS_JOB_NUMBER'] capabilities['build'] = os.environ['TRAVIS_BUILD_NUMBER'] capabilities['platform'] = 'Linux' capabilities['browserName'] = 'chrome' hub_url = '%s:%s@localhost:4445' % (username, access_key) cls.driver = webdriver.Remote(desired_capabilities=capabilities, command_executor='http://%s/wd/hub' % hub_url) else: os.environ['webdriver.chrome.driver'] = os.path.join( environment.vtroot, 'dist') # Only testing against Chrome for now cls.driver = webdriver.Chrome() cls.driver.set_window_position(0, 0) cls.driver.set_window_size(1920, 1280) port = environment.reserve_ports(1) vttest_environment.base_port = port mysql_flavor.set_mysql_flavor(None) cls.db = local_database.LocalDatabase( topology, os.path.join(environment.vttop, 'test/vttest_schema'), False, None, web_dir=os.path.join(environment.vttop, 'web/vtctld'), default_schema_dir=os.path.join(environment.vttop, 'test/vttest_schema/default'), web_dir2=os.path.join(environment.vttop, 'web/vtctld2/app')) cls.db.setup() cls.vtctld_addr = 'http://localhost:%d' % cls.db.config()['port'] utils.pause('Paused test after vtcombo was started.\n' 'For manual testing, connect to vtctld: %s' % cls.vtctld_addr)
def main(port, topology, schema_dir): shards = [] for shard in topology.split(','): m = shard_exp.match(shard) if m: shards.append( vt_processes.ShardInfo(m.group(1), m.group(2), m.group(3))) else: sys.stderr.write('invalid --shard flag format: %s\n' % shard) sys.exit(1) environment.base_port = port with local_database.LocalDatabase(shards, schema_dir) as local_db: print json.dumps(local_db.config()) sys.stdout.flush() raw_input()
def main(cmdline_options): shards = [] for shard in cmdline_options.topology.split(','): m = shard_exp.match(shard) if m: shards.append( vt_processes.ShardInfo(m.group(1), m.group(2), m.group(3))) else: sys.stderr.write('invalid --shard flag format: %s\n' % shard) sys.exit(1) environment.base_port = cmdline_options.port init_data_opts = None if cmdline_options.initialize_with_random_data: init_data_opts = init_data_options.InitDataOptions() init_data_opts.rng_seed = cmdline_options.rng_seed init_data_opts.min_table_shard_size = cmdline_options.min_table_shard_size init_data_opts.max_table_shard_size = cmdline_options.max_table_shard_size init_data_opts.null_probability = cmdline_options.null_probability with local_database.LocalDatabase( shards, cmdline_options.schema_dir, cmdline_options.vschema, cmdline_options.mysql_only, init_data_opts, web_dir=cmdline_options.web_dir) as local_db: print json.dumps(local_db.config()) sys.stdout.flush() try: raw_input() except EOFError: sys.stderr.write( 'WARNING: %s: No empty line was received on stdin.' ' Instead, stdin was closed and the cluster will be shut down now.' ' Make sure to send the empty line instead to proactively shutdown' ' the local cluster. For example, did you forget the shutdown in' ' your test\'s tearDown()?\n' % os.path.basename(__file__))