示例#1
0
  def test_query_timeout(self):
    vstart = self.env.debug_vars()
    conn = vt_occ2.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), "error: 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(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)
示例#2
0
 def test_query_timeout(self):
   vstart = self.debug_vars()
   conn = db.connect("localhost:9461", 5, dbname=self.cfg['dbname'])
   cu = conn.cursor()
   self.execute("set vt_query_timeout=1")
   try:
     cu.execute("begin", {})
     cu.execute("select sleep(2) from vtocc_test", {})
   except (db.MySQLErrors.DatabaseError, db.dbexceptions.OperationalError), e:
     self.assertContains(e[1], "error: Query")
示例#3
0
 def test_query_timeout(self):
   vstart = self.env.debug_vars()
   conn = db.connect("localhost:9461", 5, dbname=self.env.cfg['dbname'])
   cu = conn.cursor()
   self.env.execute("set vt_query_timeout=1")
   try:
     cu.execute("begin", {})
     cu.execute("select sleep(2) from vtocc_test", {})
   except (db.MySQLErrors.DatabaseError, db.dbexceptions.OperationalError), e:
     if "error: Query" not in e[1] and "error: Lost connection" not in e[1]:
       print e[1]
       self.assertFail("Query not killed as expected")
示例#4
0
 def connect(self):
     c = vt_occ2.connect("localhost:9461", 'test_keyspace', '0', 2)
     c.max_attempts = 1
     return c
示例#5
0
 def connect(self):
     c = vt_occ2.connect("localhost:%s" % self.tablet.port, 'test_keyspace',
                         '0', 2)
     c.max_attempts = 1
     return c
def _vtdb_conn(host):
  return vt_occ2.connect(host, 'test_keyspace', '0', 2)
示例#7
0
 def connect(self):
   return db.connect("localhost:9461", 2, dbname=self.cfg.get('dbname', None))
示例#8
0
def _vtdb_conn(host):
    return vt_occ2.connect(host, 'test_keyspace', '0', 2)
示例#9
0
 def connect(self):
   c = vt_occ2.connect("localhost:9461", 'test_keyspace', '0', 2)
   c.max_attempts = 1
   return c
示例#10
0
 def connect(self):
   c = vt_occ2.connect("localhost:%s" % self.tablet.port, 'test_keyspace', '0', 2)
   c.max_attempts = 1
   return c
示例#11
0
def _vtdb_conn(host):
    return vt_occ2.connect(host, "test_keyspace", "0", 2)