1 #include "test/lib/common.hpp"
2 #include "test/lib/MemcachedCluster.hpp"
4 TEST_CASE("memcached_noblock") {
5 auto test
= MemcachedCluster::network();
6 auto memc
= &test
.memc
;
7 auto timeout
= GENERATE(0, -1);
9 REQUIRE_SUCCESS(memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_NO_BLOCK
, 1));
10 REQUIRE_SUCCESS(memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_TCP_NODELAY
, 1));
11 REQUIRE_SUCCESS(memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_POLL_TIMEOUT
, timeout
));
13 auto num
= timeout
? 10'000 : 1'000'000;
15 auto rnd
= random_ascii_string(512);
16 for (auto i
= 0; i
< num
; ++i
) {
17 auto key
= to_string(i
);
18 auto rc
= memcached_set(memc
, key
.c_str(), key
.length(), rnd
.c_str(), rnd
.length(), 1, 0);
20 case MEMCACHED_SUCCESS
:
21 case MEMCACHED_BUFFERED
:
22 case MEMCACHED_SERVER_TEMPORARILY_DISABLED
:
24 case MEMCACHED_TIMEOUT
:
25 case MEMCACHED_WRITE_FAILURE
:
36 INFO("failures triggered: " << hit
);