def _test_sanity(self): # Start up a master mysql and vttablet utils.run_vtctl(['CreateKeyspace', '-force', 'test_keyspace']) utils.run_vtctl(['createshard', '-force', 'test_keyspace/0']) tablet_62344.init_tablet('master', 'test_keyspace', '0', parent=False) utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace']) utils.validate_topology() srvShard = utils.run_vtctl_json(['GetSrvShard', 'test_nj', 'test_keyspace/0']) self.assertEqual(srvShard['MasterCell'], 'test_nj') # if these statements don't run before the tablet it will wedge # waiting for the db to become accessible. this is more a bug than # a feature. tablet_62344.populate('vt_test_keyspace', self._create_vt_select_test, self._populate_vt_select_test) tablet_62344.start_vttablet() # make sure the query service is started right away result, _ = utils.run_vtctl(['Query', 'test_nj', 'test_keyspace', 'select * from vt_select_test'], mode=utils.VTCTL_VTCTL, trap_output=True) rows = result.splitlines() self.assertEqual(len(rows), 5, "expected 5 rows in vt_select_test: %s %s" % (str(rows), result)) # make sure direct dba queries work query_result = utils.run_vtctl_json(['ExecuteFetchAsDba', '-want_fields', tablet_62344.tablet_alias, 'select * from vt_test_keyspace.vt_select_test']) self.assertEqual(len(query_result['Rows']), 4, "expected 4 rows in vt_select_test: %s" % str(query_result)) self.assertEqual(len(query_result['Fields']), 2, "expected 2 fields in vt_select_test: %s" % str(query_result)) # check Ping / RefreshState utils.run_vtctl(['Ping', tablet_62344.tablet_alias]) utils.run_vtctl(['RefreshState', tablet_62344.tablet_alias]) # Quickly check basic actions. utils.run_vtctl(['SetReadOnly', tablet_62344.tablet_alias]) utils.wait_db_read_only(62344) utils.run_vtctl(['SetReadWrite', tablet_62344.tablet_alias]) utils.check_db_read_write(62344) utils.run_vtctl(['DemoteMaster', tablet_62344.tablet_alias]) utils.wait_db_read_only(62344) utils.validate_topology() utils.run_vtctl(['ValidateKeyspace', 'test_keyspace']) # not pinging tablets, as it enables replication checks, and they # break because we only have a single master, no slaves utils.run_vtctl(['ValidateShard', '-ping-tablets=false', 'test_keyspace/0']) srvShard = utils.run_vtctl_json(['GetSrvShard', 'test_nj', 'test_keyspace/0']) self.assertEqual(srvShard['MasterCell'], 'test_nj') tablet_62344.kill_vttablet() tablet_62344.init_tablet('idle') tablet_62344.scrap(force=True)
def _test_sanity(self): # Start up a master mysql and vttablet utils.run_vtctl(['CreateKeyspace', '-force', 'test_keyspace']) utils.run_vtctl(['createshard', '-force', 'test_keyspace/0']) tablet_62344.init_tablet('master', 'test_keyspace', '0', parent=False) utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace']) utils.validate_topology() srvShard = utils.run_vtctl_json(['GetSrvShard', 'test_nj', 'test_keyspace/0']) self.assertEqual(srvShard['MasterCell'], 'test_nj') # if these statements don't run before the tablet it will wedge # waiting for the db to become accessible. this is more a bug than # a feature. tablet_62344.populate('vt_test_keyspace', self._create_vt_select_test, self._populate_vt_select_test) tablet_62344.start_vttablet() # make sure the query service is started right away result, _ = utils.run_vtctl(['Query', 'test_nj', 'test_keyspace', 'select * from vt_select_test'], mode=utils.VTCTL_VTCTL, trap_output=True) rows = result.splitlines() self.assertEqual(len(rows), 5, "expected 5 rows in vt_select_test: %s %s" % (str(rows), result)) # make sure direct dba queries work query_result = utils.run_vtctl_json(['ExecuteFetch', '-want_fields', tablet_62344.tablet_alias, 'select * from vt_test_keyspace.vt_select_test']) self.assertEqual(len(query_result['Rows']), 4, "expected 4 rows in vt_select_test: %s" % str(query_result)) self.assertEqual(len(query_result['Fields']), 2, "expected 2 fields in vt_select_test: %s" % str(query_result)) # check Pings utils.run_vtctl(['Ping', tablet_62344.tablet_alias]) utils.run_vtctl(['RpcPing', tablet_62344.tablet_alias]) # Quickly check basic actions. utils.run_vtctl(['SetReadOnly', tablet_62344.tablet_alias]) utils.wait_db_read_only(62344) utils.run_vtctl(['SetReadWrite', tablet_62344.tablet_alias]) utils.check_db_read_write(62344) utils.run_vtctl(['DemoteMaster', tablet_62344.tablet_alias]) utils.wait_db_read_only(62344) utils.validate_topology() utils.run_vtctl(['ValidateKeyspace', 'test_keyspace']) # not pinging tablets, as it enables replication checks, and they # break because we only have a single master, no slaves utils.run_vtctl(['ValidateShard', '-ping-tablets=false', 'test_keyspace/0']) srvShard = utils.run_vtctl_json(['GetSrvShard', 'test_nj', 'test_keyspace/0']) self.assertEqual(srvShard['MasterCell'], 'test_nj') tablet_62344.kill_vttablet() tablet_62344.init_tablet('idle') tablet_62344.scrap(force=True)
def _test_sanity(self): # Start up a master mysql and vttablet utils.run_vtctl(['CreateKeyspace', '-force', 'test_keyspace']) utils.run_vtctl(['createshard', '-force', 'test_keyspace/0']) tablet_62344.init_tablet('master', 'test_keyspace', '0', parent=False) utils.run_vtctl( ['RebuildKeyspaceGraph', '-rebuild_srv_shards', 'test_keyspace']) utils.validate_topology() self._check_srv_shard() # if these statements don't run before the tablet it will wedge # waiting for the db to become accessible. this is more a bug than # a feature. tablet_62344.populate('vt_test_keyspace', self._create_vt_select_test, self._populate_vt_select_test) tablet_62344.start_vttablet() # make sure the query service is started right away qr = tablet_62344.execute('select * from vt_select_test') self.assertEqual(len(qr['Rows']), 4, 'expected 4 rows in vt_select_test: %s' % str(qr)) # make sure direct dba queries work query_result = utils.run_vtctl_json([ 'ExecuteFetchAsDba', tablet_62344.tablet_alias, 'select * from vt_test_keyspace.vt_select_test' ]) self.assertEqual( len(query_result['rows']), 4, 'expected 4 rows in vt_select_test: %s' % str(query_result)) self.assertEqual( len(query_result['fields']), 2, 'expected 2 fields in vt_select_test: %s' % str(query_result)) # check Ping / RefreshState utils.run_vtctl(['Ping', tablet_62344.tablet_alias]) utils.run_vtctl(['RefreshState', tablet_62344.tablet_alias]) # Quickly check basic actions. utils.run_vtctl(['SetReadOnly', tablet_62344.tablet_alias]) utils.wait_db_read_only(62344) utils.run_vtctl(['SetReadWrite', tablet_62344.tablet_alias]) utils.check_db_read_write(62344) utils.run_vtctl(['DemoteMaster', tablet_62344.tablet_alias]) utils.wait_db_read_only(62344) utils.validate_topology() utils.run_vtctl(['ValidateKeyspace', 'test_keyspace']) # not pinging tablets, as it enables replication checks, and they # break because we only have a single master, no slaves utils.run_vtctl( ['ValidateShard', '-ping-tablets=false', 'test_keyspace/0']) self._check_srv_shard() tablet_62344.kill_vttablet()
def _test_sanity(self): # Start up a master mysql and vttablet utils.run_vtctl(['CreateKeyspace', '-force', 'test_keyspace']) utils.run_vtctl(['createshard', '-force', 'test_keyspace/0']) tablet_62344.init_tablet('master', 'test_keyspace', '0', parent=False) utils.run_vtctl( ['RebuildKeyspaceGraph', '-rebuild_srv_shards', 'test_keyspace']) utils.validate_topology() self._check_srv_shard() # if these statements don't run before the tablet it will wedge # waiting for the db to become accessible. this is more a bug than # a feature. tablet_62344.populate('vt_test_keyspace', self._create_vt_select_test, self._populate_vt_select_test) tablet_62344.start_vttablet() # make sure the query service is started right away qr = tablet_62344.execute('select * from vt_select_test') self.assertEqual(len(qr['rows']), 4, 'expected 4 rows in vt_select_test: %s' % str(qr)) # make sure direct dba queries work query_result = utils.run_vtctl_json( ['ExecuteFetchAsDba', '-json', tablet_62344.tablet_alias, 'select * from vt_test_keyspace.vt_select_test']) self.assertEqual( len(query_result['rows']), 4, 'expected 4 rows in vt_select_test: %s' % str(query_result)) self.assertEqual( len(query_result['fields']), 2, 'expected 2 fields in vt_select_test: %s' % str(query_result)) # check Ping / RefreshState utils.run_vtctl(['Ping', tablet_62344.tablet_alias]) utils.run_vtctl(['RefreshState', tablet_62344.tablet_alias]) # Quickly check basic actions. utils.run_vtctl(['SetReadOnly', tablet_62344.tablet_alias]) utils.wait_db_read_only(62344) utils.run_vtctl(['SetReadWrite', tablet_62344.tablet_alias]) utils.check_db_read_write(62344) utils.run_vtctl(['DemoteMaster', tablet_62344.tablet_alias]) utils.wait_db_read_only(62344) utils.validate_topology() utils.run_vtctl(['ValidateKeyspace', 'test_keyspace']) # not pinging tablets, as it enables replication checks, and they # break because we only have a single master, no slaves utils.run_vtctl(['ValidateShard', '-ping-tablets=false', 'test_keyspace/0']) self._check_srv_shard() tablet_62344.kill_vttablet()
def run_test_sanity(): # Start up a master mysql and vttablet utils.run_vtctl('CreateKeyspace -force test_keyspace') utils.run_vtctl('CreateShard -force test_keyspace/0') tablet_62344.init_tablet('master', 'test_keyspace', '0', parent=False) utils.run_vtctl('RebuildShardGraph test_keyspace/0') utils.run_vtctl('RebuildKeyspaceGraph test_keyspace') utils.validate_topology() # if these statements don't run before the tablet it will wedge waiting for the # db to become accessible. this is more a bug than a feature. tablet_62344.populate('vt_test_keyspace', create_vt_select_test, populate_vt_select_test) tablet_62344.start_vttablet() # make sure the query service is started right away result, _ = utils.run_vtctl( 'Query test_nj test_keyspace "select * from vt_select_test"', trap_output=True) rows = result.splitlines() if len(rows) != 5: raise utils.TestError("expected 5 rows in vt_select_test", rows, result) # check Pings utils.run_vtctl('Ping ' + tablet_62344.tablet_alias) utils.run_vtctl('RpcPing ' + tablet_62344.tablet_alias) # Quickly check basic actions. utils.run_vtctl('SetReadOnly ' + tablet_62344.tablet_alias) utils.wait_db_read_only(62344) utils.run_vtctl('SetReadWrite ' + tablet_62344.tablet_alias) utils.check_db_read_write(62344) utils.run_vtctl('DemoteMaster ' + tablet_62344.tablet_alias) utils.wait_db_read_only(62344) utils.validate_topology() utils.run_vtctl('ValidateKeyspace test_keyspace') # not pinging tablets, as it enables replication checks, and they # break because we only have a single master, no slaves utils.run_vtctl('ValidateShard -ping-tablets=false test_keyspace/0') tablet_62344.kill_vttablet() tablet_62344.init_tablet('idle') tablet_62344.scrap(force=True)
def _test_sanity(self): # Start up a master mysql and vttablet utils.run_vtctl(['CreateKeyspace', '-force', 'test_keyspace']) utils.run_vtctl(['createshard', '-force', 'test_keyspace/0']) tablet_62344.init_tablet('master', 'test_keyspace', '0', parent=False) utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace']) utils.validate_topology() # if these statements don't run before the tablet it will wedge waiting for the # db to become accessible. this is more a bug than a feature. tablet_62344.populate('vt_test_keyspace', self._create_vt_select_test, self._populate_vt_select_test) tablet_62344.start_vttablet() # make sure the query service is started right away result, _ = utils.run_vtctl([ 'Query', 'test_nj', 'test_keyspace', 'select * from vt_select_test' ], trap_output=True) rows = result.splitlines() self.assertEqual( len(rows), 5, "expected 5 rows in vt_select_test: %s %s" % (str(rows), result)) # check Pings utils.run_vtctl(['Ping', tablet_62344.tablet_alias]) utils.run_vtctl(['RpcPing', tablet_62344.tablet_alias]) # Quickly check basic actions. utils.run_vtctl(['SetReadOnly', tablet_62344.tablet_alias]) utils.wait_db_read_only(62344) utils.run_vtctl(['SetReadWrite', tablet_62344.tablet_alias]) utils.check_db_read_write(62344) utils.run_vtctl(['DemoteMaster', tablet_62344.tablet_alias]) utils.wait_db_read_only(62344) utils.validate_topology() utils.run_vtctl('ValidateKeyspace test_keyspace') # not pinging tablets, as it enables replication checks, and they # break because we only have a single master, no slaves utils.run_vtctl('ValidateShard -ping-tablets=false test_keyspace/0') tablet_62344.kill_vttablet() tablet_62344.init_tablet('idle') tablet_62344.scrap(force=True)
def _test_sanity(self): # Start up a master mysql and vttablet utils.run_vtctl(["CreateKeyspace", "-force", "test_keyspace"]) utils.run_vtctl(["createshard", "-force", "test_keyspace/0"]) tablet_62344.init_tablet("master", "test_keyspace", "0", parent=False) utils.run_vtctl(["RebuildKeyspaceGraph", "-rebuild_srv_shards", "test_keyspace"]) utils.validate_topology() self._check_srv_shard() # if these statements don't run before the tablet it will wedge # waiting for the db to become accessible. this is more a bug than # a feature. tablet_62344.populate("vt_test_keyspace", self._create_vt_select_test, self._populate_vt_select_test) tablet_62344.start_vttablet() # make sure the query service is started right away qr = tablet_62344.execute("select * from vt_select_test") self.assertEqual(len(qr["rows"]), 4, "expected 4 rows in vt_select_test: %s" % str(qr)) # make sure direct dba queries work query_result = utils.run_vtctl_json( ["ExecuteFetchAsDba", "-json", tablet_62344.tablet_alias, "select * from vt_test_keyspace.vt_select_test"] ) self.assertEqual(len(query_result["rows"]), 4, "expected 4 rows in vt_select_test: %s" % str(query_result)) self.assertEqual(len(query_result["fields"]), 2, "expected 2 fields in vt_select_test: %s" % str(query_result)) # check Ping / RefreshState utils.run_vtctl(["Ping", tablet_62344.tablet_alias]) utils.run_vtctl(["RefreshState", tablet_62344.tablet_alias]) # Quickly check basic actions. utils.run_vtctl(["SetReadOnly", tablet_62344.tablet_alias]) utils.wait_db_read_only(62344) utils.run_vtctl(["SetReadWrite", tablet_62344.tablet_alias]) utils.check_db_read_write(62344) utils.run_vtctl(["DemoteMaster", tablet_62344.tablet_alias]) utils.wait_db_read_only(62344) utils.validate_topology() utils.run_vtctl(["ValidateKeyspace", "test_keyspace"]) # not pinging tablets, as it enables replication checks, and they # break because we only have a single master, no slaves utils.run_vtctl(["ValidateShard", "-ping-tablets=false", "test_keyspace/0"]) self._check_srv_shard() tablet_62344.kill_vttablet()
def run_test_sanity(): # Start up a master mysql and vttablet utils.run_vtctl('CreateKeyspace -force test_keyspace') utils.run_vtctl('CreateShard -force test_keyspace/0') tablet_62344.init_tablet('master', 'test_keyspace', '0', parent=False) utils.run_vtctl('RebuildShardGraph test_keyspace/0') utils.run_vtctl('RebuildKeyspaceGraph test_keyspace') utils.validate_topology() # if these statements don't run before the tablet it will wedge waiting for the # db to become accessible. this is more a bug than a feature. tablet_62344.populate('vt_test_keyspace', create_vt_select_test, populate_vt_select_test) tablet_62344.start_vttablet() # make sure the query service is started right away result, _ = utils.run_vtctl('Query test_nj test_keyspace "select * from vt_select_test"', trap_output=True) rows = result.splitlines() if len(rows) != 5: raise utils.TestError("expected 5 rows in vt_select_test", rows, result) # check Pings utils.run_vtctl('Ping ' + tablet_62344.tablet_alias) utils.run_vtctl('RpcPing ' + tablet_62344.tablet_alias) # Quickly check basic actions. utils.run_vtctl('SetReadOnly ' + tablet_62344.tablet_alias) utils.wait_db_read_only(62344) utils.run_vtctl('SetReadWrite ' + tablet_62344.tablet_alias) utils.check_db_read_write(62344) utils.run_vtctl('DemoteMaster ' + tablet_62344.tablet_alias) utils.wait_db_read_only(62344) utils.validate_topology() utils.run_vtctl('ValidateKeyspace test_keyspace') # not pinging tablets, as it enables replication checks, and they # break because we only have a single master, no slaves utils.run_vtctl('ValidateShard -ping-tablets=false test_keyspace/0') tablet_62344.kill_vttablet() tablet_62344.init_tablet('idle') tablet_62344.scrap(force=True)