tests: convert sprint() to format()

sprint() recently became more strict, throwing on sprint("%s", 5). Replace
with the more modern format().

Mechanically converted with https://github.com/avikivity/unsprint.
This commit is contained in:
Avi Kivity
2018-10-29 15:38:39 +02:00
parent 239ecec043
commit f70ece9f88
50 changed files with 283 additions and 283 deletions

View File

@@ -149,19 +149,19 @@ BOOST_AUTO_TEST_CASE(output) {
// data
//
BOOST_REQUIRE_EQUAL(sprint("%s", auth::root_data_resource()), "<all keyspaces>");
BOOST_REQUIRE_EQUAL(sprint("%s", auth::make_data_resource("my_keyspace")), "<keyspace my_keyspace>");
BOOST_REQUIRE_EQUAL(format("{}", auth::root_data_resource()), "<all keyspaces>");
BOOST_REQUIRE_EQUAL(format("{}", auth::make_data_resource("my_keyspace")), "<keyspace my_keyspace>");
BOOST_REQUIRE_EQUAL(
sprint("%s", auth::make_data_resource("my_keyspace", "my_table")),
format("{}", auth::make_data_resource("my_keyspace", "my_table")),
"<table my_keyspace.my_table>");
//
// role
//
BOOST_REQUIRE_EQUAL(sprint("%s", auth::root_role_resource()), "<all roles>");
BOOST_REQUIRE_EQUAL(sprint("%s", auth::make_role_resource("joe")), "<role joe>");
BOOST_REQUIRE_EQUAL(format("{}", auth::root_role_resource()), "<all roles>");
BOOST_REQUIRE_EQUAL(format("{}", auth::make_role_resource("joe")), "<role joe>");
}
BOOST_AUTO_TEST_CASE(expand) {

View File

@@ -125,7 +125,7 @@ struct expected_row {
void check(const rows_entry& r) const {
position_in_partition::equal_compare ck_eq(*SCHEMA);
if (!ck_eq(r.position(), pos)) {
BOOST_FAIL(sprint("Expected %s, but got %s", pos, r.position()));
BOOST_FAIL(format("Expected {}, but got {}", pos, r.position()));
}
BOOST_REQUIRE_EQUAL(r.continuous(), continuous);
BOOST_REQUIRE_EQUAL(r.dummy(), dummy);
@@ -148,7 +148,7 @@ static void assert_cached_rows(partition_snapshot_ptr snp, std::deque<expected_r
expected.pop_front();
}
if (!expected.empty()) {
BOOST_FAIL(sprint("Expected %s next, but no more rows", expected.front()));
BOOST_FAIL(format("Expected {} next, but no more rows", expected.front()));
}
}
@@ -178,7 +178,7 @@ static void assert_cached_tombstones(partition_snapshot_ptr snp, std::deque<rang
for (auto&& rt : rts) {
BOOST_REQUIRE(!expected.empty());
if (!expected.front().equal(*SCHEMA, rt)) {
BOOST_FAIL(sprint("Expected %s, but found %s", expected.front(), rt));
BOOST_FAIL(format("Expected {}, but found {}", expected.front(), rt));
}
expected.pop_front();
}

View File

@@ -66,7 +66,7 @@ constexpr char cql_type_name<double>::value[];
template<typename RetType, typename Type>
auto test_explicit_type_casting_in_avg_function() {
return do_with_cql_env_thread([] (auto& e) {
e.execute_cql(sprint("CREATE TABLE air_quality_data (sensor_id text, time timestamp, co_ppm %s, PRIMARY KEY (sensor_id, time));", cql_type_name<Type>::value)).get();
e.execute_cql(format("CREATE TABLE air_quality_data (sensor_id text, time timestamp, co_ppm {}, PRIMARY KEY (sensor_id, time));", cql_type_name<Type>::value)).get();
e.execute_cql(
"begin unlogged batch \n"
" INSERT INTO air_quality_data(sensor_id, time, co_ppm) VALUES ('my_home', '2016-08-30 07:01:00', 17); \n"
@@ -77,7 +77,7 @@ auto test_explicit_type_casting_in_avg_function() {
" INSERT INTO air_quality_data(sensor_id, time, co_ppm) VALUES ('my_home', '2016-08-30 07:01:05', 31); \n"
" INSERT INTO air_quality_data(sensor_id, time, co_ppm) VALUES ('my_home', '2016-08-30 07:01:10', 20); \n"
"apply batch;").get();
auto msg = e.execute_cql(sprint("select avg(CAST(co_ppm AS %s)) from air_quality_data;", cql_type_name<RetType>::value)).get0();
auto msg = e.execute_cql(format("select avg(CAST(co_ppm AS {})) from air_quality_data;", cql_type_name<RetType>::value)).get0();
assert_that(msg).is_rows().with_size(1).with_row({{data_type_for<RetType>()->decompose( RetType(17 + 18 + 19 + 20 + 30 + 31 + 20) / RetType(7) )}});
});
}

View File

@@ -40,7 +40,7 @@ rows_assertions::with_size(size_t size) {
auto rs = _rows->rs().result_set();
auto row_count = rs.size();
if (row_count != size) {
fail(sprint("Expected %d row(s) but got %d", size, row_count));
fail(format("Expected {:d} row(s) but got {:d}", size, row_count));
}
return {*this};
}
@@ -51,7 +51,7 @@ rows_assertions::is_empty() {
auto row_count = rs.size();
if (row_count != 0) {
auto&& first_row = *rs.rows().begin();
fail(sprint("Expected no rows, but got %d. First row: %s", row_count, to_string(first_row)));
fail(format("Expected no rows, but got {:d}. First row: {}", row_count, to_string(first_row)));
}
return {*this};
}
@@ -75,7 +75,7 @@ rows_assertions::with_row(std::initializer_list<bytes_opt> values) {
return {*this};
}
}
fail(sprint("Expected row not found: %s not in %s\n", to_string(expected_row), _rows));
fail(format("Expected row not found: {} not in {}\n", to_string(expected_row), _rows));
return {*this};
}
@@ -88,19 +88,19 @@ rows_assertions::with_rows(std::initializer_list<std::initializer_list<bytes_opt
int row_nr = 0;
for (auto&& row : rows) {
if (actual_i == actual_end) {
fail(sprint("Expected more rows (%d), got %d", rows.size(), rs.size()));
fail(format("Expected more rows ({:d}), got {:d}", rows.size(), rs.size()));
}
auto& actual = *actual_i;
if (!std::equal(
std::begin(row), std::end(row),
std::begin(actual), std::end(actual))) {
fail(sprint("row %d differs, expected %s got %s", row_nr, to_string(row), to_string(actual)));
fail(format("row {:d} differs, expected {} got {}", row_nr, to_string(row), to_string(actual)));
}
++actual_i;
++row_nr;
}
if (actual_i != actual_end) {
fail(sprint("Expected less rows (%d), got %d. Next row is: %s", rows.size(), rs.size(),
fail(format("Expected less rows ({:d}), got {:d}. Next row is: {}", rows.size(), rs.size(),
to_string(*actual_i)));
}
return {*this};
@@ -118,12 +118,12 @@ rows_assertions::with_rows_ignore_order(std::vector<std::vector<bytes_opt>> rows
std::begin(expected), std::end(expected));
});
if (found == std::end(actual)) {
fail(sprint("row %s not found in result set (%s)", to_string(expected),
fail(format("row {} not found in result set ({})", to_string(expected),
::join(", ", actual | boost::adaptors::transformed([] (auto& r) { return to_string(r); }))));
}
}
if (rs.size() != rows.size()) {
fail(sprint("Expected more rows (%d), got %d", rs.size(), rows.size()));
fail(format("Expected more rows ({:d}), got {:d}", rs.size(), rows.size()));
}
return {*this};
}
@@ -147,7 +147,7 @@ result_msg_assertions assert_that(shared_ptr<cql_transport::messages::result_mes
rows_assertions rows_assertions::with_serialized_columns_count(size_t columns_count) {
size_t serialized_column_count = _rows->rs().get_metadata().column_count();
if (serialized_column_count != columns_count) {
fail(sprint("Expected %d serialized columns(s) but got %d", columns_count, serialized_column_count));
fail(format("Expected {:d} serialized columns(s) but got {:d}", columns_count, serialized_column_count));
}
return {*this};
}

View File

@@ -61,7 +61,7 @@ static db::config db_config_with_auth() {
//
static void create_user_if_not_exists(cql_test_env& env, stdx::string_view user_name) {
env.execute_cql(sprint("CREATE USER IF NOT EXISTS %s WITH PASSWORD '%s'", user_name, user_name)).get();
env.execute_cql(format("CREATE USER IF NOT EXISTS {} WITH PASSWORD '{}'", user_name, user_name)).get();
}
// Invoke `f` as though the user indicated with `user_name` had logged in. The current logged in user is restored after

View File

@@ -67,11 +67,11 @@ SEASTAR_TEST_CASE(test_create_table_with_id_statement) {
e.execute_cql("DROP TABLE tbl").get();
BOOST_REQUIRE_THROW(e.execute_cql("SELECT * FROM tbl").get(), std::exception);
e.execute_cql(
sprint("CREATE TABLE tbl (a int, b int, PRIMARY KEY (a)) WITH id='%s'", id)).get();
format("CREATE TABLE tbl (a int, b int, PRIMARY KEY (a)) WITH id='{}'", id)).get();
assert_that(e.execute_cql("SELECT * FROM tbl").get0())
.is_rows().with_size(0);
BOOST_REQUIRE_THROW(
e.execute_cql(sprint("CREATE TABLE tbl2 (a int, b int, PRIMARY KEY (a)) WITH id='%s'", id)).get(),
e.execute_cql(format("CREATE TABLE tbl2 (a int, b int, PRIMARY KEY (a)) WITH id='{}'", id)).get(),
exceptions::invalid_request_exception);
BOOST_REQUIRE_THROW(
e.execute_cql("CREATE TABLE tbl2 (a int, b int, PRIMARY KEY (a)) WITH id='55'").get(),
@@ -197,7 +197,7 @@ SEASTAR_TEST_CASE(test_cassandra_stress_like_write_and_read) {
auto verify_row_for_key = [&e](sstring key) {
return e.execute_cql(
sprint("select \"C0\", \"C1\", \"C2\", \"C3\", \"C4\" from cf where \"KEY\" = %s", key)).then(
format("select \"C0\", \"C1\", \"C2\", \"C3\", \"C4\" from cf where \"KEY\" = {}", key)).then(
[](shared_ptr<cql_transport::messages::result_message> msg) {
assert_that(msg).is_rows()
.with_size(1)
@@ -227,7 +227,7 @@ SEASTAR_TEST_CASE(test_cassandra_stress_like_write_and_read) {
{},
utf8_type);
}).then([execute_update_for_key, verify_row_for_key] {
static auto make_key = [](int suffix) { return sprint("0xdeadbeefcafebabe%02d", suffix); };
static auto make_key = [](int suffix) { return format("0xdeadbeefcafebabe{:02d}", suffix); };
auto suffixes = boost::irange(0, 10);
return parallel_for_each(suffixes.begin(), suffixes.end(), [execute_update_for_key](int suffix) {
return execute_update_for_key(make_key(suffix));
@@ -491,7 +491,7 @@ SEASTAR_TEST_CASE(test_limit_is_respected_across_partitions) {
});
});
}).then([&e, k1, k2] {
return e.execute_cql(sprint("update cf set s1 = null where k = 0x%s;", to_hex(k1))).discard_result();
return e.execute_cql(format("update cf set s1 = null where k = 0x{};", to_hex(k1))).discard_result();
}).then([&e, k1, k2] {
return e.execute_cql("select s1 from cf limit 1;").then([k1, k2](shared_ptr<cql_transport::messages::result_message> msg) {
assert_that(msg).is_rows().with_rows({
@@ -499,7 +499,7 @@ SEASTAR_TEST_CASE(test_limit_is_respected_across_partitions) {
});
});
}).then([&e, k1, k2] {
return e.execute_cql(sprint("update cf set s1 = null where k = 0x%s;", to_hex(k2))).discard_result();
return e.execute_cql(format("update cf set s1 = null where k = 0x{};", to_hex(k2))).discard_result();
}).then([&e, k1, k2] {
return e.execute_cql("select s1 from cf limit 1;").then([k1, k2](shared_ptr<cql_transport::messages::result_message> msg) {
assert_that(msg).is_rows().is_empty();
@@ -622,7 +622,7 @@ SEASTAR_TEST_CASE(test_partition_range_queries_with_bounds) {
BOOST_REQUIRE(keys.size() == 5);
return now().then([keys, tokens, &e] {
return e.execute_cql(sprint("select k from cf where token(k) > %d;", tokens[1])).then([keys](shared_ptr<cql_transport::messages::result_message> msg) {
return e.execute_cql(format("select k from cf where token(k) > {:d};", tokens[1])).then([keys](shared_ptr<cql_transport::messages::result_message> msg) {
assert_that(msg).is_rows().with_rows({
{keys[2]},
{keys[3]},
@@ -630,7 +630,7 @@ SEASTAR_TEST_CASE(test_partition_range_queries_with_bounds) {
});
});
}).then([keys, tokens, &e] {
return e.execute_cql(sprint("select k from cf where token(k) >= %ld;", tokens[1])).then([keys](shared_ptr<cql_transport::messages::result_message> msg) {
return e.execute_cql(format("select k from cf where token(k) >= {:d};", tokens[1])).then([keys](shared_ptr<cql_transport::messages::result_message> msg) {
assert_that(msg).is_rows().with_rows({
{keys[1]},
{keys[2]},
@@ -639,7 +639,7 @@ SEASTAR_TEST_CASE(test_partition_range_queries_with_bounds) {
});
});
}).then([keys, tokens, &e] {
return e.execute_cql(sprint("select k from cf where token(k) > %ld and token(k) < %ld;",
return e.execute_cql(format("select k from cf where token(k) > {:d} and token(k) < {:d};",
tokens[1], tokens[4])).then([keys](shared_ptr<cql_transport::messages::result_message> msg) {
assert_that(msg).is_rows().with_rows({
{keys[2]},
@@ -647,7 +647,7 @@ SEASTAR_TEST_CASE(test_partition_range_queries_with_bounds) {
});
});
}).then([keys, tokens, &e] {
return e.execute_cql(sprint("select k from cf where token(k) < %ld;", tokens[3])).then([keys](shared_ptr<cql_transport::messages::result_message> msg) {
return e.execute_cql(format("select k from cf where token(k) < {:d};", tokens[3])).then([keys](shared_ptr<cql_transport::messages::result_message> msg) {
assert_that(msg).is_rows().with_rows({
{keys[0]},
{keys[1]},
@@ -655,22 +655,22 @@ SEASTAR_TEST_CASE(test_partition_range_queries_with_bounds) {
});
});
}).then([keys, tokens, &e] {
return e.execute_cql(sprint("select k from cf where token(k) = %ld;", tokens[3])).then([keys](shared_ptr<cql_transport::messages::result_message> msg) {
return e.execute_cql(format("select k from cf where token(k) = {:d};", tokens[3])).then([keys](shared_ptr<cql_transport::messages::result_message> msg) {
assert_that(msg).is_rows().with_rows({
{keys[3]}
});
});
}).then([keys, tokens, &e] {
return e.execute_cql(sprint("select k from cf where token(k) < %ld and token(k) > %ld;", tokens[3], tokens[3])).then([keys](shared_ptr<cql_transport::messages::result_message> msg) {
return e.execute_cql(format("select k from cf where token(k) < {:d} and token(k) > {:d};", tokens[3], tokens[3])).then([keys](shared_ptr<cql_transport::messages::result_message> msg) {
assert_that(msg).is_rows().is_empty();
});
}).then([keys, tokens, &e] {
return e.execute_cql(sprint("select k from cf where token(k) >= %ld and token(k) <= %ld;", tokens[4], tokens[2])).then([keys](shared_ptr<cql_transport::messages::result_message> msg) {
return e.execute_cql(format("select k from cf where token(k) >= {:d} and token(k) <= {:d};", tokens[4], tokens[2])).then([keys](shared_ptr<cql_transport::messages::result_message> msg) {
assert_that(msg).is_rows().is_empty();
});
}).then([keys, tokens, &e] {
auto min_token = std::numeric_limits<int64_t>::min();
return e.execute_cql(sprint("select k from cf where token(k) > %ld and token (k) < %ld;", min_token, min_token)).then([keys](shared_ptr<cql_transport::messages::result_message> msg) {
return e.execute_cql(format("select k from cf where token(k) > {:d} and token (k) < {:d};", min_token, min_token)).then([keys](shared_ptr<cql_transport::messages::result_message> msg) {
assert_that(msg).is_rows().with_rows({
{keys[0]},
{keys[1]},
@@ -769,7 +769,7 @@ SEASTAR_TEST_CASE(test_range_deletion_scenarios) {
return do_with_cql_env_thread([] (cql_test_env& e) {
e.execute_cql("create table cf (p int, c int, v text, primary key (p, c));").get();
for (auto i = 0; i < 10; ++i) {
e.execute_cql(sprint("insert into cf (p, c, v) values (1, %d, 'abc');", i)).get();
e.execute_cql(format("insert into cf (p, c, v) values (1, {:d}, 'abc');", i)).get();
}
try {
@@ -804,7 +804,7 @@ SEASTAR_TEST_CASE(test_range_deletion_scenarios_with_compact_storage) {
return do_with_cql_env_thread([] (cql_test_env& e) {
e.execute_cql("create table cf (p int, c int, v text, primary key (p, c)) with compact storage;").get();
for (auto i = 0; i < 10; ++i) {
e.execute_cql(sprint("insert into cf (p, c, v) values (1, %d, 'abc');", i)).get();
e.execute_cql(format("insert into cf (p, c, v) values (1, {:d}, 'abc');", i)).get();
}
try {
@@ -1120,7 +1120,7 @@ static const api::timestamp_type the_timestamp = 123456789;
SEASTAR_TEST_CASE(test_writetime_and_ttl) {
return do_with_cql_env([] (cql_test_env& e) {
return e.execute_cql("create table cf (p1 varchar primary key, i int, fc frozen<set<int>>, c set<int>);").discard_result().then([&e] {
auto q = sprint("insert into cf (p1, i) values ('key1', 1) using timestamp %d;", the_timestamp);
auto q = format("insert into cf (p1, i) values ('key1', 1) using timestamp {:d};", the_timestamp);
return e.execute_cql(q).discard_result();
}).then([&e] {
return e.execute_cql("select writetime(i) from cf where p1 in ('key1');");
@@ -1132,7 +1132,7 @@ SEASTAR_TEST_CASE(test_writetime_and_ttl) {
}).then([&e] {
return async([&e] {
auto ts1 = the_timestamp + 1;
e.execute_cql(sprint("UPDATE cf USING TIMESTAMP %d SET fc = {1}, c = {2} WHERE p1 = 'key1'", ts1)).get();
e.execute_cql(format("UPDATE cf USING TIMESTAMP {:d} SET fc = {{1}}, c = {{2}} WHERE p1 = 'key1'", ts1)).get();
auto msg1 = e.execute_cql("SELECT writetime(fc) FROM cf").get0();
assert_that(msg1).is_rows()
.with_rows({{
@@ -2011,8 +2011,8 @@ SEASTAR_TEST_CASE(test_select_distinct_with_where_clause) {
return seastar::async([&e] {
e.execute_cql("CREATE TABLE cf (k int, a int, b int, PRIMARY KEY (k, a))").get();
for (int i = 0; i < 10; i++) {
e.execute_cql(sprint("INSERT INTO cf (k, a, b) VALUES (%d, %d, %d)", i, i, i)).get();
e.execute_cql(sprint("INSERT INTO cf (k, a, b) VALUES (%d, %d, %d)", i, i * 10, i * 10)).get();
e.execute_cql(format("INSERT INTO cf (k, a, b) VALUES ({:d}, {:d}, {:d})", i, i, i)).get();
e.execute_cql(format("INSERT INTO cf (k, a, b) VALUES ({:d}, {:d}, {:d})", i, i * 10, i * 10)).get();
}
BOOST_REQUIRE_THROW(e.execute_cql("SELECT DISTINCT k FROM cf WHERE a >= 80 ALLOW FILTERING").get(), std::exception);
BOOST_REQUIRE_THROW(e.execute_cql("SELECT DISTINCT k FROM cf WHERE k IN (1, 2, 3) AND a = 10").get(), std::exception);
@@ -2031,8 +2031,8 @@ SEASTAR_TEST_CASE(test_select_distinct_with_where_clause) {
// static columns
e.execute_cql("CREATE TABLE cf2 (k int, a int, s int static, b int, PRIMARY KEY (k, a))").get();
for (int i = 0; i < 10; i++) {
e.execute_cql(sprint("INSERT INTO cf2 (k, a, b, s) VALUES (%d, %d, %d, %d)", i, i, i, i)).get();
e.execute_cql(sprint("INSERT INTO cf2 (k, a, b, s) VALUES (%d, %d, %d, %d)", i, i * 10, i * 10, i * 10)).get();
e.execute_cql(format("INSERT INTO cf2 (k, a, b, s) VALUES ({:d}, {:d}, {:d}, {:d})", i, i, i, i)).get();
e.execute_cql(format("INSERT INTO cf2 (k, a, b, s) VALUES ({:d}, {:d}, {:d}, {:d})", i, i * 10, i * 10, i * 10)).get();
}
assert_that(e.execute_cql("SELECT DISTINCT s FROM cf2 WHERE k = 5").get0())
.is_rows().with_size(1)
@@ -2638,18 +2638,18 @@ SEASTAR_TEST_CASE(test_insert_large_collection_values) {
utf8_type);
}).get();
sstring long_value(std::numeric_limits<uint16_t>::max() + 10, 'x');
e.execute_cql(sprint("INSERT INTO tbl (pk, l) VALUES ('Zamyatin', ['%s']);", long_value)).get();
e.execute_cql(format("INSERT INTO tbl (pk, l) VALUES ('Zamyatin', ['{}']);", long_value)).get();
assert_that(e.execute_cql("SELECT l FROM tbl WHERE pk ='Zamyatin';").get0())
.is_rows().with_rows({
{ make_list_value(list_type, list_type_impl::native_type({{long_value}})).serialize() }
});
BOOST_REQUIRE_THROW(e.execute_cql(sprint("INSERT INTO tbl (pk, s) VALUES ('Orwell', {'%s'});", long_value)).get(), std::exception);
e.execute_cql(sprint("INSERT INTO tbl (pk, m) VALUES ('Haksli', {'key': '%s'});", long_value)).get();
BOOST_REQUIRE_THROW(e.execute_cql(format("INSERT INTO tbl (pk, s) VALUES ('Orwell', {{'{}'}});", long_value)).get(), std::exception);
e.execute_cql(format("INSERT INTO tbl (pk, m) VALUES ('Haksli', {{'key': '{}'}});", long_value)).get();
assert_that(e.execute_cql("SELECT m FROM tbl WHERE pk ='Haksli';").get0())
.is_rows().with_rows({
{ make_map_value(map_type, map_type_impl::native_type({{sstring("key"), long_value}})).serialize() }
});
BOOST_REQUIRE_THROW(e.execute_cql(sprint("INSERT INTO tbl (pk, m) VALUES ('Golding', {'%s': 'value'});", long_value)).get(), std::exception);
BOOST_REQUIRE_THROW(e.execute_cql(format("INSERT INTO tbl (pk, m) VALUES ('Golding', {{'{}': 'value'}});", long_value)).get(), std::exception);
auto make_query_options = [] (cql_protocol_version_type version) {
return std::make_unique<cql3::query_options>(db::consistency_level::ONE, infinite_timeout_config, std::experimental::nullopt,
@@ -3064,8 +3064,8 @@ SEASTAR_TEST_CASE(test_long_text_value) {
e.require_table_exists("ks", "t").get();
sstring big_one(17324, 'x');
sstring bigger_one(29123, 'y');
e.execute_cql(sprint("INSERT INTO t (id, v, v2) values (1, '%s', '%s')", big_one, big_one)).get();
e.execute_cql(sprint("INSERT INTO t (id, v, v2) values (2, '%s', '%s')", bigger_one, bigger_one)).get();
e.execute_cql(format("INSERT INTO t (id, v, v2) values (1, '{}', '{}')", big_one, big_one)).get();
e.execute_cql(format("INSERT INTO t (id, v, v2) values (2, '{}', '{}')", bigger_one, bigger_one)).get();
auto msg = e.execute_cql("select v, v2 from t where id = 1").get0();
assert_that(msg).is_rows().with_rows({{utf8_type->decompose(big_one), utf8_type->decompose(big_one)}});
msg = e.execute_cql("select v, v2 from t where id = 2").get0();

View File

@@ -276,7 +276,7 @@ public:
}
future<> create_keyspace(sstring name) {
auto query = sprint("create keyspace %s with replication = { 'class' : 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor' : 1 };", name);
auto query = format("create keyspace {} with replication = {{ 'class' : 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor' : 1 }};", name);
return execute_cql(query).discard_result();
}

View File

@@ -53,7 +53,7 @@ namespace cql3 {
class not_prepared_exception : public std::runtime_error {
public:
not_prepared_exception(const cql3::prepared_cache_key_type& id) : std::runtime_error(sprint("Not prepared: %s", id)) {}
not_prepared_exception(const cql3::prepared_cache_key_type& id) : std::runtime_error(format("Not prepared: {}", id)) {}
};
namespace db {

View File

@@ -41,13 +41,13 @@ SEASTAR_TEST_CASE(test_querying_with_limits) {
auto s = db.find_schema("ks", "cf");
dht::partition_range_vector pranges;
for (uint32_t i = 1; i <= 3; ++i) {
auto pkey = partition_key::from_single_value(*s, to_bytes(sprint("key%d", i)));
auto pkey = partition_key::from_single_value(*s, to_bytes(format("key{:d}", i)));
mutation m(s, pkey);
m.partition().apply(tombstone(api::timestamp_type(1), gc_clock::now()));
db.apply(s, freeze(m)).get();
}
for (uint32_t i = 3; i <= 8; ++i) {
auto pkey = partition_key::from_single_value(*s, to_bytes(sprint("key%d", i)));
auto pkey = partition_key::from_single_value(*s, to_bytes(format("key{:d}", i)));
mutation m(s, pkey);
m.set_clustered_cell(clustering_key_prefix::make_empty(), "v", data_value(bytes("v1")), 1);
db.apply(s, freeze(m)).get();

View File

@@ -42,47 +42,47 @@ public:
flat_reader_assertions& produces_partition_start(const dht::decorated_key& dk,
stdx::optional<tombstone> tomb = stdx::nullopt) {
BOOST_TEST_MESSAGE(sprint("Expecting partition start with key %s", dk));
BOOST_TEST_MESSAGE(format("Expecting partition start with key {}", dk));
auto mfopt = read_next();
if (!mfopt) {
BOOST_FAIL(sprint("Expected: partition start with key %s, got end of stream", dk));
BOOST_FAIL(format("Expected: partition start with key {}, got end of stream", dk));
}
if (!mfopt->is_partition_start()) {
BOOST_FAIL(sprint("Expected: partition start with key %s, got: %s", dk, mutation_fragment::printer(*_reader.schema(), *mfopt)));
BOOST_FAIL(format("Expected: partition start with key {}, got: {}", dk, mutation_fragment::printer(*_reader.schema(), *mfopt)));
}
if (!mfopt->as_partition_start().key().equal(*_reader.schema(), dk)) {
BOOST_FAIL(sprint("Expected: partition start with key %s, got: %s", dk, mutation_fragment::printer(*_reader.schema(), *mfopt)));
BOOST_FAIL(format("Expected: partition start with key {}, got: {}", dk, mutation_fragment::printer(*_reader.schema(), *mfopt)));
}
if (tomb && mfopt->as_partition_start().partition_tombstone() != *tomb) {
BOOST_FAIL(sprint("Expected: partition start with tombstone %s, got: %s", *tomb, mutation_fragment::printer(*_reader.schema(), *mfopt)));
BOOST_FAIL(format("Expected: partition start with tombstone {}, got: {}", *tomb, mutation_fragment::printer(*_reader.schema(), *mfopt)));
}
return *this;
}
flat_reader_assertions& produces_static_row() {
BOOST_TEST_MESSAGE(sprint("Expecting static row"));
BOOST_TEST_MESSAGE(format("Expecting static row"));
auto mfopt = read_next();
if (!mfopt) {
BOOST_FAIL("Expected static row, got end of stream");
}
if (!mfopt->is_static_row()) {
BOOST_FAIL(sprint("Expected static row, got: %s", mutation_fragment::printer(*_reader.schema(), *mfopt)));
BOOST_FAIL(format("Expected static row, got: {}", mutation_fragment::printer(*_reader.schema(), *mfopt)));
}
return *this;
}
flat_reader_assertions& produces_row_with_key(const clustering_key& ck) {
BOOST_TEST_MESSAGE(sprint("Expect %s", ck));
BOOST_TEST_MESSAGE(format("Expect {}", ck));
auto mfopt = read_next();
if (!mfopt) {
BOOST_FAIL(sprint("Expected row with key %s, but got end of stream", ck));
BOOST_FAIL(format("Expected row with key {}, but got end of stream", ck));
}
if (!mfopt->is_clustering_row()) {
BOOST_FAIL(sprint("Expected row with key %s, but got %s", ck, mutation_fragment::printer(*_reader.schema(), *mfopt)));
BOOST_FAIL(format("Expected row with key {}, but got {}", ck, mutation_fragment::printer(*_reader.schema(), *mfopt)));
}
auto& actual = mfopt->as_clustering_row().key();
if (!actual.equal(*_reader.schema(), ck)) {
BOOST_FAIL(sprint("Expected row with key %s, but key is %s", ck, actual));
BOOST_FAIL(format("Expected row with key {}, but key is {}", ck, actual));
}
return *this;
}
@@ -99,27 +99,27 @@ public:
};
flat_reader_assertions& produces_static_row(const std::vector<expected_column>& columns) {
BOOST_TEST_MESSAGE(sprint("Expecting static row"));
BOOST_TEST_MESSAGE(format("Expecting static row"));
auto mfopt = read_next();
if (!mfopt) {
BOOST_FAIL("Expected static row, got end of stream");
}
if (!mfopt->is_static_row()) {
BOOST_FAIL(sprint("Expected static row, got: %s", mutation_fragment::printer(*_reader.schema(), *mfopt)));
BOOST_FAIL(format("Expected static row, got: {}", mutation_fragment::printer(*_reader.schema(), *mfopt)));
}
auto& cells = mfopt->as_static_row().cells();
if (cells.size() != columns.size()) {
BOOST_FAIL(sprint("Expected static row with %s columns, but has %s", columns.size(), cells.size()));
BOOST_FAIL(format("Expected static row with {} columns, but has {}", columns.size(), cells.size()));
}
for (size_t i = 0; i < columns.size(); ++i) {
const atomic_cell_or_collection* cell = cells.find_cell(columns[i].id);
if (!cell) {
BOOST_FAIL(sprint("Expected static row with column %s, but it is not present", columns[i].name));
BOOST_FAIL(format("Expected static row with column {}, but it is not present", columns[i].name));
}
auto& cdef = _reader.schema()->static_column_at(columns[i].id);
auto cmp = compare_unsigned(columns[i].value, cell->as_atomic_cell(cdef).value().linearize());
if (cmp != 0) {
BOOST_FAIL(sprint("Expected static row with column %s having value %s, but it has value %s",
BOOST_FAIL(format("Expected static row with column {} having value {}, but it has value {}",
columns[i].name,
columns[i].value,
cell->as_atomic_cell(cdef).value()));
@@ -129,32 +129,32 @@ public:
}
flat_reader_assertions& produces_row(const clustering_key& ck, const std::vector<expected_column>& columns) {
BOOST_TEST_MESSAGE(sprint("Expect %s", ck));
BOOST_TEST_MESSAGE(format("Expect {}", ck));
auto mfopt = read_next();
if (!mfopt) {
BOOST_FAIL(sprint("Expected row with key %s, but got end of stream", ck));
BOOST_FAIL(format("Expected row with key {}, but got end of stream", ck));
}
if (!mfopt->is_clustering_row()) {
BOOST_FAIL(sprint("Expected row with key %s, but got %s", ck, mutation_fragment::printer(*_reader.schema(), *mfopt)));
BOOST_FAIL(format("Expected row with key {}, but got {}", ck, mutation_fragment::printer(*_reader.schema(), *mfopt)));
}
auto& actual = mfopt->as_clustering_row().key();
if (!actual.equal(*_reader.schema(), ck)) {
BOOST_FAIL(sprint("Expected row with key %s, but key is %s", ck, actual));
BOOST_FAIL(format("Expected row with key {}, but key is {}", ck, actual));
}
auto& cells = mfopt->as_clustering_row().cells();
if (cells.size() != columns.size()) {
BOOST_FAIL(sprint("Expected row with %s columns, but has %s", columns.size(), cells.size()));
BOOST_FAIL(format("Expected row with {} columns, but has {}", columns.size(), cells.size()));
}
for (size_t i = 0; i < columns.size(); ++i) {
const atomic_cell_or_collection* cell = cells.find_cell(columns[i].id);
if (!cell) {
BOOST_FAIL(sprint("Expected row with column %s, but it is not present", columns[i].name));
BOOST_FAIL(format("Expected row with column {}, but it is not present", columns[i].name));
}
auto& cdef = _reader.schema()->regular_column_at(columns[i].id);
assert (!cdef.is_multi_cell());
auto cmp = compare_unsigned(columns[i].value, cell->as_atomic_cell(cdef).value().linearize());
if (cmp != 0) {
BOOST_FAIL(sprint("Expected row with column %s having value %s, but it has value %s",
BOOST_FAIL(format("Expected row with column {} having value {}, but it has value {}",
columns[i].name,
columns[i].value,
cell->as_atomic_cell(cdef).value().linearize()));
@@ -168,26 +168,26 @@ public:
flat_reader_assertions& produces_row(const clustering_key& ck,
const std::vector<column_id>& column_ids,
const std::vector<assert_function>& column_assert) {
BOOST_TEST_MESSAGE(sprint("Expect %s", ck));
BOOST_TEST_MESSAGE(format("Expect {}", ck));
auto mfopt = read_next();
if (!mfopt) {
BOOST_FAIL(sprint("Expected row with key %s, but got end of stream", ck));
BOOST_FAIL(format("Expected row with key {}, but got end of stream", ck));
}
if (!mfopt->is_clustering_row()) {
BOOST_FAIL(sprint("Expected row with key %s, but got %s", ck, mutation_fragment::printer(*_reader.schema(), *mfopt)));
BOOST_FAIL(format("Expected row with key {}, but got {}", ck, mutation_fragment::printer(*_reader.schema(), *mfopt)));
}
auto& actual = mfopt->as_clustering_row().key();
if (!actual.equal(*_reader.schema(), ck)) {
BOOST_FAIL(sprint("Expected row with key %s, but key is %s", ck, actual));
BOOST_FAIL(format("Expected row with key {}, but key is {}", ck, actual));
}
auto& cells = mfopt->as_clustering_row().cells();
if (cells.size() != column_ids.size()) {
BOOST_FAIL(sprint("Expected row with %s columns, but has %s", column_ids.size(), cells.size()));
BOOST_FAIL(format("Expected row with {} columns, but has {}", column_ids.size(), cells.size()));
}
for (size_t i = 0; i < column_ids.size(); ++i) {
const atomic_cell_or_collection* cell = cells.find_cell(column_ids[i]);
if (!cell) {
BOOST_FAIL(sprint("Expected row with column %d, but it is not present", column_ids[i]));
BOOST_FAIL(format("Expected row with column {:d}, but it is not present", column_ids[i]));
}
auto& cdef = _reader.schema()->regular_column_at(column_ids[i]);
column_assert[i](cdef, cell);
@@ -197,13 +197,13 @@ public:
// If ck_ranges is passed, verifies only that information relevant for ck_ranges matches.
flat_reader_assertions& produces_range_tombstone(const range_tombstone& rt, const query::clustering_row_ranges& ck_ranges = {}) {
BOOST_TEST_MESSAGE(sprint("Expect %s", rt));
BOOST_TEST_MESSAGE(format("Expect {}", rt));
auto mfo = read_next();
if (!mfo) {
BOOST_FAIL(sprint("Expected range tombstone %s, but got end of stream", rt));
BOOST_FAIL(format("Expected range tombstone {}, but got end of stream", rt));
}
if (!mfo->is_range_tombstone()) {
BOOST_FAIL(sprint("Expected range tombstone %s, but got %s", rt, mutation_fragment::printer(*_reader.schema(), *mfo)));
BOOST_FAIL(format("Expected range tombstone {}, but got {}", rt, mutation_fragment::printer(*_reader.schema(), *mfo)));
}
const schema& s = *_reader.schema();
range_tombstone_list actual_list(s);
@@ -221,7 +221,7 @@ public:
actual_list.trim(s, ck_ranges);
expected_list.trim(s, ck_ranges);
if (!actual_list.equal(s, expected_list)) {
BOOST_FAIL(sprint("Expected %s, but got %s", expected_list, actual_list));
BOOST_FAIL(format("Expected {}, but got {}", expected_list, actual_list));
}
}
return *this;
@@ -231,10 +231,10 @@ public:
BOOST_TEST_MESSAGE("Expecting partition end");
auto mfopt = read_next();
if (!mfopt) {
BOOST_FAIL(sprint("Expected partition end but got end of stream"));
BOOST_FAIL(format("Expected partition end but got end of stream"));
}
if (!mfopt->is_end_of_partition()) {
BOOST_FAIL(sprint("Expected partition end but got %s", mutation_fragment::printer(*_reader.schema(), *mfopt)));
BOOST_FAIL(format("Expected partition end but got {}", mutation_fragment::printer(*_reader.schema(), *mfopt)));
}
return *this;
}
@@ -242,10 +242,10 @@ public:
flat_reader_assertions& produces(const schema& s, const mutation_fragment& mf) {
auto mfopt = read_next();
if (!mfopt) {
BOOST_FAIL(sprint("Expected %s, but got end of stream", mutation_fragment::printer(*_reader.schema(), mf)));
BOOST_FAIL(format("Expected {}, but got end of stream", mutation_fragment::printer(*_reader.schema(), mf)));
}
if (!mfopt->equal(s, mf)) {
BOOST_FAIL(sprint("Expected %s, but got %s", mutation_fragment::printer(*_reader.schema(), mf), mutation_fragment::printer(*_reader.schema(), *mfopt)));
BOOST_FAIL(format("Expected {}, but got {}", mutation_fragment::printer(*_reader.schema(), mf), mutation_fragment::printer(*_reader.schema(), *mfopt)));
}
return *this;
}
@@ -254,7 +254,7 @@ public:
BOOST_TEST_MESSAGE("Expecting end of stream");
auto mfopt = read_next();
if (bool(mfopt)) {
BOOST_FAIL(sprint("Expected end of stream, got %s", mutation_fragment::printer(*_reader.schema(), *mfopt)));
BOOST_FAIL(format("Expected end of stream, got {}", mutation_fragment::printer(*_reader.schema(), *mfopt)));
}
return *this;
}
@@ -271,14 +271,14 @@ public:
auto mfopt = read_next();
if (!mfopt) {
BOOST_FAIL(sprint("Expected mutation fragment %s, got end of stream", ck));
BOOST_FAIL(format("Expected mutation fragment {}, got end of stream", ck));
}
if (mfopt->mutation_fragment_kind() != k) {
BOOST_FAIL(sprint("Expected mutation fragment kind %s, got: %s", k, mfopt->mutation_fragment_kind()));
BOOST_FAIL(format("Expected mutation fragment kind {}, got: {}", k, mfopt->mutation_fragment_kind()));
}
clustering_key::equality ck_eq(*_reader.schema());
if (!ck_eq(mfopt->key(), ck)) {
BOOST_FAIL(sprint("Expected key %s, got: %s", ck, mfopt->key()));
BOOST_FAIL(format("Expected key {}, got: {}", ck, mfopt->key()));
}
return *this;
}
@@ -290,7 +290,7 @@ public:
flat_reader_assertions& produces(const mutation& m, const stdx::optional<query::clustering_row_ranges>& ck_ranges = {}) {
auto mo = read_mutation_from_flat_mutation_reader(_reader, db::no_timeout).get0();
if (!mo) {
BOOST_FAIL(sprint("Expected %s, but got end of stream, at: %s", m, seastar::current_backtrace()));
BOOST_FAIL(format("Expected {}, but got end of stream, at: {}", m, seastar::current_backtrace()));
}
memory::disable_failure_guard dfg;
assert_that(*mo).is_equal_to(m, ck_ranges);
@@ -316,7 +316,7 @@ public:
auto mo = read_mutation_from_flat_mutation_reader(_reader, db::no_timeout).get0();
if (mo) {
if (!mo->partition().empty()) {
BOOST_FAIL(sprint("Mutation is not empty: %s", *mo));
BOOST_FAIL(format("Mutation is not empty: {}", *mo));
}
}
return *this;
@@ -336,7 +336,7 @@ public:
BOOST_REQUIRE(!inside_partition);
auto& dk = mfo->as_partition_start().key();
if (previous_partition && !previous_partition->as_partition_start().key().less_compare(*_reader.schema(), dk)) {
BOOST_FAIL(sprint("previous partition had greater key: prev=%s, current=%s",
BOOST_FAIL(format("previous partition had greater key: prev={}, current={}",
mutation_fragment::printer(*_reader.schema(), *previous_partition), mutation_fragment::printer(*_reader.schema(), *mfo)));
}
previous_partition = std::move(mfo);
@@ -349,7 +349,7 @@ public:
BOOST_REQUIRE(inside_partition);
if (previous_fragment) {
if (!less(previous_fragment->position(), mfo->position())) {
BOOST_FAIL(sprint("previous fragment has greater position: prev=%s, current=%s",
BOOST_FAIL(format("previous fragment has greater position: prev={}, current={}",
mutation_fragment::printer(*_reader.schema(), *previous_fragment), mutation_fragment::printer(*_reader.schema(), *mfo)));
}
}

View File

@@ -288,12 +288,12 @@ SEASTAR_TEST_CASE(test_partition_checksum) {
auto h2 = get_hash(m2);
if (eq) {
if (h1 != h2) {
BOOST_FAIL(sprint("Hash should be equal for %s and %s", m1, m2));
BOOST_FAIL(format("Hash should be equal for {} and {}", m1, m2));
}
} else {
// We're using a strong hasher, collision should be unlikely
if (h1 == h2) {
BOOST_FAIL(sprint("Hash should be different for %s and %s", m1, m2));
BOOST_FAIL(format("Hash should be different for {} and {}", m1, m2));
}
}
});
@@ -594,12 +594,12 @@ void test_flat_stream(schema_ptr s, std::vector<mutation> muts, reversed_partiti
}
};
BOOST_TEST_MESSAGE(sprint("Consume all%s", reversed_msg));
BOOST_TEST_MESSAGE(format("Consume all{}", reversed_msg));
auto fmr = flat_mutation_reader_from_mutations(muts);
auto muts2 = consume_fn(fmr, flat_stream_consumer(s, reversed));
BOOST_REQUIRE_EQUAL(muts, muts2);
BOOST_TEST_MESSAGE(sprint("Consume first fragment from partition%s", reversed_msg));
BOOST_TEST_MESSAGE(format("Consume first fragment from partition{}", reversed_msg));
fmr = flat_mutation_reader_from_mutations(muts);
muts2 = consume_fn(fmr, flat_stream_consumer(s, reversed, skip_after_first_fragment::yes));
BOOST_REQUIRE_EQUAL(muts.size(), muts2.size());
@@ -612,7 +612,7 @@ void test_flat_stream(schema_ptr s, std::vector<mutation> muts, reversed_partiti
BOOST_REQUIRE_EQUAL(m, muts[j]);
}
BOOST_TEST_MESSAGE(sprint("Consume first partition%s", reversed_msg));
BOOST_TEST_MESSAGE(format("Consume first partition{}", reversed_msg));
fmr = flat_mutation_reader_from_mutations(muts);
muts2 = consume_fn(fmr, flat_stream_consumer(s, reversed, skip_after_first_fragment::no,
skip_after_first_partition::yes));

View File

@@ -78,7 +78,7 @@ int main(int ac, char ** av) {
auto& server = netw::get_local_messaging_service();
auto port = server.port();
auto listen = server.listen_address();
print("Messaging server listening on ip %s port %d ...\n", listen, port);
fmt::print("Messaging server listening on ip {} port {:d} ...\n", listen, port);
return gms::get_failure_detector().start();
}).then([vv, config] {
return gms::get_gossiper().start();

View File

@@ -47,7 +47,7 @@ public:
auto rp = dht::ring_position(token, k.key().to_partition_key(s));
if (!rp_cmp(prev, rp)) {
BOOST_FAIL(sprint("Partitions have invalid order: %s >= %s", prev, rp));
BOOST_FAIL(format("Partitions have invalid order: {} >= {}", prev, rp));
}
prev = rp;
@@ -66,7 +66,7 @@ public:
<< ": +" << e.offset() << " len=" << e.width() << std::endl;
}
auto next = std::next(it);
BOOST_FAIL(sprint("Index blocks are not monotonic: %s >= %s", it->end(s), next->start(s)));
BOOST_FAIL(format("Index blocks are not monotonic: {} >= {}", it->end(s), next->start(s)));
}
}
_r->advance_to_next_partition().get();

View File

@@ -80,7 +80,7 @@ int main(int argc, char** argv) {
auto print_region_stats = [&r] {
std::cout << "Region occupancy: " << r.occupancy()
<< sprint(", %.2f%% of all memory", (float)r.occupancy().total_space() * 100 / memory::stats().total_memory()) << std::endl;
<< format(", {:.2f}% of all memory", (float)r.occupancy().total_space() * 100 / memory::stats().total_memory()) << std::endl;
};
std::cout << "Allocated " << refs.size() << " evictable objects" << std::endl;
@@ -97,7 +97,7 @@ int main(int argc, char** argv) {
auto duration = clk::now() - start;
std::cout << "Allocated " << obj_count << " (" << obj_count * std_obj_size << " B) standard objects in "
<< sprint("%.4f [s]", std::chrono::duration_cast<std::chrono::duration<float>>(duration).count()) << "\n";
<< format("{:.4f} [s]", std::chrono::duration_cast<std::chrono::duration<float>>(duration).count()) << "\n";
print_region_stats();
});
return 0;

View File

@@ -62,7 +62,7 @@ public:
public:
void init_handler() {
ms.register_gossip_digest_syn([this] (const rpc::client_info& cinfo, gms::gossip_digest_syn msg) {
print("Server got syn msg = %s\n", msg);
fmt::print("Server got syn msg = {}\n", msg);
auto from = netw::messaging_service::get_source(cinfo);
auto ep1 = inet_address("1.1.1.1");
@@ -78,13 +78,13 @@ public:
};
gms::gossip_digest_ack ack(std::move(digests), std::move(eps));
ms.send_gossip_digest_ack(from, std::move(ack)).handle_exception([] (auto ep) {
print("Fail to send ack : %s", ep);
fmt::print("Fail to send ack : {}", ep);
});
return messaging_service::no_wait();
});
ms.register_gossip_digest_ack([this] (const rpc::client_info& cinfo, gms::gossip_digest_ack msg) {
print("Server got ack msg = %s\n", msg);
fmt::print("Server got ack msg = {}\n", msg);
auto from = netw::messaging_service::get_source(cinfo);
// Prepare gossip_digest_ack2 message
auto ep1 = inet_address("3.3.3.3");
@@ -93,24 +93,24 @@ public:
};
gms::gossip_digest_ack2 ack2(std::move(eps));
ms.send_gossip_digest_ack2(from, std::move(ack2)).handle_exception([] (auto ep) {
print("Fail to send ack2 : %s", ep);
fmt::print("Fail to send ack2 : {}", ep);
});
digest_test_done.set_value();
return messaging_service::no_wait();
});
ms.register_gossip_digest_ack2([] (gms::gossip_digest_ack2 msg) {
print("Server got ack2 msg = %s\n", msg);
fmt::print("Server got ack2 msg = {}\n", msg);
return messaging_service::no_wait();
});
ms.register_gossip_shutdown([] (inet_address from) {
print("Server got shutdown msg = %s\n", from);
fmt::print("Server got shutdown msg = {}\n", from);
return messaging_service::no_wait();
});
ms.register_gossip_echo([] {
print("Server got gossip echo msg\n");
fmt::print("Server got gossip echo msg\n");
throw std::runtime_error("I'm throwing runtime_error exception");
return make_ready_future<>();
});
@@ -118,7 +118,7 @@ public:
public:
future<> test_gossip_digest() {
print("=== %s ===\n", __func__);
fmt::print("=== {} ===\n", __func__);
// Prepare gossip_digest_syn message
auto id = get_msg_addr();
auto ep1 = inet_address("1.1.1.1");
@@ -135,24 +135,24 @@ public:
}
future<> test_gossip_shutdown() {
print("=== %s ===\n", __func__);
fmt::print("=== {} ===\n", __func__);
auto id = get_msg_addr();
inet_address from("127.0.0.1");
return ms.send_gossip_shutdown(id, from).then([] () {
print("Client sent gossip_shutdown got reply = void\n");
fmt::print("Client sent gossip_shutdown got reply = void\n");
return make_ready_future<>();
});
}
future<> test_echo() {
print("=== %s ===\n", __func__);
fmt::print("=== {} ===\n", __func__);
auto id = get_msg_addr();
return ms.send_gossip_echo(id).then_wrapped([] (auto&& f) {
try {
f.get();
return make_ready_future<>();
} catch (std::runtime_error& e) {
print("test_echo: %s\n", e.what());
fmt::print("test_echo: {}\n", e.what());
}
return make_ready_future<>();
});
@@ -197,8 +197,8 @@ int main(int ac, char ** av) {
auto cpuid = config["cpuid"].as<uint32_t>();
t->set_server_ip(ip);
t->set_server_cpuid(cpuid);
print("=============TEST START===========\n");
print("Sending to server ....\n");
fmt::print("=============TEST START===========\n");
fmt::print("Sending to server ....\n");
t->test_gossip_digest().then([testers, t] {
return t->test_gossip_shutdown();
}).then([testers, t] {
@@ -207,7 +207,7 @@ int main(int ac, char ** av) {
if (stay_alive) {
return;
}
print("=============TEST DONE===========\n");
fmt::print("=============TEST DONE===========\n");
testers->stop().then([testers] {
delete testers;
netw::get_messaging_service().stop().then([]{

View File

@@ -94,7 +94,7 @@ static uint64_t aggregate_querier_cache_stat(distributed<database>& db, uint64_t
static void check_cache_population(distributed<database>& db, size_t queriers,
std::experimental::source_location sl = std::experimental::source_location::current()) {
BOOST_TEST_MESSAGE(sprint("%s() called from %s() %s:%i", __FUNCTION__, sl.function_name(), sl.file_name(), sl.line()));
BOOST_TEST_MESSAGE(format("{}() called from {}() {}:{:d}", __FUNCTION__, sl.function_name(), sl.file_name(), sl.line()));
parallel_for_each(boost::irange(0u, smp::count), [queriers, &db] (unsigned shard) {
return db.invoke_on(shard, [queriers] (database& local_db) {
@@ -106,7 +106,7 @@ static void check_cache_population(distributed<database>& db, size_t queriers,
static void require_eventually_empty_caches(distributed<database>& db,
std::experimental::source_location sl = std::experimental::source_location::current()) {
BOOST_TEST_MESSAGE(sprint("%s() called from %s() %s:%i", __FUNCTION__, sl.function_name(), sl.file_name(), sl.line()));
BOOST_TEST_MESSAGE(format("{}() called from {}() {}:{:d}", __FUNCTION__, sl.function_name(), sl.file_name(), sl.line()));
auto aggregated_population_is_zero = [&] () mutable {
return aggregate_querier_cache_stat(db, &query::querier_cache::stats::population) == 0;
@@ -240,7 +240,7 @@ void check_results_are_equal(std::vector<mutation>& results1, std::vector<mutati
boost::sort(results1, mut_less);
boost::sort(results2, mut_less);
for (unsigned i = 0; i < results1.size(); ++i) {
BOOST_TEST_MESSAGE(sprint("Comparing mutation #%i", i));
BOOST_TEST_MESSAGE(format("Comparing mutation #{:d}", i));
assert_that(results2[i]).is_equal_to(results1[i]);
}
}

View File

@@ -99,7 +99,7 @@ std::array<uint64_t,2> prefix_hashes[] = {
BOOST_AUTO_TEST_CASE(test_hash_output) {
auto assert_hashes_equal = [] (bytes_view data, std::array<uint64_t,2> lhs, std::array<uint64_t,2> rhs) {
if (lhs != rhs) {
BOOST_FAIL(sprint("Hashes differ for %s (got {0x%x, 0x%x} and {0x%x, 0x%x})", data,
BOOST_FAIL(format("Hashes differ for {} (got {{0x{:x}, 0x{:x}}} and {{0x{:x}, 0x{:x}}})", data,
lhs[0], lhs[1], rhs[0], rhs[1]));
}
};

View File

@@ -49,11 +49,11 @@ public:
return *this;
}
if (!_m.equal(*_schema, other, s)) {
BOOST_FAIL(sprint("Mutations differ, expected %s\n ...but got: %s",
BOOST_FAIL(format("Mutations differ, expected {}\n ...but got: {}",
mutation_partition::printer(s, other), mutation_partition::printer(*_schema, _m)));
}
if (!other.equal(s, _m, *_schema)) {
BOOST_FAIL(sprint("Mutation inequality is not symmetric for %s\n ...and: %s",
BOOST_FAIL(format("Mutation inequality is not symmetric for {}\n ...and: {}",
mutation_partition::printer(s, other), mutation_partition::printer(*_schema, _m)));
}
return *this;
@@ -65,7 +65,7 @@ public:
mutation_partition_assertion& is_not_equal_to(const schema& s, const mutation_partition& other) {
if (_m.equal(*_schema, other, s)) {
BOOST_FAIL(sprint("Mutations equal but expected to differ: %s\n ...and: %s",
BOOST_FAIL(format("Mutations equal but expected to differ: {}\n ...and: {}",
mutation_partition::printer(s, other), mutation_partition::printer(*_schema, _m)));
}
return *this;
@@ -73,14 +73,14 @@ public:
mutation_partition_assertion& has_same_continuity(const mutation_partition& other) {
if (!_m.equal_continuity(*_schema, other)) {
BOOST_FAIL(sprint("Continuity doesn't match: %s\n ...and: %s", mutation_partition::printer(*_schema, other), mutation_partition::printer(*_schema, _m)));
BOOST_FAIL(format("Continuity doesn't match: {}\n ...and: {}", mutation_partition::printer(*_schema, other), mutation_partition::printer(*_schema, _m)));
}
return *this;
}
mutation_partition_assertion& is_continuous(const position_range& r, is_continuous cont = is_continuous::yes) {
if (!_m.check_continuity(*_schema, r, cont)) {
BOOST_FAIL(sprint("Expected range %s to be %s in %s", r, cont ? "continuous" : "discontinuous", mutation_partition::printer(*_schema, _m)));
BOOST_FAIL(format("Expected range {} to be {} in {}", r, cont ? "continuous" : "discontinuous", mutation_partition::printer(*_schema, _m)));
}
return *this;
}
@@ -105,24 +105,24 @@ public:
return *this;
}
if (_m != other) {
BOOST_FAIL(sprint("Mutations differ, expected %s\n ...but got: %s", other, _m));
BOOST_FAIL(format("Mutations differ, expected {}\n ...but got: {}", other, _m));
}
if (other != _m) {
BOOST_FAIL(sprint("Mutation inequality is not symmetric for %s\n ...and: %s", other, _m));
BOOST_FAIL(format("Mutation inequality is not symmetric for {}\n ...and: {}", other, _m));
}
return *this;
}
mutation_assertion& is_not_equal_to(const mutation& other) {
if (_m == other) {
BOOST_FAIL(sprint("Mutations equal but expected to differ: %s\n ...and: %s", other, _m));
BOOST_FAIL(format("Mutations equal but expected to differ: {}\n ...and: {}", other, _m));
}
return *this;
}
mutation_assertion& has_schema(schema_ptr s) {
if (_m.schema() != s) {
BOOST_FAIL(sprint("Expected mutation of schema %s, but got %s", *s, *_m.schema()));
BOOST_FAIL(format("Expected mutation of schema {}, but got {}", *s, *_m.schema()));
}
return *this;
}

View File

@@ -414,7 +414,7 @@ SEASTAR_TEST_CASE(test_partitions_with_only_expired_tombstones_are_dropped) {
auto new_key = [s] {
static int ctr = 0;
return partition_key::from_singular(*s, data_value(to_bytes(sprint("key%d", ctr++))));
return partition_key::from_singular(*s, data_value(to_bytes(format("key{:d}", ctr++))));
};
auto make_ring = [&] (int n) {

View File

@@ -334,13 +334,13 @@ SEASTAR_TEST_CASE(test_sm_fast_forwarding_combining_reader) {
mutation m(s.schema(), pkeys[n]);
int i{0};
s.add_row(m, ckeys[i], sprint("val_%i", i));
s.add_row(m, ckeys[i], format("val_{:d}", i));
++i;
s.add_row(m, ckeys[i], sprint("val_%i", i));
s.add_row(m, ckeys[i], format("val_{:d}", i));
++i;
s.add_row(m, ckeys[i], sprint("val_%i", i));
s.add_row(m, ckeys[i], format("val_{:d}", i));
++i;
s.add_row(m, ckeys[i], sprint("val_%i", i));
s.add_row(m, ckeys[i], format("val_{:d}", i));
return m;
};
@@ -422,10 +422,10 @@ SEASTAR_THREAD_TEST_CASE(combined_mutation_reader_test) {
for (auto pkey_index : pkey_indexes) {
muts.emplace_back(s.schema(), pkeys[pkey_index]);
auto& mut = muts.back();
s.add_row(mut, ckeys[ckey_index], sprint("%s_%i_val", value_prefix, ckey_index));
s.add_row(mut, ckeys[ckey_index], format("{}_{:d}_val", value_prefix, ckey_index));
if (static_row) {
s.add_static_row(mut, sprint("%s_static_val", value_prefix));
s.add_static_row(mut, format("{}_static_val", value_prefix));
}
}
@@ -512,7 +512,7 @@ static mutation make_mutation_with_key(simple_schema& s, dht::decorated_key dk)
static int i{0};
mutation m(s.schema(), std::move(dk));
s.add_row(m, s.make_ckey(++i), sprint("val_%i", i));
s.add_row(m, s.make_ckey(++i), format("val_{:d}", i));
return m;
}
@@ -711,10 +711,10 @@ sstables::shared_sstable create_sstable(simple_schema& sschema, const sstring& p
for (std::size_t p = 0; p < (1 << 10); ++p) {
mutation m(sschema.schema(), sschema.make_pkey(p));
sschema.add_static_row(m, sprint("%i_static_val", p));
sschema.add_static_row(m, format("{:d}_static_val", p));
for (std::size_t c = 0; c < (1 << 4); ++c) {
sschema.add_row(m, sschema.make_ckey(c), sprint("val_%i", c));
sschema.add_row(m, sschema.make_ckey(c), format("val_{:d}", c));
}
mutations.emplace_back(std::move(m));
@@ -1237,7 +1237,7 @@ SEASTAR_TEST_CASE(test_fast_forwarding_combined_reader_is_consistent_with_slicin
rd.consume_pausable([&](mutation_fragment&& mf) {
position_in_partition::less_compare less(*s);
if (!less(mf.position(), position_in_partition_view::before_all_clustered_rows())) {
BOOST_FAIL(sprint("Received clustering fragment: %s", mutation_fragment::printer(*s, mf)));
BOOST_FAIL(format("Received clustering fragment: {}", mutation_fragment::printer(*s, mf)));
}
result.partition().apply(*s, std::move(mf));
return stop_iteration::no;
@@ -1248,11 +1248,11 @@ SEASTAR_TEST_CASE(test_fast_forwarding_combined_reader_is_consistent_with_slicin
rd.fast_forward_to(prange, db::no_timeout).get();
rd.consume_pausable([&](mutation_fragment&& mf) {
if (!mf.relevant_for_range(*s, prange.start())) {
BOOST_FAIL(sprint("Received fragment which is not relevant for range: %s, range: %s", mutation_fragment::printer(*s, mf), prange));
BOOST_FAIL(format("Received fragment which is not relevant for range: {}, range: {}", mutation_fragment::printer(*s, mf), prange));
}
position_in_partition::less_compare less(*s);
if (!less(mf.position(), prange.end())) {
BOOST_FAIL(sprint("Received fragment is out of range: %s, range: %s", mutation_fragment::printer(*s, mf), prange));
BOOST_FAIL(format("Received fragment is out of range: {}, range: {}", mutation_fragment::printer(*s, mf), prange));
}
result.partition().apply(*s, std::move(mf));
return stop_iteration::no;
@@ -1304,7 +1304,7 @@ SEASTAR_TEST_CASE(test_combined_reader_slicing_with_overlapping_range_tombstones
rd.consume_pausable([&] (mutation_fragment&& mf) {
if (mf.position().has_clustering_key() && !mf.range().overlaps(*s, prange.start(), prange.end())) {
BOOST_FAIL(sprint("Received fragment which is not relevant for the slice: %s, slice: %s", mutation_fragment::printer(*s, mf), range));
BOOST_FAIL(format("Received fragment which is not relevant for the slice: {}, slice: {}", mutation_fragment::printer(*s, mf), range));
}
result.partition().apply(*s, std::move(mf));
return stop_iteration::no;
@@ -1339,7 +1339,7 @@ SEASTAR_TEST_CASE(test_combined_reader_slicing_with_overlapping_range_tombstones
auto consume_clustered = [&] (mutation_fragment&& mf) {
position_in_partition::less_compare less(*s);
if (less(mf.position(), last_pos)) {
BOOST_FAIL(sprint("Out of order fragment: %s, last pos: %s", mutation_fragment::printer(*s, mf), last_pos));
BOOST_FAIL(format("Out of order fragment: {}, last pos: {}", mutation_fragment::printer(*s, mf), last_pos));
}
last_pos = position_in_partition(mf.position());
result.partition().apply(*s, std::move(mf));
@@ -2103,7 +2103,7 @@ SEASTAR_THREAD_TEST_CASE(test_multishard_streaming_reader) {
const auto min_size = std::min(reference_muts.size(), tested_muts.size());
for (size_t i = 0; i < min_size; ++i) {
BOOST_TEST_MESSAGE(sprint("Comparing mutation %i/%i", i, min_size - 1));
BOOST_TEST_MESSAGE(format("Comparing mutation {:d}/{:d}", i, min_size - 1));
assert_that(tested_muts[i]).is_equal_to(reference_muts[i]);
}

View File

@@ -67,7 +67,7 @@ static void test_streamed_mutation_forwarding_is_consistent_with_slicing(populat
.with_ranges(ranges)
.build();
BOOST_TEST_MESSAGE(sprint("ranges: %s", ranges));
BOOST_TEST_MESSAGE(format("ranges: {}", ranges));
mutation_source ms = populate(m.schema(), {m});
@@ -120,7 +120,7 @@ static void test_streamed_mutation_forwarding_is_consistent_with_slicing(populat
fwd_reader.consume(consumer(m.schema(), builder), db::no_timeout).get0();
BOOST_REQUIRE(bool(builder));
for (auto&& range : ranges) {
BOOST_TEST_MESSAGE(sprint("fwd %s", range));
BOOST_TEST_MESSAGE(format("fwd {}", range));
fwd_reader.fast_forward_to(position_range(range), db::no_timeout).get();
fwd_reader.consume(consumer(m.schema(), builder), db::no_timeout).get0();
}
@@ -177,7 +177,7 @@ static void test_streamed_mutation_forwarding_guarantees(populate_fn populate) {
for (; start < end; ++start) {
if (!contains_key(start)) {
BOOST_TEST_MESSAGE(sprint("skip %d", start));
BOOST_TEST_MESSAGE(format("skip {:d}", start));
continue;
}
sm.produces_row_with_key(keys[start]);
@@ -555,7 +555,7 @@ static void test_range_queries(populate_fn populate) {
auto ds = populate(s, partitions);
auto test_slice = [&] (dht::partition_range r) {
BOOST_TEST_MESSAGE(sprint("Testing range %s", r));
BOOST_TEST_MESSAGE(format("Testing range {}", r));
assert_that(ds.make_reader(s, r))
.produces(slice(partitions, r))
.produces_end_of_stream();
@@ -1046,7 +1046,7 @@ void test_slicing_with_overlapping_range_tombstones(populate_fn populate) {
rd.consume_pausable([&] (mutation_fragment&& mf) {
if (mf.position().has_clustering_key() && !mf.range().overlaps(*s, prange.start(), prange.end())) {
BOOST_FAIL(sprint("Received fragment which is not relevant for the slice: %s, slice: %s", mutation_fragment::printer(*s, mf), range));
BOOST_FAIL(format("Received fragment which is not relevant for the slice: {}, slice: {}", mutation_fragment::printer(*s, mf), range));
}
result.partition().apply(*s, std::move(mf));
return stop_iteration::no;
@@ -1075,7 +1075,7 @@ void test_slicing_with_overlapping_range_tombstones(populate_fn populate) {
auto consume_clustered = [&] (mutation_fragment&& mf) {
position_in_partition::less_compare less(*s);
if (less(mf.position(), last_pos)) {
BOOST_FAIL(sprint("Out of order fragment: %s, last pos: %s", mutation_fragment::printer(*s, mf), last_pos));
BOOST_FAIL(format("Out of order fragment: {}, last pos: {}", mutation_fragment::printer(*s, mf), last_pos));
}
last_pos = position_in_partition(mf.position());
result.partition().apply(*s, std::move(mf));
@@ -1391,12 +1391,12 @@ class random_mutation_generator::impl {
// Create enough columns so that row can overflow its vector storage
for (column_id i = 0; i < column_count; ++i) {
{
auto column_name = sprint("v%d", i);
auto column_name = format("v{:d}", i);
auto col_type = type == counter_type || _bool_dist(_gen) ? type : list_type_impl::get_instance(type, true);
builder.with_column(to_bytes(column_name), col_type, column_kind::regular_column);
}
{
auto column_name = sprint("s%d", i);
auto column_name = format("s{:d}", i);
builder.with_column(to_bytes(column_name), type, column_kind::static_column);
}
}

View File

@@ -392,7 +392,7 @@ SEASTAR_TEST_CASE(test_flush_in_the_middle_of_a_scan) {
auto new_key = [&] {
static thread_local int next = 0;
return dht::global_partitioner().decorate_key(*s,
partition_key::from_single_value(*s, to_bytes(sprint("key%d", next++))));
partition_key::from_single_value(*s, to_bytes(format("key{:d}", next++))));
};
auto make_mutation = [&] {
mutation m(s, new_key());
@@ -516,11 +516,11 @@ SEASTAR_TEST_CASE(test_cell_ordering) {
auto assert_order = [] (atomic_cell_view first, atomic_cell_view second) {
if (compare_atomic_cell_for_merge(first, second) >= 0) {
BOOST_TEST_MESSAGE(sprint("Expected %s < %s", first, second));
BOOST_TEST_MESSAGE(format("Expected {} < {}", first, second));
abort();
}
if (compare_atomic_cell_for_merge(second, first) <= 0) {
BOOST_TEST_MESSAGE(sprint("Expected %s < %s", second, first));
BOOST_TEST_MESSAGE(format("Expected {} < {}", second, first));
abort();
}
};
@@ -858,7 +858,7 @@ SEASTAR_TEST_CASE(test_apply_monotonically_is_monotonic) {
actual.add(s, c2);
auto expected_cont = expected.partition().get_continuity(s);
if (!actual.contained_in(expected_cont)) {
BOOST_FAIL(sprint("Continuity should be contained in the expected one, expected %s (%s + %s), got %s (%s + %s)",
BOOST_FAIL(format("Continuity should be contained in the expected one, expected {} ({} + {}), got {} ({} + {})",
expected_cont, target.partition().get_continuity(s), second.partition().get_continuity(s),
actual, c1, c2));
}
@@ -1050,12 +1050,12 @@ SEASTAR_TEST_CASE(test_mutation_hash) {
auto h2 = get_hash(m2);
if (eq) {
if (h1 != h2) {
BOOST_FAIL(sprint("Hash should be equal for %s and %s", m1, m2));
BOOST_FAIL(format("Hash should be equal for {} and {}", m1, m2));
}
} else {
// We're using a strong hasher, collision should be unlikely
if (h1 == h2) {
BOOST_FAIL(sprint("Hash should be different for %s and %s", m1, m2));
BOOST_FAIL(format("Hash should be different for {} and {}", m1, m2));
}
}
};
@@ -1079,7 +1079,7 @@ SEASTAR_TEST_CASE(test_query_digest) {
auto digest1 = *m1.query(ps1, query::result_options::only_digest(query::digest_algorithm::xxHash)).digest();
auto digest2 = *m2.query(ps2, query::result_options::only_digest(query::digest_algorithm::xxHash)).digest();
if (digest1 != digest2) {
BOOST_FAIL(sprint("Digest should be the same for %s and %s", m1, m2));
BOOST_FAIL(format("Digest should be the same for {} and {}", m1, m2));
}
};
@@ -1540,7 +1540,7 @@ SEASTAR_TEST_CASE(test_mutation_diff_with_random_generator) {
return seastar::async([] {
auto check_partitions_match = [] (const mutation_partition& mp1, const mutation_partition& mp2, const schema& s) {
if (!mp1.equal(s, mp2)) {
BOOST_FAIL(sprint("Partitions don't match, got: %s\n...and: %s", mutation_partition::printer(s, mp1), mutation_partition::printer(s, mp2)));
BOOST_FAIL(format("Partitions don't match, got: {}\n...and: {}", mutation_partition::printer(s, mp1), mutation_partition::printer(s, mp2)));
}
};
for_each_mutation_pair([&] (auto&& m1, auto&& m2, are_equal eq) {

View File

@@ -55,13 +55,13 @@ void check_tombstone_slice(const schema& s, std::vector<range_tombstone> list,
for (auto&& rt : list) {
if (!less(rt.position(), position_in_partition::for_range_end(range))) {
BOOST_FAIL(sprint("Range tombstone out of range: %s, range: %s", rt, range));
BOOST_FAIL(format("Range tombstone out of range: {}, range: {}", rt, range));
}
if (!less(position_in_partition::for_range_start(range), rt.end_position())) {
BOOST_FAIL(sprint("Range tombstone out of range: %s, range: %s", rt, range));
BOOST_FAIL(format("Range tombstone out of range: {}, range: {}", rt, range));
}
if (!less(prev_pos, rt.position())) {
BOOST_FAIL(sprint("Range tombstone breaks position monotonicity: %s, list: %s", rt, list));
BOOST_FAIL(format("Range tombstone breaks position monotonicity: {}, list: {}", rt, list));
}
prev_pos = position_in_partition(rt.position());
actual.apply(s, rt);

View File

@@ -141,7 +141,7 @@ BOOST_AUTO_TEST_CASE(test_ring_position_ordering) {
keys[2]._token = keys[3]._token = keys[4]._token;
std::sort(keys.begin() + 2, keys.begin() + 5, dht::ring_position_less_comparator(*table.schema()));
BOOST_TEST_MESSAGE(sprint("Keys: %s", keys));
BOOST_TEST_MESSAGE(format("Keys: {}", keys));
auto positions = boost::copy_range<std::vector<dht::ring_position>>(keys);
auto views = boost::copy_range<std::vector<dht::ring_position_view>>(positions);

View File

@@ -49,7 +49,7 @@ void time_it(Func func, int iterations = 5, int iterations_between_clock_reading
auto end = clk::now();
auto duration = std::chrono::duration<double>(end - start).count();
std::cout << sprint("%.2f", (double)count / duration) << " tps\n";
std::cout << format("{:.2f}", (double)count / duration) << " tps\n";
}
}
@@ -132,7 +132,7 @@ future<> time_parallel(Func func, unsigned concurrency_per_core, int iterations
}).then([start] (auto total) {
auto end = clk::now();
auto duration = std::chrono::duration<double>(end - start).count();
std::cout << sprint("%.2f", (double)total / duration) << " tps\n";
std::cout << format("{:.2f}", (double)total / duration) << " tps\n";
}).then([exec] {
return exec->stop().finally([exec] {});
});

View File

@@ -108,7 +108,7 @@ int main(int argc, char** argv) {
monotonic_counter<uint64_t> miss_ctr([&] { return tracker.get_stats().reads_with_misses; });
stats_printer.set_callback([&] {
auto MB = 1024 * 1024;
std::cout << sprint("rd/s: %d, wr/s: %d, ev/s: %d, pmerge/s: %d, miss/s: %d, cache: %d/%d [MB], LSA: %d/%d [MB], std free: %d [MB]",
std::cout << format("rd/s: {:d}, wr/s: {:d}, ev/s: {:d}, pmerge/s: {:d}, miss/s: {:d}, cache: {:d}/{:d} [MB], LSA: {:d}/{:d} [MB], std free: {:d} [MB]",
reads_ctr.change(),
mutations_ctr.change(),
eviction_ctr.change(),
@@ -121,7 +121,7 @@ int main(int argc, char** argv) {
seastar::memory::stats().free_memory() / MB) << "\n\n";
auto print_percentiles = [] (const utils::estimated_histogram& hist) {
return sprint("min: %-6d, 50%%: %-6d, 90%%: %-6d, 99%%: %-6d, 99.9%%: %-6d, max: %-6d [us]",
return format("min: {:-6d}, 50%: {:-6d}, 90%: {:-6d}, 99%: {:-6d}, 99.9%: {:-6d}, max: {:-6d} [us]",
hist.percentile(0),
hist.percentile(0.5),
hist.percentile(0.9),

View File

@@ -350,7 +350,7 @@ public:
const std::string test_run_count_name = "test_run_count";
params_value[test_run_count_name.c_str()] = test_run_count;
params_value[all_params_names + "," + test_run_count_name] = all_params_values + std::string(sprint(",%d", test_run_count));
params_value[all_params_names + "," + test_run_count_name] = all_params_values + std::string(format(",{:d}", test_run_count));
Json::Value stats_value{Json::objectValue};
for (size_t i = 0; i < stats_names.size(); ++i) {
@@ -385,7 +385,7 @@ public:
} else if (oformat == "json") {
_writer = std::make_unique<json_output_writer>();
} else {
throw std::runtime_error(sprint("Unsupported output format: %s", oformat));
throw std::runtime_error(format("Unsupported output format: {}", oformat));
}
}
@@ -534,7 +534,7 @@ static void check_and_report_no_index_reads(test_result& r) {
static void check_fragment_count(test_result& r, uint64_t expected) {
if (r.fragments_read != expected) {
r.set_error(sprint("Expected to read %d fragments", expected));
r.set_error(format("Expected to read {:d} fragments", expected));
}
}
@@ -791,7 +791,7 @@ static void drop_keyspace_if_exists(cql_test_env& env, sstring name) {
static
table_config read_config(cql_test_env& env, const sstring& name) {
auto msg = env.execute_cql(sprint("select n_rows, value_size from ks.config where name = '%s'", name)).get0();
auto msg = env.execute_cql(format("select n_rows, value_size from ks.config where name = '{}'", name)).get0();
auto rows = dynamic_pointer_cast<cql_transport::messages::result_message::rows>(msg);
auto rs = rows->rs().result_set();
if (rs.size() < 1) {
@@ -814,7 +814,7 @@ void populate(cql_test_env& env, table_config cfg) {
std::cout << "Saving test config...\n";
env.execute_cql("create table config (name text primary key, n_rows int, value_size int)").get();
env.execute_cql(sprint("insert into ks.config (name, n_rows, value_size) values ('%s', %d, %d)", cfg.name, cfg.n_rows, cfg.value_size)).get();
env.execute_cql(format("insert into ks.config (name, n_rows, value_size) values ('{}', {:d}, {:d})", cfg.name, cfg.n_rows, cfg.value_size)).get();
std::cout << "Creating test tables...\n";

View File

@@ -78,7 +78,7 @@ private:
std::vector<schema::column> columns;
for (unsigned i = 0; i < _cfg.num_columns; ++i) {
columns.push_back(schema::column{ to_bytes(sprint("column%04d", i)), utf8_type });
columns.push_back(schema::column{ to_bytes(format("column{:04d}", i)), utf8_type });
}
schema_builder builder(make_lw_shared(schema(generate_legacy_id("ks", "perf-test"), "ks", "perf-test",
@@ -243,6 +243,6 @@ future<> time_runs(unsigned iterations, unsigned parallelism, distributed<test_e
});
});
}).then([acc, iterations, parallelism] {
std::cout << sprint("%.2f", mean(*acc)) << " +- " << sprint("%.2f", error_of<tag::mean>(*acc)) << " partitions / sec (" << iterations << " runs, " << parallelism << " concurrent ops)\n";
std::cout << format("{:.2f}", mean(*acc)) << " +- " << format("{:.2f}", error_of<tag::mean>(*acc)) << " partitions / sec (" << iterations << " runs, " << parallelism << " concurrent ops)\n";
});
}

View File

@@ -138,7 +138,7 @@ void run_test(const sstring& name, schema_ptr s, MutationGenerator&& gen) {
auto prev_rows_merged_from_memtable = tracker.get_stats().rows_merged_from_memtable;
auto prev_rows_dropped_from_memtable = tracker.get_stats().rows_dropped_from_memtable;
std::cout << sprint("cache: %d/%d [MB], memtable: %d/%d [MB], alloc/comp: %d/%d [MB] (amp: %.3f)\n",
std::cout << format("cache: {:d}/{:d} [MB], memtable: {:d}/{:d} [MB], alloc/comp: {:d}/{:d} [MB] (amp: {:.3f})\n",
tracker.region().occupancy().used_space() / MB,
tracker.region().occupancy().total_space() / MB,
mt->occupancy().used_space() / MB,
@@ -174,7 +174,7 @@ void run_test(const sstring& name, schema_ptr s, MutationGenerator&& gen) {
auto compacted = logalloc::memory_compacted() - prev_compacted;
auto allocated = logalloc::memory_allocated() - prev_allocated;
std::cout << sprint("update: %.6f [ms], stall: %s, cache: %d/%d [MB], alloc/comp: %d/%d [MB] (amp: %.3f), pr/me/dr %d/%d/%d\n",
std::cout << format("update: {:.6f} [ms], stall: {}, cache: {:d}/{:d} [MB], alloc/comp: {:d}/{:d} [MB] (amp: {:.3f}), pr/me/dr {:d}/{:d}/{:d}\n",
d.count() * 1000,
slm,
tracker.region().occupancy().used_space() / MB,
@@ -189,7 +189,7 @@ void run_test(const sstring& name, schema_ptr s, MutationGenerator&& gen) {
cache.invalidate([] {}).get();
});
std::cout << sprint("invalidation: %.6f [ms]", d.count() * 1000) << "\n";
std::cout << format("invalidation: {:.6f} [ms]", d.count() * 1000) << "\n";
}
void test_small_partitions() {

View File

@@ -81,7 +81,7 @@ private:
const mutation_source _mutation_source;
static sstring make_value(size_t i) {
return sprint("value%010d", i);
return format("value{:010d}", i);
}
static std::vector<mutation> make_mutations(simple_schema& s, const noncopyable_function<sstring(size_t)>& make_value) {

View File

@@ -35,21 +35,21 @@ public:
auto cpy = _list;
cpy.apply(_s, other);
if (!cpy.equal(_s, _list)) {
BOOST_FAIL(sprint("Expected to include at least what's in %s, but does not: %s", other, _list));
BOOST_FAIL(format("Expected to include at least what's in {}, but does not: {}", other, _list));
}
return *this;
}
range_tombstone_list_assertions& is_equal_to(const range_tombstone_list& other) {
if (!_list.equal(_s, other)) {
BOOST_FAIL(sprint("Lists differ, expected: %s\n ...but got: %s", other, _list));
BOOST_FAIL(format("Lists differ, expected: {}\n ...but got: {}", other, _list));
}
return *this;
}
range_tombstone_list_assertions& is_equal_to_either(const range_tombstone_list& list1, const range_tombstone_list& list2) {
if (!_list.equal(_s, list1) && !_list.equal(_s, list2)) {
BOOST_FAIL(sprint("Expected to be either %s\n ...or %s\n ...but got: %s", list1, list2, _list));
BOOST_FAIL(format("Expected to be either {}\n ...or {}\n ...but got: {}", list1, list2, _list));
}
return *this;
}

View File

@@ -48,7 +48,7 @@ static clustering_key_prefix key(std::vector<int32_t> components) {
static void assert_rt(const range_tombstone& expected, const range_tombstone& actual) {
if (!expected.equal(*s, actual)) {
BOOST_FAIL(sprint("Expected %s but got %s", expected, actual));
BOOST_FAIL(format("Expected {} but got {}", expected, actual));
}
}

View File

@@ -67,12 +67,12 @@ row_assertion::describe(schema_ptr schema) const {
auto&& value = e.second;
const column_definition* def = schema->get_column_definition(name);
if (!def) {
BOOST_FAIL(sprint("Schema is missing column definition for '%s'", name));
BOOST_FAIL(format("Schema is missing column definition for '{}'", name));
}
if (value.is_null()) {
return sprint("%s=null", to_sstring(name));
return format("{}=null", to_sstring(name));
} else {
return sprint("%s=\"%s\"", to_sstring(name), def->type->to_string(def->type->decompose(value)));
return format("{}=\"{}\"", to_sstring(name), def->type->to_string(def->type->decompose(value)));
}
})) + "}";
}
@@ -84,7 +84,7 @@ result_set_assertions::has(const row_assertion& ra) const {
return *this;
}
}
BOOST_FAIL(sprint("Row %s not found in %s", ra.describe(_rs.schema()), _rs));
BOOST_FAIL(format("Row {} not found in {}", ra.describe(_rs.schema()), _rs));
return *this;
}
@@ -93,7 +93,7 @@ result_set_assertions::has_only(const row_assertion& ra) const {
BOOST_REQUIRE(_rs.rows().size() == 1);
auto& row = _rs.rows()[0];
if (!ra.matches(row)) {
BOOST_FAIL(sprint("Expected %s but got %s", ra.describe(_rs.schema()), row));
BOOST_FAIL(format("Expected {} but got {}", ra.describe(_rs.schema()), row));
}
return *this;
}

View File

@@ -34,13 +34,13 @@
static
partition_key new_key(schema_ptr s) {
static thread_local int next = 0;
return partition_key::from_single_value(*s, to_bytes(sprint("key%d", next++)));
return partition_key::from_single_value(*s, to_bytes(format("key{:d}", next++)));
}
static
clustering_key new_ckey(schema_ptr s) {
static thread_local int next = 0;
return clustering_key::from_single_value(*s, to_bytes(sprint("ckey%d", next++)));
return clustering_key::from_single_value(*s, to_bytes(format("ckey{:d}", next++)));
}
int main(int argc, char** argv) {

View File

@@ -71,11 +71,11 @@ struct table {
return i;
}
}
throw std::runtime_error(sprint("key not found: %s", dk));
throw std::runtime_error(format("key not found: {}", dk));
}
sstring value_tag(int key, uint64_t phase) {
return sprint("k_0x%x_p_0x%x", key, phase);
return format("k_0x{:x}_p_0x{:x}", key, phase);
}
mutation get_mutation(int key, api::timestamp_type t, const sstring& tag) {
@@ -193,11 +193,11 @@ public:
std::tie(value, t) = _t.s.get_value(row);
test_log.trace("reader {}: {} @{}, {}", _id, value, t, clustering_row::printer(*_t.s.schema(), row));
if (_value && value != _value) {
throw std::runtime_error(sprint("Saw values from two different writes in partition %d: %s and %s", _key, _value, value));
throw std::runtime_error(format("Saw values from two different writes in partition {:d}: {} and {}", _key, _value, value));
}
auto lowest_timestamp = _writetimes[_key];
if (t < lowest_timestamp) {
throw std::runtime_error(sprint("Expected to see the write @%d, but saw @%d (%s), c_key=%s", lowest_timestamp, t, value, row.key()));
throw std::runtime_error(format("Expected to see the write @{:d}, but saw @{:d} ({}), c_key={}", lowest_timestamp, t, value, row.key()));
}
_value = std::move(value);
return stop_iteration::no;
@@ -307,7 +307,7 @@ int main(int argc, char** argv) {
auto rd = t.make_single_key_reader(pk, ck_range);
auto row_count = rd->rd.consume(validating_consumer(t, id), db::no_timeout).get0();
if (row_count != len) {
throw std::runtime_error(sprint("Expected %d fragments, got %d", len, row_count));
throw std::runtime_error(format("Expected {:d} fragments, got {:d}", len, row_count));
}
}
};
@@ -319,7 +319,7 @@ int main(int argc, char** argv) {
auto rd = t.make_scanning_reader();
auto row_count = rd->rd.consume(validating_consumer(t, id), db::no_timeout).get0();
if (row_count != expected_row_count) {
throw std::runtime_error(sprint("Expected %d fragments, got %d", expected_row_count, row_count));
throw std::runtime_error(format("Expected {:d} fragments, got {:d}", expected_row_count, row_count));
}
}
};
@@ -328,20 +328,20 @@ int main(int argc, char** argv) {
t.mutate_next_phase();
auto readers = parallel_for_each(boost::irange(0u, concurrency), [&] (auto i) {
reader_id id{sprint("single-%d", i)};
reader_id id{format("single-{:d}", i)};
return seastar::async([&, i, id] {
single_partition_reader(i, id);
}).handle_exception([&, id] (auto e) {
fail(sprint("%s failed: %s", id, e));
fail(format("{} failed: {}", id, e));
});
});
auto scanning_readers = parallel_for_each(boost::irange(0u, scan_concurrency), [&] (auto i) {
reader_id id{sprint("scan-%d", i)};
reader_id id{format("scan-{:d}", i)};
return seastar::async([&, id] {
scanning_reader(id);
}).handle_exception([&, id] (auto e) {
fail(sprint("%s failed: %s", id, e));
fail(format("{} failed: {}", id, e));
});
});

View File

@@ -62,7 +62,7 @@ static
mutation make_new_mutation(schema_ptr s, partition_key key) {
mutation m(s, key);
static thread_local int next_value = 1;
m.set_clustered_cell(clustering_key::make_empty(), "v", data_value(to_bytes(sprint("v%d", next_value++))), next_timestamp++);
m.set_clustered_cell(clustering_key::make_empty(), "v", data_value(to_bytes(format("v{:d}", next_value++))), next_timestamp++);
return m;
}
@@ -85,7 +85,7 @@ mutation make_new_large_mutation(schema_ptr s, partition_key key) {
static
partition_key new_key(schema_ptr s) {
static thread_local int next = 0;
return partition_key::from_single_value(*s, to_bytes(sprint("key%d", next++)));
return partition_key::from_single_value(*s, to_bytes(format("key{:d}", next++)));
}
static
@@ -95,12 +95,12 @@ mutation make_new_mutation(schema_ptr s) {
static inline
mutation make_new_large_mutation(schema_ptr s, int key) {
return make_new_large_mutation(s, partition_key::from_single_value(*s, to_bytes(sprint("key%d", key))));
return make_new_large_mutation(s, partition_key::from_single_value(*s, to_bytes(format("key{:d}", key))));
}
static inline
mutation make_new_mutation(schema_ptr s, int key) {
return make_new_mutation(s, partition_key::from_single_value(*s, to_bytes(sprint("key%d", key))));
return make_new_mutation(s, partition_key::from_single_value(*s, to_bytes(format("key{:d}", key))));
}
snapshot_source make_decorated_snapshot_source(snapshot_source src, std::function<mutation_source(mutation_source)> decorator) {
@@ -350,7 +350,7 @@ SEASTAR_TEST_CASE(test_cache_delegates_to_underlying_only_once_multiple_mutation
std::vector<mutation> partitions;
for (int i = 0; i < partition_count; ++i) {
partitions.emplace_back(
make_partition_mutation(to_bytes(sprint("key_%d", i))));
make_partition_mutation(to_bytes(format("key_{:d}", i))));
}
std::sort(partitions.begin(), partitions.end(), mutation_decorated_key_less_comparator());
@@ -834,7 +834,7 @@ void test_sliced_read_row_presence(flat_mutation_reader reader, schema_ptr s, st
expected.pop_front();
auto& cr = mfopt->as_clustering_row();
if (!ck_eq(cr.key(), ck)) {
BOOST_FAIL(sprint("Expected %s, but got %s", ck, cr.key()));
BOOST_FAIL(format("Expected {}, but got {}", ck, cr.key()));
}
}
}
@@ -2525,7 +2525,7 @@ static void check_continuous(row_cache& cache, const dht::partition_range& pr, c
auto s1 = cache.get_cache_tracker().get_stats();
if (s0.reads_with_misses != s1.reads_with_misses) {
std::cerr << cache << "\n";
BOOST_FAIL(sprint("Got cache miss while reading range %s", r));
BOOST_FAIL(format("Got cache miss while reading range {}", r));
}
}
@@ -2622,7 +2622,7 @@ SEASTAR_TEST_CASE(test_no_misses_when_read_is_repeated) {
for (auto n_ranges : {1, 2, 4}) {
auto ranges = gen.make_random_ranges(n_ranges);
BOOST_TEST_MESSAGE(sprint("Reading {}", ranges));
BOOST_TEST_MESSAGE(format("Reading {{}}", ranges));
populate_range(cache, pr, ranges);
check_continuous(cache, pr, ranges);
@@ -2631,7 +2631,7 @@ SEASTAR_TEST_CASE(test_no_misses_when_read_is_repeated) {
auto s2 = tracker.get_stats();
if (s1.reads_with_misses != s2.reads_with_misses) {
BOOST_FAIL(sprint("Got cache miss when repeating read of %s on %s", ranges, m1));
BOOST_FAIL(format("Got cache miss when repeating read of {} on {}", ranges, m1));
}
}
});
@@ -3053,7 +3053,7 @@ SEASTAR_TEST_CASE(test_concurrent_reads_and_eviction) {
}
return m2 == actual;
})) {
BOOST_FAIL(sprint("Mutation read doesn't match any expected version, slice: %s, read: %s\nexpected: [%s]",
BOOST_FAIL(format("Mutation read doesn't match any expected version, slice: {}, read: {}\nexpected: [{}]",
slice, actual, ::join(",\n", possible_versions)));
}
}

View File

@@ -145,7 +145,7 @@ SEASTAR_TEST_CASE(test_cannot_drop_secondary_index_backing_mv) {
e.execute_cql("create index on cf (a)").get();
auto s = e.local_db().find_schema(sstring("ks"), sstring("cf"));
auto index_name = s->index_names().front();
assert_that_failed(e.execute_cql(sprint("drop materialized view %s_index", index_name)));
assert_that_failed(e.execute_cql(format("drop materialized view {}_index", index_name)));
});
}

View File

@@ -83,13 +83,13 @@ public:
// Make a clustering_key which is n-th in some arbitrary sequence of keys
clustering_key make_ckey(uint32_t n) {
return make_ckey(sprint("ck%010d", n));
return make_ckey(format("ck{:010d}", n));
}
// Make a partition key which is n-th in some arbitrary sequence of keys.
// There is no particular order for the keys, they're not in ring order.
dht::decorated_key make_pkey(uint32_t n) {
return make_pkey(sprint("pk%010d", n));
return make_pkey(format("pk{:010d}", n));
}
dht::decorated_key make_pkey(sstring pk) {

View File

@@ -106,7 +106,7 @@ public:
void assert_toc(const std::set<component_type>& expected_components) {
for (auto& expected : expected_components) {
if(_sst->_recognized_components.count(expected) == 0) {
BOOST_FAIL(sprint("Expected component of TOC missing: %s\n ... in: %s",
BOOST_FAIL(format("Expected component of TOC missing: {}\n ... in: {}",
expected,
std::set<component_type>(
cbegin(_sst->_recognized_components),
@@ -115,7 +115,7 @@ public:
}
for (auto& present : _sst->_recognized_components) {
if (expected_components.count(present) == 0) {
BOOST_FAIL(sprint("Unexpected component of TOC: %s\n ... when expecting: %s",
BOOST_FAIL(format("Unexpected component of TOC: {}\n ... when expecting: {}",
present,
expected_components));
}
@@ -1969,7 +1969,7 @@ SEASTAR_THREAD_TEST_CASE(test_uncompressed_large_subset_of_columns_sparse_read)
std::vector<const column_definition*> column_defs(64);
for (int i = 0; i < 64; ++i) {
column_defs[i] = UNCOMPRESSED_LARGE_SUBSET_OF_COLUMNS_SPARSE_SCHEMA->get_column_definition(to_bytes(sprint("val%d", (i + 1))));
column_defs[i] = UNCOMPRESSED_LARGE_SUBSET_OF_COLUMNS_SPARSE_SCHEMA->get_column_definition(to_bytes(format("val{:d}", (i + 1))));
BOOST_REQUIRE(column_defs[i]);
}
@@ -2180,7 +2180,7 @@ SEASTAR_THREAD_TEST_CASE(test_uncompressed_large_subset_of_columns_dense_read) {
std::vector<const column_definition*> column_defs(64);
for (int i = 0; i < 64; ++i) {
column_defs[i] = UNCOMPRESSED_LARGE_SUBSET_OF_COLUMNS_DENSE_SCHEMA->get_column_definition(to_bytes(sprint("val%d", (i + 1))));
column_defs[i] = UNCOMPRESSED_LARGE_SUBSET_OF_COLUMNS_DENSE_SCHEMA->get_column_definition(to_bytes(format("val{:d}", (i + 1))));
BOOST_REQUIRE(column_defs[i]);
}
@@ -2748,7 +2748,7 @@ SEASTAR_THREAD_TEST_CASE(test_uncompressed_collections_read) {
for (auto&& entry : m_view.cells) {
auto cmp = compare_unsigned(int32_type->decompose(int32_t(val[idx])), entry.first);
if (cmp != 0) {
BOOST_FAIL(sprint("Expected row with column %s having value %s, but it has value %s",
BOOST_FAIL(format("Expected row with column {} having value {}, but it has value {}",
def.id,
int32_type->decompose(int32_t(val[idx])),
entry.first));
@@ -2768,7 +2768,7 @@ SEASTAR_THREAD_TEST_CASE(test_uncompressed_collections_read) {
for (auto&& entry : m_view.cells) {
auto cmp = compare_unsigned(utf8_type->decompose(val[idx]), entry.second.value().linearize());
if (cmp != 0) {
BOOST_FAIL(sprint("Expected row with column %s having value %s, but it has value %s",
BOOST_FAIL(format("Expected row with column {} having value {}, but it has value {}",
def.id,
utf8_type->decompose(val[idx]),
entry.second.value().linearize()));
@@ -2790,7 +2790,7 @@ SEASTAR_THREAD_TEST_CASE(test_uncompressed_collections_read) {
auto cmp2 = compare_unsigned(utf8_type->decompose(val[idx].second), entry.second.value().linearize());
if (cmp1 != 0 || cmp2 != 0) {
BOOST_FAIL(
sprint("Expected row with column %s having value (%s, %s), but it has value (%s, %s)",
format("Expected row with column {} having value ({}, {}), but it has value ({}, {})",
def.id,
int32_type->decompose(int32_t(val[idx].first)),
utf8_type->decompose(val[idx].second),

View File

@@ -2862,7 +2862,7 @@ SEASTAR_TEST_CASE(test_counter_read) {
} else if (col.name_as_text() == "c2") {
BOOST_REQUIRE_EQUAL(ccv.total_value(), -92);
} else {
BOOST_FAIL(sprint("Unexpected column \'%s\'", col.name_as_text()));
BOOST_FAIL(format("Unexpected column \'{}\'", col.name_as_text()));
}
});
});
@@ -2876,7 +2876,7 @@ SEASTAR_TEST_CASE(test_counter_read) {
if (col.name_as_text() == "c1") {
BOOST_REQUIRE(!c.as_atomic_cell(col).is_live());
} else {
BOOST_FAIL(sprint("Unexpected column \'%s\'", col.name_as_text()));
BOOST_FAIL(format("Unexpected column \'{}\'", col.name_as_text()));
}
});
@@ -3720,7 +3720,7 @@ SEASTAR_TEST_CASE(test_repeated_tombstone_skipping) {
auto ck1 = table.make_ckey(1);
auto ck2 = table.make_ckey((1 + i) / 2);
auto ck3 = table.make_ckey(i);
BOOST_TEST_MESSAGE(sprint("checking %s %s", ck2, ck3));
BOOST_TEST_MESSAGE(format("checking {} {}", ck2, ck3));
auto slice = partition_slice_builder(*table.schema())
.with_range(query::clustering_range::make_singular(ck1))
.with_range(query::clustering_range::make_singular(ck2))

View File

@@ -1066,7 +1066,7 @@ SEASTAR_TEST_CASE(test_promoted_index_repeats_open_tombstones) {
int id = 0;
for (auto& compact : { schema_builder::compact_storage::no, schema_builder::compact_storage::yes }) {
const auto generation = id++;
schema_builder builder("ks", sprint("cf%d", generation));
schema_builder builder("ks", format("cf{:d}", generation));
builder.with_column("p", utf8_type, column_kind::partition_key);
builder.with_column("c1", bytes_type, column_kind::clustering_key);
builder.with_column("v", int32_type);
@@ -1369,7 +1369,7 @@ SEASTAR_THREAD_TEST_CASE(test_large_index_pages_do_not_cause_large_allocations)
auto make_pkey_text = [] (size_t pad_size) -> sstring {
static int i = 0;
return sprint("pkey_0x%x_%s", i++, make_random_string(pad_size));
return format("pkey_0x{:x}_{}", i++, make_random_string(pad_size));
};
// Choose min from several random keys
@@ -1429,7 +1429,7 @@ SEASTAR_THREAD_TEST_CASE(test_large_index_pages_do_not_cause_large_allocations)
auto large_allocs_after = memory::stats().large_allocations();
auto duration = std::chrono::steady_clock::now() - t0;
BOOST_TEST_MESSAGE(sprint("Read took %d us", duration / 1us));
BOOST_TEST_MESSAGE(format("Read took {:d} us", duration / 1us));
assert_that(actual).is_equal_to(expected);
BOOST_REQUIRE_EQUAL(large_allocs_after - large_allocs_before, 0);

View File

@@ -1247,10 +1247,10 @@ SEASTAR_TEST_CASE(promoted_index_write) {
for (int k = 0; k < 20; k++) {
auto& row = m.partition().clustered_row(*s,
clustering_key::from_exploded(
*s, {to_bytes(sprint("%d%c%c", k, i, j))}));
*s, {to_bytes(format("{:d}{:c}{:c}", k, i, j))}));
row.cells().apply(*col,
atomic_cell::make_live(*col->type, 2345,
col->type->decompose(sstring(sprint("z%c",i)))));
col->type->decompose(sstring(format("z{:c}",i)))));
row.apply(row_marker(1234));
}
}
@@ -1259,7 +1259,7 @@ SEASTAR_TEST_CASE(promoted_index_write) {
auto sst = make_sstable(s, dirname, 100,
sstables::sstable::version_types::la, big);
return write_memtable_to_sstable_for_test(*mtp, sst).then([s, dirname] {
auto large_partition_file = seastar::sprint("%s/la-3-big-Index.db", get_test_dir("large_partition", s));
auto large_partition_file = seastar::format("{}/la-3-big-Index.db", get_test_dir("large_partition", s));
return compare_files(large_partition_file, dirname + "/la-100-big-Index.db");
}).then([sst, mtp] {});
});

View File

@@ -217,12 +217,12 @@ public:
inline sstring get_test_dir(const sstring& name, const sstring& ks, const sstring& cf)
{
return seastar::sprint("tests/sstables/%s/%s/%s-1c6ace40fad111e7b9cf000000000002", name, ks, cf);
return seastar::format("tests/sstables/{}/{}/{}-1c6ace40fad111e7b9cf000000000002", name, ks, cf);
}
inline sstring get_test_dir(const sstring& name, const schema_ptr s)
{
return seastar::sprint("tests/sstables/%s/%s/%s-1c6ace40fad111e7b9cf000000000002", name, s->ks_name(), s->cf_name());
return seastar::format("tests/sstables/{}/{}/{}-1c6ace40fad111e7b9cf000000000002", name, s->ks_name(), s->cf_name());
}
inline std::array<sstables::sstable::version_types, 3> all_sstable_versions = {

View File

@@ -36,7 +36,7 @@
static std::vector<dht::ring_position> make_ring(schema_ptr s, int n_keys) {
std::vector<dht::ring_position> ring;
for (int i = 0; i < 10; ++i) {
auto pk = partition_key::from_single_value(*s, to_bytes(sprint("key%d", i)));
auto pk = partition_key::from_single_value(*s, to_bytes(format("key{:d}", i)));
ring.emplace_back(dht::global_partitioner().decorate_key(*s, pk));
}
std::sort(ring.begin(), ring.end(), dht::ring_position_less_comparator(*s));
@@ -59,7 +59,7 @@ SEASTAR_TEST_CASE(test_get_restricted_ranges) {
if (!std::equal(actual.begin(), actual.end(), expected.begin(), [&s](auto&& r1, auto&& r2) {
return r1.equal(r2, dht::ring_position_comparator(*s));
})) {
BOOST_FAIL(sprint("Ranges differ, expected %s but got %s", expected, actual));
BOOST_FAIL(format("Ranges differ, expected {} but got {}", expected, actual));
}
};

View File

@@ -41,11 +41,11 @@ private:
for (const element& right_e : right) {
seastar::visit(left_e, [&] (auto&& a) {
seastar::visit(right_e, [&] (auto&& b) {
BOOST_TEST_MESSAGE(sprint("cmp(%s, %s) == %d", a, b, order));
BOOST_TEST_MESSAGE(format("cmp({}, {}) == {:d}", a, b, order));
auto r = _cmp(a, b);
auto actual = this->sgn(r);
if (actual != order) {
BOOST_FAIL(sprint("Expected cmp(%s, %s) == %d, but got %d", a, b, order, actual));
BOOST_FAIL(format("Expected cmp({}, {}) == {:d}, but got {:d}", a, b, order, actual));
}
});
});

View File

@@ -37,7 +37,7 @@ void test_parsing_fails(const shared_ptr<const abstract_type>& type, sstring str
{
try {
type->from_string(str);
BOOST_FAIL(sprint("Parsing of '%s' should have failed", str));
BOOST_FAIL(format("Parsing of '{}' should have failed", str));
} catch (const marshal_exception& e) {
// expected
}
@@ -741,7 +741,7 @@ BOOST_AUTO_TEST_CASE(test_parsing_of_user_type) {
}
static auto msg = [] (const char* m, data_type x, data_type y) -> std::string {
return sprint("%s(%s, %s)", m, x->name(), y->name());
return format("{}({}, {})", m, x->name(), y->name());
};
// Sort order does not change

View File

@@ -36,7 +36,7 @@ SEASTAR_TEST_CASE(test_builder_with_large_partition) {
e.execute_cql("create table cf (p int, c int, v int, primary key (p, c))").get();
for (auto i = 0; i < 1024; ++i) {
e.execute_cql(sprint("insert into cf (p, c, v) values (0, %d, 0)", i)).get();
e.execute_cql(format("insert into cf (p, c, v) values (0, {:d}, 0)", i)).get();
}
auto f = e.local_view_builder().wait_until_built("ks", "vcf", lowres_clock::now() + 10s);
@@ -60,7 +60,7 @@ SEASTAR_TEST_CASE(test_builder_with_multiple_partitions) {
e.execute_cql("create table cf (p int, c int, v int, primary key (p, c))").get();
for (auto i = 0; i < 1024; ++i) {
e.execute_cql(sprint("insert into cf (p, c, v) values (%d, %d, 0)", i % 5, i)).get();
e.execute_cql(format("insert into cf (p, c, v) values ({:d}, {:d}, 0)", i % 5, i)).get();
}
auto f = e.local_view_builder().wait_until_built("ks", "vcf", lowres_clock::now() + 10s);
@@ -84,7 +84,7 @@ SEASTAR_TEST_CASE(test_builder_with_multiple_partitions_of_batch_size_rows) {
e.execute_cql("create table cf (p int, c int, v int, primary key (p, c))").get();
for (auto i = 0; i < 1024; ++i) {
e.execute_cql(sprint("insert into cf (p, c, v) values (%d, %d, 0)", i % db::view::view_builder::batch_size, i)).get();
e.execute_cql(format("insert into cf (p, c, v) values ({:d}, {:d}, 0)", i % db::view::view_builder::batch_size, i)).get();
}
auto f = e.local_view_builder().wait_until_built("ks", "vcf", lowres_clock::now() + 10s);
@@ -108,7 +108,7 @@ SEASTAR_TEST_CASE(test_builder_view_added_during_ongoing_build) {
e.execute_cql("create table cf (p int, c int, v int, primary key (p, c))").get();
for (auto i = 0; i < 5000; ++i) {
e.execute_cql(sprint("insert into cf (p, c, v) values (0, %d, 0)", i)).get();
e.execute_cql(format("insert into cf (p, c, v) values (0, {:d}, 0)", i)).get();
}
auto f1 = e.local_view_builder().wait_until_built("ks", "vcf1", lowres_clock::now() + 60s);
@@ -166,7 +166,7 @@ SEASTAR_TEST_CASE(test_builder_across_tokens_with_large_partitions) {
auto make_key = [&] (auto) { return to_hex(random_bytes(128, gen)); };
for (auto&& k : boost::irange(0, 4) | boost::adaptors::transformed(make_key)) {
for (auto i = 0; i < 1000; ++i) {
e.execute_cql(sprint("insert into cf (p, c, v) values (0x%s, %d, 0)", k, i)).get();
e.execute_cql(format("insert into cf (p, c, v) values (0x{}, {:d}, 0)", k, i)).get();
}
}
@@ -208,7 +208,7 @@ SEASTAR_TEST_CASE(test_builder_across_tokens_with_small_partitions) {
auto make_key = [&] (auto) { return to_hex(random_bytes(128, gen)); };
for (auto&& k : boost::irange(0, 1000) | boost::adaptors::transformed(make_key)) {
for (auto i = 0; i < 4; ++i) {
e.execute_cql(sprint("insert into cf (p, c, v) values (0x%s, %d, 0)", k, i)).get();
e.execute_cql(format("insert into cf (p, c, v) values (0x{}, {:d}, 0)", k, i)).get();
}
}
@@ -246,7 +246,7 @@ SEASTAR_TEST_CASE(test_builder_with_tombstones) {
e.execute_cql("create table cf (p int, c1 int, c2 int, v int, primary key (p, c1, c2))").get();
for (auto i = 0; i < 100; ++i) {
e.execute_cql(sprint("insert into cf (p, c1, c2, v) values (0, %d, %d, 1)", i % 2, i)).get();
e.execute_cql(format("insert into cf (p, c1, c2, v) values (0, {:d}, {:d}, 1)", i % 2, i)).get();
}
e.execute_cql("delete from cf where p = 0 and c1 = 0").get();
@@ -286,7 +286,7 @@ SEASTAR_TEST_CASE(test_builder_with_concurrent_writes) {
auto k = keys.begin();
for (; k != half; ++k) {
for (size_t i = 0; i < rows_per_partition; ++i) {
e.execute_cql(sprint("insert into cf (p, c, v) values (0x%s, %d, 0)", *k, i)).get();
e.execute_cql(format("insert into cf (p, c, v) values (0x{}, {:d}, 0)", *k, i)).get();
}
}
@@ -297,7 +297,7 @@ SEASTAR_TEST_CASE(test_builder_with_concurrent_writes) {
for (; k != keys.end(); ++k) {
for (size_t i = 0; i < rows_per_partition; ++i) {
e.execute_cql(sprint("insert into cf (p, c, v) values (0x%s, %d, 0)", *k, i)).get();
e.execute_cql(format("insert into cf (p, c, v) values (0x{}, {:d}, 0)", *k, i)).get();
}
}
@@ -318,7 +318,7 @@ SEASTAR_TEST_CASE(test_builder_with_concurrent_drop) {
auto make_key = [&] (auto) { return to_hex(random_bytes(128, gen)); };
for (auto&& k : boost::irange(0, 1000) | boost::adaptors::transformed(make_key)) {
for (auto i = 0; i < 5; ++i) {
e.execute_cql(sprint("insert into cf (p, c, v) values (0x%s, %d, 0)", k, i)).get();
e.execute_cql(format("insert into cf (p, c, v) values (0x{}, {:d}, 0)", k, i)).get();
}
}

View File

@@ -936,11 +936,11 @@ void test_expired_marker_with_limit(cql_test_env& e, std::function<void()>&& may
"primary key (a, p)").get();
for (int i = 1; i <= 100; i++) {
e.execute_cql(sprint("insert into cf (p, a, b) values (%d, %d, %d)", i, i, i)).get();
e.execute_cql(format("insert into cf (p, a, b) values ({:d}, {:d}, {:d})", i, i, i)).get();
}
for (int i = 1; i <= 100; i++) {
if (i % 50 != 0) {
e.execute_cql(sprint("delete a from cf where p = %d", i)).get();
e.execute_cql(format("delete a from cf where p = {:d}", i)).get();
}
}
@@ -948,11 +948,11 @@ void test_expired_marker_with_limit(cql_test_env& e, std::function<void()>&& may
for (auto view : {"vcf1", "vcf2"}) {
eventually([&] {
auto msg = e.execute_cql(sprint("select * from %s limit 1", view)).get0();
auto msg = e.execute_cql(format("select * from {} limit 1", view)).get0();
assert_that(msg).is_rows().with_size(1);
msg = e.execute_cql(sprint("select * from %s limit 2", view)).get0();
msg = e.execute_cql(format("select * from {} limit 2", view)).get0();
assert_that(msg).is_rows().with_size(2);
msg = e.execute_cql(sprint("select * from %s", view)).get0();
msg = e.execute_cql(format("select * from {}", view)).get0();
assert_that(msg).is_rows().with_rows({
{{int32_type->decompose(50)}, {int32_type->decompose(50)}, {int32_type->decompose(50)}},
{{int32_type->decompose(100)}, {int32_type->decompose(100)}, {int32_type->decompose(100)}},
@@ -1376,16 +1376,16 @@ void do_test_3362_no_ttls_with_collections(cql_test_env& e, collection_kind t) {
suf = " : 17}";
break;
}
e.execute_cql(sprint("create table cf (p int, c int, a %s, primary key (p, c))", type)).get();
e.execute_cql(format("create table cf (p int, c int, a {}, primary key (p, c))", type)).get();
e.execute_cql("create materialized view vcf as select p, c from cf "
"where p is not null and c is not null "
"primary key (p, c)").get();
e.execute_cql(sprint("update cf using timestamp 10 set a = a + %s2%s where p = 1 and c = 1", pref, suf)).get();
e.execute_cql(format("update cf using timestamp 10 set a = a + {}2{} where p = 1 and c = 1", pref, suf)).get();
eventually([&] {
auto msg = e.execute_cql("select * from vcf where p = 1 and c = 1").get0();
assert_that(msg).is_rows().with_rows({{ {int32_type->decompose(1)}, {int32_type->decompose(1)} }});
});
e.execute_cql(sprint("update cf using timestamp 20 set a = a + %s1%s where p = 1 and c = 1", pref, suf)).get();
e.execute_cql(format("update cf using timestamp 20 set a = a + {}1{} where p = 1 and c = 1", pref, suf)).get();
eventually([&] {
auto msg = e.execute_cql("select * from vcf where p = 1 and c = 1").get0();
assert_that(msg).is_rows().with_rows({{ {int32_type->decompose(1)}, {int32_type->decompose(1)} }});
@@ -1393,7 +1393,7 @@ void do_test_3362_no_ttls_with_collections(cql_test_env& e, collection_kind t) {
if (t == collection_kind::map) {
e.execute_cql("delete a[1] from cf using timestamp 21 where p = 1 and c = 1").get();
} else {
e.execute_cql(sprint("update cf using timestamp 21 set a = a - %s1%s where p = 1 and c = 1", pref, suf)).get();
e.execute_cql(format("update cf using timestamp 21 set a = a - {}1{} where p = 1 and c = 1", pref, suf)).get();
}
eventually([&] {
auto msg = e.execute_cql("select * from vcf where p = 1 and c = 1").get0();
@@ -1402,13 +1402,13 @@ void do_test_3362_no_ttls_with_collections(cql_test_env& e, collection_kind t) {
if (t == collection_kind::map) {
e.execute_cql("delete a[2] from cf using timestamp 11 where p = 1 and c = 1").get();
} else {
e.execute_cql(sprint("update cf using timestamp 11 set a = a - %s2%s where p = 1 and c = 1", pref, suf)).get();
e.execute_cql(format("update cf using timestamp 11 set a = a - {}2{} where p = 1 and c = 1", pref, suf)).get();
}
eventually([&] {
auto msg = e.execute_cql("select * from vcf where p = 1 and c = 1").get0();
assert_that(msg).is_rows().is_empty();
});
e.execute_cql(sprint("update cf using timestamp 12 set a = a + %s2%s where p = 1 and c = 1", pref, suf)).get();
e.execute_cql(format("update cf using timestamp 12 set a = a + {}2{} where p = 1 and c = 1", pref, suf)).get();
eventually([&] {
auto msg = e.execute_cql("select * from vcf where p = 1 and c = 1").get0();
assert_that(msg).is_rows().with_rows({{ {int32_type->decompose(1)}, {int32_type->decompose(1)} }});
@@ -1449,16 +1449,16 @@ void do_test_3362_with_ttls_with_collections(cql_test_env& e, collection_kind t)
suf = " : 17}";
break;
}
e.execute_cql(sprint("create table cf (p int, c int, a %s, primary key (p, c))", type)).get();
e.execute_cql(format("create table cf (p int, c int, a {}, primary key (p, c))", type)).get();
e.execute_cql("create materialized view vcf as select p, c from cf "
"where p is not null and c is not null "
"primary key (p, c)").get();
e.execute_cql(sprint("update cf using timestamp 2 and ttl 5 set a = a + %s1%s where p = 1 and c = 1", pref, suf)).get();
e.execute_cql(format("update cf using timestamp 2 and ttl 5 set a = a + {}1{} where p = 1 and c = 1", pref, suf)).get();
eventually([&] {
auto msg = e.execute_cql("select * from vcf where p = 1 and c = 1").get0();
assert_that(msg).is_rows().with_rows({{ {int32_type->decompose(1)}, {int32_type->decompose(1)} }});
});
e.execute_cql(sprint("update cf using timestamp 1 set a = a + %s2%s where p = 1 and c = 1", pref, suf)).get();
e.execute_cql(format("update cf using timestamp 1 set a = a + {}2{} where p = 1 and c = 1", pref, suf)).get();
eventually([&] {
auto msg = e.execute_cql("select * from vcf where p = 1 and c = 1").get0();
assert_that(msg).is_rows().with_rows({{ {int32_type->decompose(1)}, {int32_type->decompose(1)} }});

View File

@@ -54,7 +54,7 @@ SEASTAR_TEST_CASE(test_case_sensitivity) {
for (auto view : {"mv_test", "mv_test2"}) {
eventually([&] {
auto msg = e.execute_cql(sprint("select \"theKey\", \"theClustering\", \"theValue\" from %s ", view)).get0();
auto msg = e.execute_cql(format("select \"theKey\", \"theClustering\", \"theValue\" from {} ", view)).get0();
assert_that(msg).is_rows()
.with_size(1)
.with_row({
@@ -69,7 +69,7 @@ SEASTAR_TEST_CASE(test_case_sensitivity) {
for (auto view : {"mv_test", "mv_test2"}) {
eventually([&] {
auto msg = e.execute_cql(sprint("select \"theKey\", \"Col\", \"theValue\" from %s ", view)).get0();
auto msg = e.execute_cql(format("select \"theKey\", \"Col\", \"theValue\" from {} ", view)).get0();
assert_that(msg).is_rows()
.with_size(1)
.with_row({
@@ -848,7 +848,7 @@ SEASTAR_TEST_CASE(test_static_table) {
"primary key (v, p, c)").get();
for (auto i = 0; i < 100; ++i) {
e.execute_cql(sprint("insert into cf (p, c, sv, v) values (0, %d, %d, %d)", i % 2, i * 100, i)).get();
e.execute_cql(format("insert into cf (p, c, sv, v) values (0, {:d}, {:d}, {:d})", i % 2, i * 100, i)).get();
}
eventually([&] {
@@ -905,7 +905,7 @@ SEASTAR_TEST_CASE(test_old_timestamps) {
"primary key (v, p, c)").get();
for (auto i = 0; i < 100; ++i) {
e.execute_cql(sprint("insert into cf (p, c, v) values (0, %d, 1)", i % 2)).get();
e.execute_cql(format("insert into cf (p, c, v) values (0, {:d}, 1)", i % 2)).get();
}
eventually([&] {
@@ -1105,7 +1105,7 @@ SEASTAR_TEST_CASE(test_range_tombstone) {
"primary key ((v, p), c1, c2)").get();
for (auto i = 0; i < 100; ++i) {
e.execute_cql(sprint("insert into cf (p, c1, c2, v) values (0, %d, %d, 1)", i % 2, i)).get();
e.execute_cql(format("insert into cf (p, c1, c2, v) values (0, {:d}, {:d}, 1)", i % 2, i)).get();
}
eventually([&] {
@@ -1373,7 +1373,7 @@ SEASTAR_TEST_CASE(test_conflicting_timestamp) {
"where p is not null and c is not null and v is not null primary key (v, c, p)").get();
for (auto i = 0; i < 50; ++i) {
e.execute_cql(sprint("insert into cf (p, c, v) values (1, 1, %d)", i)).get();
e.execute_cql(format("insert into cf (p, c, v) values (1, 1, {:d})", i)).get();
}
eventually([&] {
auto msg = e.execute_cql("select * from mv").get0();
@@ -3062,7 +3062,7 @@ SEASTAR_TEST_CASE(test_old_timestamps_with_restrictions) {
"primary key (val, k ,c)").get();
for (auto i = 0; i < 100; ++i) {
e.execute_cql(sprint("insert into cf (k, c, val) values (0, %d, 'baz') using timestamp 300", i % 2)).get();
e.execute_cql(format("insert into cf (k, c, val) values (0, {:d}, 'baz') using timestamp 300", i % 2)).get();
}
eventually([&] {
@@ -3505,7 +3505,7 @@ SEASTAR_TEST_CASE(test_base_non_pk_columns_in_view_partition_key_are_non_emtpy)
e.execute_cql("insert into cf (p1, p2, c, v) values (1, '', '', '')").get();
size_t id = 0;
auto make_view_name = [&id] { return sprint("vcf_%d", id++); };
auto make_view_name = [&id] { return format("vcf_{:d}", id++); };
auto views_matching = {
"create materialized view %s as select * from cf "
@@ -3533,7 +3533,7 @@ SEASTAR_TEST_CASE(test_base_non_pk_columns_in_view_partition_key_are_non_emtpy)
auto f = e.local_view_builder().wait_until_built("ks", name, lowres_clock::now() + 5s);
e.execute_cql(sprint(view, name)).get();
f.get();
auto msg = e.execute_cql(sprint("select p1, p2, c, v from %s", name)).get0();
auto msg = e.execute_cql(format("select p1, p2, c, v from {}", name)).get0();
assert_that(msg).is_rows()
.with_size(1)
.with_row({
@@ -3558,7 +3558,7 @@ SEASTAR_TEST_CASE(test_base_non_pk_columns_in_view_partition_key_are_non_emtpy)
auto f = e.local_view_builder().wait_until_built("ks", name, lowres_clock::now() + 5s);
e.execute_cql(sprint(view, name)).get();
f.get();
auto msg = e.execute_cql(sprint("select p1, p2, c, v from %s", name)).get0();
auto msg = e.execute_cql(format("select p1, p2, c, v from {}", name)).get0();
assert_that(msg).is_rows().is_empty();
}
auto name = make_view_name();
@@ -3567,13 +3567,13 @@ SEASTAR_TEST_CASE(test_base_non_pk_columns_in_view_partition_key_are_non_emtpy)
"where p1 is not null and p2 is not null and c is not null and v is not null "
"primary key (v, p1, p2, c)", name)).get();
f.get();
auto msg = e.execute_cql(sprint("select p1, p2, c, v from %s", name)).get0();
auto msg = e.execute_cql(format("select p1, p2, c, v from {}", name)).get0();
assert_that(msg).is_rows().is_empty();
e.local_db().flush_all_memtables().get();
e.execute_cql("update cf set v = 'a' where p1 = 1 and p2 = '' and c = ''").get();
eventually([&] {
auto msg = e.execute_cql(sprint("select p1, p2, c, v from %s", name)).get0();
auto msg = e.execute_cql(format("select p1, p2, c, v from {}", name)).get0();
assert_that(msg).is_rows()
.with_size(1)
.with_row({
@@ -3585,12 +3585,12 @@ SEASTAR_TEST_CASE(test_base_non_pk_columns_in_view_partition_key_are_non_emtpy)
});
e.execute_cql("update cf set v = '' where p1 = 1 and p2 = '' and c = ''").get();
eventually([&] {
auto msg = e.execute_cql(sprint("select p1, p2, c, v from %s", name)).get0();
auto msg = e.execute_cql(format("select p1, p2, c, v from {}", name)).get0();
assert_that(msg).is_rows().is_empty();
});
e.execute_cql("delete v from cf where p1 = 1 and p2 = '' and c = ''").get();
eventually([&] {
auto msg = e.execute_cql(sprint("select p1, p2, c, v from %s", name)).get0();
auto msg = e.execute_cql(format("select p1, p2, c, v from {}", name)).get0();
assert_that(msg).is_rows().is_empty();
});
});

View File

@@ -290,7 +290,7 @@ SEASTAR_TEST_CASE(test_query_built_indexes_virtual_table) {
assert_that(rs).is_rows().with_rows_ignore_order({
{ {utf8_type->decompose(sstring("ks"))}, {utf8_type->decompose(idx)} },
});
rs = e.execute_cql(sprint("select * from system.\"IndexInfo\" where table_name = 'ks' and index_name = '%s'", idx)).get0();
rs = e.execute_cql(format("select * from system.\"IndexInfo\" where table_name = 'ks' and index_name = '{}'", idx)).get0();
assert_that(rs).is_rows().with_size(1);
rs = e.execute_cql("select * from system.\"IndexInfo\" where table_name = 'ks' and index_name = 'vcf'").get0();
assert_that(rs).is_rows().with_size(0);