1 #include "test/lib/common.hpp"
2 #include "test/lib/ReturnMatcher.hpp"
5 TEST_CASE("memcached_vbucket") {
7 LoneReturnMatcher test
{*memc
};
8 uint32_t server_map
[] = {0, 1, 2, 1};
10 REQUIRE_SUCCESS(memcached_bucket_set(*memc
, server_map
, nullptr, 4, 2));
11 REQUIRE(MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET
== memcached_behavior_get_distribution(*memc
));
12 REQUIRE_SUCCESS(memcached_behavior_set_key_hash(*memc
, MEMCACHED_HASH_CRC
));
14 auto servers
= memcached_servers_parse("localhost:11211, localhost1:11210, localhost2:11211");
16 REQUIRE_SUCCESS(memcached_server_push(*memc
, servers
));
17 REQUIRE(3 == memcached_server_count(*memc
));
19 tuple
<const char *, uint32_t, uint32_t> keys
[] = {
29 for (const auto &k
: keys
) {
30 auto [key
, server
, bucket
] = k
;
32 REQUIRE(bucket
== (memcached_generate_hash_value(S(key
), memcached_behavior_get_key_hash(*memc
)) % 4));
33 REQUIRE(server
== memcached_generate_hash(*memc
, S(key
)));
36 memcached_server_list_free(servers
);