1 #include "test/lib/common.hpp"
2 #include "test/lib/Shell.hpp"
3 #include "test/lib/MemcachedCluster.hpp"
5 using Catch::Matchers::Contains
;
7 TEST_CASE("bin/memslap") {
8 Shell sh
{string
{TESTING_ROOT
"/../src/bin"}};
10 SECTION("no servers provided") {
12 REQUIRE_FALSE(sh
.run("memslap", output
));
13 REQUIRE(output
== "No servers provided.\n");
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"));
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 ");
37 for (const auto &server
: test
.cluster
.getServers()) {
38 servers
+= "localhost:" + to_string(get
<int>(server
.getSocketOrPort())) + ", ";
41 for (const auto flag
: flags
) {
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"));
49 REQUIRE(output
.empty());