~yeban/libmemcached/todo-hosts.c-2

« back to all changes in this revision

Viewing changes to tests/mem_functions.c

  • Committer: Brian Aker
  • Date: 2011-02-22 02:35:52 UTC
  • Revision ID: brian@tangent.org-20110222023552-o3gobm2761fenyh5
Merge in test case from JC Redoutey .

Show diffs side-by-side

added added

removed removed

Lines of Context:
5902
5902
  return TEST_SUCCESS;
5903
5903
}
5904
5904
 
 
5905
/*
 
5906
 * This tests ensures expected disconnections (for some behavior changes
 
5907
 * for instance) do not wrongly increase failure counter
 
5908
 */
 
5909
static test_return_t wrong_failure_counter_two_test(memcached_st *memc)
 
5910
{
 
5911
  memcached_return rc;
 
5912
 
 
5913
  memcached_st *memc_clone;
 
5914
  memc_clone= memcached_clone(NULL, memc);
 
5915
  test_true(memc_clone);
 
5916
 
 
5917
  /* Set value to force connection to the server */
 
5918
  const char *key= "marmotte";
 
5919
  const char *value= "milka";
 
5920
  char *string = NULL;
 
5921
  size_t string_length;
 
5922
  uint32_t flags;
 
5923
 
 
5924
  rc= memcached_set(memc_clone, key, strlen(key),
 
5925
                    value, strlen(value),
 
5926
                    (time_t)0, (uint32_t)0);
 
5927
  test_true_got(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED, memcached_strerror(NULL, rc));
 
5928
 
 
5929
 
 
5930
  /* put failure limit to 1 */
 
5931
  rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT, 1);
 
5932
  assert(rc == MEMCACHED_SUCCESS);
 
5933
  /* Put a retry timeout to effectively activate failure_limit effect */
 
5934
  rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 1);
 
5935
  assert(rc == MEMCACHED_SUCCESS);
 
5936
  /* change behavior that triggers memcached_quit()*/
 
5937
  rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1);
 
5938
  assert(rc == MEMCACHED_SUCCESS);
 
5939
 
 
5940
 
 
5941
  /* Check if we still are connected */
 
5942
  string= memcached_get(memc_clone, key, strlen(key),
 
5943
                        &string_length, &flags, &rc);
 
5944
 
 
5945
  test_true_got(rc == MEMCACHED_SUCCESS, memcached_strerror(NULL, rc));
 
5946
  test_true(string);
 
5947
  free(string);
 
5948
 
 
5949
  return TEST_SUCCESS;
 
5950
}
 
5951
 
5905
5952
 
5906
5953
 
5907
5954
 
6326
6373
  {"user_supplied_bug20", 1, (test_callback_fn)user_supplied_bug20 },
6327
6374
  {"user_supplied_bug21", 1, (test_callback_fn)user_supplied_bug21 },
6328
6375
  {"wrong_failure_counter_test", 1, (test_callback_fn)wrong_failure_counter_test},
 
6376
  {"wrong_failure_counter_two_test", 1, (test_callback_fn)wrong_failure_counter_two_test},
6329
6377
  {0, 0, (test_callback_fn)0}
6330
6378
};
6331
6379