1 #include "test/lib/common.hpp"
2 #include "test/lib/MemcachedCluster.hpp"
4 memcached_return_t
dump_cb(const memcached_st
*, const char *, size_t, void *ctx
) {
5 auto *c
= reinterpret_cast<size_t *>(ctx
);
7 return MEMCACHED_SUCCESS
;
10 TEST_CASE("memcached_dump") {
11 pair
<string
, MemcachedCluster
> tests
[]{
12 {"mixed", MemcachedCluster::mixed()},
13 {"network", MemcachedCluster::network()},
14 {"socket", 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 REQUIRE_SUCCESS(memcached_set(memc
, key
, len
, key
, len
, 0, 0));
32 // let memcached sort itself
33 using namespace chrono_literals
;
34 this_thread::sleep_for(3s
);
36 SECTION("dumps 64 KVs") {
38 memcached_dump_fn fn
[] = {dump_cb
};
40 REQUIRE_SUCCESS(memcached_dump(memc
, fn
, &counter
, 1));
41 REQUIRE(counter
== 64);