From d244ece986e336ffa97d00ac36f859e2e29372af Mon Sep 17 00:00:00 2001 From: GregBestland Date: Tue, 2 Aug 2016 09:20:21 -0500 Subject: [PATCH] misc fixes for jenkins --- tests/integration/long/test_schema.py | 6 ++--- tests/integration/standard/test_query.py | 21 ++++++++++-------- tests/integration/standard/test_udts.py | 28 ++++++++++++------------ 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/tests/integration/long/test_schema.py b/tests/integration/long/test_schema.py index 87ca5f3c..349a158a 100644 --- a/tests/integration/long/test_schema.py +++ b/tests/integration/long/test_schema.py @@ -37,7 +37,7 @@ class SchemaTests(unittest.TestCase): @classmethod def setup_class(cls): cls.cluster = Cluster(protocol_version=PROTOCOL_VERSION) - cls.session = cls.cluster.connect() + cls.session = cls.cluster.connect(wait_for_all_pools=True) @classmethod def teardown_class(cls): @@ -98,7 +98,7 @@ class SchemaTests(unittest.TestCase): """ cluster = Cluster(protocol_version=PROTOCOL_VERSION) - session = cluster.connect() + session = cluster.connect(wait_for_all_pools=True) for i in range(30): try: @@ -131,7 +131,7 @@ class SchemaTests(unittest.TestCase): """ # This should yield a schema disagreement cluster = Cluster(protocol_version=PROTOCOL_VERSION, max_schema_agreement_wait=0.001) - session = cluster.connect() + session = cluster.connect(wait_for_all_pools=True) rs = session.execute("CREATE KEYSPACE test_schema_disagreement WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}") self.check_and_wait_for_agreement(session, rs, False) diff --git a/tests/integration/standard/test_query.py b/tests/integration/standard/test_query.py index 719f2b1f..1b092868 100644 --- a/tests/integration/standard/test_query.py +++ b/tests/integration/standard/test_query.py @@ -406,15 +406,18 @@ class PreparedStatementArgTest(unittest.TestCase): clus = Cluster( load_balancing_policy=white_list, protocol_version=PROTOCOL_VERSION, prepare_on_all_hosts=False, reprepare_on_up=False) - session = clus.connect() - mock_handler = MockLoggingHandler() - logger = logging.getLogger(cluster.__name__) - logger.addHandler(mock_handler) - select_statement = session.prepare("SELECT * FROM system.local") - session.execute(select_statement) - session.execute(select_statement) - session.execute(select_statement) - self.assertEqual(2, mock_handler.get_message_count('debug', "Re-preparing")) + try: + session = clus.connect(wait_for_all_pools=True) + mock_handler = MockLoggingHandler() + logger = logging.getLogger(cluster.__name__) + logger.addHandler(mock_handler) + select_statement = session.prepare("SELECT * FROM system.local") + session.execute(select_statement) + session.execute(select_statement) + session.execute(select_statement) + self.assertEqual(2, mock_handler.get_message_count('debug', "Re-preparing")) + finally: + clus.shutdown() class PrintStatementTests(unittest.TestCase): diff --git a/tests/integration/standard/test_udts.py b/tests/integration/standard/test_udts.py index 441b518a..81c86069 100644 --- a/tests/integration/standard/test_udts.py +++ b/tests/integration/standard/test_udts.py @@ -56,7 +56,7 @@ class UDTTests(BasicSegregatedKeyspaceUnitTestCase): """ c = Cluster(protocol_version=PROTOCOL_VERSION) - s = c.connect(self.keyspace_name) + s = c.connect(self.keyspace_name, wait_for_all_pools=True) s.execute("CREATE TYPE user (age int, name text)") s.execute("CREATE TABLE mytable (a int PRIMARY KEY, b frozen)") @@ -100,7 +100,7 @@ class UDTTests(BasicSegregatedKeyspaceUnitTestCase): """ c = Cluster(protocol_version=PROTOCOL_VERSION) - s = c.connect() + s = c.connect(wait_for_all_pools=True) s.execute(""" CREATE KEYSPACE udt_test_register_before_connecting @@ -128,7 +128,7 @@ class UDTTests(BasicSegregatedKeyspaceUnitTestCase): c.register_user_type("udt_test_register_before_connecting", "user", User1) c.register_user_type("udt_test_register_before_connecting2", "user", User2) - s = c.connect() + s = c.connect(wait_for_all_pools=True) s.set_keyspace("udt_test_register_before_connecting") s.execute("INSERT INTO mytable (a, b) VALUES (%s, %s)", (0, User1(42, 'bob'))) @@ -158,7 +158,7 @@ class UDTTests(BasicSegregatedKeyspaceUnitTestCase): """ c = Cluster(protocol_version=PROTOCOL_VERSION) - s = c.connect(self.keyspace_name) + s = c.connect(self.keyspace_name, wait_for_all_pools=True) s.execute("CREATE TYPE user (age int, name text)") s.execute("CREATE TABLE mytable (a int PRIMARY KEY, b frozen)") @@ -202,7 +202,7 @@ class UDTTests(BasicSegregatedKeyspaceUnitTestCase): """ c = Cluster(protocol_version=PROTOCOL_VERSION) - s = c.connect(self.keyspace_name) + s = c.connect(self.keyspace_name, wait_for_all_pools=True) s.execute("CREATE TYPE user (age int, name text)") User = namedtuple('user', ('age', 'name')) @@ -252,7 +252,7 @@ class UDTTests(BasicSegregatedKeyspaceUnitTestCase): """ c = Cluster(protocol_version=PROTOCOL_VERSION) - s = c.connect(self.keyspace_name) + s = c.connect(self.keyspace_name, wait_for_all_pools=True) s.execute("CREATE TYPE user (a text, b int, c uuid, d blob)") User = namedtuple('user', ('a', 'b', 'c', 'd')) @@ -282,7 +282,7 @@ class UDTTests(BasicSegregatedKeyspaceUnitTestCase): """ c = Cluster(protocol_version=PROTOCOL_VERSION) - s = c.connect(self.keyspace_name) + s = c.connect(self.keyspace_name, wait_for_all_pools=True) MAX_TEST_LENGTH = 254 @@ -366,7 +366,7 @@ class UDTTests(BasicSegregatedKeyspaceUnitTestCase): """ c = Cluster(protocol_version=PROTOCOL_VERSION) - s = c.connect(self.keyspace_name) + s = c.connect(self.keyspace_name, wait_for_all_pools=True) s.row_factory = dict_factory MAX_NESTING_DEPTH = 16 @@ -397,7 +397,7 @@ class UDTTests(BasicSegregatedKeyspaceUnitTestCase): """ c = Cluster(protocol_version=PROTOCOL_VERSION) - s = c.connect(self.keyspace_name) + s = c.connect(self.keyspace_name, wait_for_all_pools=True) s.row_factory = dict_factory MAX_NESTING_DEPTH = 16 @@ -437,7 +437,7 @@ class UDTTests(BasicSegregatedKeyspaceUnitTestCase): """ c = Cluster(protocol_version=PROTOCOL_VERSION) - s = c.connect(self.keyspace_name) + s = c.connect(self.keyspace_name, wait_for_all_pools=True) s.row_factory = dict_factory MAX_NESTING_DEPTH = 16 @@ -468,7 +468,7 @@ class UDTTests(BasicSegregatedKeyspaceUnitTestCase): """ c = Cluster(protocol_version=PROTOCOL_VERSION) - s = c.connect(self.keyspace_name) + s = c.connect(self.keyspace_name, wait_for_all_pools=True) User = namedtuple('user', ('age', 'name')) with self.assertRaises(UserTypeDoesNotExist): @@ -488,7 +488,7 @@ class UDTTests(BasicSegregatedKeyspaceUnitTestCase): """ c = Cluster(protocol_version=PROTOCOL_VERSION) - s = c.connect(self.keyspace_name) + s = c.connect(self.keyspace_name, wait_for_all_pools=True) # create UDT alpha_type_list = [] @@ -533,7 +533,7 @@ class UDTTests(BasicSegregatedKeyspaceUnitTestCase): """ c = Cluster(protocol_version=PROTOCOL_VERSION) - s = c.connect(self.keyspace_name) + s = c.connect(self.keyspace_name, wait_for_all_pools=True) # create UDT alpha_type_list = [] @@ -600,7 +600,7 @@ class UDTTests(BasicSegregatedKeyspaceUnitTestCase): raise unittest.SkipTest("Support for nested collections was introduced in Cassandra 2.1.3") c = Cluster(protocol_version=PROTOCOL_VERSION) - s = c.connect(self.keyspace_name) + s = c.connect(self.keyspace_name, wait_for_all_pools=True) s.encoder.mapping[tuple] = s.encoder.cql_encode_tuple name = self._testMethodName