-
Notifications
You must be signed in to change notification settings - Fork 17
test: add initial test suite #273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -26,4 +26,5 @@ include_files = { | |
|
||
exclude_files = { | ||
"lib/tarantool-python", | ||
"test/test-tarantool/*.test.lua", | ||
} |
This file contains hidden or 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,20 @@ | ||
TEST_RUN_EXTRA_PARAMS?= | ||
PYTHON?=python | ||
|
||
default: | ||
false | ||
|
||
.PHONY: lint flake8 luacheck | ||
lint: flake8 luacheck | ||
|
||
flake8: | ||
python -m flake8 *.py lib/*.py | ||
$(PYTHON) -m flake8 *.py lib/*.py | ||
|
||
luacheck: | ||
luacheck --config .luacheckrc . | ||
|
||
test_integration: | ||
$(PYTHON) test/test-run.py --force $(TEST_RUN_EXTRA_PARAMS) | ||
|
||
test: test_integration | ||
|
||
.PHONY: lint flake8 luacheck test test_integration |
This file contains hidden or 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,19 @@ | ||
#!/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') | ||
|
||
os.exit(test:check() and 0 or 1) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,15 @@ | ||
{ | ||
"set_language.test.sql": { | ||
"memtx": {"engine": "memtx"} | ||
}, | ||
"setopt_delimeter.test.lua": { | ||
"memtx": {"engine": "memtx"} | ||
}, | ||
"worker_hang_when_gc_triggered_inside_colorer.test.lua": { | ||
"vinyl": {"engine": "vinyl"} | ||
}, | ||
"*": { | ||
"memtx": {"engine": "memtx"}, | ||
"vinyl": {"engine": "vinyl"} | ||
} | ||
} | ||
Totktonada marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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 hidden or 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". | ||
Totktonada marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
|
||
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.