-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test-run supports three types of tests: - tarantool - Test-Suite for Functional Testing - app - Another functional Test-Suite - unittest - Unit-Testing Test Suite Patch adds tests for two of supported test types: - test-app for type 'app' - test-tarantool for type 'tarantool' How-to run: $ make test_integration - test-tarantool/panic_on_broken_lsn.test.lua [1] 1. tarantool/tarantool-qa#96
- Loading branch information
Showing
25 changed files
with
612 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
TEST_RUN_EXTRA_PARAMS?= | ||
UNIT_TEST_DIR=test/test-unit | ||
|
||
default: | ||
false | ||
|
||
.PHONY: lint flake8 luacheck | ||
lint: flake8 luacheck | ||
|
||
flake8: | ||
python -m flake8 *.py lib/*.py | ||
|
||
luacheck: | ||
luacheck --config .luacheckrc . | ||
|
||
build_unit_tests: | ||
make -C $(UNIT_TEST_DIR) | ||
|
||
test_integration: build_unit_tests | ||
test/test-run.py --builddir=build/ --var=build/test/var --force $(TEST_RUN_EXTRA_PARAMS) | ||
|
||
test: test_integration | ||
|
||
.PHONY: lint flake8 luacheck test test_integration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- Options for test-run tarantoolctl | ||
local workdir = os.getenv('TEST_WORKDIR') | ||
default_cfg = { | ||
pid_file = workdir, | ||
wal_dir = workdir, | ||
snap_dir = workdir, | ||
vinyl_dir = workdir, | ||
logger = workdir, | ||
background = false, | ||
} | ||
|
||
instance_dir = workdir | ||
|
||
-- vim: set ft=lua : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env tarantool | ||
|
||
-- Test is an example of TAP test | ||
|
||
local tap = require('tap') | ||
local test = tap.test('cfg') | ||
test:plan(4) | ||
|
||
box.cfg{listen = box.NULL} | ||
test:is(nil, box.info.listen, 'no cfg.listen - no info.listen') | ||
|
||
box.cfg{listen = '127.0.0.1:0'} | ||
test:ok(box.info.listen:match('127.0.0.1'), 'real IP in info.listen') | ||
test:ok(not box.info.listen:match(':0'), 'real port in info.listen') | ||
|
||
box.cfg{listen = box.NULL} | ||
test:is(nil, box.info.listen, 'cfg.listen reset drops info.listen') | ||
|
||
test:check() | ||
os.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[default] | ||
core = app | ||
description = application tests | ||
is_parallel = True | ||
pretest_clean = True | ||
use_unix_sockets_iproto = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../test-run.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env tarantool | ||
local os = require('os') | ||
|
||
box.cfg{ | ||
listen = os.getenv("LISTEN"), | ||
memtx_memory = 107374182, | ||
pid_file = "tarantool.pid", | ||
force_recovery = true, | ||
wal_max_size = 500 | ||
} | ||
|
||
require('console').listen(os.getenv('ADMIN')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"set_language.test.lua": { | ||
"memtx": {"engine": "memtx"} | ||
}, | ||
"setopt_delimeter.test.lua": { | ||
"memtx": {"engine": "memtx"} | ||
}, | ||
"panic_on_broken_lsn.test.lua": { | ||
"vinyl": {"engine": "vinyl"} | ||
}, | ||
"manage_cluster.test.lua": {}, | ||
"*": { | ||
"memtx": {"engine": "memtx"}, | ||
"vinyl": {"engine": "vinyl"} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
IPROTO_UPDATE | ||
query [('IPROTO_CODE', 4)] [('IPROTO_SPACE_ID', 280)] | ||
True | ||
query [('IPROTO_CODE', 4)] [('IPROTO_KEY', (1,)), ('IPROTO_SPACE_ID', 280)] | ||
True | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
""" | ||
Original Tarantool's test box-py/iproto.test.py had a problem when output with | ||
running under Python 2 was not the same as with running under Python 3. | ||
Fixed in commit 697b79781cc63e2d87d86d43713998261d602334 | ||
"test: make output of box-py/iproto.test.py deterministic". | ||
""" | ||
|
||
from __future__ import print_function | ||
|
||
import msgpack | ||
from tarantool.const import * | ||
from tarantool import Connection | ||
from tarantool.response import Response | ||
from lib.tarantool_connection import TarantoolConnection | ||
|
||
# Note re IPROTO_SQL_INFO_* keys: they cannot appear in the | ||
# response map at the top level, but have the same codes as other | ||
# IPROTO_* constants. Exclude those names so. | ||
key_names = {} | ||
for (k,v) in list(globals().items()): | ||
if type(k) == str and k.startswith("IPROTO_") and \ | ||
not k.startswith("IPROTO_SQL_INFO_") and type(v) == int: | ||
key_names[v] = k | ||
|
||
def repr_dict(todump): | ||
d = {} | ||
for (k, v) in todump.items(): | ||
k_name = key_names.get(k, k) | ||
d[k_name] = v | ||
return repr(sorted(d.items())) | ||
|
||
|
||
def test(header, body): | ||
# Connect and authenticate | ||
c = Connection("localhost", server.iproto.port) | ||
c.connect() | ||
print("query", repr_dict(header), repr_dict(body)) | ||
header = msgpack.dumps(header) | ||
body = msgpack.dumps(body) | ||
query = msgpack.dumps(len(header) + len(body)) + header + body | ||
# Send raw request using connected socket | ||
s = c._socket | ||
try: | ||
s.send(query) | ||
except OSError as e: | ||
print(" => ", "Failed to send request") | ||
c.close() | ||
print(iproto.py_con.ping() > 0) | ||
|
||
print("IPROTO_UPDATE") | ||
test({ IPROTO_CODE : REQUEST_TYPE_UPDATE }, { IPROTO_SPACE_ID: 280 }) | ||
test({ IPROTO_CODE : REQUEST_TYPE_UPDATE }, | ||
{ IPROTO_SPACE_ID: 280, IPROTO_KEY: (1, )}) | ||
print("\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
-- test-run result file version 2 | ||
-- regression test for https://github.com/tarantool/tarantool-qa/issues/96 | ||
|
||
ok, err = pcall(box.schema.user.grant, 'guest', 'replication') | ||
| --- | ||
| ... | ||
test_run = require('test_run').new() | ||
| --- | ||
| ... | ||
test_run:cmd('create server replica with rpl_master=default, script="test-tarantool/replica.lua"') | ||
| --- | ||
| - true | ||
| ... | ||
test_run:cmd('start server replica') | ||
| --- | ||
| - true | ||
| ... | ||
test_run:cmd('stop server replica') | ||
| --- | ||
| - true | ||
| ... | ||
test_run:cmd('cleanup server replica') | ||
| --- | ||
| - true | ||
| ... | ||
test_run:cmd('delete server replica') | ||
| --- | ||
| - true | ||
| ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-- regression test for https://github.com/tarantool/tarantool-qa/issues/96 | ||
|
||
ok, err = pcall(box.schema.user.grant, 'guest', 'replication') | ||
test_run = require('test_run').new() | ||
test_run:cmd('create server replica with rpl_master=default, script="test-tarantool/replica.lua"') | ||
test_run:cmd('start server replica') | ||
test_run:cmd('stop server replica') | ||
test_run:cmd('cleanup server replica') | ||
test_run:cmd('delete server replica') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env tarantool | ||
local os = require('os') | ||
|
||
box.cfg{ | ||
listen = os.getenv("LISTEN"), | ||
memtx_memory = 107374182, | ||
pid_file = "tarantool.pid", | ||
wal_max_size = 2500 | ||
} | ||
|
||
require('console').listen(os.getenv('ADMIN')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
1..22 | ||
ok 1 - error on position 2 for <[[> | ||
ok 2 - error on position 2 for <[field]> | ||
ok 3 - error on position 1 for <'field1'.field2> | ||
ok 4 - error on position 2 for <[]> | ||
ok 5 - error on position 1 for <''> | ||
ok 6 - error on position 1 for < field1> | ||
ok 7 - error on position 1 for <1field> | ||
ok 8 - error on position 2 for <.1field> | ||
ok 9 - error on position 8 for <['field> | ||
ok 10 - error on position 9 for <['field'> | ||
ok 11 - error on position 5 for <[123> | ||
ok 12 - error on position 3 for <['']> | ||
ok 13 - error on position 2 for <.[123]> | ||
ok 22 - invalid token for index_base 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env tarantool | ||
|
||
local repl_include_self = arg[1] and arg[1] == 'true' or false | ||
local repl_list | ||
|
||
if repl_include_self then | ||
repl_list = {os.getenv("MASTER"), os.getenv("LISTEN")} | ||
else | ||
repl_list = os.getenv("MASTER") | ||
end | ||
|
||
-- Start the console first to allow test-run to attach even before | ||
-- box.cfg is finished. | ||
require('console').listen(os.getenv('ADMIN')) | ||
|
||
box.cfg({ | ||
listen = os.getenv("LISTEN"), | ||
replication = repl_list, | ||
memtx_memory = 107374182, | ||
replication_timeout = 0.1, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
-- test-run result file version 2 | ||
-- Simple SQL test that uses '\set language' command. | ||
-- Command introduced in commit 6e38b88eb6bbe543a1e3ba0a6a0be2f6f58abc86 | ||
-- ('Implement SQL driver') | ||
|
||
-- Create table for tests | ||
CREATE TABLE t (a BOOLEAN PRIMARY KEY); | ||
| --- | ||
| - row_count: 1 | ||
| ... | ||
INSERT INTO t VALUES (true), (false); | ||
| --- | ||
| - row_count: 2 | ||
| ... | ||
|
||
-- Create user-defined function. | ||
\set language lua | ||
| --- | ||
| - true | ||
| ... | ||
test_run = require('test_run').new() | ||
| --- | ||
| ... | ||
\set language sql | ||
| --- | ||
| - true | ||
| ... | ||
|
||
SELECT a FROM t WHERE a; | ||
| --- | ||
| - metadata: | ||
| - name: A | ||
| type: boolean | ||
| rows: | ||
| - [true] | ||
| ... | ||
SELECT a FROM t WHERE a != true; | ||
| --- | ||
| - metadata: | ||
| - name: A | ||
| type: boolean | ||
| rows: | ||
| - [false] | ||
| ... | ||
|
||
-- Cleaning. | ||
DROP TABLE t; | ||
| --- | ||
| - row_count: 1 | ||
| ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-- Simple SQL test that uses '\set language' command. | ||
-- Command introduced in commit 6e38b88eb6bbe543a1e3ba0a6a0be2f6f58abc86 | ||
-- ('Implement SQL driver') | ||
|
||
-- Create table for tests | ||
CREATE TABLE t (a BOOLEAN PRIMARY KEY); | ||
INSERT INTO t VALUES (true), (false); | ||
|
||
-- Create user-defined function. | ||
\set language lua | ||
test_run = require('test_run').new() | ||
\set language sql | ||
|
||
SELECT a FROM t WHERE a; | ||
SELECT a FROM t WHERE a != true; | ||
|
||
-- Cleaning. | ||
DROP TABLE t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
-- test-run result file version 2 | ||
-- Simple test that uses 'setopt delimiter' command. | ||
-- Command introduced in commit 6e38b88eb6bbe543a1e3ba0a6a0be2f6f58abc86 | ||
-- ('Implement SQL driver') | ||
|
||
test_run = require('test_run').new() | ||
| --- | ||
| ... | ||
|
||
-- Using delimiter | ||
_ = test_run:cmd("setopt delimiter ';'") | ||
| --- | ||
| ... | ||
function test_a() | ||
local a = 1 | ||
end; | ||
| --- | ||
| ... | ||
_ = test_run:cmd("setopt delimiter ''"); | ||
| --- | ||
| ... | ||
|
||
box.cfg{} | ||
| --- | ||
| ... | ||
|
||
-- Using multiline | ||
box.cfg{ \ | ||
coredump = false, \ | ||
log_format = plain, \ | ||
log_level = 5, \ | ||
strip_core = true \ | ||
} | ||
| --- | ||
| ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- Simple test that uses 'setopt delimiter' command. | ||
-- Command introduced in commit 6e38b88eb6bbe543a1e3ba0a6a0be2f6f58abc86 | ||
-- ('Implement SQL driver') | ||
|
||
test_run = require('test_run').new() | ||
|
||
-- Using delimiter | ||
_ = test_run:cmd("setopt delimiter ';'") | ||
function test_a() | ||
local a = 1 | ||
end; | ||
_ = test_run:cmd("setopt delimiter ''"); | ||
|
||
box.cfg{} | ||
|
||
-- Using multiline | ||
box.cfg{ \ | ||
coredump = false, \ | ||
log_format = plain, \ | ||
log_level = 5, \ | ||
strip_core = true \ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[default] | ||
core = tarantool | ||
description = tarantool tests | ||
script = box.lua | ||
use_unix_sockets = True | ||
pretest_clean = True | ||
config = engine.cfg |
Oops, something went wrong.