Skip to content

Commit c0b7060

Browse files
committed
Add memtier benchmark to testing
Closes #81
1 parent 9cd03cd commit c0b7060

File tree

2 files changed

+50
-6
lines changed

2 files changed

+50
-6
lines changed

.github/workflows/testing.yaml

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

4444
- run: make test-memcached
45+
46+
- run: tarantool test/bench/memcached.lua

test/bench/memcached.lua

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,57 @@
11
#!/usr/bin/env tarantool
22

3+
local fio = require('fio')
4+
local popen = require('popen')
5+
package.cpath = './?.so;' .. package.cpath
6+
local memcached = require('memcached')
7+
8+
local port = 11211
9+
10+
local function run_memtier(instance, memtier_path, proto)
11+
print(string.format("Run memtier benchmark with protocol '%s'", proto))
12+
13+
-- TODO: configure memcached protocol
14+
-- https://github.com/tarantool/memcached/issues/77
15+
local memtier_proto = 'memcache_' .. proto
16+
local memtier_argv = {
17+
memtier_path,
18+
'--server=127.0.0.1',
19+
string.format('--port=%d', port),
20+
string.format('--protocol=%s', memtier_proto),
21+
'--threads=20',
22+
'--test-time=30',
23+
'--hide-histogram'
24+
}
25+
local ph, err = popen.new(memtier_argv, {
26+
stdout = popen.opts.INHERIT,
27+
stderr = popen.opts.INHERIT,
28+
})
29+
local res = ph:wait()
30+
ph:close()
31+
32+
local rc = res.exit_code
33+
if rc ~= 0 then
34+
os.exit(rc)
35+
end
36+
end
37+
338
box.cfg{
439
wal_mode = 'none',
540
memtx_memory = 100 * 1024 * 1024,
6-
log_nonblock = false,
41+
log_nonblock = false,
742
}
843

9-
package.cpath = './?.so;' .. package.cpath
10-
11-
require('memcached').create('memcached', '0.0.0.0:11211', {
12-
expire_full_scan_time = 120
44+
local mc = memcached.create('memcached',
45+
string.format('0.0.0.0:%d', port), {
46+
expire_full_scan_time = 120,
1347
})
1448

15-
-- box.schema.user.grant('guest', 'read,write,execute', 'universe')
49+
local root = fio.cwd()
50+
local memtier_path = fio.pathjoin(root, 'test/bench/memtier_benchmark')
51+
52+
run_memtier(mc, memtier_path, 'text')
53+
run_memtier(mc, memtier_path, 'binary')
54+
55+
mc:stop()
56+
57+
os.exit(0)

0 commit comments

Comments
 (0)