testing: memslap
[awesomized/libmemcached] / test / tests / bin / memslap.cpp
diff --git a/test/tests/bin/memslap.cpp b/test/tests/bin/memslap.cpp
new file mode 100644 (file)
index 0000000..dee7ebc
--- /dev/null
@@ -0,0 +1,43 @@
+#include "test/lib/common.hpp"
+#include "test/lib/Shell.hpp"
+#include "test/lib/MemcachedCluster.hpp"
+
+using Catch::Matchers::Contains;
+
+TEST_CASE("bin/memslap") {
+  Shell sh{string{TESTING_ROOT "/../src/bin"}};
+
+  SECTION("no servers provided") {
+    string output;
+    REQUIRE_FALSE(sh.run("memslap", output));
+    REQUIRE(output == "No servers provided\n");
+  }
+
+  SECTION("--help") {
+    string output;
+
+    REQUIRE(sh.run("memslap --help", output));
+    REQUIRE_THAT(output, Contains("memslap"));
+    REQUIRE_THAT(output, Contains("v1"));
+    REQUIRE_THAT(output, Contains("help"));
+    REQUIRE_THAT(output, Contains("version"));
+    REQUIRE_THAT(output, Contains("option"));
+    REQUIRE_THAT(output, Contains("--"));
+    REQUIRE_THAT(output, Contains("="));
+  }
+
+  SECTION("with servers") {
+    auto test = MemcachedCluster::udp();
+    auto flags = {"--binary", "--udp", "--flush", "--test=mget", "--test=get", "--tcp-nodelay",
+                  "--non-blocking", "--initial-load=1000"};
+    string servers{"--servers="};
+
+    for (const auto &server : test.cluster.getServers()) {
+      servers += "localhost:" + to_string(get<int>(server.getSocketOrPort())) + ", ";
+    }
+
+    for (const auto flag : flags) {
+      REQUIRE(sh.run("memslap --quiet --concurrency=2 " + servers + flag));
+    }
+  }
+}