bin: consolidate clients
[awesomized/libmemcached] / test / tests / bin / memaslap.cpp
1 #include "test/lib/common.hpp"
2 #include "test/lib/Shell.hpp"
3 #include "test/lib/MemcachedCluster.hpp"
4
5 #if HAVE_MEMASLAP
6
7 using Catch::Matchers::Contains;
8
9 TEST_CASE("bin/memaslap") {
10 Shell sh{string{TESTING_ROOT "/../src/bin"}};
11
12 SECTION("no servers provided") {
13 string output;
14 REQUIRE_FALSE(sh.run("memaslap", output));
15 REQUIRE_THAT(output, Contains("No servers provided\n"));
16 }
17
18 SECTION("--help") {
19 string output;
20
21 REQUIRE(sh.run("memaslap --help", output));
22 REQUIRE_THAT(output, Contains("memaslap"));
23 REQUIRE_THAT(output, Contains("v1"));
24 /* FIXME
25 REQUIRE_THAT(output, Contains("help"));
26 REQUIRE_THAT(output, Contains("version"));
27 REQUIRE_THAT(output, Contains("option"));
28 */
29 REQUIRE_THAT(output, Contains("--"));
30 REQUIRE_THAT(output, Contains("="));
31 }
32
33 SECTION("with servers") {
34 auto test = MemcachedCluster::network();
35 auto examples = {
36 " -T 2 -c 8 -t 2s -S 1s",
37 " -T 2 -c 8 -t 2s -v 0.2 -e 0.05 -b",
38 " -T 2 -c 8 -t 2s -w 40k -o 0.2",
39 " -T 2 -c 8 -t 2s -d 20 -P 40k",
40 #if 0
41 " -T 2 -c 8 -t 2s -d 50 -a -n 10",
42 #endif
43 };
44 string servers{"-s "};
45
46 for (const auto &server : test.cluster.getServers()) {
47 servers += "127.0.0.1:" + to_string(get<int>(server.getSocketOrPort())) + ",";
48 }
49 for (const auto args : examples) {
50 string output;
51 INFO(args);
52 auto ok = sh.run("memaslap -b " + servers + args, output);
53 INFO(output);
54 REQUIRE(ok);
55 REQUIRE_THAT(output, Contains("TPS"));
56 }
57 }
58 }
59 #endif // HAVE_MEMASLAP