Skip to content

Commit 99dc668

Browse files
committed
test: add a test with memtier benchmark
memtier is a benchmark made by RedisLabs for load-generation and benchmarking of NoSQL key-value databases. 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/memtier.test.lua $ test/test-run.py bench/memtier.test.lua $ make test-memcached-bench Memtier benchmark has been enabled on CI. Closes #81
1 parent 857df93 commit 99dc668

File tree

6 files changed

+93
-15
lines changed

6 files changed

+93
-15
lines changed

.github/workflows/testing.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,8 @@ jobs:
4242
run: pip install -r test-run/requirements.txt
4343

4444
- run: make test-memcached
45+
4546
- run: make test-memcached-capable
47+
48+
- name: Run benchmarks
49+
run: make test-memcached-bench

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/memtier.test.lua

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

0 commit comments

Comments
 (0)