1 #include "../lib/common.hpp"
2 #include "../lib/MemcachedCluster.hpp"
4 memcached_return_t
dump_cb(const memcached_st
*, const char *, size_t, void *ctx
) {
5 size_t *c
= reinterpret_cast<size_t *>(ctx
);
7 return MEMCACHED_SUCCESS
;
10 TEST_CASE("memcached dump") {
11 MemcachedCluster tests
[]{
12 MemcachedCluster::mixed(),
13 MemcachedCluster::net(),
14 MemcachedCluster::socket()
17 LOOPED_SECTION(tests
) {
18 auto memc
= &test
.memc
;
20 SECTION("prepared with 64 KVs") {
21 for (int i
= 0; i
< 64; ++i
) {
23 int len
= snprintf(key
, sizeof(key
) - 1, "k_%d", i
);
26 auto rc
= memcached_set(memc
, key
, len
, key
, len
, 0, 0);
27 INFO("last error: " << memcached_last_error(memc
));
28 REQUIRE(MEMCACHED_SUCCESS
== rc
);
34 // let memcached sort itself
35 using namespace chrono_literals
;
36 this_thread::sleep_for(3s
);
38 SECTION("dumps 64 KVs") {
40 memcached_dump_fn fn
[] = {dump_cb
};
42 REQUIRE(MEMCACHED_SUCCESS
== memcached_dump(memc
, fn
, &counter
, 1));
43 REQUIRE(counter
== 64);