Merge lp:~brianaker/libmemcached/1220229 Build: jenkins-Libmemcached-362
authorContinuous Integration <ci@tangent.org>
Thu, 10 Oct 2013 08:07:55 +0000 (01:07 -0700)
committerContinuous Integration <ci@tangent.org>
Thu, 10 Oct 2013 08:07:55 +0000 (01:07 -0700)
clients/generator.cc
clients/memcp.cc
clients/memslap.cc
docs/memcached_auto.rst
libmemcached/auto.cc
libtest/main.cc
tests/libmemcached-1.0/all_tests.h
tests/libmemcached-1.0/mem_functions.cc
tests/libmemcached-1.0/mem_functions.h

index df805153ce29327e51e93d73842fe0d66ba099b4..1f40daedbc6fd21a1b70fac8c6433d1c892d5ded 100644 (file)
@@ -22,6 +22,8 @@
 
 #include "clients/generator.h"
 
+#define KEY_BYTES 20
+
 /* Use this for string generation */
 static const char ALPHANUMERICS[]=
   "0123456789ABCDEFGHIJKLMNOPQRSTWXYZabcdefghijklmnopqrstuvwxyz";
@@ -75,13 +77,13 @@ pairs_st *pairs_generate(uint64_t number_of, size_t value_length)
 
   for (uint64_t x= 0; x < number_of; x++)
   {
-    pairs[x].key= (char *)calloc(100, sizeof(char));
+    pairs[x].key= (char *)calloc(KEY_BYTES, sizeof(char));
 
     if (pairs[x].key == NULL)
       goto error;
 
-    get_random_string(pairs[x].key, 100);
-    pairs[x].key_length= 100;
+    get_random_string(pairs[x].key, KEY_BYTES);
+    pairs[x].key_length= KEY_BYTES;
 
     if (value_length)
     {
index 7aa805f95865a019e9c982816c8d704397bd33cc..6c6d1e96fe6142bdac3186445787b3df720c9a49 100644 (file)
@@ -1,5 +1,5 @@
 /* LibMemcached
- * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/
  * Copyright (C) 2006-2009 Brian Aker
  * All rights reserved.
  *
index 05a491fbef9aec5d7a41c94abb69f85cfa64af28..9bc4f2385683583960aa12348c11ecf1633a224f 100644 (file)
@@ -66,6 +66,8 @@
 #define DEFAULT_EXECUTE_NUMBER 10000
 #define DEFAULT_CONCURRENCY 1
 
+#define VALUE_BYTES 4096
+
 #define PROGRAM_NAME "memslap"
 #define PROGRAM_DESCRIPTION "Generates a load against a memcached custer of servers."
 
@@ -336,7 +338,7 @@ void scheduler(memcached_server_st *servers, conclusions_st *conclusion)
 
     if (opt_test == SET_TEST)
     {
-      context->execute_pairs= pairs_generate(opt_execute_number, 400);
+      context->execute_pairs= pairs_generate(opt_execute_number, VALUE_BYTES);
       context->execute_number= opt_execute_number;
     }
 
@@ -432,7 +434,7 @@ void options_parse(int argc, char *argv[])
       break;
 
     case OPT_DEBUG: /* --debug or -d */
-      opt_verbose = OPT_DEBUG;
+      opt_verbose= OPT_DEBUG;
       break;
 
     case OPT_VERSION: /* --version or -V */
@@ -566,7 +568,7 @@ pairs_st *load_create_data(memcached_st *memc, unsigned int number_of,
   /* We always used non-blocking IO for load since it is faster */
   memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NO_BLOCK, 0);
 
-  pairs_st *pairs= pairs_generate(number_of, 400);
+  pairs_st *pairs= pairs_generate(number_of, VALUE_BYTES);
   *actual_loaded= execute_set(memc_clone, pairs, number_of);
 
   memcached_free(memc_clone);
index c3f4c7f5b8343bfe44d6a8e54e0ff78709c37177..0f78e6e7d8d1a7610a358293d81b7d6ad8049cbe 100644 (file)
@@ -53,7 +53,8 @@ MEMCACHED_EXPIRATION_NOT_ADD, the operation will fail. For all other
 expiration values, the operation will succeed by seeding the value for that
 key with a initial value to expire with the provided expiration time. The
 flags will be set to zero.The value is then returned via the uint32_t
-value pointer you pass to it.
+value pointer you pass to it. memcached_increment_with_initial is only available 
+when using the binary protocol.
 
 memcached_decrement_with_initial takes a key and keylength and decrements
 the value by the offset passed to it. If the object specified by key does
@@ -62,7 +63,8 @@ MEMCACHED_EXPIRATION_NOT_ADD, the operation will fail. For all other
 expiration values, the operation will succeed by seeding the value for that
 key with a initial value to expire with the provided expiration time. The
 flags will be set to zero.The value is then returned via the uint32_t
-value pointer you pass to it.
+value pointer you pass to it. memcached_decrement_with_initial is only available
+when using the binary protocol.
 
 :c:func:`memcached_increment_by_key`, :c:func:`memcached_decrement_by_key`,
 :c:func:`memcached_increment_with_initial_by_key`, and
index 685528f2fae41adc40e8924016fdd3d8b88601c1..04efe85d7975cdcd3dd4fb55272947353e500477 100644 (file)
@@ -54,11 +54,17 @@ static void auto_response(memcached_instance_st* instance, const bool reply,  me
 
   if (memcached_fatal(rc))
   {
+    fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, memcached_strerror(NULL, rc));
     assert(memcached_last_error(instance->root) != MEMCACHED_SUCCESS);
     *value= UINT64_MAX;
   }
+  else if (memcached_failed(rc))
+  {
+    *value= UINT64_MAX;
+  }
   else
   {
+    assert(memcached_last_error(instance->root) != MEMCACHED_NOTFOUND);
     *value= instance->root->result.numeric_value;
   }
 }
index 83e95cd65a7bc10c9bab62c0b7611d70a354d957..3084ca4b4c8d79771a00383ca128a973bd6b50fa 100644 (file)
@@ -2,7 +2,7 @@
  *
  *  Data Differential YATL (i.e. libtest)  library
  *
- *  Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ *  Copyright (C) 2012-2013 Data Differential, http://datadifferential.com/
  *
  *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted provided that the following conditions are
@@ -43,6 +43,9 @@
 #include <ctime>
 #include <fnmatch.h>
 #include <iostream>
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
 #include <fstream>
 #include <memory>
 #include <sys/stat.h>
index 2012d477d37901901aa69665613c576dc06207ec..d748d39e7e31e31e04df94a1c9550716b2a5097c 100644 (file)
@@ -70,9 +70,11 @@ test_st tests[] ={
   {"partial mget", false, (test_callback_fn*)get_test5 },
   {"stats_servername", false, (test_callback_fn*)stats_servername_test },
   {"increment", false, (test_callback_fn*)increment_test },
-  {"increment_with_initial", true, (test_callback_fn*)increment_with_initial_test },
+  {"memcached_increment_with_initial(0)", true, (test_callback_fn*)increment_with_initial_test },
+  {"memcached_increment_with_initial(999)", true, (test_callback_fn*)increment_with_initial_999_test },
   {"decrement", false, (test_callback_fn*)decrement_test },
-  {"decrement_with_initial", true, (test_callback_fn*)decrement_with_initial_test },
+  {"memcached_decrement_with_initial(3)", true, (test_callback_fn*)decrement_with_initial_test },
+  {"memcached_decrement_with_initial(999)", true, (test_callback_fn*)decrement_with_initial_999_test },
   {"increment_by_key", false, (test_callback_fn*)increment_by_key_test },
   {"increment_with_initial_by_key", true, (test_callback_fn*)increment_with_initial_by_key_test },
   {"decrement_by_key", false, (test_callback_fn*)decrement_by_key_test },
index e50f5794318491c0e74c71161357411d7fa9932e..6e6f4a7bce9e45d638c8c486de3e78281f9b388d 100644 (file)
@@ -1294,26 +1294,41 @@ test_return_t increment_test(memcached_st *memc)
   return TEST_SUCCESS;
 }
 
-test_return_t increment_with_initial_test(memcached_st *memc)
+static test_return_t __increment_with_initial_test(memcached_st *memc, uint64_t initial)
 {
-  test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
-
   uint64_t new_number;
-  uint64_t initial= 0;
 
   test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc));
 
