diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml index 69364f0..f77b034 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/testing.yaml @@ -42,4 +42,8 @@ jobs: run: pip install -r test-run/requirements.txt - run: make test-memcached + - run: make test-memcached-capable + + - name: Run benchmarks + run: make test-memcached-bench diff --git a/README.md b/README.md index 2486852..943d177 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ + [![Static analysis](https://github.com/tarantool/memcached/actions/workflows/check.yaml/badge.svg)](https://github.com/tarantool/memcached/actions/workflows/check.yaml) [![Testing](https://github.com/tarantool/memcached/actions/workflows/testing.yaml/badge.svg)](https://github.com/tarantool/memcached/actions/workflows/testing.yaml) diff --git a/memcached/internal/proto_bin.c b/memcached/internal/proto_bin.c index b9ecf15..516e184 100644 --- a/memcached/internal/proto_bin.c +++ b/memcached/internal/proto_bin.c @@ -1015,7 +1015,7 @@ memcached_bin_process(struct memcached_connection *con) /** * return -1 on error (forced closing of connection) - * return 0 in everything ok + * return 0 if everything ok * - if con->noprocess == 1 then skip execution * return >1 if we need more data */ diff --git a/test-run b/test-run index 8865771..38400e9 160000 --- a/test-run +++ b/test-run @@ -1 +1 @@ -Subproject commit 886577172b82073b33d8a23a7f7555a85e6c146e +Subproject commit 38400e91c600677fb661154d00459d660fa9880d diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 923b972..0361f79 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -5,3 +5,7 @@ add_dependencies(test-memcached internalso) add_custom_target(test-memcached-capable COMMAND ${CMAKE_SOURCE_DIR}/test/test-run.py --suite capable) add_dependencies(test-memcached-capable libmemcached) + +add_custom_target(test-memcached-bench + COMMAND ${CMAKE_SOURCE_DIR}/test/test-run.py --force --long --suite bench) +add_dependencies(test-memcached-bench internalso memtier) diff --git a/test/bench/bench.lua b/test/bench/bench.lua new file mode 100644 index 0000000..8c0b49b --- /dev/null +++ b/test/bench/bench.lua @@ -0,0 +1,10 @@ +#!/usr/bin/env tarantool + +box.cfg{ + wal_mode = 'none', + memtx_memory = 100 * 1024 * 1024, +} + +require('console').listen(os.getenv('ADMIN')) + +box.schema.user.grant('guest', 'read,write,execute', 'universe') diff --git a/test/bench/memcached.lua b/test/bench/memcached.lua deleted file mode 100644 index eb2f79c..0000000 --- a/test/bench/memcached.lua +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env tarantool - -box.cfg{ - wal_mode = 'none', - slab_alloc_arena = 0.1, - logger_nonblock = false, -} - -package.cpath = './?.so;' .. package.cpath - -require('memcached').create('memcached', '0.0.0.0:11211', { - expire_full_scan_time = 120 -}) - --- box.schema.user.grant('guest', 'read,write,execute', 'universe') diff --git a/test/bench/memtier.test.lua b/test/bench/memtier.test.lua new file mode 100755 index 0000000..657fc9a --- /dev/null +++ b/test/bench/memtier.test.lua @@ -0,0 +1,68 @@ +#!/usr/bin/env tarantool + +local tap = require('tap') +local fio = require('fio') +local has_popen, popen = pcall(require, 'popen') +package.cpath = './?.so;' .. package.cpath +local memcached = require('memcached') +local test = tap.test('memcached benchmarks') + +if not has_popen then + test:plan(0) + os.exit(0) +end + +test:plan(3) + +local is_test_run = os.getenv('LISTEN') + +if type(box.cfg) == 'function' then + box.cfg{ + wal_mode = 'none', + memtx_memory = 100 * 1024 * 1024, + } + box.schema.user.grant('guest', 'read,write,execute', 'universe') +end + +local port = 11211 +local mc = memcached.create('memcached', tostring(port), {}) + +local function run_memtier(instance, memtier_path, proto) + instance:cfg({ + protocol = proto, + }) + local memtier_proto = 'memcache_' .. proto + local memtier_argv = { + memtier_path, + '--server=127.0.0.1', + string.format('--port=%d', port), + string.format('--protocol=%s', memtier_proto), + '--threads=10', + '--test-time=2', + '--hide-histogram' + } + + local stdout = is_test_run and popen.opts.PIPE or popen.opts.INHERIT + local stderr = is_test_run and popen.opts.PIPE or popen.opts.INHERIT + local ph = popen.new(memtier_argv, { + stdout = stdout, + stderr = stderr, + }) + local res = ph:wait() + ph:close() + + return res.exit_code +end + +-- path to memtier_benchmark in case of tarantool that run in project root dir +local memtier_path = 'test/bench/memtier_benchmark' +if not fio.path.exists(memtier_path) then + -- path to memtier_benchmark in case of test-run + memtier_path = './memtier_benchmark' +end + +test:is(fio.path.exists(memtier_path), true, 'memtier_benchmark binary is available') +test:is(run_memtier(mc, memtier_path, 'text'), 0, 'memtier with text protocol') +test:is(run_memtier(mc, memtier_path, 'binary'), 0, 'memtier with binary protocol') + +os.exit(0) diff --git a/test/bench/suite.ini b/test/bench/suite.ini new file mode 100644 index 0000000..590a46b --- /dev/null +++ b/test/bench/suite.ini @@ -0,0 +1,7 @@ +[default] +core = app +description = memcached load tests with #! using TAP +script = bench.lua +is_parallel = False +long_run = memtier.test.lua +lua_libs = memtier_benchmark diff --git a/test/binary/binary.lua b/test/binary/binary.lua index 6c6948e..152079f 100644 --- a/test/binary/binary.lua +++ b/test/binary/binary.lua @@ -2,7 +2,7 @@ box.cfg{ wal_mode = 'none', - slab_alloc_arena = 0.1, + memtx_memory = 100 * 1024 * 1024, } package.cpath = './?.so;' .. package.cpath diff --git a/test/capable/capable.lua b/test/capable/capable.lua index 97aa7e0..f9b1e0e 100644 --- a/test/capable/capable.lua +++ b/test/capable/capable.lua @@ -2,7 +2,7 @@ box.cfg{ wal_mode = 'none', - slab_alloc_arena = 0.1, + memtx_memory = 100 * 1024 * 1024, } package.cpath = './?.so;' .. package.cpath diff --git a/test/sasl/sasl.lua b/test/sasl/sasl.lua index d700b4f..736e919 100644 --- a/test/sasl/sasl.lua +++ b/test/sasl/sasl.lua @@ -66,7 +66,7 @@ env['SASL_CONF_PATH'] = fio.pathjoin(fio.cwd(), '../sasl/config/') box.cfg{ wal_mode = 'none', - slab_alloc_arena = 0.1, + memtx_memory = 100 * 1024 * 1024, } local memcached = require('memcached') diff --git a/test/text/text.lua b/test/text/text.lua index 4f957a5..dd8f143 100644 --- a/test/text/text.lua +++ b/test/text/text.lua @@ -2,7 +2,7 @@ box.cfg{ wal_mode = 'none', - slab_alloc_arena = 0.1, + memtx_memory = 100 * 1024 * 1024, } package.cpath = './?.so;' .. package.cpath diff --git a/third_party/memtier b/third_party/memtier index 40d47a0..820605c 160000 --- a/third_party/memtier +++ b/third_party/memtier @@ -1 +1 @@ -Subproject commit 40d47a0e3b84b14e2ca88d9f0d506b4f04e39b16 +Subproject commit 820605c79f19fd165e3a31dddc89a9b465ccd459