bin: consolidate clients
[m6w6/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", "--tcp-nodelay",
33 "--non-blocking", "--execute-number=1000"};
34 string servers{"--servers="};
35
36 for (const auto &server : test.cluster.getServers()) {
37 servers += "localhost:" + to_string(get<int>(server.getSocketOrPort())) + ", ";
38 }
39
40 for (const auto flag : flags) {
41 REQUIRE(sh.run("memslap --quiet --concurrency=2 " + servers + flag));
42 }
43 }
44 }