dee7ebc3c94c11112dae11b316e9feb1d8c8a51d
[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"));
21 REQUIRE_THAT(output, Contains("v1"));
22 REQUIRE_THAT(output, Contains("help"));
23 REQUIRE_THAT(output, Contains("version"));
24 REQUIRE_THAT(output, Contains("option"));
25 REQUIRE_THAT(output, Contains("--"));
26 REQUIRE_THAT(output, Contains("="));
27 }
28
29 SECTION("with servers") {
30 auto test = MemcachedCluster::udp();
31 auto flags = {"--binary", "--udp", "--flush", "--test=mget", "--test=get", "--tcp-nodelay",
32 "--non-blocking", "--initial-load=1000"};
33 string servers{"--servers="};
34
35 for (const auto &server : test.cluster.getServers()) {
36 servers += "localhost:" + to_string(get<int>(server.getSocketOrPort())) + ", ";
37 }
38
39 for (const auto flag : flags) {
40 REQUIRE(sh.run("memslap --quiet --concurrency=2 " + servers + flag));
41 }
42 }
43 }