From 05281ee045bb6d9b5fa39b09489175247b60251a Mon Sep 17 00:00:00 2001 From: Jonathan Ellis Date: Mon, 4 May 2009 19:01:46 +0000 Subject: [PATCH] demonstrate problem with _blocking methods by checking insert return values. patch by jbellis; reviewed by nk11 for CASSANDRA-120 git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@771398 13f79535-47bb-0310-9956-ffa450edef68 --- test/system/test_server.py | 41 ++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/test/system/test_server.py b/test/system/test_server.py index a804fad7e6..ff6f3d5144 100644 --- a/test/system/test_server.py +++ b/test/system/test_server.py @@ -14,13 +14,15 @@ _SUPER_COLUMNS = [superColumn_t(name='sc1', column_t(columnName='c6', value='value6', timestamp=0)])] def _insert_simple(method=client.insert_blocking): - method('Table1', 'key1', 'Standard1:c1', 'value1', 0) - method('Table1', 'key1', 'Standard1:c2', 'value2', 0) + v1 = method('Table1', 'key1', 'Standard1:c1', 'value1', 0) + v2 = method('Table1', 'key1', 'Standard1:c2', 'value2', 0) + assert v1 == v2 + return v1 def _insert_batch(method): cfmap = {'Standard1': _SIMPLE_COLUMNS, 'Standard2': _SIMPLE_COLUMNS} - method(batch_mutation_t(table='Table1', key='key1', cfmap=cfmap)) + return method(batch_mutation_t(table='Table1', key='key1', cfmap=cfmap)) def _verify_batch(): _verify_simple() @@ -34,10 +36,11 @@ def _verify_simple(): assert L == _SIMPLE_COLUMNS, L def _insert_super(): - client.insert('Table1', 'key1', 'Super1:sc1:c4', 'value4', 0) - client.insert('Table1', 'key1', 'Super1:sc2:c5', 'value5', 0) - client.insert('Table1', 'key1', 'Super1:sc2:c6', 'value6', 0) - time.sleep(0.1) + v1 = client.insert_blocking('Table1', 'key1', 'Super1:sc1:c4', 'value4', 0) + v2 = client.insert_blocking('Table1', 'key1', 'Super1:sc2:c5', 'value5', 0) + v3 = client.insert_blocking('Table1', 'key1', 'Super1:sc2:c6', 'value6', 0) + assert v1 == v2 == v3 + return v1 def _verify_super(supercolumn='Super1'): assert client.get_column('Table1', 'key1', supercolumn + ':sc1:c4') == \ @@ -73,7 +76,7 @@ class TestMutations(CassandraTester): _verify_simple() def test_insert_blocking(self): - _insert_simple(client.insert_blocking) + assert _insert_simple(client.insert_blocking) _verify_simple() def test_super_insert(self): @@ -86,7 +89,7 @@ class TestMutations(CassandraTester): _verify_batch() def test_batch_insert_blocking(self): - _insert_batch(client.batch_insert_blocking) + assert _insert_batch(client.batch_insert_blocking) _verify_batch() def test_batch_insert_super(self): @@ -105,7 +108,7 @@ class TestMutations(CassandraTester): _verify_super('Super2') def test_cf_remove_column(self): - _insert_simple() + assert _insert_simple() client.remove('Table1', 'key1', 'Standard1:c1', 1, True) time.sleep(0.1) _expect_missing(lambda: client.get_column('Table1', 'key1', 'Standard1:c1')) @@ -138,8 +141,8 @@ class TestMutations(CassandraTester): def test_cf_remove(self): - _insert_simple() - _insert_super() + assert _insert_simple() + assert _insert_super() # Remove the key1:Standard1 cf: client.remove('Table1', 'key1', 'Standard1', 3, True) @@ -160,8 +163,8 @@ class TestMutations(CassandraTester): def test_super_cf_remove_column(self): - _insert_simple() - _insert_super() + assert _insert_simple() + assert _insert_super() # Make sure remove clears out what it's supposed to, and _only_ that: client.remove('Table1', 'key1', 'Super1:sc2:c5', 5, True) @@ -205,8 +208,8 @@ class TestMutations(CassandraTester): column_t(columnName='c7', value='value7', timestamp=0)])], actual def test_super_cf_remove_supercolumn(self): - _insert_simple() - _insert_super() + assert _insert_simple() + assert _insert_super() # Make sure remove clears out what it's supposed to, and _only_ that: client.remove('Table1', 'key1', 'Super1:sc2', 5, True) @@ -242,7 +245,7 @@ class TestMutations(CassandraTester): assert client.get_key_range('Table1', '', '', 1000) == [] def test_range_with_remove(self): - _insert_simple() + assert _insert_simple() assert client.get_key_range('Table1', 'key1', '', 1000) == ['key1'] client.remove('Table1', 'key1', 'Standard1:c1', 1, True) @@ -251,14 +254,14 @@ class TestMutations(CassandraTester): def test_range_collation(self): for key in ['-a', '-b', 'a', 'b'] + [str(i) for i in xrange(100)]: - client.insert_blocking('Table1', key, 'Standard1:' + key, 'v', 0) + assert client.insert_blocking('Table1', key, 'Standard1:' + key, 'v', 0) L = client.get_key_range('Table1', '', '', 1000) # note the collated ordering rather than ascii assert L == ['0', '1', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '2', '20', '21', '22', '23', '24', '25', '26', '27','28', '29', '3', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '4', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '5', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '6', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '7', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '8', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '9', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', 'a', '-a', 'b', '-b'], L def test_range_partial(self): for key in ['-a', '-b', 'a', 'b'] + [str(i) for i in xrange(100)]: - client.insert_blocking('Table1', key, 'Standard1:' + key, 'v', 0) + assert client.insert_blocking('Table1', key, 'Standard1:' + key, 'v', 0) L = client.get_key_range('Table1', 'a', '', 1000) assert L == ['a', '-a', 'b', '-b'], L