def test_query_timeout(self): vstart = self.env.debug_vars() conn = vtclient.connect("localhost:9461", 'test_keyspace', '0', 5) cu = conn.cursor() self.env.execute("set vt_query_timeout=0.25") try: conn.begin() cu.execute("select sleep(0.5) from vtocc_test", {}) except dbexceptions.DatabaseError as e: if "error: Query" not in str(e) and "error: Lost connection" not in str(e): self.fail("Query not killed as expected") else: self.fail("Did not receive exception") try: cu.execute("select 1 from dual", {}) except dbexceptions.DatabaseError as e: self.assertContains(str(e), "not_in_tx: Transaction") else: self.fail("Did not receive exception") cu.close() conn.close() vend = self.env.debug_vars() self.assertEqual(vend.Voltron.ActivePool.Timeout, 250000000) self.assertEqual(vend.ActivePoolTimeout, 250000000) self.assertEqual(vstart.mget("Kills.Queries", 0)+1, vend.Kills.Queries) self.env.execute("set vt_query_timeout=30") vend = self.env.debug_vars() self.assertEqual(vend.Voltron.ActivePool.Timeout, 30000000000) self.assertEqual(vend.ActivePoolTimeout, 30000000000)
def test_query_timeout(self): vstart = self.env.debug_vars() conn = vtclient.connect("localhost:9461", 'test_keyspace', '0', 5) cu = conn.cursor() self.env.execute("set vt_query_timeout=0.25") try: conn.begin() cu.execute("select sleep(0.5) from vtocc_test", {}) except dbexceptions.DatabaseError as e: if "error: Query" not in str( e) and "error: Lost connection" not in str(e): self.fail("Query not killed as expected") else: self.fail("Did not receive exception") try: cu.execute("select 1 from dual", {}) except dbexceptions.DatabaseError as e: self.assertContains(str(e), "not_in_tx: Transaction") else: self.fail("Did not receive exception") cu.close() conn.close() vend = self.env.debug_vars() self.assertEqual(vend.Voltron.ActivePool.Timeout, 250000000) self.assertEqual(vend.ActivePoolTimeout, 250000000) self.assertEqual( vstart.mget("Kills.Queries", 0) + 1, vend.Kills.Queries) self.env.execute("set vt_query_timeout=30") vend = self.env.debug_vars() self.assertEqual(vend.Voltron.ActivePool.Timeout, 30000000000) self.assertEqual(vend.ActivePoolTimeout, 30000000000)
def connect(self): c = vtclient.connect("localhost:9461", 'test_keyspace', '0', 2) c.max_attempts = 1 return c
def connect(self): c = vtclient.connect("localhost:%s" % self.tablet.port, 'test_keyspace', '0', 2) c.max_attempts = 1 return c
def get_replica_connection(shard=0): db_key = "%s.%d.replica" % (TEST_KEYSPACE, shard) replica_db_params = get_vt_connection_params(db_key) logging.debug("connecting to replica with params %s" % replica_db_params) replica_conn = vtclient.connect(**replica_db_params) return replica_conn
def get_master_connection(shard=0): db_key = "%s.%d.master" % (TEST_KEYSPACE, shard) master_db_params = get_vt_connection_params(db_key) logging.debug("connecting to master with params %s" % master_db_params) master_conn = vtclient.connect(**master_db_params) return master_conn
def _vtdb_conn(host): return vtclient.connect(host, 'test_keyspace', '0', 2)
def _vtdb_conn(self, host): return vtclient.connect(host, 'test_keyspace', '0', 2)