update TODO
[awesomized/libmemcached] / test / tests / bin / memslap.cpp
1 #include "test/lib/common.hpp"
2 #include "test/lib/Shell.hpp"
3 #include "test/lib/MemcachedCluster.hpp"
4
5 using Catch::Matchers::Contains;
6
7 TEST_CASE("bin/memslap") {
8 Shell sh{string{TESTING_ROOT "/../src/bin"}};
9
10 SECTION("no servers provided") {
11 string output;
12 REQUIRE_FALSE(sh.run("memslap", output));
13 REQUIRE(output == "No servers provided.\n");
14 }
15
16 SECTION("--help") {
17 string output;
18
19 REQUIRE(sh.run("memslap --help", output));
20 REQUIRE_THAT(output, Contains("memslap v1"));
21 REQUIRE_THAT(output, Contains("Usage:"));
22 REQUIRE_THAT(output, Contains("Options:"));
23 REQUIRE_THAT(output, Contains("-h|--help"));
24 REQUIRE_THAT(output, Contains("-V|--version"));
25 REQUIRE_THAT(output, Contains("--concurrency"));
26 REQUIRE_THAT(output, Contains("Environment:"));
27 REQUIRE_THAT(output, Contains("MEMCACHED_SERVERS"));
28 }
29
30 SECTION("with servers") {
31 auto test = MemcachedCluster::udp();
32 auto flags = {"--binary", "--udp", "--flush", "--test=mget", "--test=get", "--test=set",
33 "--tcp-nodelay", "--non-blocking", "--execute-number=1000"};
34 string servers{"--servers="};
35 auto verbosity = GENERATE(as<string>(), " --verbose ", " --quiet ");
36
37 for (const auto &server : test.cluster.getServers()) {
38 servers += "localhost:" + to_string(get<int>(server.getSocketOrPort())) + ", ";
39 }
40
41 for (const auto flag : flags) {
42 string output;
43 REQUIRE(sh.run("memslap --concurrency=2 " + servers + verbosity + flag, output));
44 if (verbosity != " --quiet ") {
45 REQUIRE_THAT(output, Contains("Starting"));
46 REQUIRE_THAT(output, Contains("Time to"));
47 REQUIRE_THAT(output, Contains("seconds"));
48 } else {
49 REQUIRE(output.empty());
50 }
51 }
52 }
53 }