def setup(): utils.zk_setup() # start mysql instance external to the test setup_procs = [master_tablet.init_mysql(), replica_tablet.init_mysql()] utils.wait_procs(setup_procs) setup_tablets()
def setUpModule(): try: utils.zk_setup() except: tearDownModule() raise
def setup(): utils.zk_setup() setup_procs = [ shard_0_master.init_mysql(), shard_0_replica.init_mysql(), shard_1_master.init_mysql(), shard_1_replica.init_mysql(), ] utils.wait_procs(setup_procs)
def setUpModule(): try: utils.zk_setup() # start mysql instance external to the test setup_procs = [master_tablet.init_mysql(), replica_tablet.init_mysql()] utils.wait_procs(setup_procs) setup_tablets() except: tearDownModule() raise
def setUpModule(): try: utils.zk_setup() setup_procs = [t.init_mysql() for t in tablets] utils.wait_procs(setup_procs) vtctld.start() except: tearDownModule() raise
def setup(): utils.zk_setup() # start mysql instance external to the test setup_procs = [ tablet_62344.init_mysql(), tablet_62044.init_mysql(), tablet_41983.init_mysql(), tablet_31981.init_mysql(), ] utils.wait_procs(setup_procs)
def setup(): utils.zk_setup() setup_procs = [ shard_0_master.init_mysql(), shard_0_replica1.init_mysql(), shard_0_replica2.init_mysql(), shard_0_rdonly.init_mysql(), shard_0_backup.init_mysql(), shard_1_master.init_mysql(), shard_1_replica1.init_mysql(), ] utils.wait_procs(setup_procs)
def setup(): utils.zk_setup() utils.prog_compile(['mysqlctl', 'vtaction', 'vtctl', 'vttablet', ]) # start mysql instance external to the test setup_procs = [master_tablet.init_mysql(), replica_tablet.init_mysql() ] utils.wait_procs(setup_procs) setup_tablets()
def setUpModule(): try: utils.zk_setup() setup_procs = [ shard_0_master.init_mysql(), shard_0_replica.init_mysql(), shard_1_master.init_mysql(), shard_1_replica.init_mysql(), ] utils.wait_procs(setup_procs) except: tearDownModule() raise
def setUpModule(): try: utils.zk_setup(add_bad_host=True) # start mysql instance external to the test setup_procs = [ tablet_62344.init_mysql(), tablet_62044.init_mysql(), tablet_41983.init_mysql(), tablet_31981.init_mysql(), ] utils.wait_procs(setup_procs) except: tearDownModule() raise
def setUpModule(): logging.debug("in setUpModule") try: utils.zk_setup() # start mysql instance external to the test setup_procs = [shard_0_master.init_mysql(), shard_0_replica.init_mysql(), shard_1_master.init_mysql(), shard_1_replica.init_mysql() ] utils.wait_procs(setup_procs) setup_tablets() except: tearDownModule() raise
def setup(): utils.zk_setup() utils.debug("Creating certificates") os.makedirs(cert_dir) # Create CA certificate ca_key = cert_dir + "/ca-key.pem" ca_cert = cert_dir + "/ca-cert.pem" openssl(["genrsa", "-out", cert_dir + "/ca-key.pem"]) ca_config = cert_dir + "/ca.config" with open(ca_config, 'w') as fd: fd.write(""" [ req ] default_bits = 1024 default_keyfile = keyfile.pem distinguished_name = req_distinguished_name attributes = req_attributes prompt = no output_password = mypass [ req_distinguished_name ] C = US ST = California L = Mountain View O = Google OU = Vitess CN = Mysql CA emailAddress = [email protected] [ req_attributes ] challengePassword = A challenge password """) openssl(["req", "-new", "-x509", "-nodes", "-days", "3600", "-batch", "-config", ca_config, "-key", ca_key, "-out", ca_cert]) # Create mysql server certificate, remove passphrase, and sign it server_key = cert_dir + "/server-key.pem" server_cert = cert_dir + "/server-cert.pem" server_req = cert_dir + "/server-req.pem" server_config = cert_dir + "/server.config" with open(server_config, 'w') as fd: fd.write(""" [ req ] default_bits = 1024 default_keyfile = keyfile.pem distinguished_name = req_distinguished_name attributes = req_attributes prompt = no output_password = mypass [ req_distinguished_name ] C = US ST = California L = Mountain View O = Google OU = Vitess CN = Mysql Server emailAddress = [email protected] [ req_attributes ] challengePassword = A challenge password """) openssl(["req", "-newkey", "rsa:2048", "-days", "3600", "-nodes", "-batch", "-config", server_config, "-keyout", server_key, "-out", server_req]) openssl(["rsa", "-in", server_key, "-out", server_key]) openssl(["x509", "-req", "-in", server_req, "-days", "3600", "-CA", ca_cert, "-CAkey", ca_key, "-set_serial", "01", "-out", server_cert]) # Create mysql client certificate, remove passphrase, and sign it client_key = cert_dir + "/client-key.pem" client_cert = cert_dir + "/client-cert.pem" client_req = cert_dir + "/client-req.pem" client_config = cert_dir + "/client.config" with open(client_config, 'w') as fd: fd.write(""" [ req ] default_bits = 1024 default_keyfile = keyfile.pem distinguished_name = req_distinguished_name attributes = req_attributes prompt = no output_password = mypass [ req_distinguished_name ] C = US ST = California L = Mountain View O = Google OU = Vitess CN = Mysql Client emailAddress = [email protected] [ req_attributes ] challengePassword = A challenge password """) openssl(["req", "-newkey", "rsa:2048", "-days", "3600", "-nodes", "-batch", "-config", client_config, "-keyout", client_key, "-out", client_req]) openssl(["rsa", "-in", client_key, "-out", client_key]) openssl(["x509", "-req", "-in", client_req, "-days", "3600", "-CA", ca_cert, "-CAkey", ca_key, "-set_serial", "02", "-out", client_cert]) # Create vt server certificate, remove passphrase, and sign it vt_server_key = cert_dir + "/vt-server-key.pem" vt_server_cert = cert_dir + "/vt-server-cert.pem" vt_server_req = cert_dir + "/vt-server-req.pem" openssl(["req", "-newkey", "rsa:2048", "-days", "3600", "-nodes", "-batch", "-keyout", vt_server_key, "-out", vt_server_req]) openssl(["rsa", "-in", vt_server_key, "-out", vt_server_key]) openssl(["x509", "-req", "-in", vt_server_req, "-days", "3600", "-CA", ca_cert, "-CAkey", ca_key, "-set_serial", "03", "-out", vt_server_cert]) extra_my_cnf = cert_dir + "/secure.cnf" fd = open(extra_my_cnf, "w") fd.write("ssl-ca=" + ca_cert + "\n") fd.write("ssl-cert=" + server_cert + "\n") fd.write("ssl-key=" + server_key + "\n") fd.close() setup_procs = [ shard_0_master.init_mysql(extra_my_cnf=extra_my_cnf), shard_0_slave.init_mysql(extra_my_cnf=extra_my_cnf), ] utils.wait_procs(setup_procs)
def setUpModule(): try: utils.zk_setup() logging.debug("Creating certificates") os.makedirs(cert_dir) # Create CA certificate ca_key = cert_dir + "/ca-key.pem" ca_cert = cert_dir + "/ca-cert.pem" openssl(["genrsa", "-out", cert_dir + "/ca-key.pem"]) ca_config = cert_dir + "/ca.config" with open(ca_config, 'w') as fd: fd.write(""" [ req ] default_bits = 1024 default_keyfile = keyfile.pem distinguished_name = req_distinguished_name attributes = req_attributes prompt = no output_password = mypass [ req_distinguished_name ] C = US ST = California L = Mountain View O = Google OU = Vitess CN = Mysql CA emailAddress = [email protected] [ req_attributes ] challengePassword = A challenge password """) openssl(["req", "-new", "-x509", "-nodes", "-days", "3600", "-batch", "-config", ca_config, "-key", ca_key, "-out", ca_cert]) # Create mysql server certificate, remove passphrase, and sign it server_key = cert_dir + "/server-key.pem" server_cert = cert_dir + "/server-cert.pem" server_req = cert_dir + "/server-req.pem" server_config = cert_dir + "/server.config" with open(server_config, 'w') as fd: fd.write(""" [ req ] default_bits = 1024 default_keyfile = keyfile.pem distinguished_name = req_distinguished_name attributes = req_attributes prompt = no output_password = mypass [ req_distinguished_name ] C = US ST = California L = Mountain View O = Google OU = Vitess CN = Mysql Server emailAddress = [email protected] [ req_attributes ] challengePassword = A challenge password """) openssl(["req", "-newkey", "rsa:2048", "-days", "3600", "-nodes", "-batch", "-config", server_config, "-keyout", server_key, "-out", server_req]) openssl(["rsa", "-in", server_key, "-out", server_key]) openssl(["x509", "-req", "-in", server_req, "-days", "3600", "-CA", ca_cert, "-CAkey", ca_key, "-set_serial", "01", "-out", server_cert]) # Create mysql client certificate, remove passphrase, and sign it client_key = cert_dir + "/client-key.pem" client_cert = cert_dir + "/client-cert.pem" client_req = cert_dir + "/client-req.pem" client_config = cert_dir + "/client.config" with open(client_config, 'w') as fd: fd.write(""" [ req ] default_bits = 1024 default_keyfile = keyfile.pem distinguished_name = req_distinguished_name attributes = req_attributes prompt = no output_password = mypass [ req_distinguished_name ] C = US ST = California L = Mountain View O = Google OU = Vitess CN = Mysql Client emailAddress = [email protected] [ req_attributes ] challengePassword = A challenge password """) openssl(["req", "-newkey", "rsa:2048", "-days", "3600", "-nodes", "-batch", "-config", client_config, "-keyout", client_key, "-out", client_req]) openssl(["rsa", "-in", client_key, "-out", client_key]) openssl(["x509", "-req", "-in", client_req, "-days", "3600", "-CA", ca_cert, "-CAkey", ca_key, "-set_serial", "02", "-out", client_cert]) # Create vt server certificate, remove passphrase, and sign it vt_server_key = cert_dir + "/vt-server-key.pem" vt_server_cert = cert_dir + "/vt-server-cert.pem" vt_server_req = cert_dir + "/vt-server-req.pem" openssl(["req", "-newkey", "rsa:2048", "-days", "3600", "-nodes", "-batch", "-keyout", vt_server_key, "-out", vt_server_req]) openssl(["rsa", "-in", vt_server_key, "-out", vt_server_key]) openssl(["x509", "-req", "-in", vt_server_req, "-days", "3600", "-CA", ca_cert, "-CAkey", ca_key, "-set_serial", "03", "-out", vt_server_cert]) extra_my_cnf = cert_dir + "/secure.cnf" fd = open(extra_my_cnf, "w") fd.write("ssl-ca=" + ca_cert + "\n") fd.write("ssl-cert=" + server_cert + "\n") fd.write("ssl-key=" + server_key + "\n") fd.close() setup_procs = [ shard_0_master.init_mysql(extra_my_cnf=extra_my_cnf), shard_0_slave.init_mysql(extra_my_cnf=extra_my_cnf), ] utils.wait_procs(setup_procs) utils.run_vtctl('CreateKeyspace test_keyspace') shard_0_master.init_tablet('master', 'test_keyspace', '0') shard_0_slave.init_tablet('replica', 'test_keyspace', '0') utils.run_vtctl('RebuildKeyspaceGraph test_keyspace', auto_log=True) # create databases so vttablet can start behaving normally shard_0_master.create_db('vt_test_keyspace') shard_0_slave.create_db('vt_test_keyspace') except: tearDownModule() raise
def setup(): utils.zk_setup() utils.debug("Creating certificates") os.makedirs(cert_dir) # Create CA certificate ca_key = cert_dir + "/ca-key.pem" ca_cert = cert_dir + "/ca-cert.pem" openssl(["genrsa", "-out", cert_dir + "/ca-key.pem"]) ca_config = cert_dir + "/ca.config" with open(ca_config, 'w') as fd: fd.write(""" [ req ] default_bits = 1024 default_keyfile = keyfile.pem distinguished_name = req_distinguished_name attributes = req_attributes prompt = no output_password = mypass [ req_distinguished_name ] C = US ST = California L = Mountain View O = Google OU = Vitess CN = Mysql CA emailAddress = [email protected] [ req_attributes ] challengePassword = A challenge password """) openssl([ "req", "-new", "-x509", "-nodes", "-days", "3600", "-batch", "-config", ca_config, "-key", ca_key, "-out", ca_cert ]) # Create mysql server certificate, remove passphrase, and sign it server_key = cert_dir + "/server-key.pem" server_cert = cert_dir + "/server-cert.pem" server_req = cert_dir + "/server-req.pem" server_config = cert_dir + "/server.config" with open(server_config, 'w') as fd: fd.write(""" [ req ] default_bits = 1024 default_keyfile = keyfile.pem distinguished_name = req_distinguished_name attributes = req_attributes prompt = no output_password = mypass [ req_distinguished_name ] C = US ST = California L = Mountain View O = Google OU = Vitess CN = Mysql Server emailAddress = [email protected] [ req_attributes ] challengePassword = A challenge password """) openssl([ "req", "-newkey", "rsa:2048", "-days", "3600", "-nodes", "-batch", "-config", server_config, "-keyout", server_key, "-out", server_req ]) openssl(["rsa", "-in", server_key, "-out", server_key]) openssl([ "x509", "-req", "-in", server_req, "-days", "3600", "-CA", ca_cert, "-CAkey", ca_key, "-set_serial", "01", "-out", server_cert ]) # Create mysql client certificate, remove passphrase, and sign it client_key = cert_dir + "/client-key.pem" client_cert = cert_dir + "/client-cert.pem" client_req = cert_dir + "/client-req.pem" client_config = cert_dir + "/client.config" with open(client_config, 'w') as fd: fd.write(""" [ req ] default_bits = 1024 default_keyfile = keyfile.pem distinguished_name = req_distinguished_name attributes = req_attributes prompt = no output_password = mypass [ req_distinguished_name ] C = US ST = California L = Mountain View O = Google OU = Vitess CN = Mysql Client emailAddress = [email protected] [ req_attributes ] challengePassword = A challenge password """) openssl([ "req", "-newkey", "rsa:2048", "-days", "3600", "-nodes", "-batch", "-config", client_config, "-keyout", client_key, "-out", client_req ]) openssl(["rsa", "-in", client_key, "-out", client_key]) openssl([ "x509", "-req", "-in", client_req, "-days", "3600", "-CA", ca_cert, "-CAkey", ca_key, "-set_serial", "02", "-out", client_cert ]) # Create vt server certificate, remove passphrase, and sign it vt_server_key = cert_dir + "/vt-server-key.pem" vt_server_cert = cert_dir + "/vt-server-cert.pem" vt_server_req = cert_dir + "/vt-server-req.pem" openssl([ "req", "-newkey", "rsa:2048", "-days", "3600", "-nodes", "-batch", "-keyout", vt_server_key, "-out", vt_server_req ]) openssl(["rsa", "-in", vt_server_key, "-out", vt_server_key]) openssl([ "x509", "-req", "-in", vt_server_req, "-days", "3600", "-CA", ca_cert, "-CAkey", ca_key, "-set_serial", "03", "-out", vt_server_cert ]) extra_my_cnf = cert_dir + "/secure.cnf" fd = open(extra_my_cnf, "w") fd.write("ssl-ca=" + ca_cert + "\n") fd.write("ssl-cert=" + server_cert + "\n") fd.write("ssl-key=" + server_key + "\n") fd.close() setup_procs = [ shard_0_master.init_mysql(extra_my_cnf=extra_my_cnf), shard_0_slave.init_mysql(extra_my_cnf=extra_my_cnf), ] utils.wait_procs(setup_procs) utils.run_vtctl('CreateKeyspace test_keyspace') shard_0_master.init_tablet('master', 'test_keyspace', '0') shard_0_slave.init_tablet('replica', 'test_keyspace', '0') utils.run_vtctl('RebuildShardGraph test_keyspace/0', auto_log=True) utils.run_vtctl('RebuildKeyspaceGraph test_keyspace', auto_log=True) # create databases so vttablet can start behaving normally shard_0_master.create_db('vt_test_keyspace') shard_0_slave.create_db('vt_test_keyspace')
def setup(): utils.prog_compile(['zkclient2', ]) utils.zk_setup()
def setUp(self): utils.zk_setup() utils.setup() if self.vttop is None: raise EnvironmentError("VTTOP not defined") if self.vtroot is None: raise EnvironmentError("VTROOT not defined") framework.execute('go build', verbose=utils.options.verbose, cwd=self.vttop+'/go/cmd/mysqlctl') utils.wait_procs([self.tablet.init_mysql()]) self.tablet.mquery("", ["create database vt_test_keyspace", "set global read_only = off"]) self.mysql_conn, mcu = self.tablet.connect('vt_test_keyspace') self.clean_sqls = [] self.init_sqls = [] clean_mode = False with open(os.path.join(self.vttop, "test", "test_data", "test_schema.sql")) as f: for line in f: line = line.rstrip() if line == "# clean": clean_mode = True if line=='' or line.startswith("#"): continue if clean_mode: self.clean_sqls.append(line) else: self.init_sqls.append(line) try: for line in self.init_sqls: mcu.execute(line, {}) finally: mcu.close() utils.run_vtctl('CreateKeyspace -force /zk/global/vt/keyspaces/test_keyspace') self.tablet.init_tablet('master', 'test_keyspace', '0') customrules = '/tmp/customrules.json' self.create_customrules(customrules) schema_override = '/tmp/schema_override.json' self.create_schema_override(schema_override) if utils.options.memcache: self.tablet.start_vttablet(memcache=True, customrules=customrules, schema_override=schema_override) else: self.tablet.start_vttablet(customrules=customrules, schema_override=schema_override) # FIXME(szopa): This is necessary here only because of a bug that # makes the qs reload its config only after an action. utils.run_vtctl('Ping ' + self.tablet.zk_tablet_path) for i in range(30): try: self.conn = self.connect() self.txlogger = subprocess.Popen(['curl', '-s', '-N', 'http://localhost:9461/debug/txlog'], stdout=open('/tmp/vtocc_txlog.log', 'w')) self.txlog = framework.Tailer(open('/tmp/vtocc_txlog.log'), flush=self.tablet.flush) self.log = framework.Tailer(open(os.path.join(self.tablet.tablet_dir, 'vttablet.INFO')), flush=self.tablet.flush) querylog_file = '/tmp/vtocc_streamlog_%s.log' % self.tablet.port utils.run_bg(['curl', '-s', '-N', 'http://localhost:9461/debug/querylog?full=true'], stdout=open(querylog_file, 'w')) time.sleep(1) self.querylog = framework.Tailer(open(querylog_file), sleep=0.1) return except dbexceptions.OperationalError: if i == 29: raise time.sleep(1)
def setUp(self): utils.zk_setup() if self.vttop is None: raise EnvironmentError("VTTOP not defined") if self.vtroot is None: raise EnvironmentError("VTROOT not defined") framework.execute("go build", verbose=utils.options.verbose, cwd=self.vttop + "/go/cmd/mysqlctl") utils.wait_procs([self.tablet.init_mysql()]) self.tablet.mquery("", ["create database vt_test_keyspace", "set global read_only = off"]) self.mysql_conn, mcu = self.tablet.connect("vt_test_keyspace") self.clean_sqls = [] self.init_sqls = [] clean_mode = False with open(os.path.join(self.vttop, "test", "test_data", "test_schema.sql")) as f: for line in f: line = line.rstrip() if line == "# clean": clean_mode = True if line == "" or line.startswith("#"): continue if clean_mode: self.clean_sqls.append(line) else: self.init_sqls.append(line) try: for line in self.init_sqls: mcu.execute(line, {}) finally: mcu.close() utils.run_vtctl("CreateKeyspace -force /zk/global/vt/keyspaces/test_keyspace") self.tablet.init_tablet("master", "test_keyspace", "0") customrules = "/tmp/customrules.json" self.create_customrules(customrules) schema_override = "/tmp/schema_override.json" self.create_schema_override(schema_override) if utils.options.memcache: self.tablet.start_vttablet(memcache=True, customrules=customrules, schema_override=schema_override) else: self.tablet.start_vttablet(customrules=customrules, schema_override=schema_override) # FIXME(szopa): This is necessary here only because of a bug that # makes the qs reload its config only after an action. utils.run_vtctl("Ping " + self.tablet.zk_tablet_path) for i in range(30): try: self.conn = self.connect() self.querylog = framework.Tailer(open(self.tablet.querylog_file, "r")) self.log = framework.Tailer(open(self.tablet.logfile, "r")) self.txlogger = subprocess.Popen( ["curl", "-s", "-N", "http://localhost:9461/debug/txlog"], stdout=open("/tmp/vtocc_txlog.log", "w") ) self.txlog = framework.Tailer(open("/tmp/vtocc_txlog.log", "r")) return except dbexceptions.OperationalError: if i == 29: raise time.sleep(1)
def setUp(self): utils.zk_setup() utils.setup() if self.vttop is None: raise EnvironmentError("VTTOP not defined") if self.vtroot is None: raise EnvironmentError("VTROOT not defined") framework.execute('go build', verbose=utils.options.verbose, cwd=self.vttop + '/go/cmd/mysqlctl') utils.wait_procs([self.tablet.init_mysql()]) self.tablet.mquery( "", ["create database vt_test_keyspace", "set global read_only = off"]) self.mysql_conn, mcu = self.tablet.connect('vt_test_keyspace') self.clean_sqls = [] self.init_sqls = [] clean_mode = False with open( os.path.join(self.vttop, "test", "test_data", "test_schema.sql")) as f: for line in f: line = line.rstrip() if line == "# clean": clean_mode = True if line == '' or line.startswith("#"): continue if clean_mode: self.clean_sqls.append(line) else: self.init_sqls.append(line) try: for line in self.init_sqls: mcu.execute(line, {}) finally: mcu.close() utils.run_vtctl( 'CreateKeyspace -force /zk/global/vt/keyspaces/test_keyspace') self.tablet.init_tablet('master', 'test_keyspace', '0') customrules = '/tmp/customrules.json' self.create_customrules(customrules) schema_override = '/tmp/schema_override.json' self.create_schema_override(schema_override) if utils.options.memcache: self.tablet.start_vttablet(memcache=True, customrules=customrules, schema_override=schema_override) else: self.tablet.start_vttablet(customrules=customrules, schema_override=schema_override) # FIXME(szopa): This is necessary here only because of a bug that # makes the qs reload its config only after an action. utils.run_vtctl('Ping ' + self.tablet.zk_tablet_path) for i in range(30): try: self.conn = self.connect() self.txlogger = subprocess.Popen( ['curl', '-s', '-N', 'http://localhost:9461/debug/txlog'], stdout=open('/tmp/vtocc_txlog.log', 'w')) self.txlog = framework.Tailer(open('/tmp/vtocc_txlog.log'), flush=self.tablet.flush) self.log = framework.Tailer(open( os.path.join(self.tablet.tablet_dir, 'vttablet.INFO')), flush=self.tablet.flush) querylog_file = '/tmp/vtocc_streamlog_%s.log' % self.tablet.port utils.run_bg([ 'curl', '-s', '-N', 'http://localhost:9461/debug/querylog?full=true' ], stdout=open(querylog_file, 'w')) time.sleep(1) self.querylog = framework.Tailer(open(querylog_file), sleep=0.1) return except dbexceptions.OperationalError: if i == 29: raise time.sleep(1)
def setup(): utils.prog_compile([ 'zkclient2', ]) utils.zk_setup()