-  test_compare(MEMCACHED_SUCCESS, 
-               memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number));
-  test_compare(new_number, initial);
+  if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL))
+  {
+    test_compare(MEMCACHED_SUCCESS, 
+                 memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number));
+    test_compare(new_number, initial);
 
-  test_compare(MEMCACHED_SUCCESS, 
-               memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number));
-  test_compare(new_number, (initial +1));
+    test_compare(MEMCACHED_SUCCESS, 
+                 memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number));
+    test_compare(new_number, (initial +1));
+  }
+  else
+  {
+    test_compare(MEMCACHED_INVALID_ARGUMENTS, 
+                 memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number));
+  }
 
   return TEST_SUCCESS;
 }
 
+test_return_t increment_with_initial_test(memcached_st *memc)
+{
+  return __increment_with_initial_test(memc, 0);
+}
+
+test_return_t increment_with_initial_999_test(memcached_st *memc)
+{
+  return __increment_with_initial_test(memc, 999);
+}
+
 test_return_t decrement_test(memcached_st *memc)
 {
   test_compare(return_value_based_on_buffering(memc),
@@ -1341,12 +1356,10 @@ test_return_t decrement_test(memcached_st *memc)
   return TEST_SUCCESS;
 }
 
-test_return_t decrement_with_initial_test(memcached_st *memc)
+static test_return_t __decrement_with_initial_test(memcached_st *memc, uint64_t initial)
 {
   test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
 
-  uint64_t initial= 3;
-
   test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc));
 
   uint64_t new_number;
