Merge pull request #112 from joaquincasares/test_connection_master_fix
Jenkins-ify these test exceptions on the master branch
This commit is contained in:
@@ -22,7 +22,8 @@ except ImportError:
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
from threading import Thread, Event
|
from threading import Thread, Event
|
||||||
|
|
||||||
from cassandra import ConsistencyLevel
|
from cassandra import ConsistencyLevel, OperationTimedOut
|
||||||
|
from cassandra.cluster import NoHostAvailable
|
||||||
from cassandra.decoder import QueryMessage
|
from cassandra.decoder import QueryMessage
|
||||||
from cassandra.io.asyncorereactor import AsyncoreConnection
|
from cassandra.io.asyncorereactor import AsyncoreConnection
|
||||||
|
|
||||||
@@ -36,11 +37,33 @@ class ConnectionTest(object):
|
|||||||
|
|
||||||
klass = None
|
klass = None
|
||||||
|
|
||||||
|
def get_connection(self):
|
||||||
|
"""
|
||||||
|
Helper method to solve automated testing issues within Jenkins.
|
||||||
|
Officially patched under the 2.0 branch through
|
||||||
|
17998ef72a2fe2e67d27dd602b6ced33a58ad8ef, but left as is for the
|
||||||
|
1.0 branch due to possible regressions for fixing an
|
||||||
|
automated testing edge-case.
|
||||||
|
"""
|
||||||
|
conn = None
|
||||||
|
e = None
|
||||||
|
for i in xrange(5):
|
||||||
|
try:
|
||||||
|
conn = self.klass.factory()
|
||||||
|
break
|
||||||
|
except (OperationTimedOut, NoHostAvailable) as e:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if conn:
|
||||||
|
return conn
|
||||||
|
else:
|
||||||
|
raise e
|
||||||
|
|
||||||
def test_single_connection(self):
|
def test_single_connection(self):
|
||||||
"""
|
"""
|
||||||
Test a single connection with sequential requests.
|
Test a single connection with sequential requests.
|
||||||
"""
|
"""
|
||||||
conn = self.klass.factory()
|
conn = self.get_connection()
|
||||||
query = "SELECT keyspace_name FROM system.schema_keyspaces LIMIT 1"
|
query = "SELECT keyspace_name FROM system.schema_keyspaces LIMIT 1"
|
||||||
event = Event()
|
event = Event()
|
||||||
|
|
||||||
@@ -63,7 +86,7 @@ class ConnectionTest(object):
|
|||||||
"""
|
"""
|
||||||
Test a single connection with pipelined requests.
|
Test a single connection with pipelined requests.
|
||||||
"""
|
"""
|
||||||
conn = self.klass.factory()
|
conn = self.get_connection()
|
||||||
query = "SELECT keyspace_name FROM system.schema_keyspaces LIMIT 1"
|
query = "SELECT keyspace_name FROM system.schema_keyspaces LIMIT 1"
|
||||||
responses = [False] * 100
|
responses = [False] * 100
|
||||||
event = Event()
|
event = Event()
|
||||||
@@ -85,7 +108,7 @@ class ConnectionTest(object):
|
|||||||
"""
|
"""
|
||||||
Test multiple connections with pipelined requests.
|
Test multiple connections with pipelined requests.
|
||||||
"""
|
"""
|
||||||
conns = [self.klass.factory() for i in range(5)]
|
conns = [self.get_connection() for i in range(5)]
|
||||||
events = [Event() for i in range(5)]
|
events = [Event() for i in range(5)]
|
||||||
query = "SELECT keyspace_name FROM system.schema_keyspaces LIMIT 1"
|
query = "SELECT keyspace_name FROM system.schema_keyspaces LIMIT 1"
|
||||||
|
|
||||||
@@ -116,7 +139,7 @@ class ConnectionTest(object):
|
|||||||
num_threads = 5
|
num_threads = 5
|
||||||
event = Event()
|
event = Event()
|
||||||
|
|
||||||
conn = self.klass.factory()
|
conn = self.get_connection()
|
||||||
query = "SELECT keyspace_name FROM system.schema_keyspaces LIMIT 1"
|
query = "SELECT keyspace_name FROM system.schema_keyspaces LIMIT 1"
|
||||||
|
|
||||||
def cb(all_responses, thread_responses, request_num, *args, **kwargs):
|
def cb(all_responses, thread_responses, request_num, *args, **kwargs):
|
||||||
@@ -173,7 +196,7 @@ class ConnectionTest(object):
|
|||||||
|
|
||||||
threads = []
|
threads = []
|
||||||
for i in range(num_conns):
|
for i in range(num_conns):
|
||||||
conn = self.klass.factory()
|
conn = self.get_connection()
|
||||||
t = Thread(target=send_msgs, args=(conn, events[i]))
|
t = Thread(target=send_msgs, args=(conn, events[i]))
|
||||||
threads.append(t)
|
threads.append(t)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user