Skip to content

Commit 258273e

Browse files
committed
Update and refine the readme
1 parent 1689f58 commit 258273e

File tree

1 file changed

+124
-49
lines changed

1 file changed

+124
-49
lines changed

README.md

+124-49
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,126 @@
22

33
[![Coverage Status](https://coveralls.io/repos/github/tarantool/test-run/badge.svg)](https://coveralls.io/github/tarantool/test-run)
44

5-
### Test Suite
6-
7-
Bunch of tests, that lay down in the subfolder (recursively) with `suite.ini`
8-
file. `suite.ini` is basic ini-file, that consists of one section `default`,
9-
and a number of fields:
10-
11-
* `core`
12-
* `description` - Test Suite description
13-
* `script` - shebang file to start tarantool with
14-
* disables:
15-
* `disabled` - tests that must be skipped
16-
* `release_disabled` - tests that must be skipped when Tarantool has been
17-
builded with `Release`
18-
* `valgrind_disabled` - tests that must be skipped when Valgrind is enabled
19-
* `lua_libs` - paths for lua files, that should be copied into the folder,
20-
where server is started (delimited with the space, e.g. `lua_libs=lua/1.lua
21-
lua/2.lua`)
22-
* `long_run` - mark tests as long, enabled only with `--long` option (delimited
23-
with the space, e.g. `long_run=t1.test.lua t2.test.lua`)
24-
* `config` - test configuration file name
25-
26-
Field `core` must be one of:
27-
28-
* `tarantool` - Test-Suite for Functional Testing
29-
* `app` - Another functional Test-Suite
30-
* `unittest` - Unit-Testing Test Suite
31-
32-
### Test
33-
34-
Each test consists of files `*.test(.lua|.sql|.py)?`, `*.result`, and may have
35-
skip condition file `*.skipcond`. On first run (without `.result`) `.result`
36-
is generated from output. Each run, in the beggining, `.skipcond` file is
37-
executed. In the local env there's object `self`, that's `Test` object. If test
38-
must be skipped - you must put `self.skip = 1` in this file. Next,
39-
`.test(.lua|.py)?` is executed and file `.reject` is created, then `.reject` is
40-
compared with `.result`. If something differs, then 15 last string of this diff
41-
file are printed and `.reject` file is saving in the `<vardir>/rejects/<suite>`
42-
subfolder given in options or set localy as `var/rejects/<suite>` by default.
43-
If not, then `.reject` file is deleted.
5+
## Test suite configuration
6+
7+
Test suite is a bunch of tests located in a subdirectory (recursively) with a `suite.ini`
8+
file. The `suite.ini` is a basic ini-file with one section `[default]`.
9+
10+
```ini
11+
[default]
12+
core = luatest
13+
description = Example test suite using luatest
14+
...
15+
```
16+
17+
There's a syntax for single- and multiline lists. (TODO see ./sql-tap/suite.ini)
18+
For example:
19+
20+
```ini
21+
single_line = first.test.lua second.test.lua third.test.lua
22+
multiline = first.test.lua ;
23+
second.test.lua ;
24+
third.test.lua ;
25+
...
26+
```
27+
28+
Below is a list of configuration values (fields) in the `suite.ini` file.
29+
30+
### General configuration
31+
32+
* `core` — major testing dependency or method
33+
Should have one of the following values:
34+
35+
* `tarantool` — test suite used for functional testing
36+
* `app` — TAP-tests, another functional test suite
37+
* `unittest` — unit testing test suite
38+
* `luatest` — test suite using luatest library
39+
40+
* `description` — test suite description
41+
* `script` (optional) — shebang file to start tarantool with.
42+
Most often, the value is a file in the same directory as `suite.ini`, like `box.lua` or `master.lua`.
43+
44+
* `config` — name of a test configuration file, for example, `engine.cfg`.
45+
TODO: what's a test configuration file?
46+
47+
* `lua_libs` — paths to Lua files that should be copied to the directory,
48+
where a server is started. For example:
49+
50+
```ini
51+
lua_libs = lua/require_mod.lua lua/serializer_test.lua lua/process_timeout.lua
52+
```
53+
54+
### Skipping tests
55+
56+
A number of fields are used to disable (skip) certain tests:
57+
58+
* `disabled` — list of tests that should be skipped
59+
* `release_disabled` — list of tests that should be skipped when Tarantool is
60+
built with `Release`
61+
* `valgrind_disabled` — list of tests that should be skipped when Valgrind is enabled
62+
* `long_run` — mark tests as long, such tests will run only with `--long` option.
63+
64+
```ini
65+
long_run = t1.test.lua t2.test.lua
66+
```
67+
68+
### Other parameters
69+
70+
71+
* `show_reproduce_content` (optional, `True` by default) — TODO: what's this?
72+
* `is_parallel` (optional, `False` by default) — whether the tests in the suite can run in parallel
73+
74+
* `use_unix_sockets` (optional, `False` by default) — use hard-coded UNIX sockets
75+
* `use_unix_sockets_iproto` (optional, `False` by default) — use hard-coded UNIX sockets for IProto.
76+
77+
### Fragile tests
78+
79+
Tests which fail sometimes due to external reasons can be marked as fragile (flaky).
80+
Test-run will retry each test if it fails.
81+
It's recommended to provide a list of related
82+
[tarantool/tarantool](https://github.com/tarantool/tarantool) issues
83+
next to each fragile test.
84+
85+
```ini
86+
fragile = {
87+
"retries": 10,
88+
"tests": {
89+
"tarantoolctl.test.lua": {
90+
"issues": [ "gh-5059", "gh-5346" ],
91+
},
92+
{...},
93+
{...},
94+
}
95+
}
96+
```
97+
98+
## Steps of a test run
99+
100+
Each test consists of files `*.test(.lua|.sql|.py)?`, `*.result`,
101+
and an optional skip condition file `*.skipcond`.
102+
103+
In the beginning of each test run, the `.skipcond` file is executed as a Python script.
104+
In the local Python environment there's a `self` object, which is an instance of the [`Test` class](./lib/test.py).
105+
To skip the test under some condition, set `self.skip = 1`.
106+
107+
Next, the test in `.test(.lua|.py)?` is executed.
108+
If this is a first test run and there's no `.result` file yet, it is generated from the output.
109+
If there is a `.result` file, output is written to a `.reject` file,
110+
which is then compared to `.result`.
111+
112+
If there's a difference between `.reject` and `.result`, the following happens:
113+
114+
1. The last 15 lines of diff are printed to output.
115+
2. The `.reject` file is saved in the `<vardir>/rejects/<suite>`
116+
subfolder given in options or set locally as `var/rejects/<suite>` by default.
117+
118+
If there is no difference between `.reject` and `.result`, the `.reject` file is deleted.
44119

45120
### Test configuration
46121

47-
Test configuration file contains config for multiple run. For each test section
48-
system runs separated test and compares result with common `.result` file. For
49-
example we need to run one test for different db engines("*" means default
122+
Test configuration file contains configuration for multiple runs.
123+
For each test section, system runs a separate test and compares the result to the common `.result` file.
124+
For example, we need to run a test with different DB engines (`"*"` means the default
50125
configuration):
51126

52127
```json
@@ -62,15 +137,15 @@ configuration):
62137
}
63138
```
64139

65-
In test case we can get configuration from inspector:
140+
In the test case we can get configuration from the inspector:
66141

67142
```lua
68143
engine = test_run:get_cfg('engine')
69144
-- first run engine is 'memtx'
70145
-- second run engine is 'sophia'
71146
```
72147

73-
"engine" value has a special meaning for *.test.sql files: if it is "memtx" or
148+
"engine" value has a special meaning for `*.test.sql` files: if it is "memtx" or
74149
"vinyl", then the corresponding default engine will be set before executing
75150
commands from a test file. An engine is set with the following commands:
76151

@@ -79,11 +154,11 @@ UPDATE "_session_settings" SET "value" = 'memtx|vinyl' WHERE "name" = 'sql_defau
79154
pragma sql_default_engine='memtx|vinyl'
80155
```
81156

82-
If the first fails, then the second will be executed. When both fails, fail the test.
157+
If the first fails, then the second will be executed. When both fail, the test fails.
83158

84-
#### Python
159+
#### Python tests
85160

86-
Files: `<name>.test.py`, `<name>.result` and `<name>.skipcond`(optionaly).
161+
Files: `<name>.test.py`, `<name>.result` and `<name>.skipcond` (optionally).
87162

88163
Environment:
89164

@@ -173,7 +248,7 @@ Tests interact only with `AdminConnection`. Supports some preprocessor functions
173248

174249
**Delimiter example:**
175250

176-
```
251+
```lua
177252
env = require('test_run')
178253
test_run = env.new()
179254
box.schema.space.create('temp')
@@ -194,7 +269,7 @@ test
194269

195270
**Delimiter result:**
196271

197-
```
272+
```yaml
198273
env = require('test_run')
199274
test_run = env.new()
200275
box.schema.space.create('temp')

0 commit comments

Comments
 (0)