Author: eevans
Date: Thu Sep 2 19:02:23 2010
New Revision: 992055
URL: http://svn.apache.org/viewvc?rev=992055&view=rev
Log:
functional tests for truncate and describe_ring (avro)
Patch by Nirmal Ranganathan (w/ minor changes); reviewd by eevans
Modified:
cassandra/trunk/test/system/test_avro_meta.py
cassandra/trunk/test/system/test_avro_standard.py
Modified: cassandra/trunk/test/system/test_avro_meta.py
URL:
http://svn.apache.org/viewvc/cassandra/trunk/test/system/test_avro_meta.py?rev=992055&r1=992054&r2=992055&view=diff
==============================================================================
--- cassandra/trunk/test/system/test_avro_meta.py (original)
+++ cassandra/trunk/test/system/test_avro_meta.py Thu Sep 2 19:02:23 2010
@@ -16,6 +16,7 @@
# limitations under the License.
from . import AvroTester
+import avro_utils
from avro.ipc import AvroRemoteException
class TestMetaOperations(AvroTester):
@@ -28,7 +29,7 @@ class TestMetaOperations(AvroTester):
assert 'Keyspace1' in keyspaces, "Keyspace1 not in " + keyspaces
def test_describe_keyspace(self):
- "retrieving a keyspace metadata"
+ "retrieving meta-data for keyspace"
ks1 = self.client.request('describe_keyspace',
{'keyspace': "Keyspace1"})
assert ks1['replication_factor'] == 1
@@ -53,3 +54,13 @@ class TestMetaOperations(AvroTester):
part = "org.apache.cassandra.dht.CollatingOrderPreservingPartitioner"
result = self.client.request('describe_partitioner', {})
assert result == part, "got %s, expected %s" % (result, part)
+
+ def test_describe_ring(self):
+ "getting ring meta-data"
+ result = self.client.request('describe_ring', {'keyspace':'Keyspace1'})
+ assert result[0]['endpoints'] == ['127.0.0.1']
+
+ def test_describe_ring_on_invalid_keyspace(self):
+ "getting ring meta-data w/ an invalid keyspace"
+ avro_utils.assert_raises(AvroRemoteException, self.client.request,
+ 'describe_ring', {'keyspace':'system'})
Modified: cassandra/trunk/test/system/test_avro_standard.py
URL:
http://svn.apache.org/viewvc/cassandra/trunk/test/system/test_avro_standard.py?rev=992055&r1=992054&r2=992055&view=diff
==============================================================================
--- cassandra/trunk/test/system/test_avro_standard.py (original)
+++ cassandra/trunk/test/system/test_avro_standard.py Thu Sep 2 19:02:23 2010
@@ -30,6 +30,30 @@ def new_column(suffix, stamp=None, ttl=0
column['ttl'] = ttl
return column
+def _create_multi_key_column():
+ mutations = list()
+
+ for i in range(10):
+ mutation = {'column_or_supercolumn': {'column': new_column(i)}}
+ mutations.append(mutation)
+
+ mutation_params = dict()
+ mutation_params['mutation_map'] = list()
+ for i in range(3):
+ entry = {'key': 'k'+str(i), 'mutations': {'Standard1': mutations}}
+ mutation_params['mutation_map'].append(entry)
+ mutation_params['consistency_level'] = 'ONE'
+ return mutation_params
+
+def _read_multi_key_column_count():
+ count_params = dict()
+ count_params['keys'] = ['k0', 'k1', 'k2']
+ count_params['column_parent'] = {'column_family': 'Standard1'}
+ sr = {'start': '', 'finish': '', 'reversed': False, 'count': 1000}
+ count_params['predicate'] = {'slice_range': sr}
+ count_params['consistency_level'] = 'ONE'
+ return count_params
+
def timestamp():
return long(time() * 1e6)
@@ -294,33 +318,26 @@ class TestStandardOperations(AvroTester)
"obtaining the column count for multiple rows"
self.client.request('set_keyspace', {'keyspace': 'Keyspace1'})
- mutations = list()
+ self.client.request('batch_mutate', _create_multi_key_column())
- for i in range(10):
- mutation = {'column_or_supercolumn': {'column': new_column(i)}}
- mutations.append(mutation)
+ counts = self.client.request('multiget_count',
_read_multi_key_column_count())
+ for e in counts:
+ assert(e['count'] == 10), \
+ "expected 10 results for %s, got %d" % (e['key'], e['count'])
- mutation_params = dict()
- mutation_params['mutation_map'] = list()
- for i in range(3):
- entry = {'key': 'k'+str(i), 'mutations': {'Standard1': mutations}}
- mutation_params['mutation_map'].append(entry)
- mutation_params['consistency_level'] = 'ONE'
+ def test_truncate(self):
+ "truncate a column family"
+ self.client.request('set_keyspace', {'keyspace': 'Keyspace1'})
- self.client.request('batch_mutate', mutation_params)
+ self.client.request('batch_mutate', _create_multi_key_column())
- count_params = dict()
- count_params['keys'] = ['k0', 'k1', 'k2']
- count_params['column_parent'] = {'column_family': 'Standard1'}
- sr = {'start': '', 'finish': '', 'reversed': False, 'count': 1000}
- count_params['predicate'] = {'slice_range': sr}
- count_params['consistency_level'] = 'ONE'
+ # truncate Standard1
+ self.client.request('truncate',{'column_family':'Standard1'})
- counts = self.client.request('multiget_count', count_params)
+ counts = self.client.request('multiget_count',
_read_multi_key_column_count())
for e in counts:
- assert(e['count'] == 10), \
- "expected 10 results for %s, got %d" % (e['key'], e['count'])
-
+ assert(e['count'] == 0)
+
def __get(self, key, cf, super_name, col_name, consistency_level='ONE'):
"""
Given arguments for the key, column family, super column name,