test: Move B+tree compactiont test from unit to boost
This time the boost test needs to stop being pure-boost test, since bptree compaction test case needs to run in seastar thread. Other collection tests are already such, not bptree_test joins the party. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
@@ -630,7 +630,6 @@ scylla_tests = set([
|
||||
'test/unit/lsa_sync_eviction_test',
|
||||
'test/unit/row_cache_alloc_stress_test',
|
||||
'test/unit/row_cache_stress_test',
|
||||
'test/unit/bptree_compaction_test',
|
||||
'test/unit/cross_shard_barrier_test',
|
||||
])
|
||||
|
||||
@@ -1394,7 +1393,6 @@ pure_boost_tests = set([
|
||||
'test/boost/small_vector_test',
|
||||
'test/boost/top_k_test',
|
||||
'test/boost/vint_serialization_test',
|
||||
'test/boost/bptree_test',
|
||||
'test/boost/utf8_test',
|
||||
'test/boost/string_format_test',
|
||||
'test/manual/streaming_histogram_test',
|
||||
@@ -1415,7 +1413,6 @@ tests_not_using_seastar_test_framework = set([
|
||||
'test/unit/lsa_async_eviction_test',
|
||||
'test/unit/lsa_sync_eviction_test',
|
||||
'test/unit/row_cache_alloc_stress_test',
|
||||
'test/unit/bptree_compaction_test',
|
||||
'test/manual/sstable_scan_footprint_test',
|
||||
'test/unit/cross_shard_barrier_test',
|
||||
]) | pure_boost_tests
|
||||
|
||||
@@ -7,11 +7,10 @@
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#define BOOST_TEST_MODULE bptree
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <fmt/core.h>
|
||||
|
||||
#include <seastar/testing/thread_test_case.hh>
|
||||
#include "utils/assert.hh"
|
||||
#include "utils/bptree.hh"
|
||||
#include "test/unit/collection_stress.hh"
|
||||
@@ -478,3 +477,50 @@ BOOST_AUTO_TEST_CASE(stress_test) {
|
||||
|
||||
delete itc;
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(stress_compaction_test) {
|
||||
constexpr int TEST_NODE_SIZE = 7;
|
||||
|
||||
using test_key = tree_test_key_base;
|
||||
|
||||
class test_data {
|
||||
int _value;
|
||||
public:
|
||||
test_data() : _value(0) {}
|
||||
test_data(test_key& k) : _value((int)k + 10) {}
|
||||
|
||||
operator unsigned long() const { return _value; }
|
||||
bool match_key(const test_key& k) const { return _value == (int)k + 10; }
|
||||
};
|
||||
using test_tree = tree<test_key, test_data, test_key_compare, TEST_NODE_SIZE, key_search::both, with_debug::yes>;
|
||||
using test_validator = validator<test_key, test_data, test_key_compare, TEST_NODE_SIZE>;
|
||||
|
||||
stress_config cfg;
|
||||
cfg.count = 10000;
|
||||
cfg.iters = 13;
|
||||
cfg.verb = false;
|
||||
|
||||
tree_pointer<test_tree> t(test_key_compare{});
|
||||
test_validator tv;
|
||||
|
||||
stress_compact_collection(cfg,
|
||||
/* insert */ [&] (int key) {
|
||||
test_key k(key);
|
||||
auto ti = t->emplace(copy_key(k), k);
|
||||
SCYLLA_ASSERT(ti.second);
|
||||
},
|
||||
/* erase */ [&] (int key) {
|
||||
t->erase(test_key(key));
|
||||
},
|
||||
/* validate */ [&] {
|
||||
if (cfg.verb) {
|
||||
fmt::print("Validating:\n");
|
||||
tv.print_tree(*t, '|');
|
||||
}
|
||||
tv.validate(*t);
|
||||
},
|
||||
/* clear */ [&] {
|
||||
t->clear();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
add_scylla_test(bptree_compaction_test
|
||||
KIND UNIT)
|
||||
add_scylla_test(cross_shard_barrier_test
|
||||
KIND UNIT)
|
||||
add_scylla_test(lsa_sync_eviction_test
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020-present ScyllaDB
|
||||
*/
|
||||
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include <seastar/core/app-template.hh>
|
||||
#include <seastar/core/thread.hh>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fmt/core.h>
|
||||
|
||||
constexpr int TEST_NODE_SIZE = 7;
|
||||
|
||||
#include "tree_test_key.hh"
|
||||
#include "utils/assert.hh"
|
||||
#include "utils/bptree.hh"
|
||||
#include "bptree_validation.hh"
|
||||
#include "collection_stress.hh"
|
||||
|
||||
using namespace bplus;
|
||||
using namespace seastar;
|
||||
|
||||
using test_key = tree_test_key_base;
|
||||
|
||||
class test_data {
|
||||
int _value;
|
||||
public:
|
||||
test_data() : _value(0) {}
|
||||
test_data(test_key& k) : _value((int)k + 10) {}
|
||||
|
||||
operator unsigned long() const { return _value; }
|
||||
bool match_key(const test_key& k) const { return _value == (int)k + 10; }
|
||||
};
|
||||
using test_tree = tree<test_key, test_data, test_key_compare, TEST_NODE_SIZE, key_search::both, with_debug::yes>;
|
||||
using test_validator = validator<test_key, test_data, test_key_compare, TEST_NODE_SIZE>;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
namespace bpo = boost::program_options;
|
||||
app_template app;
|
||||
app.add_options()
|
||||
("count", bpo::value<int>()->default_value(10000), "number of keys to fill the tree with")
|
||||
("iters", bpo::value<int>()->default_value(13), "number of iterations")
|
||||
("verb", bpo::value<bool>()->default_value(false), "be verbose");
|
||||
|
||||
return app.run(argc, argv, [&app] {
|
||||
auto count = app.configuration()["count"].as<int>();
|
||||
auto iter = app.configuration()["iters"].as<int>();
|
||||
auto verb = app.configuration()["verb"].as<bool>();
|
||||
|
||||
return seastar::async([count, iter, verb] {
|
||||
stress_config cfg;
|
||||
cfg.count = count;
|
||||
cfg.iters = iter;
|
||||
cfg.verb = verb;
|
||||
|
||||
tree_pointer<test_tree> t(test_key_compare{});
|
||||
test_validator tv;
|
||||
|
||||
stress_compact_collection(cfg,
|
||||
/* insert */ [&] (int key) {
|
||||
test_key k(key);
|
||||
auto ti = t->emplace(copy_key(k), k);
|
||||
SCYLLA_ASSERT(ti.second);
|
||||
},
|
||||
/* erase */ [&] (int key) {
|
||||
t->erase(test_key(key));
|
||||
},
|
||||
/* validate */ [&] {
|
||||
if (verb) {
|
||||
fmt::print("Validating:\n");
|
||||
tv.print_tree(*t, '|');
|
||||
}
|
||||
tv.validate(*t);
|
||||
},
|
||||
/* clear */ [&] {
|
||||
t->clear();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user