You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by gd...@apache.org on 2010/09/15 22:38:59 UTC

svn commit: r997491 - in /cassandra/trunk/test/system: test_avro_super.py test_avro_system.py

Author: gdusbabek
Date: Wed Sep 15 20:38:59 2010
New Revision: 997491

URL: http://svn.apache.org/viewvc?rev=997491&view=rev
Log:
avro system tests. patch by gdusbabek, reviewed by jbellis. CASSANDRA-1477

Modified:
    cassandra/trunk/test/system/test_avro_super.py
    cassandra/trunk/test/system/test_avro_system.py

Modified: cassandra/trunk/test/system/test_avro_super.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/system/test_avro_super.py?rev=997491&r1=997490&r2=997491&view=diff
==============================================================================
--- cassandra/trunk/test/system/test_avro_super.py (original)
+++ cassandra/trunk/test/system/test_avro_super.py Wed Sep 15 20:38:59 2010
@@ -58,9 +58,9 @@ def SliceRange(start='', finish='', reve
 
 def ColumnParent(*args, **kwargs):
     cp = {}
-    if args and args[0]:
+    if args and len(args) > 0:
         cp['column_family'] = args[0]
-    if args and args[1]:
+    if args and len(args) > 1:
         cp['super_column'] = args[1]
     for k,v in kwargs.items():
         cp[k] = v
@@ -68,7 +68,7 @@ def ColumnParent(*args, **kwargs):
 
 def Deletion(*args, **kwargs):
     cp = {}
-    if args and args[0]:
+    if args and len(args) > 0:
         cp['clock'] = args[0]
     for k,v in kwargs.items():
         cp[k] = v
@@ -76,7 +76,7 @@ def Deletion(*args, **kwargs):
    
 def ColumnPath(*args, **kwargs):
     cp = {}
-    if args and args[0]:
+    if args and len(args) > 0:
         cp['column_family'] = args[0]
     for k,v in kwargs.items():
         cp[k] = v

Modified: cassandra/trunk/test/system/test_avro_system.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/system/test_avro_system.py?rev=997491&r1=997490&r2=997491&view=diff
==============================================================================
--- cassandra/trunk/test/system/test_avro_system.py (original)
+++ cassandra/trunk/test/system/test_avro_system.py Wed Sep 15 20:38:59 2010
@@ -19,6 +19,13 @@ import avro_utils
 from . import AvroTester
 from avro.ipc import AvroRemoteException
 
+# cheat a little until these are moved into avro_utils.
+from test_avro_super import Clock as Clock
+from test_avro_super import ColumnParent as ColumnParent
+from test_avro_super import SlicePredicate as SlicePredicate
+from test_avro_super import SliceRange as SliceRange
+from test_avro_super import Column as Column
+
 class TestSystemOperations(AvroTester):
     """
     Cassandra system operations.
@@ -135,4 +142,38 @@ class TestSystemOperations(AvroTester):
         assert 'RenameColumnFamily' not in [x['name'] for x in ks1['cf_defs']]
         assert 'NewColumnFamily' not in [x['name'] for x in ks1['cf_defs']]
         assert 'Standard1' in [x['name'] for x in ks1['cf_defs']]
+    
+    def test_cf_recreate(self):
+        "ensures that keyspaces and column familes can be dropped and recreated in short order"
+        for x in range(1):
+            keyspace = 'test_cf_recreate'
+            cf_name = 'recreate_cf'
+            
+            # create
+            newcf = {'keyspace': keyspace, 'name': cf_name}
+            newks = {'name': keyspace,
+                     'strategy_class': 'org.apache.cassandra.locator.SimpleStrategy',
+                     'strategy_options': {},
+                     'replication_factor': 1,
+                     'cf_defs': [newcf]}
+            self.client.request('system_add_keyspace', {'ks_def': newks})
+            self.client.request('set_keyspace', {'keyspace': keyspace})
+            
+            # insert
+            self.client.request('insert', {'key': 'key0', 'column_parent': ColumnParent(cf_name), 'column': Column('colA', 'colA-value', Clock(0)), 'consistency_level': 'ONE' })
+            col1 = self.client.request('get_slice', {'key': 'key0', 'column_parent': ColumnParent(cf_name), 'predicate': SlicePredicate(slice_range=SliceRange('', '', False, 100)), 'consistency_level': 'ONE'})[0]['column']
+            assert col1['name'] == 'colA' and col1['value'] == 'colA-value', col1
+                    
+            # drop
+            self.client.request('system_drop_column_family', {'column_family': cf_name})
+            
+            # recreate
+            self.client.request('system_add_column_family', {'cf_def': newcf})
+            
+            # query
+            cosc_list = self.client.request('get_slice', {'key': 'key0', 'column_parent': ColumnParent(cf_name), 'predicate': SlicePredicate(slice_range=SliceRange('', '', False, 100)), 'consistency_level': 'ONE'})
+            # this was failing prior to CASSANDRA-1477.
+            assert len(cosc_list) == 0 , 'cosc length test failed'
+            
+            self.client.request('system_drop_keyspace', {'keyspace': keyspace})