From 2b37492d4b6ec59f61519448eaa45fa567b0c509 Mon Sep 17 00:00:00 2001 From: abudnik Date: Thu, 24 Dec 2015 17:07:14 +0400 Subject: [PATCH] server-send: tests: significantly decreased running time of tests --- tests/server_send.cpp | 57 +++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/tests/server_send.cpp b/tests/server_send.cpp index 54a3386bf..7cf029f09 100644 --- a/tests/server_send.cpp +++ b/tests/server_send.cpp @@ -79,10 +79,11 @@ static void ssend_configure(const std::string &path) static void ssend_test_insert_many_keys_old_ts(session &s, int num, const std::string &id_prefix, const std::string &data_prefix) { + std::vector results; s.set_trace_id(rand()); for (int i = 0; i < num; ++i) { - std::string id = id_prefix + lexical_cast(i); - std::string data = data_prefix + lexical_cast(i); + auto id = id_prefix + lexical_cast(i); + auto data = data_prefix + lexical_cast(i); key k(id); s.transform(k); @@ -95,39 +96,59 @@ static void ssend_test_insert_many_keys_old_ts(session &s, int num, const std::s dnet_current_time(&io.timestamp); io.timestamp.tsec -= 1000; - ELLIPTICS_REQUIRE(res, s.write_data(io, data)); + results.push_back(s.write_data(io, data)); + } + + for (auto &r : results) { + ELLIPTICS_REQUIRE(res, std::move(r)); } } static void ssend_test_insert_many_keys(session &s, int num, const std::string &id_prefix, const std::string &data_prefix) { + std::vector results; s.set_trace_id(rand()); for (int i = 0; i < num; ++i) { - std::string id = id_prefix + lexical_cast(i); - std::string data = data_prefix + lexical_cast(i); + auto id = id_prefix + lexical_cast(i); + auto data = data_prefix + lexical_cast(i); + + results.push_back(s.write_data(id, data, 0)); + } - ELLIPTICS_REQUIRE(res, s.write_data(id, data, 0)); + for (auto &r : results) { + ELLIPTICS_REQUIRE(res, std::move(r)); } } static void ssend_test_read_many_keys(session &s, int num, const std::string &id_prefix, const std::string &data_prefix) { + std::vector results; s.set_trace_id(rand()); for (int i = 0; i < num; ++i) { - std::string id = id_prefix + lexical_cast(i); - std::string data = data_prefix + lexical_cast(i); + auto id = id_prefix + lexical_cast(i); - ELLIPTICS_COMPARE_REQUIRE(res, s.read_data(id, 0, 0), data); + results.push_back(s.read_data(id, 0, 0)); + } + + for (int i = 0; i < num; ++i) { + auto data = data_prefix + lexical_cast(i); + + ELLIPTICS_COMPARE_REQUIRE(res, std::move(results[i]), data); } } static void ssend_test_read_many_keys_error(session &s, int num, const std::string &id_prefix, int error) { + std::vector results; s.set_trace_id(rand()); for (int i = 0; i < num; ++i) { - std::string id = id_prefix + lexical_cast(i); + auto id = id_prefix + lexical_cast(i); + + results.push_back(s.read_data(id, 0, 0)); + } - ELLIPTICS_REQUIRE_ERROR(res, s.read_data(id, 0, 0), error); + for (auto &r : results) { + ELLIPTICS_REQUIRE_ERROR(res, std::move(r), error); } } @@ -231,16 +252,20 @@ static void ssend_test_server_send(session &s, int num, const std::string &id_pr logger &log = s.get_logger(); s.set_trace_id(rand()); + std::vector write_results; std::vector keys; for (int i = 0; i < num; ++i) { - std::string id = id_prefix + lexical_cast(i); - std::string data = data_prefix + lexical_cast(i); - - ELLIPTICS_REQUIRE(res, s.write_data(id, data, 0)); + auto id = id_prefix + lexical_cast(i); + auto data = data_prefix + lexical_cast(i); + write_results.push_back(s.write_data(id, data, 0)); keys.push_back(id); } + for (auto &r : write_results) { + ELLIPTICS_REQUIRE(res, std::move(r)); + } + BH_LOG(log, DNET_LOG_NOTICE, "%s: keys: %d, dst_groups: %s, starting copy", __func__, num, print_groups(dst_groups)); @@ -365,7 +390,7 @@ static bool ssend_register_tests(test_suite *suite, node &n) tests::create_session(n, {*g}, 0, 0), num, id_prefix, data_prefix); } - // the fith stage - check that moving keys to itself doesn't permitted + // the fifth stage - check that moving keys to itself doesn't permitted iflags = DNET_IFLAGS_MOVE; id_prefix = "server_send self write test"; data_prefix = "server_send self write data";