@@ -1367,6 +1380,16 @@ test_return_t decrement_with_initial_test(memcached_st *memc)
   return TEST_SUCCESS;
 }
 
+test_return_t decrement_with_initial_test(memcached_st *memc)
+{
+  return __decrement_with_initial_test(memc, 3);
+}
+
+test_return_t decrement_with_initial_999_test(memcached_st *memc)
+{
+  return __decrement_with_initial_test(memc, 999);
+}
+
 test_return_t increment_by_key_test(memcached_st *memc)
 {
   const char *master_key= "foo";
@@ -1398,24 +1421,32 @@ test_return_t increment_by_key_test(memcached_st *memc)
 
 test_return_t increment_with_initial_by_key_test(memcached_st *memc)
 {
-  test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
-
   uint64_t new_number;
   const char *master_key= "foo";
   const char *key= "number";
   uint64_t initial= 0;
 
-  test_compare(MEMCACHED_SUCCESS,
-               memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key),
-                                                       key, strlen(key),
-                                                       1, initial, 0, &new_number));
-  test_compare(new_number, initial);
+  if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL))
+  {
+    test_compare(MEMCACHED_SUCCESS,
+                 memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key),
+                                                         key, strlen(key),
+                                                         1, initial, 0, &new_number));
+    test_compare(new_number, initial);
 
-  test_compare(MEMCACHED_SUCCESS,
-               memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key),
-                                                       key, strlen(key),
-                                                       1, initial, 0, &new_number));
-  test_compare(new_number, (initial +1));
+    test_compare(MEMCACHED_SUCCESS,
+                 memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key),
+                                                         key, strlen(key),
+                                                         1, initial, 0, &new_number));
+    test_compare(new_number, (initial +1));
+  }
+  else
+  {
+    test_compare(MEMCACHED_INVALID_ARGUMENTS,
+                 memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key),
+                                                         key, strlen(key),
+                                                         1, initial, 0, &new_number));
+  }
 
   return TEST_SUCCESS;
 }
@@ -1456,19 +1487,30 @@ test_return_t decrement_with_initial_by_key_test(memcached_st *memc)
   uint64_t new_number;
   uint64_t initial= 3;
 
-  test_compare(MEMCACHED_SUCCESS,
-               memcached_decrement_with_initial_by_key(memc,
-                                                       test_literal_param("foo"),
-                                                       test_literal_param("number"),
-                                                       1, initial, 0, &new_number));
-  test_compare(new_number, initial);
+  if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL))
+  {
+    test_compare(MEMCACHED_SUCCESS,
+                 memcached_decrement_with_initial_by_key(memc,
+                                                         test_literal_param("foo"),
+                                                         test_literal_param("number"),
+                                                         1, initial, 0, &new_number));
+    test_compare(new_number, initial);
 
-  test_compare(MEMCACHED_SUCCESS,
-               memcached_decrement_with_initial_by_key(memc,
-                                                       test_literal_param("foo"),
-                                                       test_literal_param("number"),
-                                                       1, initial, 0, &new_number));
-  test_compare(new_number, (initial - 1));
+    test_compare(MEMCACHED_SUCCESS,
+                 memcached_decrement_with_initial_by_key(memc,
+                                                         test_literal_param("foo"),
+                                                         test_literal_param("number"),
+                                                         1, initial, 0, &new_number));
+    test_compare(new_number, (initial - 1));
+  }
+  else
+  {
+    test_compare(MEMCACHED_INVALID_ARGUMENTS,
+                 memcached_decrement_with_initial_by_key(memc,
+                                                         test_literal_param("foo"),
+                                                         test_literal_param("number"),
+                                                         1, initial, 0, &new_number));
+  }
 
   return TEST_SUCCESS;
 }
index 9edc820ec1ae197b466b4480d3d67d89427dc938..757369316fbcfafccda44d9cecfadce089ae1f55 100644 (file)
@@ -67,6 +67,7 @@ test_return_t decrement_by_key_test(memcached_st *memc);
 test_return_t decrement_test(memcached_st *memc);
 test_return_t decrement_with_initial_by_key_test(memcached_st *memc);
 test_return_t decrement_with_initial_test(memcached_st *memc);
+test_return_t decrement_with_initial_999_test(memcached_st *memc);
 test_return_t delete_test(memcached_st *memc);
 test_return_t deprecated_set_memory_alloc(memcached_st *memc);
 test_return_t enable_cas(memcached_st *memc);
@@ -88,6 +89,7 @@ test_return_t increment_by_key_test(memcached_st *memc);
 test_return_t increment_test(memcached_st *memc);
 test_return_t increment_with_initial_by_key_test(memcached_st *memc);
 test_return_t increment_with_initial_test(memcached_st *memc);
+test_return_t increment_with_initial_999_test(memcached_st *memc);
 test_return_t init_test(memcached_st *not_used);
 test_return_t jenkins_run (memcached_st *);
 test_return_t key_setup(memcached_st *memc);