sstables: move column_family_test class from test/boost to test/lib

Column_family_test allows performing private methods on column_family's
sstable_set. It may be useful not only in the boost tests, so it's moved
from test/boost/sstable_test.hh to test/lib/sstable_test_env.hh.
sstable_test.hh includes sstable_test_env.hh, so no includes need to be
changed.

Signed-off-by: Wojciech Mitros <wojciech.mitros@scylladb.com>
This commit is contained in:
Wojciech Mitros
2020-12-11 00:33:18 +01:00
parent 0feff8712e
commit 693b4e0fcd
2 changed files with 35 additions and 34 deletions

View File

@@ -37,40 +37,6 @@
#include <boost/test/unit_test.hpp>
#include <array>
constexpr auto la = sstables::sstable::version_types::la;
constexpr auto big = sstables::sstable::format_types::big;
class column_family_test {
lw_shared_ptr<column_family> _cf;
public:
column_family_test(lw_shared_ptr<column_family> cf) : _cf(cf) {}
void add_sstable(sstables::shared_sstable sstable) {
_cf->_sstables->insert(std::move(sstable));
}
// NOTE: must run in a thread
void rebuild_sstable_list(const std::vector<sstables::shared_sstable>& new_sstables,
const std::vector<sstables::shared_sstable>& sstables_to_remove) {
_cf->_sstables = _cf->build_new_sstable_list(new_sstables, sstables_to_remove).get0();
}
static void update_sstables_known_generation(column_family& cf, unsigned generation) {
cf.update_sstables_known_generation(generation);
}
static uint64_t calculate_generation_for_new_table(column_family& cf) {
return cf.calculate_generation_for_new_table();
}
static int64_t calculate_shard_from_sstable_generation(int64_t generation) {
return column_family::calculate_shard_from_sstable_generation(generation);
}
future<stop_iteration> try_flush_memtable_to_sstable(lw_shared_ptr<memtable> mt) {
return _cf->try_flush_memtable_to_sstable(mt, sstable_write_permit::unconditional());
}
};
namespace sstables {

View File

@@ -31,6 +31,41 @@
#include "test/lib/test_services.hh"
#include "test/lib/log.hh"
constexpr auto la = sstables::sstable::version_types::la;
constexpr auto big = sstables::sstable::format_types::big;
class column_family_test {
lw_shared_ptr<column_family> _cf;
public:
column_family_test(lw_shared_ptr<column_family> cf) : _cf(cf) {}
void add_sstable(sstables::shared_sstable sstable) {
_cf->_sstables->insert(std::move(sstable));
}
// NOTE: must run in a thread
void rebuild_sstable_list(const std::vector<sstables::shared_sstable>& new_sstables,
const std::vector<sstables::shared_sstable>& sstables_to_remove) {
_cf->_sstables = _cf->build_new_sstable_list(new_sstables, sstables_to_remove).get0();
}
static void update_sstables_known_generation(column_family& cf, unsigned generation) {
cf.update_sstables_known_generation(generation);
}
static uint64_t calculate_generation_for_new_table(column_family& cf) {
return cf.calculate_generation_for_new_table();
}
static int64_t calculate_shard_from_sstable_generation(int64_t generation) {
return column_family::calculate_shard_from_sstable_generation(generation);
}
future<stop_iteration> try_flush_memtable_to_sstable(lw_shared_ptr<memtable> mt) {
return _cf->try_flush_memtable_to_sstable(mt, sstable_write_permit::unconditional());
}
};
namespace sstables {
class test_env_sstables_manager : public sstables_manager {