Added additional test for errors taking place in connections acquired from a
session pool.
This commit is contained in:
parent
5b6a9b017a
commit
39333aa7d4
@ -12,6 +12,13 @@ class TestConnection(TestCase):
|
||||
count, = cursor.fetchone()
|
||||
self.failUnlessEqual(count, 10)
|
||||
|
||||
def __ConnectAndGenerateError(self):
|
||||
"""Connect to the database, perform a query which raises an error"""
|
||||
connection = self.pool.acquire()
|
||||
cursor = connection.cursor()
|
||||
self.failUnlessRaises(cx_Oracle.DatabaseError, cursor.execute,
|
||||
"select 1 / 0 from dual")
|
||||
|
||||
def testPool(self):
|
||||
"""test that the pool is created and has the right attributes"""
|
||||
pool = cx_Oracle.SessionPool(USERNAME, PASSWORD, TNSENTRY, 2, 8, 3)
|
||||
@ -96,3 +103,15 @@ class TestConnection(TestCase):
|
||||
for thread in threads:
|
||||
thread.join()
|
||||
|
||||
def testThreadingWithErrors(self):
|
||||
"""test session pool to database with multiple threads (with errors)"""
|
||||
self.pool = cx_Oracle.SessionPool(USERNAME, PASSWORD, TNSENTRY, 5, 20,
|
||||
2, threaded = True)
|
||||
threads = []
|
||||
for i in range(20):
|
||||
thread = threading.Thread(None, self.__ConnectAndGenerateError)
|
||||
threads.append(thread)
|
||||
thread.start()
|
||||
for thread in threads:
|
||||
thread.join()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user