test_true(memc_clone->flags.randomize_replica_read == memc->flags.randomize_replica_read);
}
test_true(memc_clone->get_key_failure == memc->get_key_failure);
- test_true(memc_clone->hash == memc->hash);
- test_true(memc_clone->distribution_hash == memc->distribution_hash);
+ test_true(hashkit_compare(&memc_clone->hashkit, &memc->hashkit));
+ test_true(hashkit_compare(&memc_clone->distribution_hashkit, &memc->distribution_hashkit));
test_true(memc_clone->io_bytes_watermark == memc->io_bytes_watermark);
test_true(memc_clone->io_msg_watermark == memc->io_msg_watermark);
test_true(memc_clone->io_key_prefetch == memc->io_key_prefetch);
{
memcached_return_t rc;
bool set= true;
+
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_CORK, set);
+#ifdef __APPLE__
+ return TEST_SKIPPED;
+#endif
+
if (rc == MEMCACHED_SUCCESS)
return TEST_SUCCESS;
rc= pre_cork(memc);
+#ifdef __APPLE__
+ return TEST_SKIPPED;
+#endif
+
if (rc != TEST_SUCCESS)
return rc;
return TEST_SUCCESS;
}
+static uint32_t hash_md5_test_function(const char *string, size_t string_length, void *context)
+{
+ (void)context;
+ return libhashkit_md5(string, string_length);
+}
+
+static uint32_t hash_crc_test_function(const char *string, size_t string_length, void *context)
+{
+ (void)context;
+ return libhashkit_crc32(string, string_length);
+}
+
+static test_return_t memcached_get_hashkit_test (memcached_st *memc)
+{
+ uint32_t x;
+ const char **ptr;
+ hashkit_st *kit;
+ hashkit_return_t hash_rc;
+
+ uint32_t md5_hosts[]= {4U, 1U, 0U, 1U, 4U, 2U, 0U, 3U, 0U, 0U, 3U, 1U, 0U, 0U, 1U, 3U, 0U, 0U, 0U, 3U, 1U, 0U, 4U, 4U, 3U};
+ uint32_t crc_hosts[]= {2U, 4U, 1U, 0U, 2U, 4U, 4U, 4U, 1U, 2U, 3U, 4U, 3U, 4U, 1U, 3U, 3U, 2U, 0U, 0U, 0U, 1U, 2U, 4U, 0U};
+
+ kit= memcached_get_hashkit(memc);
+
+ hash_rc= hashkit_set_custom_function(kit, hash_md5_test_function, NULL);
+ test_true(hash_rc == HASHKIT_SUCCESS);
+
+ /*
+ Verify Setting the hash.
+ */
+ for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
+ {
+ uint32_t hash_val;
+
+ hash_val= hashkit_digest(kit, *ptr, strlen(*ptr));
+ test_true(md5_values[x] == hash_val);
+ }
+
+
+ /*
+ Now check memcached_st.
+ */
+ for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
+ {
+ uint32_t hash_val;
+
+ hash_val= memcached_generate_hash(memc, *ptr, strlen(*ptr));
+ test_true(md5_hosts[x] == hash_val);
+ }
+
+ hash_rc= hashkit_set_custom_function(kit, hash_crc_test_function, NULL);
+ test_true(hash_rc == HASHKIT_SUCCESS);
+
+ /*
+ Verify Setting the hash.
+ */
+ for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
+ {
+ uint32_t hash_val;
+
+ hash_val= hashkit_digest(kit, *ptr, strlen(*ptr));
+ test_true(crc_values[x] == hash_val);
+ }
+
+ for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
+ {
+ uint32_t hash_val;
+
+ hash_val= memcached_generate_hash(memc, *ptr, strlen(*ptr));
+ test_true(crc_hosts[x] == hash_val);
+ }
+
+ return TEST_SUCCESS;
+}
+
static test_return_t ketama_compatibility_libmemcached(memcached_st *trash)
{
{"hsieh", 0, (test_callback_fn)hsieh_run },
{"murmur", 0, (test_callback_fn)murmur_run },
{"jenkis", 0, (test_callback_fn)jenkins_run },
+ {"memcached_get_hashkit", 0, (test_callback_fn)memcached_get_hashkit_test },
{0, 0, (test_callback_fn)0}
};