Skip to content

Commit 87422f0

Browse files
committed
Add a test with memtier benchmark
memtier benchmark has been added in commit 'Add memtier benchmark' (a3e2815). It was added to build, but it's run was not automated. This patch adds a test that wraps memtier benchmark and allows to run it using test-run.py or pure tarantool: $ tarantool test/bench/memcached.lua $ test/test-run.py bench/memcached.lua $ make test-memcached-bench Closes #81
1 parent e7fbb9a commit 87422f0

File tree

5 files changed

+83
-15
lines changed

5 files changed

+83
-15
lines changed

test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ add_dependencies(test-memcached internalso)
55
add_custom_target(test-memcached-capable
66
COMMAND ${CMAKE_SOURCE_DIR}/test/test-run.py --suite capable)
77
add_dependencies(test-memcached-capable libmemcached)
8+
9+
add_custom_target(test-memcached-bench
10+
COMMAND ${CMAKE_SOURCE_DIR}/test/test-run.py --force --long --suite bench)
11+
add_dependencies(test-memcached-bench internalso memtier)

test/bench/bench.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env tarantool
2+
3+
box.cfg{
4+
wal_mode = 'none',
5+
memtx_memory = 100 * 1024 * 1024,
6+
}
7+
8+
require('console').listen(os.getenv('ADMIN'))
9+
10+
box.schema.user.grant('guest', 'read,write,execute', 'universe')

test/bench/memcached.lua

Lines changed: 0 additions & 15 deletions
This file was deleted.

test/bench/memcached.test.lua

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env tarantool
2+
3+
local tap = require('tap')
4+
local fio = require('fio')
5+
local popen = require('popen')
6+
package.cpath = './?.so;' .. package.cpath
7+
local memcached = require('memcached')
8+
local test = tap.test('memcached benchmarks')
9+
test:plan(3)
10+
11+
local is_test_run = os.getenv('LISTEN')
12+
13+
if type(box.cfg) == 'function' then
14+
box.cfg{
15+
wal_mode = 'none',
16+
memtx_memory = 100 * 1024 * 1024,
17+
}
18+
box.schema.user.grant('guest', 'read,write,execute', 'universe')
19+
end
20+
21+
local port = 11211
22+
local mc = memcached.create('memcached', tostring(port), {})
23+
24+
local function run_memtier(instance, memtier_path, proto)
25+
instance:cfg({
26+
protocol = proto,
27+
})
28+
local memtier_proto = 'memcache_' .. proto
29+
local memtier_argv = {
30+
memtier_path,
31+
'--server=127.0.0.1',
32+
string.format('--port=%d', port),
33+
string.format('--protocol=%s', memtier_proto),
34+
'--threads=10',
35+
'--test-time=2',
36+
'--hide-histogram'
37+
}
38+
39+
local stdout = is_test_run and popen.opts.PIPE or popen.opts.INHERIT
40+
local stderr = is_test_run and popen.opts.PIPE or popen.opts.INHERIT
41+
local ph = popen.new(memtier_argv, {
42+
stdout = stdout,
43+
stderr = stderr,
44+
})
45+
local res = ph:wait()
46+
ph:close()
47+
48+
return res.exit_code
49+
end
50+
51+
-- path to memtier_benchmark in case of tarantool that run in project root dir
52+
local memtier_path = 'test/bench/memtier_benchmark'
53+
if not fio.path.exists(memtier_path) then
54+
-- path to memtier_benchmark in case of test-run
55+
memtier_path = './memtier_benchmark'
56+
end
57+
58+
test:is(fio.path.exists(memtier_path), true, 'memtier_benchmark binary is available')
59+
test:is(run_memtier(mc, memtier_path, 'text'), 0, 'memtier with text protocol')
60+
test:is(run_memtier(mc, memtier_path, 'binary'), 0, 'memtier with binary protocol')
61+
62+
os.exit(0)

test/bench/suite.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[default]
2+
core = app
3+
description = memcached load tests with #! using TAP
4+
script = bench.lua
5+
is_parallel = False
6+
long_run = memcached.lua
7+
lua_libs = memtier_benchmark

0 commit comments

Comments
 (0)