~d-ci/libmemcached/pushtest

« back to all changes in this revision

Viewing changes to tests/libmemcached-1.0/generate.cc

  • Committer: Continuous Integration
  • Date: 2013-11-04 17:14:31 UTC
  • mfrom: (1079.33.11 workspace)
  • Revision ID: ci@tangent.org-20131104171431-yj69t4kajuanut6c
Merge lp:libmemcached/1.0 Build: jenkins-Libmemcached-377

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
#include "clients/generator.h"
49
49
#include "clients/execute.h"
50
50
 
51
 
#define GLOBAL_COUNT 10000
 
51
#include "tests/memc.hpp"
 
52
 
 
53
#ifdef __APPLE__
 
54
# define GLOBAL_COUNT 3000
 
55
#else
 
56
# define GLOBAL_COUNT 10000
 
57
#endif
 
58
 
52
59
#define GLOBAL2_COUNT 100
53
60
 
54
61
using namespace libtest;
69
76
static test_return_t generate_pairs(memcached_st *)
70
77
{
71
78
  global_pairs= pairs_generate(GLOBAL_COUNT, 400);
72
 
  global_count= GLOBAL_COUNT;
73
79
 
74
 
  for (size_t x= 0; x < global_count; x++)
 
80
  for (size_t x= 0; x < GLOBAL_COUNT; ++x)
75
81
  {
76
82
    global_keys[x]= global_pairs[x].key;
77
83
    global_keys_length[x]=  global_pairs[x].key_length;
83
89
test_return_t generate_large_pairs(memcached_st *memc)
84
90
{
85
91
  global_pairs= pairs_generate(GLOBAL2_COUNT, MEMCACHED_MAX_BUFFER+10);
86
 
  global_count= GLOBAL2_COUNT;
87
92
 
88
 
  for (size_t x= 0; x < global_count; x++)
 
93
  for (size_t x= 0; x < GLOBAL2_COUNT; x++)
89
94
  {
90
95
    global_keys[x]= global_pairs[x].key;
91
96
    global_keys_length[x]=  global_pairs[x].key_length;
92
97
  }
93
98
 
94
99
  memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true);
95
 
  unsigned int check_execute= execute_set(memc, global_pairs, (unsigned int)global_count);
 
100
  global_count= execute_set(memc, global_pairs, (unsigned int)GLOBAL2_COUNT);
96
101
 
97
 
  test_true(check_execute > (global_count / 2));
 
102
  ASSERT_TRUE(global_count > (GLOBAL2_COUNT / 2));
98
103
 
99
104
  return TEST_SUCCESS;
100
105
}
103
108
{
104
109
  test_compare(TEST_SUCCESS, generate_pairs(memc));
105
110
 
106
 
  unsigned int check_execute= execute_set(memc, global_pairs, (unsigned int)global_count);
 
111
  global_count= execute_set(memc, global_pairs, (unsigned int)GLOBAL_COUNT);
107
112
 
108
113
  /* Possible false, positive, memcached may have ejected key/value based on
109
114
   * memory needs. */
110
115
 
111
 
  test_true(check_execute > (global_count / 2));
 
116
  ASSERT_TRUE(global_count > (GLOBAL2_COUNT / 2));
112
117
 
113
118
  return TEST_SUCCESS;
114
119
}
119
124
{
120
125
  test_compare(TEST_SUCCESS, generate_pairs(memc));
121
126
 
122
 
  unsigned int check_execute= execute_set(memc, global_pairs, (unsigned int)global_count);
 
127
  global_count= execute_set(memc, global_pairs, (unsigned int)GLOBAL2_COUNT);
123
128
 
124
 
  test_compare(check_execute, global_count);
 
129
  ASSERT_EQ(global_count, GLOBAL2_COUNT);
125
130
 
126
131
  // @todo hosts used size stats
127
132
  memcached_return_t rc;
172
177
    uint32_t flags;
173
178
    uint32_t count;
174
179
 
175
 
    for (size_t x= count= 0; x < global_count; x++)
 
180
    for (size_t x= count= 0; x < global_count; ++x)
176
181
    {
177
182
      memcached_return_t rc;
178
183
      return_value= memcached_get(memc_clone, global_keys[x], global_keys_length[x],
195
200
 
196
201
test_return_t get_read(memcached_st *memc)
197
202
{
 
203
  test::Memc clone(memc);
198
204
  size_t keys_returned= 0;
199
 
  for (size_t x= 0; x < global_count; x++)
 
205
  for (size_t x= 0; x < global_count; ++x)
200
206
  {
201
207
    size_t return_value_length;
202
208
    uint32_t flags;
203
209
    memcached_return_t rc;
204
 
    char *return_value= memcached_get(memc, global_keys[x], global_keys_length[x],
 
210
    char *return_value= memcached_get(&clone, global_keys[x], global_keys_length[x],
205
211
                                      &return_value_length, &flags, &rc);
206
212
    /*
207
213
      test_true(return_value);
341
347
      total++;
342
348
    }
343
349
  }
 
350
 
344
351
  /*
345
352
    Possible false, positive, memcached may have ejected key/value based on memory needs.
346
353
  */
347
 
  test_true(total > (global_count / 2));
 
354
  ASSERT_TRUE(total);
348
355
 
349
356
  return TEST_SUCCESS;
350
357
}
362
369
    }
363
370
  }
364
371
 
365
 
  /*
366
 
     Possible false, positive, memcached may have ejected key/value based on memory needs.
367
 
  */
368
 
  test_true(total > (global_count / 2));
 
372
  ASSERT_TRUE(total);
369
373
 
370
374
  return TEST_SUCCESS;
371
375
}