mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
test: Don't nest seastar::async calls (cont)
The continuation of the previous patch for the cases when the sstables::test_env::run_with_async sits lower the stack from the SEASTAR_THREAD_TEST_CASE. The patching is similar but also requires some care about reference-captured variables. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
@@ -40,9 +40,9 @@ struct my_consumer {
|
||||
};
|
||||
}
|
||||
|
||||
static void broken_sst(sstring dir, unsigned long generation, schema_ptr s, sstring msg, std::optional<sstring> sst_name,
|
||||
static future<> broken_sst(sstring dir, unsigned long generation, schema_ptr s, sstring msg, std::optional<sstring> sst_name,
|
||||
sstable_version_types version = la) {
|
||||
sstables::test_env::do_with_async([&] (sstables::test_env& env) {
|
||||
return sstables::test_env::do_with_async([=] (sstables::test_env& env) {
|
||||
try {
|
||||
sstable_ptr sstp = env.reusable_sst(s, dir, generation, version).get0();
|
||||
auto r = sstp->make_reader(s, env.make_reader_permit(), query::full_partition_range, s->full_slice());
|
||||
@@ -56,10 +56,10 @@ static void broken_sst(sstring dir, unsigned long generation, schema_ptr s, sstr
|
||||
BOOST_REQUIRE(ex_what.find(*sst_name) != sstring::npos);
|
||||
}
|
||||
}
|
||||
}).get();
|
||||
});
|
||||
}
|
||||
|
||||
static void broken_sst(sstring dir, unsigned long generation, sstring msg, std::optional<sstring> sst_name = std::nullopt) {
|
||||
static future<> broken_sst(sstring dir, unsigned long generation, sstring msg, std::optional<sstring> sst_name = std::nullopt) {
|
||||
// Using an empty schema for this function, which is only about loading
|
||||
// a malformed component and checking that it fails.
|
||||
auto s = make_shared_schema({}, "ks", "cf", {}, {}, {}, {}, utf8_type);
|
||||
@@ -81,26 +81,26 @@ SEASTAR_TEST_CASE(test_empty_index) {
|
||||
});
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(missing_column_in_schema) {
|
||||
SEASTAR_TEST_CASE(missing_column_in_schema) {
|
||||
schema_ptr s = schema_builder("test_ks", "test_table")
|
||||
.with_column("key1", utf8_type, column_kind::partition_key)
|
||||
.with_column("key2", utf8_type, column_kind::clustering_key)
|
||||
.with_column("key3", utf8_type, column_kind::clustering_key)
|
||||
.build(schema_builder::compact_storage::no);
|
||||
broken_sst("test/resource/sstables/incompatible_serialized_type", 122, s,
|
||||
return broken_sst("test/resource/sstables/incompatible_serialized_type", 122, s,
|
||||
"Column val missing in current schema",
|
||||
"test/resource/sstables/incompatible_serialized_type/mc-122-big-Data.db",
|
||||
sstable::version_types::mc);
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(incompatible_serialized_type) {
|
||||
SEASTAR_TEST_CASE(incompatible_serialized_type) {
|
||||
schema_ptr s = schema_builder("test_ks", "test_table")
|
||||
.with_column("key1", utf8_type, column_kind::partition_key)
|
||||
.with_column("key2", utf8_type, column_kind::clustering_key)
|
||||
.with_column("key3", utf8_type, column_kind::clustering_key)
|
||||
.with_column("val", int32_type, column_kind::regular_column)
|
||||
.build(schema_builder::compact_storage::no);
|
||||
broken_sst("test/resource/sstables/incompatible_serialized_type", 122, s,
|
||||
return broken_sst("test/resource/sstables/incompatible_serialized_type", 122, s,
|
||||
"val definition in serialization header does not match schema. Expected "
|
||||
"org.apache.cassandra.db.marshal.Int32Type but got "
|
||||
"org.apache.cassandra.db.marshal.UTF8Type",
|
||||
@@ -108,7 +108,7 @@ SEASTAR_THREAD_TEST_CASE(incompatible_serialized_type) {
|
||||
sstable::version_types::mc);
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(invalid_boundary) {
|
||||
SEASTAR_TEST_CASE(invalid_boundary) {
|
||||
schema_ptr s = schema_builder("test_ks", "test_t")
|
||||
.with_column("p", int32_type, column_kind::partition_key)
|
||||
.with_column("a", int32_type, column_kind::clustering_key)
|
||||
@@ -116,20 +116,20 @@ SEASTAR_THREAD_TEST_CASE(invalid_boundary) {
|
||||
.with_column("c", int32_type, column_kind::clustering_key)
|
||||
.with_column("r", int32_type, column_kind::regular_column)
|
||||
.build(schema_builder::compact_storage::no);
|
||||
broken_sst("test/resource/sstables/invalid_boundary", 33, s,
|
||||
return broken_sst("test/resource/sstables/invalid_boundary", 33, s,
|
||||
"Corrupted range tombstone: invalid boundary type static_clustering",
|
||||
"test/resource/sstables/invalid_boundary/mc-33-big-Data.db",
|
||||
sstable::version_types::mc);
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(mismatched_timestamp) {
|
||||
SEASTAR_TEST_CASE(mismatched_timestamp) {
|
||||
schema_ptr s = schema_builder("test_ks", "test_table")
|
||||
.with_column("key1", utf8_type, column_kind::partition_key)
|
||||
.with_column("key2", utf8_type, column_kind::clustering_key)
|
||||
.with_column("key3", utf8_type, column_kind::clustering_key)
|
||||
.with_column("val", utf8_type, column_kind::regular_column)
|
||||
.build(schema_builder::compact_storage::no);
|
||||
broken_sst("test/resource/sstables/mismatched_timestamp", 122, s,
|
||||
return broken_sst("test/resource/sstables/mismatched_timestamp", 122, s,
|
||||
"Range tombstone with ck ckp{00056b65793262} and two different tombstones at ends: "
|
||||
"{tombstone: timestamp=1544745393692803, deletion_time=1544745393}, {tombstone: "
|
||||
"timestamp=1446576446577440, deletion_time=1442880998}",
|
||||
@@ -137,14 +137,14 @@ SEASTAR_THREAD_TEST_CASE(mismatched_timestamp) {
|
||||
sstable::version_types::mc);
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(broken_open_tombstone) {
|
||||
SEASTAR_TEST_CASE(broken_open_tombstone) {
|
||||
schema_ptr s = schema_builder("test_ks", "test_table")
|
||||
.with_column("key1", utf8_type, column_kind::partition_key)
|
||||
.with_column("key2", utf8_type, column_kind::clustering_key)
|
||||
.with_column("key3", utf8_type, column_kind::clustering_key)
|
||||
.with_column("val", utf8_type, column_kind::regular_column)
|
||||
.build(schema_builder::compact_storage::no);
|
||||
broken_sst("test/resource/sstables/broken_open_tombstone", 122, s,
|
||||
return broken_sst("test/resource/sstables/broken_open_tombstone", 122, s,
|
||||
"Range tombstones have to be disjoint: current opened range tombstone "
|
||||
"{tombstone: timestamp=1544745393692803, deletion_time=1544745393}, "
|
||||
"new tombstone {tombstone: timestamp=1544745393692803, "
|
||||
@@ -153,102 +153,102 @@ SEASTAR_THREAD_TEST_CASE(broken_open_tombstone) {
|
||||
sstable::version_types::mc);
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(broken_close_tombstone) {
|
||||
SEASTAR_TEST_CASE(broken_close_tombstone) {
|
||||
schema_ptr s = schema_builder("test_ks", "test_table")
|
||||
.with_column("key1", utf8_type, column_kind::partition_key)
|
||||
.with_column("key2", utf8_type, column_kind::clustering_key)
|
||||
.with_column("key3", utf8_type, column_kind::clustering_key)
|
||||
.with_column("val", utf8_type, column_kind::regular_column)
|
||||
.build(schema_builder::compact_storage::no);
|
||||
broken_sst("test/resource/sstables/broken_close_tombstone", 122, s,
|
||||
return broken_sst("test/resource/sstables/broken_close_tombstone", 122, s,
|
||||
"Closing range tombstone that wasn't opened: clustering ckp{00056b65793262}, kind incl "
|
||||
"end, tombstone {tombstone: timestamp=1544745393692803, deletion_time=1544745393}",
|
||||
"test/resource/sstables/broken_close_tombstone/mc-122-big-Data.db",
|
||||
sstable::version_types::mc);
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(broken_start_composite) {
|
||||
SEASTAR_TEST_CASE(broken_start_composite) {
|
||||
schema_ptr s =
|
||||
schema_builder("test_ks", "test_table")
|
||||
.with_column("test_key", utf8_type, column_kind::partition_key)
|
||||
.with_column("test_val", utf8_type, column_kind::clustering_key)
|
||||
.build(schema_builder::compact_storage::no);
|
||||
broken_sst("test/resource/sstables/broken_start_composite", 76, s,
|
||||
return broken_sst("test/resource/sstables/broken_start_composite", 76, s,
|
||||
"Unexpected start composite marker 2", "test/resource/sstables/broken_start_composite/la-76-big-Data.db");
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(broken_end_composite) {
|
||||
SEASTAR_TEST_CASE(broken_end_composite) {
|
||||
schema_ptr s =
|
||||
schema_builder("test_ks", "test_table")
|
||||
.with_column("test_key", utf8_type, column_kind::partition_key)
|
||||
.with_column("test_val", utf8_type, column_kind::clustering_key)
|
||||
.build(schema_builder::compact_storage::no);
|
||||
broken_sst("test/resource/sstables/broken_end_composite", 76, s,
|
||||
return broken_sst("test/resource/sstables/broken_end_composite", 76, s,
|
||||
"Unexpected end composite marker 3", "test/resource/sstables/broken_end_composite/la-76-big-Data.db");
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(static_mismatch) {
|
||||
SEASTAR_TEST_CASE(static_mismatch) {
|
||||
schema_ptr s =
|
||||
schema_builder("test_foo_bar_zed_baz_ks", "test_foo_bar_zed_baz_table")
|
||||
.with_column("test_foo_bar_zed_baz_key", utf8_type, column_kind::partition_key)
|
||||
.with_column("test_foo_bar_zed_baz_val", utf8_type, column_kind::clustering_key)
|
||||
.with_column("test_foo_bar_zed_baz_static", utf8_type, column_kind::regular_column)
|
||||
.build(schema_builder::compact_storage::no);
|
||||
broken_sst("test/resource/sstables/static_column", 58, s,
|
||||
return broken_sst("test/resource/sstables/static_column", 58, s,
|
||||
"Mismatch between static cell and non-static column definition",
|
||||
"test/resource/sstables/static_column/la-58-big-Data.db");
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(static_with_clustering) {
|
||||
SEASTAR_TEST_CASE(static_with_clustering) {
|
||||
schema_ptr s =
|
||||
schema_builder("test_foo_bar_zed_baz_ks", "test_foo_bar_zed_baz_table")
|
||||
.with_column("test_foo_bar_zed_baz_key", utf8_type, column_kind::partition_key)
|
||||
.with_column("test_foo_bar_zed_baz_val", utf8_type, column_kind::clustering_key)
|
||||
.with_column("test_foo_bar_zed_baz_static", utf8_type, column_kind::static_column)
|
||||
.build(schema_builder::compact_storage::no);
|
||||
broken_sst("test/resource/sstables/static_with_clustering", 58, s,
|
||||
return broken_sst("test/resource/sstables/static_with_clustering", 58, s,
|
||||
"Static row has clustering key information. I didn't expect that!",
|
||||
"test/resource/sstables/static_with_clustering/la-58-big-Data.db");
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(zero_sized_histogram) {
|
||||
broken_sst("test/resource/sstables/zero_sized_histogram", 5,
|
||||
SEASTAR_TEST_CASE(zero_sized_histogram) {
|
||||
return broken_sst("test/resource/sstables/zero_sized_histogram", 5,
|
||||
"Estimated histogram with zero size found. Can't continue!",
|
||||
"test/resource/sstables/zero_sized_histogram/la-5-big-Statistics.db");
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(bad_column_name) {
|
||||
broken_sst("test/resource/sstables/bad_column_name", 58,
|
||||
SEASTAR_TEST_CASE(bad_column_name) {
|
||||
return broken_sst("test/resource/sstables/bad_column_name", 58,
|
||||
"Found 3 clustering elements in column name. Was not expecting that!",
|
||||
"test/resource/sstables/bad_column_name/la-58-big-Data.db");
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(empty_toc) {
|
||||
broken_sst("test/resource/sstables/badtoc", 1,
|
||||
SEASTAR_TEST_CASE(empty_toc) {
|
||||
return broken_sst("test/resource/sstables/badtoc", 1,
|
||||
"Empty TOC in sstable test/resource/sstables/badtoc/la-1-big-TOC.txt");
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(alien_toc) {
|
||||
broken_sst("test/resource/sstables/badtoc", 2,
|
||||
SEASTAR_TEST_CASE(alien_toc) {
|
||||
return broken_sst("test/resource/sstables/badtoc", 2,
|
||||
"test/resource/sstables/badtoc/la-2-big-Statistics.db: file not found");
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(truncated_toc) {
|
||||
broken_sst("test/resource/sstables/badtoc", 3,
|
||||
SEASTAR_TEST_CASE(truncated_toc) {
|
||||
return broken_sst("test/resource/sstables/badtoc", 3,
|
||||
"test/resource/sstables/badtoc/la-3-big-Statistics.db: file not found");
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(wrong_format_toc) {
|
||||
broken_sst("test/resource/sstables/badtoc", 4,
|
||||
SEASTAR_TEST_CASE(wrong_format_toc) {
|
||||
return broken_sst("test/resource/sstables/badtoc", 4,
|
||||
"test/resource/sstables/badtoc/la-4-big-TOC.txt: file not found");
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(compression_truncated) {
|
||||
broken_sst("test/resource/sstables/badcompression", 1,
|
||||
SEASTAR_TEST_CASE(compression_truncated) {
|
||||
return broken_sst("test/resource/sstables/badcompression", 1,
|
||||
"test/resource/sstables/badcompression/la-1-big-Statistics.db: file not found");
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(compression_bytes_flipped) {
|
||||
broken_sst("test/resource/sstables/badcompression", 2,
|
||||
SEASTAR_TEST_CASE(compression_bytes_flipped) {
|
||||
return broken_sst("test/resource/sstables/badcompression", 2,
|
||||
"test/resource/sstables/badcompression/la-2-big-Statistics.db: file not found");
|
||||
}
|
||||
|
||||
@@ -1731,8 +1731,8 @@ static schema_builder make_partition_key_with_values_of_different_types_schema_b
|
||||
static thread_local const schema_builder PARTITION_KEY_WITH_VALUES_OF_DIFFERENT_TYPES_SCHEMA_BUILDER =
|
||||
make_partition_key_with_values_of_different_types_schema_builder();
|
||||
|
||||
static void test_partition_key_with_values_of_different_types_read(const sstring& path, compression_parameters cp) {
|
||||
test_env::do_with_async([path, cp] (test_env& env) {
|
||||
static future<> test_partition_key_with_values_of_different_types_read(const sstring& path, compression_parameters cp) {
|
||||
return test_env::do_with_async([path, cp] (test_env& env) {
|
||||
auto s = schema_builder(PARTITION_KEY_WITH_VALUES_OF_DIFFERENT_TYPES_SCHEMA_BUILDER).set_compressor_params(cp).build();
|
||||
|
||||
auto bool_cdef = s->get_column_definition(to_bytes("bool_val"));
|
||||
@@ -1821,31 +1821,31 @@ static void test_partition_key_with_values_of_different_types_read(const sstring
|
||||
"variable length text 3"))
|
||||
.produces_partition_end()
|
||||
.produces_end_of_stream();
|
||||
}).get();
|
||||
});
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(test_uncompressed_partition_key_with_values_of_different_types_read) {
|
||||
test_partition_key_with_values_of_different_types_read(
|
||||
SEASTAR_TEST_CASE(test_uncompressed_partition_key_with_values_of_different_types_read) {
|
||||
return test_partition_key_with_values_of_different_types_read(
|
||||
UNCOMPRESSED_PARTITION_KEY_WITH_VALUES_OF_DIFFERENT_TYPES_PATH, compression_parameters::no_compression());
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(test_lz4_partition_key_with_values_of_different_types_read) {
|
||||
test_partition_key_with_values_of_different_types_read(
|
||||
SEASTAR_TEST_CASE(test_lz4_partition_key_with_values_of_different_types_read) {
|
||||
return test_partition_key_with_values_of_different_types_read(
|
||||
LZ4_PARTITION_KEY_WITH_VALUES_OF_DIFFERENT_TYPES_PATH, compressor::lz4);
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(test_snappy_partition_key_with_values_of_different_types_read) {
|
||||
test_partition_key_with_values_of_different_types_read(
|
||||
SEASTAR_TEST_CASE(test_snappy_partition_key_with_values_of_different_types_read) {
|
||||
return test_partition_key_with_values_of_different_types_read(
|
||||
SNAPPY_PARTITION_KEY_WITH_VALUES_OF_DIFFERENT_TYPES_PATH, compressor::snappy);
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(test_deflate_partition_key_with_values_of_different_types_read) {
|
||||
test_partition_key_with_values_of_different_types_read(
|
||||
SEASTAR_TEST_CASE(test_deflate_partition_key_with_values_of_different_types_read) {
|
||||
return test_partition_key_with_values_of_different_types_read(
|
||||
DEFLATE_PARTITION_KEY_WITH_VALUES_OF_DIFFERENT_TYPES_PATH, compressor::deflate);
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(test_zstd_partition_key_with_values_of_different_types_read) {
|
||||
test_partition_key_with_values_of_different_types_read(
|
||||
SEASTAR_TEST_CASE(test_zstd_partition_key_with_values_of_different_types_read) {
|
||||
return test_partition_key_with_values_of_different_types_read(
|
||||
ZSTD_PARTITION_KEY_WITH_VALUES_OF_DIFFERENT_TYPES_PATH, compressor::create({
|
||||
{"sstable_compression", "org.apache.cassandra.io.compress.ZstdCompressor"},
|
||||
{"compression_level", "1"}}));
|
||||
@@ -3819,8 +3819,8 @@ SEASTAR_TEST_CASE(test_write_multiple_partitions) {
|
||||
});
|
||||
}
|
||||
|
||||
static void test_write_many_partitions(sstring table_name, tombstone partition_tomb, compression_parameters cp) {
|
||||
test_env::do_with_async([table_name, partition_tomb, cp] (test_env& env) {
|
||||
static future<> test_write_many_partitions(sstring table_name, tombstone partition_tomb, compression_parameters cp) {
|
||||
return test_env::do_with_async([table_name, partition_tomb, cp] (test_env& env) {
|
||||
// CREATE TABLE <table_name> (pk int, PRIMARY KEY (pk)) WITH compression = {'sstable_compression': ''};
|
||||
schema_builder builder("sst3", table_name);
|
||||
builder.with_column("pk", int32_type, column_kind::partition_key);
|
||||
@@ -3847,46 +3847,46 @@ static void test_write_many_partitions(sstring table_name, tombstone partition_t
|
||||
boost::sort(muts, mutation_decorated_key_less_comparator());
|
||||
validate_read(env, s, tmp.path(), muts, version);
|
||||
}
|
||||
}).get();
|
||||
});
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(test_write_many_live_partitions) {
|
||||
test_write_many_partitions(
|
||||
SEASTAR_TEST_CASE(test_write_many_live_partitions) {
|
||||
return test_write_many_partitions(
|
||||
"many_live_partitions",
|
||||
tombstone{},
|
||||
compression_parameters::no_compression());
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(test_write_many_deleted_partitions) {
|
||||
test_write_many_partitions(
|
||||
SEASTAR_TEST_CASE(test_write_many_deleted_partitions) {
|
||||
return test_write_many_partitions(
|
||||
"many_deleted_partitions",
|
||||
tombstone{write_timestamp, write_time_point},
|
||||
compression_parameters::no_compression());
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(test_write_many_partitions_lz4) {
|
||||
test_write_many_partitions(
|
||||
SEASTAR_TEST_CASE(test_write_many_partitions_lz4) {
|
||||
return test_write_many_partitions(
|
||||
"many_partitions_lz4",
|
||||
tombstone{},
|
||||
compression_parameters{compressor::lz4});
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(test_write_many_partitions_snappy) {
|
||||
test_write_many_partitions(
|
||||
SEASTAR_TEST_CASE(test_write_many_partitions_snappy) {
|
||||
return test_write_many_partitions(
|
||||
"many_partitions_snappy",
|
||||
tombstone{},
|
||||
compression_parameters{compressor::snappy});
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(test_write_many_partitions_deflate) {
|
||||
test_write_many_partitions(
|
||||
SEASTAR_TEST_CASE(test_write_many_partitions_deflate) {
|
||||
return test_write_many_partitions(
|
||||
"many_partitions_deflate",
|
||||
tombstone{},
|
||||
compression_parameters{compressor::deflate});
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(test_write_many_partitions_zstd) {
|
||||
test_write_many_partitions(
|
||||
SEASTAR_TEST_CASE(test_write_many_partitions_zstd) {
|
||||
return test_write_many_partitions(
|
||||
"many_partitions_zstd",
|
||||
tombstone{},
|
||||
compression_parameters{compressor::create({
|
||||
|
||||
Reference in New Issue
Block a user