From 1d2d810d664a57aec966ece646ac473797f6e037 Mon Sep 17 00:00:00 2001 From: Joaquin Casares Date: Fri, 25 Apr 2014 19:23:18 -0500 Subject: [PATCH] Add schema disagreement checks --- tests/integration/__init__.py | 2 +- tests/integration/long/test_schema.py | 56 ++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index 9475f8ab..d79f305f 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -36,7 +36,7 @@ except ImportError as e: CLUSTER_NAME = 'test_cluster' MULTIDC_CLUSTER_NAME = 'multidc_test_cluster' CCM_CLUSTER = None -DEFAULT_CASSANDRA_VERSION = '1.2.15' +DEFAULT_CASSANDRA_VERSION = '1.2.16' path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'ccm') if not os.path.exists(path): diff --git a/tests/integration/long/test_schema.py b/tests/integration/long/test_schema.py index cc9d3256..4a5c2a60 100644 --- a/tests/integration/long/test_schema.py +++ b/tests/integration/long/test_schema.py @@ -14,7 +14,7 @@ import logging -from cassandra import ConsistencyLevel +from cassandra import ConsistencyLevel, OperationTimedOut from cassandra.cluster import Cluster from cassandra.query import SimpleStatement @@ -63,3 +63,57 @@ class SchemaTests(unittest.TestCase): ss = SimpleStatement(statement, consistency_level=ConsistencyLevel.QUORUM) session.execute(ss) + + def test_for_schema_disagreements_different_keyspaces(self): + cluster = Cluster() + session = cluster.connect() + + for i in xrange(30): + try: + session.execute(''' + CREATE KEYSPACE test_%s + WITH replication = {'class': 'SimpleStrategy', + 'replication_factor': 1} + ''' % i) + + session.execute(''' + CREATE TABLE test_%s.cf ( + key int, + value int, + PRIMARY KEY (key)) + ''' % i) + + for j in xrange(100): + session.execute('INSERT INTO test_%s.cf (key, value) VALUES (%s, %s)' % (i, j, j)) + + session.execute(''' + DROP KEYSPACE test_%s + ''' % i) + except OperationTimedOut: pass + + def test_for_schema_disagreements_same_keyspace(self): + cluster = Cluster() + session = cluster.connect() + + for i in xrange(30): + try: + session.execute(''' + CREATE KEYSPACE test + WITH replication = {'class': 'SimpleStrategy', + 'replication_factor': 1} + ''') + + session.execute(''' + CREATE TABLE test.cf ( + key int, + value int, + PRIMARY KEY (key)) + ''') + + for j in xrange(100): + session.execute('INSERT INTO test.cf (key, value) VALUES (%s, %s)' % (j, j)) + + session.execute(''' + DROP KEYSPACE test + ''') + except OperationTimedOut: pass