You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by al...@apache.org on 2013/05/11 00:33:51 UTC
git commit: Move CassandraServerTest.test_get_count() to thrift
server tests
Updated Branches:
refs/heads/cassandra-1.1 971a95abf -> ce8bc33d4
Move CassandraServerTest.test_get_count() to thrift server tests
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/ce8bc33d
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/ce8bc33d
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/ce8bc33d
Branch: refs/heads/cassandra-1.1
Commit: ce8bc33d438dc0877a2bcb0049d4c1d84db508d5
Parents: 971a95a
Author: Aleksey Yeschenko <al...@apache.org>
Authored: Sat May 11 01:30:17 2013 +0300
Committer: Aleksey Yeschenko <al...@apache.org>
Committed: Sat May 11 01:30:17 2013 +0300
----------------------------------------------------------------------
test/system/test_thrift_server.py | 29 +++++
.../cassandra/service/CassandraServerTest.java | 88 ---------------
2 files changed, 29 insertions(+), 88 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/ce8bc33d/test/system/test_thrift_server.py
----------------------------------------------------------------------
diff --git a/test/system/test_thrift_server.py b/test/system/test_thrift_server.py
index bcb75e8..8c459f2 100644
--- a/test/system/test_thrift_server.py
+++ b/test/system/test_thrift_server.py
@@ -273,6 +273,35 @@ class TestMutations(ThriftTester):
p = SlicePredicate(slice_range=SliceRange('', '', False, 10))
assert client.get_count('key1', ColumnParent('Standard1'), p, ConsistencyLevel.ONE) == 10
+ # test get_count() to work correctly with 'count' settings around page size (CASSANDRA-4833)
+ def test_count_around_page_size(self):
+ def slice_predicate(count):
+ return SlicePredicate(slice_range=SliceRange('', '', False, count))
+
+ _set_keyspace('Keyspace1')
+
+ key = 'key1'
+ parent = ColumnParent('Standard1')
+ cl = ConsistencyLevel.ONE
+
+ for i in xrange(0, 3050):
+ client.insert(key, parent, Column(str(i), '', 0), cl)
+
+ # same as page size
+ assert client.get_count(key, parent, slice_predicate(1024), cl) == 1024
+
+ # 1 above page size
+ assert client.get_count(key, parent, slice_predicate(1025), cl) == 1025
+
+ # above number or columns
+ assert client.get_count(key, parent, slice_predicate(4000), cl) == 3050
+
+ # same as number of columns
+ assert client.get_count(key, parent, slice_predicate(3050), cl) == 3050
+
+ # 1 above number of columns
+ assert client.get_count(key, parent, slice_predicate(3051), cl) == 3050
+
def test_insert_blocking(self):
_set_keyspace('Keyspace1')
_insert_simple()
http://git-wip-us.apache.org/repos/asf/cassandra/blob/ce8bc33d/test/unit/org/apache/cassandra/service/CassandraServerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/service/CassandraServerTest.java b/test/unit/org/apache/cassandra/service/CassandraServerTest.java
deleted file mode 100644
index 48701de..0000000
--- a/test/unit/org/apache/cassandra/service/CassandraServerTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.cassandra.service;
-
-import org.junit.Test;
-
-import org.apache.cassandra.SchemaLoader;
-import org.apache.cassandra.Util;
-import org.apache.cassandra.config.Schema;
-import org.apache.cassandra.db.DecoratedKey;
-import org.apache.cassandra.db.RowMutation;
-import org.apache.cassandra.db.filter.QueryPath;
-import org.apache.cassandra.thrift.*;
-import org.apache.cassandra.utils.ByteBufferUtil;
-
-public class CassandraServerTest extends SchemaLoader
-{
- /**
- * test get_count() to work correctly with 'count' settings around page size.
- * (CASSANDRA-4833)
- */
- @Test
- public void test_get_count() throws Exception
- {
- Schema.instance.clear(); // Schema are now written on disk and will be reloaded
- new EmbeddedCassandraService().start();
-
- DecoratedKey key = Util.dk("testkey");
- for (int i = 0; i < 3050; i++)
- {
- RowMutation rm = new RowMutation("Keyspace1", key.key);
- rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes(String.valueOf(i))),
- ByteBufferUtil.EMPTY_BYTE_BUFFER,
- System.currentTimeMillis());
- rm.apply();
- }
-
- CassandraServer server = new CassandraServer();
- server.set_keyspace("Keyspace1");
-
- // same as page size
- int count = server.get_count(key.key, new ColumnParent("Standard1"), predicateWithCount(1024), ConsistencyLevel.ONE);
- assert count == 1024 : "expected 1024 but was " + count;
-
- // 1 above page size
- count = server.get_count(key.key, new ColumnParent("Standard1"), predicateWithCount(1025), ConsistencyLevel.ONE);
- assert count == 1025 : "expected 1025 but was " + count;
-
- // above number of columns
- count = server.get_count(key.key, new ColumnParent("Standard1"), predicateWithCount(4000), ConsistencyLevel.ONE);
- assert count == 3050 : "expected 3050 but was " + count;
-
- // same as number of columns
- count = server.get_count(key.key, new ColumnParent("Standard1"), predicateWithCount(3050), ConsistencyLevel.ONE);
- assert count == 3050 : "expected 3050 but was " + count;
-
- // 1 above number of columns
- count = server.get_count(key.key, new ColumnParent("Standard1"), predicateWithCount(3051), ConsistencyLevel.ONE);
- assert count == 3050 : "expected 3050 but was " + count;
- }
-
- private SlicePredicate predicateWithCount(int count)
- {
- SliceRange range = new SliceRange();
- range.setStart("".getBytes());
- range.setFinish("".getBytes());
- range.setCount(count);
- SlicePredicate predicate = new SlicePredicate();
- predicate.setSlice_range(range);
- return predicate;
- }
-}