We currently have two method families to generate partition keys: * make_keys() in test/lib/simple_schema.hh * token_generation_for_shard() in test/lib/sstable_utils.hh Both work only for schemas with a single partition key column of `text` type and both generate keys of fixed size. This is very restrictive and simplistic. Tests, which wanted anything more complicated than that had to rely on open-coded key generation. Also, many tests started to rely on the simplistic nature of these keys, in particular two tests started failing because the new key generation method generated keys of varying size: * sstable_compaction_test.sstable_run_based_compaction_test * sstable_mutation_test.test_key_count_estimation These two tests seems to depend on generated keys all being of the same size. This makes some sense in the case of the key count estimation test, but makes no sense at all to me in the case of the sstable run test. Closes #12657 * github.com:scylladb/scylladb: test/lib/sstable_utils: remove now unused token_generation_for_shard() and friends test/lib/simple_schema: remove now unused make_keys() and friends test: migrate to tests::generate_partition_key[s]() test/lib/test_services: add table_for_tests::make_default_schema() test/lib: add key_utils.hh test/lib/random_schema.hh: value_generator: add min_size_in_bytes
80 lines
2.5 KiB
C++
80 lines
2.5 KiB
C++
/*
|
|
* This file is open source software, licensed to you under the terms
|
|
* of the Apache License, Version 2.0 (the "License"). See the NOTICE file
|
|
* distributed with this work for additional information regarding copyright
|
|
* ownership. 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.
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2016-present ScyllaDB
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include <seastar/core/seastar.hh>
|
|
|
|
#include "schema.hh"
|
|
#include "schema_builder.hh"
|
|
#include "row_cache.hh"
|
|
#include "replica/database.hh"
|
|
#include "cell_locking.hh"
|
|
#include "compaction/compaction_manager.hh"
|
|
#include "compaction/table_state.hh"
|
|
#include "sstables/sstables_manager.hh"
|
|
|
|
struct table_for_tests {
|
|
class table_state;
|
|
struct data {
|
|
schema_ptr s;
|
|
reader_concurrency_semaphore semaphore;
|
|
cache_tracker tracker;
|
|
replica::cf_stats cf_stats{0};
|
|
replica::column_family::config cfg;
|
|
cell_locker_stats cl_stats;
|
|
tasks::task_manager tm;
|
|
compaction_manager cm{tm, compaction_manager::for_testing_tag{}};
|
|
lw_shared_ptr<replica::column_family> cf;
|
|
std::unique_ptr<table_state> table_s;
|
|
data();
|
|
~data();
|
|
};
|
|
lw_shared_ptr<data> _data;
|
|
|
|
static schema_ptr make_default_schema();
|
|
|
|
explicit table_for_tests(sstables::sstables_manager& sstables_manager);
|
|
|
|
explicit table_for_tests(sstables::sstables_manager& sstables_manager, schema_ptr s, std::optional<sstring> datadir = {});
|
|
|
|
schema_ptr schema() { return _data->s; }
|
|
|
|
const replica::cf_stats& cf_stats() const noexcept { return _data->cf_stats; }
|
|
|
|
operator lw_shared_ptr<replica::column_family>() { return _data->cf; }
|
|
|
|
replica::column_family& operator*() { return *_data->cf; }
|
|
replica::column_family* operator->() { return _data->cf.get(); }
|
|
|
|
compaction_manager& get_compaction_manager() noexcept { return _data->cm; }
|
|
|
|
compaction::table_state& as_table_state() noexcept;
|
|
|
|
future<> stop();
|
|
|
|
future<> stop_and_keep_alive() {
|
|
return stop().finally([cf = *this] {});
|
|
}
|
|
};
|