database_test: Add test case for row limit
This patch introduces database_test and adds a test case to ensure the row limit is respected when querying multiple partition ranges. Signed-off-by: Duarte Nunes <duarte@scylladb.com> Message-Id: <20160623111723.17523-1-duarte@scylladb.com>
This commit is contained in:
committed by
Tomasz Grabiec
parent
e647ec1c4a
commit
1ffae6e6ee
@@ -219,6 +219,7 @@ scylla_tests = [
|
||||
'tests/idl_test',
|
||||
'tests/range_tombstone_list_test',
|
||||
'tests/anchorless_list_test',
|
||||
'tests/database_test',
|
||||
]
|
||||
|
||||
apps = [
|
||||
|
||||
1
test.py
1
test.py
@@ -72,6 +72,7 @@ boost_tests = [
|
||||
'range_tombstone_list_test',
|
||||
'streamed_mutation_test',
|
||||
'anchorless_list_test',
|
||||
'database_test',
|
||||
]
|
||||
|
||||
other_tests = [
|
||||
|
||||
62
tests/database_test.cc
Normal file
62
tests/database_test.cc
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2016 ScyllaDB
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is part of Scylla.
|
||||
*
|
||||
* Scylla is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Scylla is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Scylla. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define BOOST_TEST_DYN_LINK
|
||||
|
||||
#include <seastar/core/thread.hh>
|
||||
#include <seastar/tests/test-utils.hh>
|
||||
|
||||
#include "tests/cql_test_env.hh"
|
||||
#include "tests/result_set_assertions.hh"
|
||||
|
||||
#include "database.hh"
|
||||
#include "partition_slice_builder.hh"
|
||||
#include "frozen_mutation.hh"
|
||||
|
||||
#include "disk-error-handler.hh"
|
||||
|
||||
thread_local disk_error_signal_type commit_error;
|
||||
thread_local disk_error_signal_type general_disk_error;
|
||||
|
||||
SEASTAR_TEST_CASE(test_querying_with_limits) {
|
||||
return do_with_cql_env([](cql_test_env& e) {
|
||||
return seastar::async([&] {
|
||||
e.execute_cql("create table ks.cf (k text, v int, primary key (k));").get();
|
||||
auto& db = e.local_db();
|
||||
auto s = db.find_schema("ks", "cf");
|
||||
std::vector<query::partition_range> pranges;
|
||||
for (uint32_t i = 1; i <= 5; ++i) {
|
||||
auto pkey = partition_key::from_single_value(*s, to_bytes(sprint("key%d", i)));
|
||||
mutation m(pkey, s);
|
||||
m.set_clustered_cell(clustering_key_prefix::make_empty(), "v", data_value(bytes("v1")), 1);
|
||||
db.apply(s, freeze(m)).get();
|
||||
pranges.emplace_back(query::partition_range::make_singular(dht::global_partitioner().decorate_key(*s, std::move(pkey))));
|
||||
}
|
||||
|
||||
auto cmd = query::read_command(s->id(), s->version(), partition_slice_builder(*s).build(), 3);
|
||||
|
||||
{
|
||||
auto result = db.query(s, cmd, query::result_request::only_result, pranges).get0();
|
||||
assert_that(query::result_set::from_raw_result(s, cmd.slice, *result)).has_size(3);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user