From: Brian Aker Date: Wed, 20 Feb 2013 00:24:20 +0000 (-0500) Subject: Add functional test for MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH X-Git-Tag: 1.0.17~6^2~2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=a91a3e36b9edd7ff5addea56498c41513b296c83;p=m6w6%2Flibmemcached Add functional test for MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH --- diff --git a/tests/libmemcached-1.0/all_tests.h b/tests/libmemcached-1.0/all_tests.h index fe28e733..643812d3 100644 --- a/tests/libmemcached-1.0/all_tests.h +++ b/tests/libmemcached-1.0/all_tests.h @@ -144,6 +144,7 @@ test_st behavior_tests[] ={ {"MEMCACHED_BEHAVIOR_TCP_KEEPALIVE", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_TCP_KEEPALIVE_test}, {"MEMCACHED_BEHAVIOR_TCP_KEEPIDLE", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_TCP_KEEPIDLE_test}, {"MEMCACHED_BEHAVIOR_POLL_TIMEOUT", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_POLL_TIMEOUT_test}, + {"MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH_TEST", true, (test_callback_fn*)MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH_TEST }, {"MEMCACHED_CALLBACK_DELETE_TRIGGER_and_MEMCACHED_BEHAVIOR_NOREPLY", false, (test_callback_fn*)test_MEMCACHED_CALLBACK_DELETE_TRIGGER_and_MEMCACHED_BEHAVIOR_NOREPLY}, {0, 0, 0} }; diff --git a/tests/libmemcached-1.0/mem_functions.cc b/tests/libmemcached-1.0/mem_functions.cc index 46f940d9..67db52af 100644 --- a/tests/libmemcached-1.0/mem_functions.cc +++ b/tests/libmemcached-1.0/mem_functions.cc @@ -1750,6 +1750,54 @@ test_return_t mget_execute(memcached_st *original_memc) return TEST_SUCCESS; } +test_return_t MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH_TEST(memcached_st *original_memc) +{ + test_skip(true, memcached_behavior_get(original_memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); + + memcached_st *memc= create_single_instance_memcached(original_memc, "--BINARY-PROTOCOL"); + test_true(memc); + + test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH, 8)); + + keys_st keys(20480); + + /* First add all of the items.. */ + char blob[1024] = {0}; + + for (size_t x= 0; x < keys.size(); ++x) + { + uint64_t query_id= memcached_query_id(memc); + memcached_return_t rc= memcached_add(memc, + keys.key_at(x), keys.length_at(x), + blob, sizeof(blob), + 0, 0); + test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED); + test_compare(query_id +1, memcached_query_id(memc)); + } + + /* Try to get all of them with a large multiget */ + size_t counter= 0; + memcached_execute_fn callbacks[]= { &callback_counter }; + test_compare(MEMCACHED_SUCCESS, + memcached_mget_execute(memc, + keys.keys_ptr(), keys.lengths_ptr(), + keys.size(), callbacks, &counter, 1)); + + { + uint64_t query_id= memcached_query_id(memc); + test_compare(MEMCACHED_SUCCESS, + memcached_fetch_execute(memc, callbacks, (void *)&counter, 1)); + test_compare(query_id, memcached_query_id(memc)); + + /* Verify that we got all of the items */ + test_compare(keys.size(), counter); + } + + memcached_free(memc); + + return TEST_SUCCESS; +} + #define REGRESSION_BINARY_VS_BLOCK_COUNT 20480 static pairs_st *global_pairs= NULL; diff --git a/tests/libmemcached-1.0/mem_functions.h b/tests/libmemcached-1.0/mem_functions.h index 374bc9c4..0ecea0d2 100644 --- a/tests/libmemcached-1.0/mem_functions.h +++ b/tests/libmemcached-1.0/mem_functions.h @@ -108,6 +108,7 @@ test_return_t memcached_server_remove_test(memcached_st*); test_return_t memcached_stat_execute_test(memcached_st *memc); test_return_t mget_end(memcached_st *memc); test_return_t mget_execute(memcached_st *original_memc); +test_return_t MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH_TEST(memcached_st *original_memc); test_return_t mget_result_alloc_test(memcached_st *memc); test_return_t mget_result_function(memcached_st *memc); test_return_t mget_result_test(memcached_st *memc);