Exemplo n.º 1
0
  def test_query_timeout(self):
    vstart = self.env.debug_vars()
    conn = tablet_conn.connect(self.env.address, '', 'test_keyspace', '0', 5, user='******', password='******')
    cu = cursor.TabletCursor(conn)
    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.QueryTimeout, 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.QueryTimeout, 30000000000)
Exemplo n.º 2
0
  def test_query_timeout(self):
    vstart = self.env.debug_vars()
    conn = tablet_conn.connect(
        self.env.address, "", "test_keyspace", "0", 5, caller_id="dev")
    cu = cursor.TabletCursor(conn)
    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: the query was killed" 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.QueryTimeout, 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.QueryTimeout, 30000000000)
Exemplo n.º 3
0
    def test_query_timeout(self):
        vstart = self.env.debug_vars()
        conn = tablet_conn.connect("localhost:9461", '', 'test_keyspace', '0',
                                   5)
        cu = cursor.TabletCursor(conn)
        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)
Exemplo n.º 4
0
 def connect(self):
     c = tablet_conn.connect(self.address,
                             '',
                             'test_keyspace',
                             '0',
                             2,
                             user='******',
                             password='******')
     c.max_attempts = 1
     return c
Exemplo n.º 5
0
 def connect(self):
   c = tablet_conn.connect(
       self.address, '', 'test_keyspace', '0', 2, caller_id='dev')
   c.max_attempts = 1
   return c
Exemplo n.º 6
0
 def connect(self):
     c = tablet_conn.connect(
         self.address, "", "test_keyspace", "0", 2, user="******", password="******"
     )
     c.max_attempts = 1
     return c
Exemplo n.º 7
0
 def connect(self):
   c = tablet_conn.connect("localhost:9461", '', 'test_keyspace', '0', 2)
   c.max_attempts = 1
   return c
Exemplo n.º 8
0
 def connect(self):
   c = tablet_conn.connect("localhost:%s" % self.tablet.port, '', 'test_keyspace', '0', 2)
   c.max_attempts = 1
   return c
Exemplo n.º 9
0
 def connect(self):
   c = tablet_conn.connect(self.address, '', 'test_keyspace', '0', 2, user='******', password='******')
   c.max_attempts = 1
   return c
Exemplo n.º 10
0
 def connect(self):
     c = tablet_conn.connect(self.address, "", "test_keyspace", "0", 2)
     c.max_attempts = 1
     return c
Exemplo n.º 11
0
 def connect(self):
     c = tablet_conn.connect("localhost:%s" % self.port, "", "test_keyspace", "0", 2)
     c.max_attempts = 1
     return c
Exemplo n.º 12
0
 def connect(self):
   c = tablet_conn.connect("localhost:9461", '', 'test_keyspace', '0', 2)
   c.max_attempts = 1
   return c
Exemplo n.º 13
0
 def connect(self):
   c = tablet_conn.connect("localhost:%s" % self.tablet.port, '', 'test_keyspace', '0', 2)
   c.max_attempts = 1
   return c