Merge lp:~brianaker/libmemcached/1220229 into lp:libmemcached/1.0

Proposed by Brian Aker
Status: Merged
Merged at revision: 1168
Proposed branch: lp:~brianaker/libmemcached/1220229
Merge into: lp:libmemcached/1.0
Diff against target: 396 lines (+135/-74)
9 files modified
clients/generator.cc (+5/-3)
clients/memcp.cc (+1/-1)
clients/memslap.cc (+5/-3)
docs/memcached_auto.rst (+4/-2)
libmemcached/auto.cc (+6/-0)
libtest/main.cc (+4/-1)
tests/libmemcached-1.0/all_tests.h (+4/-2)
tests/libmemcached-1.0/mem_functions.cc (+104/-62)
tests/libmemcached-1.0/mem_functions.h (+2/-0)
To merge this branch: bzr merge lp:~brianaker/libmemcached/1220229
Reviewer Review Type Date Requested Status
Tangent Trunk Pending
Review via email: mp+185662@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'clients/generator.cc'
2--- clients/generator.cc 2013-01-08 01:03:28 +0000
3+++ clients/generator.cc 2013-09-15 07:21:23 +0000
4@@ -22,6 +22,8 @@
5
6 #include "clients/generator.h"
7
8+#define KEY_BYTES 20
9+
10 /* Use this for string generation */
11 static const char ALPHANUMERICS[]=
12 "0123456789ABCDEFGHIJKLMNOPQRSTWXYZabcdefghijklmnopqrstuvwxyz";
13@@ -75,13 +77,13 @@
14
15 for (uint64_t x= 0; x < number_of; x++)
16 {
17- pairs[x].key= (char *)calloc(100, sizeof(char));
18+ pairs[x].key= (char *)calloc(KEY_BYTES, sizeof(char));
19
20 if (pairs[x].key == NULL)
21 goto error;
22
23- get_random_string(pairs[x].key, 100);
24- pairs[x].key_length= 100;
25+ get_random_string(pairs[x].key, KEY_BYTES);
26+ pairs[x].key_length= KEY_BYTES;
27
28 if (value_length)
29 {
30
31=== modified file 'clients/memcp.cc'
32--- clients/memcp.cc 2013-05-03 20:00:36 +0000
33+++ clients/memcp.cc 2013-09-15 07:21:23 +0000
34@@ -1,5 +1,5 @@
35 /* LibMemcached
36- * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/
37+ * Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/
38 * Copyright (C) 2006-2009 Brian Aker
39 * All rights reserved.
40 *
41
42=== modified file 'clients/memslap.cc'
43--- clients/memslap.cc 2013-03-13 03:23:07 +0000
44+++ clients/memslap.cc 2013-09-15 07:21:23 +0000
45@@ -66,6 +66,8 @@
46 #define DEFAULT_EXECUTE_NUMBER 10000
47 #define DEFAULT_CONCURRENCY 1
48
49+#define VALUE_BYTES 4096
50+
51 #define PROGRAM_NAME "memslap"
52 #define PROGRAM_DESCRIPTION "Generates a load against a memcached custer of servers."
53
54@@ -336,7 +338,7 @@
55
56 if (opt_test == SET_TEST)
57 {
58- context->execute_pairs= pairs_generate(opt_execute_number, 400);
59+ context->execute_pairs= pairs_generate(opt_execute_number, VALUE_BYTES);
60 context->execute_number= opt_execute_number;
61 }
62
63@@ -432,7 +434,7 @@
64 break;
65
66 case OPT_DEBUG: /* --debug or -d */
67- opt_verbose = OPT_DEBUG;
68+ opt_verbose= OPT_DEBUG;
69 break;
70
71 case OPT_VERSION: /* --version or -V */
72@@ -566,7 +568,7 @@
73 /* We always used non-blocking IO for load since it is faster */
74 memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NO_BLOCK, 0);
75
76- pairs_st *pairs= pairs_generate(number_of, 400);
77+ pairs_st *pairs= pairs_generate(number_of, VALUE_BYTES);
78 *actual_loaded= execute_set(memc_clone, pairs, number_of);
79
80 memcached_free(memc_clone);
81
82=== modified file 'docs/memcached_auto.rst'
83--- docs/memcached_auto.rst 2012-03-08 07:13:01 +0000
84+++ docs/memcached_auto.rst 2013-09-15 07:21:23 +0000
85@@ -53,7 +53,8 @@
86 expiration values, the operation will succeed by seeding the value for that
87 key with a initial value to expire with the provided expiration time. The
88 flags will be set to zero.The value is then returned via the uint32_t
89-value pointer you pass to it.
90+value pointer you pass to it. memcached_increment_with_initial is only available
91+when using the binary protocol.
92
93 memcached_decrement_with_initial takes a key and keylength and decrements
94 the value by the offset passed to it. If the object specified by key does
95@@ -62,7 +63,8 @@
96 expiration values, the operation will succeed by seeding the value for that
97 key with a initial value to expire with the provided expiration time. The
98 flags will be set to zero.The value is then returned via the uint32_t
99-value pointer you pass to it.
100+value pointer you pass to it. memcached_decrement_with_initial is only available
101+when using the binary protocol.
102
103 :c:func:`memcached_increment_by_key`, :c:func:`memcached_decrement_by_key`,
104 :c:func:`memcached_increment_with_initial_by_key`, and
105
106=== modified file 'libmemcached/auto.cc'
107--- libmemcached/auto.cc 2013-03-31 23:24:29 +0000
108+++ libmemcached/auto.cc 2013-09-15 07:21:23 +0000
109@@ -54,11 +54,17 @@
110
111 if (memcached_fatal(rc))
112 {
113+ fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, memcached_strerror(NULL, rc));
114 assert(memcached_last_error(instance->root) != MEMCACHED_SUCCESS);
115 *value= UINT64_MAX;
116 }
117+ else if (memcached_failed(rc))
118+ {
119+ *value= UINT64_MAX;
120+ }
121 else
122 {
123+ assert(memcached_last_error(instance->root) != MEMCACHED_NOTFOUND);
124 *value= instance->root->result.numeric_value;
125 }
126 }
127
128=== modified file 'libtest/main.cc'
129--- libtest/main.cc 2013-07-18 10:28:37 +0000
130+++ libtest/main.cc 2013-09-15 07:21:23 +0000
131@@ -2,7 +2,7 @@
132 *
133 * Data Differential YATL (i.e. libtest) library
134 *
135- * Copyright (C) 2012 Data Differential, http://datadifferential.com/
136+ * Copyright (C) 2012-2013 Data Differential, http://datadifferential.com/
137 *
138 * Redistribution and use in source and binary forms, with or without
139 * modification, are permitted provided that the following conditions are
140@@ -43,6 +43,9 @@
141 #include <ctime>
142 #include <fnmatch.h>
143 #include <iostream>
144+#ifdef HAVE_STRINGS_H
145+# include <strings.h>
146+#endif
147 #include <fstream>
148 #include <memory>
149 #include <sys/stat.h>
150
151=== modified file 'tests/libmemcached-1.0/all_tests.h'
152--- tests/libmemcached-1.0/all_tests.h 2013-02-23 21:43:42 +0000
153+++ tests/libmemcached-1.0/all_tests.h 2013-09-15 07:21:23 +0000
154@@ -70,9 +70,11 @@
155 {"partial mget", false, (test_callback_fn*)get_test5 },
156 {"stats_servername", false, (test_callback_fn*)stats_servername_test },
157 {"increment", false, (test_callback_fn*)increment_test },
158- {"increment_with_initial", true, (test_callback_fn*)increment_with_initial_test },
159+ {"memcached_increment_with_initial(0)", true, (test_callback_fn*)increment_with_initial_test },
160+ {"memcached_increment_with_initial(999)", true, (test_callback_fn*)increment_with_initial_999_test },
161 {"decrement", false, (test_callback_fn*)decrement_test },
162- {"decrement_with_initial", true, (test_callback_fn*)decrement_with_initial_test },
163+ {"memcached_decrement_with_initial(3)", true, (test_callback_fn*)decrement_with_initial_test },
164+ {"memcached_decrement_with_initial(999)", true, (test_callback_fn*)decrement_with_initial_999_test },
165 {"increment_by_key", false, (test_callback_fn*)increment_by_key_test },
166 {"increment_with_initial_by_key", true, (test_callback_fn*)increment_with_initial_by_key_test },
167 {"decrement_by_key", false, (test_callback_fn*)decrement_by_key_test },
168
169=== modified file 'tests/libmemcached-1.0/mem_functions.cc'
170--- tests/libmemcached-1.0/mem_functions.cc 2013-04-20 04:14:00 +0000
171+++ tests/libmemcached-1.0/mem_functions.cc 2013-09-15 07:21:23 +0000
172@@ -1294,24 +1294,39 @@
173 return TEST_SUCCESS;
174 }
175
176+static test_return_t __increment_with_initial_test(memcached_st *memc, uint64_t initial)
177+{
178+ uint64_t new_number;
179+
180+ test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc));
181+
182+ if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL))
183+ {
184+ test_compare(MEMCACHED_SUCCESS,
185+ memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number));
186+ test_compare(new_number, initial);
187+
188+ test_compare(MEMCACHED_SUCCESS,
189+ memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number));
190+ test_compare(new_number, (initial +1));
191+ }
192+ else
193+ {
194+ test_compare(MEMCACHED_INVALID_ARGUMENTS,
195+ memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number));
196+ }
197+
198+ return TEST_SUCCESS;
199+}
200+
201 test_return_t increment_with_initial_test(memcached_st *memc)
202 {
203- test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
204-
205- uint64_t new_number;
206- uint64_t initial= 0;
207-
208- test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc));
209-
210- test_compare(MEMCACHED_SUCCESS,
211- memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number));
212- test_compare(new_number, initial);
213-
214- test_compare(MEMCACHED_SUCCESS,
215- memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number));
216- test_compare(new_number, (initial +1));
217-
218- return TEST_SUCCESS;
219+ return __increment_with_initial_test(memc, 0);
220+}
221+
222+test_return_t increment_with_initial_999_test(memcached_st *memc)
223+{
224+ return __increment_with_initial_test(memc, 999);
225 }
226
227 test_return_t decrement_test(memcached_st *memc)
228@@ -1341,30 +1356,38 @@
229 return TEST_SUCCESS;
230 }
231
232+static test_return_t __decrement_with_initial_test(memcached_st *memc, uint64_t initial)
233+{
234+ test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
235+
236+ test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc));
237+
238+ uint64_t new_number;
239+ test_compare(MEMCACHED_SUCCESS,
240+ memcached_decrement_with_initial(memc,
241+ test_literal_param(__func__),
242+ 1, initial,
243+ 0, &new_number));
244+ test_compare(new_number, initial);
245+
246+ test_compare(MEMCACHED_SUCCESS,
247+ memcached_decrement_with_initial(memc,
248+ test_literal_param(__func__),
249+ 1, initial,
250+ 0, &new_number));
251+ test_compare(new_number, (initial - 1));
252+
253+ return TEST_SUCCESS;
254+}
255+
256 test_return_t decrement_with_initial_test(memcached_st *memc)
257 {
258- test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
259-
260- uint64_t initial= 3;
261-
262- test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc));
263-
264- uint64_t new_number;
265- test_compare(MEMCACHED_SUCCESS,
266- memcached_decrement_with_initial(memc,
267- test_literal_param(__func__),
268- 1, initial,
269- 0, &new_number));
270- test_compare(new_number, initial);
271-
272- test_compare(MEMCACHED_SUCCESS,
273- memcached_decrement_with_initial(memc,
274- test_literal_param(__func__),
275- 1, initial,
276- 0, &new_number));
277- test_compare(new_number, (initial - 1));
278-
279- return TEST_SUCCESS;
280+ return __decrement_with_initial_test(memc, 3);
281+}
282+
283+test_return_t decrement_with_initial_999_test(memcached_st *memc)
284+{
285+ return __decrement_with_initial_test(memc, 999);
286 }
287
288 test_return_t increment_by_key_test(memcached_st *memc)
289@@ -1398,24 +1421,32 @@
290
291 test_return_t increment_with_initial_by_key_test(memcached_st *memc)
292 {
293- test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
294-
295 uint64_t new_number;
296 const char *master_key= "foo";
297 const char *key= "number";
298 uint64_t initial= 0;
299
300- test_compare(MEMCACHED_SUCCESS,
301- memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key),
302- key, strlen(key),
303- 1, initial, 0, &new_number));
304- test_compare(new_number, initial);
305+ if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL))
306+ {
307+ test_compare(MEMCACHED_SUCCESS,
308+ memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key),
309+ key, strlen(key),
310+ 1, initial, 0, &new_number));
311+ test_compare(new_number, initial);
312
313- test_compare(MEMCACHED_SUCCESS,
314- memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key),
315- key, strlen(key),
316- 1, initial, 0, &new_number));
317- test_compare(new_number, (initial +1));
318+ test_compare(MEMCACHED_SUCCESS,
319+ memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key),
320+ key, strlen(key),
321+ 1, initial, 0, &new_number));
322+ test_compare(new_number, (initial +1));
323+ }
324+ else
325+ {
326+ test_compare(MEMCACHED_INVALID_ARGUMENTS,
327+ memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key),
328+ key, strlen(key),
329+ 1, initial, 0, &new_number));
330+ }
331
332 return TEST_SUCCESS;
333 }
334@@ -1456,19 +1487,30 @@
335 uint64_t new_number;
336 uint64_t initial= 3;
337
338- test_compare(MEMCACHED_SUCCESS,
339- memcached_decrement_with_initial_by_key(memc,
340- test_literal_param("foo"),
341- test_literal_param("number"),
342- 1, initial, 0, &new_number));
343- test_compare(new_number, initial);
344+ if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL))
345+ {
346+ test_compare(MEMCACHED_SUCCESS,
347+ memcached_decrement_with_initial_by_key(memc,
348+ test_literal_param("foo"),
349+ test_literal_param("number"),
350+ 1, initial, 0, &new_number));
351+ test_compare(new_number, initial);
352
353- test_compare(MEMCACHED_SUCCESS,
354- memcached_decrement_with_initial_by_key(memc,
355- test_literal_param("foo"),
356- test_literal_param("number"),
357- 1, initial, 0, &new_number));
358- test_compare(new_number, (initial - 1));
359+ test_compare(MEMCACHED_SUCCESS,
360+ memcached_decrement_with_initial_by_key(memc,
361+ test_literal_param("foo"),
362+ test_literal_param("number"),
363+ 1, initial, 0, &new_number));
364+ test_compare(new_number, (initial - 1));
365+ }
366+ else
367+ {
368+ test_compare(MEMCACHED_INVALID_ARGUMENTS,
369+ memcached_decrement_with_initial_by_key(memc,
370+ test_literal_param("foo"),
371+ test_literal_param("number"),
372+ 1, initial, 0, &new_number));
373+ }
374
375 return TEST_SUCCESS;
376 }
377
378=== modified file 'tests/libmemcached-1.0/mem_functions.h'
379--- tests/libmemcached-1.0/mem_functions.h 2013-02-23 21:43:42 +0000
380+++ tests/libmemcached-1.0/mem_functions.h 2013-09-15 07:21:23 +0000
381@@ -67,6 +67,7 @@
382 test_return_t decrement_test(memcached_st *memc);
383 test_return_t decrement_with_initial_by_key_test(memcached_st *memc);
384 test_return_t decrement_with_initial_test(memcached_st *memc);
385+test_return_t decrement_with_initial_999_test(memcached_st *memc);
386 test_return_t delete_test(memcached_st *memc);
387 test_return_t deprecated_set_memory_alloc(memcached_st *memc);
388 test_return_t enable_cas(memcached_st *memc);
389@@ -88,6 +89,7 @@
390 test_return_t increment_test(memcached_st *memc);
391 test_return_t increment_with_initial_by_key_test(memcached_st *memc);
392 test_return_t increment_with_initial_test(memcached_st *memc);
393+test_return_t increment_with_initial_999_test(memcached_st *memc);
394 test_return_t init_test(memcached_st *not_used);
395 test_return_t jenkins_run (memcached_st *);
396 test_return_t key_setup(memcached_st *memc);

Subscribers

People subscribed via source and target branches

to all changes: