From fbb7de82d298d84c665ab465069fc6d925880e09 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Mon, 23 Nov 2020 16:39:46 +0100 Subject: [PATCH] testing --- src/bin/memslap.cc | 8 ++++---- test/tests/bin/memslap.cpp | 15 ++++++++++++--- test/tests/bin/memstat.cpp | 6 ++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/bin/memslap.cc b/src/bin/memslap.cc index d1c58cd6..baf6df63 100644 --- a/src/bin/memslap.cc +++ b/src/bin/memslap.cc @@ -210,6 +210,10 @@ static opt_apply wrap_stoul(unsigned long &ul) { }; } +static std::ostream &align(std::ostream &io) { + return io << std::right << std::setw(8); +} + int main(int argc, char *argv[]) { client_options opt{PROGRAM_NAME, PROGRAM_VERSION, PROGRAM_DESCRIPTION}; auto concurrency = DEFAULT_CONCURRENCY; @@ -270,10 +274,6 @@ int main(int argc, char *argv[]) { auto total_start = time_clock::now(); std::cout << std::fixed << std::setprecision(3); - auto align = [](std::ostream &io) -> std::ostream &{ - return io << std::right << std::setw(8); - }; - if (opt.isset("flush")) { if (opt.isset("verbose")) { std::cout << "- Flushing servers ...\n"; diff --git a/test/tests/bin/memslap.cpp b/test/tests/bin/memslap.cpp index cc640cdd..bc0b817b 100644 --- a/test/tests/bin/memslap.cpp +++ b/test/tests/bin/memslap.cpp @@ -29,16 +29,25 @@ TEST_CASE("bin/memslap") { SECTION("with servers") { auto test = MemcachedCluster::udp(); - auto flags = {"--binary", "--udp", "--flush", "--test=mget", "--test=get", "--tcp-nodelay", - "--non-blocking", "--execute-number=1000"}; + auto flags = {"--binary", "--udp", "--flush", "--test=mget", "--test=get", "--test=set", + "--tcp-nodelay", "--non-blocking", "--execute-number=1000"}; string servers{"--servers="}; + auto verbosity = GENERATE(as(), " --verbose ", " --quiet "); for (const auto &server : test.cluster.getServers()) { servers += "localhost:" + to_string(get(server.getSocketOrPort())) + ", "; } for (const auto flag : flags) { - REQUIRE(sh.run("memslap --quiet --concurrency=2 " + servers + flag)); + string output; + REQUIRE(sh.run("memslap --concurrency=2 " + servers + verbosity + flag, output)); + if (verbosity != " --quiet ") { + REQUIRE_THAT(output, Contains("Starting")); + REQUIRE_THAT(output, Contains("Time to")); + REQUIRE_THAT(output, Contains("seconds")); + } else { + REQUIRE(output.empty()); + } } } } diff --git a/test/tests/bin/memstat.cpp b/test/tests/bin/memstat.cpp index c6499777..05f935de 100644 --- a/test/tests/bin/memstat.cpp +++ b/test/tests/bin/memstat.cpp @@ -41,6 +41,12 @@ TEST_CASE("bin/memstat") { REQUIRE_SUCCESS(memcached_server_add(*memc, "localhost", port)); SECTION("okay") { + SECTION("stat") { + string output; + REQUIRE(sh.run(comm, output)); + REQUIRE_THAT(output, Contains("Server:")); + REQUIRE_THAT(output, Contains("pid:")); + } SECTION("version") { REQUIRE_SUCCESS(memcached_version(*memc)); auto inst = memcached_server_instance_by_position(*memc, 0); -- 2.30.2