testing: let retry's sleeping duration grow faster
[awesomized/libmemcached] / test / tests / memcached / regression / lp_000-442-914.cpp
1 #include "test/lib/common.hpp"
2 #include "test/lib/MemcachedCluster.hpp"
3
4 #include <iomanip>
5
6 /* Original Comment:
7 * The test case isn't obvious so I should probably document why
8 * it works the way it does. Bug 442914 was caused by a bug
9 * in the logic in memcached_purge (it did not handle the case
10 * where the number of bytes sent was equal to the watermark).
11 * In this test case, create messages so that we hit that case
12 * and then disable noreply mode and issue a new command to
13 * verify that it isn't stuck. If we change the format for the
14 * delete command or the watermarks, we need to update this
15 * test....
16 */
17
18 TEST_CASE("memcached_regression_lp442914") {
19 MemcachedCluster test{Cluster{Server{MEMCACHED_BINARY, {"-p", random_port_string}}, 1}};
20 auto memc = &test.memc;
21
22 REQUIRE_SUCCESS(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1));
23 REQUIRE_SUCCESS(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1));
24
25
26 for (auto x = 0; x < 250; ++x) {
27 stringstream ss;
28 ss << setfill('0') << setw(250) << x;
29 REQUIRE_SUCCESS(memcached_delete(memc, ss.str().c_str(), ss.str().length(), 0));
30 }
31
32 stringstream key;
33 key << setfill('0') << setw(37) << 251;
34 REQUIRE_SUCCESS(memcached_delete(memc, key.str().c_str(), key.str().length(), 0));
35
36 REQUIRE_SUCCESS(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 0));
37
38 REQUIRE_RC(MEMCACHED_NOTFOUND, memcached_delete(memc, key.str().c_str(), key.str().length(), 0));
39 }