Skip to content

Commit 924fb2a

Browse files
committed
Update and refine the readme
1 parent 5eadc16 commit 924fb2a

File tree

1 file changed

+169
-57
lines changed

1 file changed

+169
-57
lines changed

README.md

+169-57
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,161 @@
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.
44-
45-
### Test configuration
46-
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
5+
## Test suite configuration file
6+
7+
Test suite is a bunch of tests located in a directory 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 values
31+
32+
* `core` — major type of tests in this suite.
33+
Should have one of the following values:
34+
35+
* `tarantool` — diff-test, a test that reads a file with commands,
36+
feeds it line by line to the tarantool console,
37+
writes requests and responses to an output file,
38+
and then compares that file with a reference file.
39+
* `app` — a Lua script test.
40+
Most of such tests produce
41+
[TAP13 output](http://testanything.org/tap-version-13-specification.html)
42+
using the built-in `tap` module.
43+
Test-run validates such output without a reference file.
44+
Some tests produce non-TAP13 output, which is compared to a reference file.
45+
* `luatest` — test suite using the [luatest](https://github.com/tarantool/luatest/) library.
46+
* `unittest` — an executable test file.
47+
48+
* `description`
49+
50+
* `script` — A file with Tarantool commands.
51+
It is used to start the default server using `tarantoolctl`.
52+
The value should be a file in the same directory as `suite.ini`, like `box.lua` or `master.lua`.
53+
This setting is mandatory for suites with diff-tests (`core = tarantool`)
54+
and ignored with other types of tests.
55+
56+
* `config` — name of a test configuration file, for example, `engine.cfg`.
57+
For details, see the [test configuration](#test-configuration) section below.
58+
59+
* `lua_libs` — paths to Lua files that should be copied to the directory,
60+
where a server is started. For example:
61+
62+
```ini
63+
lua_libs = lua/require_mod.lua lua/serializer_test.lua lua/process_timeout.lua
64+
```
65+
66+
### Disabling and skipping tests
67+
68+
A number of fields are used to disable certain tests:
69+
70+
* `disabled` — list of tests that should be skipped.
71+
72+
* `release_disabled` — list of tests that should only run when Tarantool is
73+
built in the debug mode (with `-DCMAKE_BUILD_TYPE=Debug` and not `=RelWithDebInfo`).
74+
Tests that use error injections, which are only available in debug builds,
75+
should always be `release_disabled`.
76+
77+
* `valgrind_disabled` — list of tests that should be skipped when Valgrind is enabled
78+
79+
* `long_run` — mark tests as long. Such tests will run only with `--long` option.
80+
81+
```ini
82+
long_run = t1.test.lua t2.test.lua
83+
```
84+
85+
### Other parameters
86+
87+
* `show_reproduce_content` (optional, `True` by default) — when set to `True`,
88+
show the contents of the reproduce file for each failed test.
89+
Reproduce files are not required for investigating results of
90+
tests that run each case in a separate Tarantool instance.
91+
For such tests it makes sense to set `show_reproduce_content = False`.
92+
(Implemented in [#113](https://github.com/tarantool/test-run/issues/113))
93+
94+
* `is_parallel` (optional, `False` by default) — whether the tests in the suite can run in parallel
95+
96+
* `use_unix_sockets` (optional, `False` by default) — use hard-coded UNIX sockets
97+
* `use_unix_sockets_iproto` (optional, `False` by default) — use hard-coded UNIX sockets for IProto.
98+
99+
### Fragile tests
100+
101+
Tests which fail sometimes due to external reasons can be marked as fragile (flaky).
102+
Test-run will retry each test if it fails.
103+
It's recommended to provide a list of related
104+
[tarantool/tarantool](https://github.com/tarantool/tarantool) issues
105+
next to each fragile test.
106+
107+
```ini
108+
fragile = {
109+
"retries": 10,
110+
"tests": {
111+
"tarantoolctl.test.lua": {
112+
"issues": [ "gh-5059", "gh-5346" ],
113+
},
114+
{...},
115+
{...},
116+
}
117+
}
118+
```
119+
120+
## Test composition
121+
122+
Each test consists of the following files:
123+
124+
* Test file: `<name>.test.lua`, `<name>_test.lua`, `<name>.test.py`, or `<name>.test.sql`.
125+
* Reference file: `<name>.result`.
126+
* Skip condition file: `<name>.skipcond`.
127+
128+
Reference file contains saved test output.
129+
It is required for tests with non-TAP13 output.
130+
Running `test-run.py` with `--update-result` option will update
131+
the `.result` files with new test output.
132+
133+
The optional skip condition file is a Python script.
134+
In the local Python environment of a test run there's a `self` object,
135+
which is an instance of the [`Test` class](./lib/test.py).
136+
Set `self.skip = 1` to skip this test.
137+
138+
139+
## Test execution
140+
141+
Running a test begins with executing the `.skipcond` file.
142+
If `self.skip` is set to `1`, test-run skips this test
143+
and reports TODO.
144+
145+
Next, the test file is executed and the output is written to a `.reject` file.
146+
If the output is TAP13-compatible, test-run validates it.
147+
Otherwise, test-run compares it with the `.result` file.
148+
If there's a difference between `.reject` and `.result`, the test fails and
149+
the last 15 lines of diff are printed to output.
150+
151+
Whenever a test fails, the `.reject` file is saved in the `<vardir>/rejects/<suite>`
152+
subdirectory given in options or set locally as `var/rejects/<suite>` by default.
153+
If the test is considered successful, the `.reject` file is deleted.
154+
155+
## Test configuration
156+
157+
Test configuration file contains configuration for multiple runs.
158+
For each test section, system runs a separate test and compares the result to the common `.result` file.
159+
For example, we need to run a test with different DB engines (`"*"` means the default
50160
configuration):
51161

52162
```json
@@ -62,15 +172,15 @@ configuration):
62172
}
63173
```
64174

65-
In test case we can get configuration from inspector:
175+
In the test case we can get configuration from the inspector:
66176

67177
```lua
68178
engine = test_run:get_cfg('engine')
69179
-- first run engine is 'memtx'
70180
-- second run engine is 'sophia'
71181
```
72182

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

@@ -79,11 +189,13 @@ UPDATE "_session_settings" SET "value" = 'memtx|vinyl' WHERE "name" = 'sql_defau
79189
pragma sql_default_engine='memtx|vinyl'
80190
```
81191

82-
If the first fails, then the second will be executed. When both fails, fail the test.
192+
If the first fails, then the second will be executed. When both fail, the test fails.
193+
194+
## Writing various types of tests
83195

84-
#### Python
196+
### Python tests
85197

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

88200
Environment:
89201

@@ -166,14 +278,14 @@ box.info.lsn
166278
...
167279
```
168280

169-
#### Lua
281+
### Lua
170282

171283
Files: `<name>.test.lua`, `<name>.result` and `<name>.skipcond`(optionaly).
172284
Tests interact only with `AdminConnection`. Supports some preprocessor functions (eg `delimiter`)
173285

174286
**Delimiter example:**
175287

176-
```
288+
```lua
177289
env = require('test_run')
178290
test_run = env.new()
179291
box.schema.space.create('temp')
@@ -194,7 +306,7 @@ test
194306

195307
**Delimiter result:**
196308

197-
```
309+
```yaml
198310
env = require('test_run')
199311
test_run = env.new()
200312
box.schema.space.create('temp')
@@ -255,14 +367,14 @@ function echo(...) \
255367
end
256368
```
257369

258-
#### SQL
370+
### SQL
259371

260372
*.test.sql files are just SQL statements written line-by-line.
261373

262374
It is possible to mix SQL and Lua commands using `\set language lua` and `\set
263375
language sql` commands.
264376

265-
##### Interaction with the test environment
377+
## Interaction with the test environment
266378

267379
In lua test you can use `test_run` module to interact with the test
268380
environment.
@@ -337,7 +449,7 @@ test_run:cmd('setopt delimiter ""');
337449
join(test_run, 30)
338450
```
339451

340-
### pretest_clean()
452+
## pretest_clean()
341453

342454
Nothing will be done before a Python test and for `core = unittest`
343455
test suites.
@@ -353,7 +465,7 @@ The following files will be removed:
353465
* `*.inprogress`
354466
* `[0-9]*/`
355467

356-
### Tags
468+
## Tags
357469

358470
Usage:
359471

0 commit comments

Comments
 (0)