2
2
3
3
[ ![ Coverage Status] ( https://coveralls.io/repos/github/tarantool/test-run/badge.svg )] ( https://coveralls.io/github/tarantool/test-run )
4
4
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
+
6
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
7
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
8
+ ## Table of Contents
9
+
10
+ - [ Test suite configuration file] ( #test-suite-configuration-file )
11
+ - [ General configuration values] ( #general-configuration-values )
12
+ - [ Disabling and skipping tests] ( #disabling-and-skipping-tests )
13
+ - [ Other parameters] ( #other-parameters )
14
+ - [ Fragile tests] ( #fragile-tests )
15
+ - [ Test composition] ( #test-composition )
16
+ - [ Test execution] ( #test-execution )
17
+ - [ Test configuration] ( #test-configuration )
18
+ - [ Writing various types of tests] ( #writing-various-types-of-tests )
19
+ - [ Python tests] ( #python-tests )
20
+ - [ Lua] ( #lua )
21
+ - [ SQL] ( #sql )
22
+ - [ Interaction with the test environment] ( #interaction-with-the-test-environment )
23
+ - [ pretest_clean()] ( #pretest_clean )
24
+ - [ Tags] ( #tags )
25
+ - [ Projects that use test-run] ( #projects-that-use-test-run )
26
+
27
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
28
+
29
+ ## Test suite configuration file
30
+
31
+ Test suite is a bunch of tests located in a directory with a ` suite.ini `
32
+ file. The ` suite.ini ` is a basic ini-file with one section ` [default] ` .
33
+
34
+ ``` ini
35
+ [default]
36
+ core = luatest
37
+ description = Example test suite using luatest
38
+ ...
39
+ ```
40
+
41
+ There's a syntax for single- and multiline lists. (TODO see ./sql-tap/suite.ini)
42
+ For example:
43
+
44
+ ``` ini
45
+ single_line = first.test.lua second.test.lua third.test.lua
46
+ multiline = first.test.lua ;
47
+ second.test.lua ;
48
+ third.test.lua ;
49
+ ...
50
+ ```
51
+
52
+ Below is a list of configuration values (fields) in the ` suite.ini ` file.
53
+
54
+ ### General configuration values
55
+
56
+ * ` core ` — major type of tests in this suite.
57
+ Should have one of the following values:
58
+
59
+ * ` tarantool ` — diff-test, a test that reads a file with commands,
60
+ feeds it line by line to the tarantool console,
61
+ writes requests and responses to an output file,
62
+ and then compares that file with a reference file.
63
+ * ` app ` — a Lua script test.
64
+ Most of such tests produce
65
+ [ TAP13 output] ( http://testanything.org/tap-version-13-specification.html )
66
+ using the built-in ` tap ` module.
67
+ Test-run validates such output without a reference file.
68
+ Some tests produce non-TAP13 output, which is compared to a reference file.
69
+ * ` luatest ` — test suite using the [ luatest] ( https://github.com/tarantool/luatest/ ) library.
70
+ * ` unittest ` — an executable test file.
71
+
72
+ * ` description `
73
+
74
+ * ` script ` — A file with Tarantool commands.
75
+ It is used to start the default server using ` tarantoolctl ` .
76
+ The value should be a file in the same directory as ` suite.ini ` , like ` box.lua ` or ` master.lua ` .
77
+ This setting is mandatory for suites with diff-tests (` core = tarantool ` )
78
+ and ignored with other types of tests.
79
+
80
+ * ` config ` — name of a test configuration file, for example, ` engine.cfg ` .
81
+ For details, see the [ test configuration] ( #test-configuration ) section below.
82
+
83
+ * ` lua_libs ` — paths to Lua files that should be copied to the directory,
84
+ where a server is started. For example:
85
+
86
+ ``` ini
87
+ lua_libs = lua/require_mod.lua lua/serializer_test.lua lua/process_timeout.lua
88
+ ```
89
+
90
+ ### Disabling and skipping tests
91
+
92
+ A number of fields are used to disable certain tests:
93
+
94
+ * ` disabled ` — list of tests that should be skipped.
95
+
96
+ * ` release_disabled ` — list of tests that should only run when Tarantool is
97
+ built in the debug mode (with ` -DCMAKE_BUILD_TYPE=Debug ` and not ` =RelWithDebInfo ` ).
98
+ Tests that use error injections, which are only available in debug builds,
99
+ should always be ` release_disabled ` .
100
+
101
+ * ` valgrind_disabled ` — list of tests that should be skipped when Valgrind is enabled
102
+
103
+ * ` long_run ` — mark tests as long. Such tests will run only with ` --long ` option.
104
+
105
+ ``` ini
106
+ long_run = t1.test.lua t2.test.lua
107
+ ```
108
+
109
+ ### Other parameters
110
+
111
+ * ` show_reproduce_content ` (optional, ` True ` by default) — when set to ` True ` ,
112
+ show the contents of the reproduce file for each failed test.
113
+ Reproduce files are not required for investigating results of
114
+ tests that run each case in a separate Tarantool instance.
115
+ For such tests it makes sense to set ` show_reproduce_content = False ` .
116
+ (Implemented in [ #113 ] ( https://github.com/tarantool/test-run/issues/113 ) )
117
+
118
+ * ` is_parallel ` (optional, ` False ` by default) — whether the tests in the suite can run in parallel
119
+
120
+ * ` use_unix_sockets ` (optional, ` False ` by default) — use hard-coded UNIX sockets
121
+ * ` use_unix_sockets_iproto ` (optional, ` False ` by default) — use hard-coded UNIX sockets for IProto.
122
+
123
+ ### Fragile tests
124
+
125
+ Tests which fail sometimes due to external reasons can be marked as fragile (flaky).
126
+ Test-run will retry each test if it fails.
127
+ It's recommended to provide a list of related
128
+ [ tarantool/tarantool] ( https://github.com/tarantool/tarantool ) issues
129
+ next to each fragile test.
130
+
131
+ ``` ini
132
+ fragile = {
133
+ " retries" : 10,
134
+ " tests" : {
135
+ " tarantoolctl.test.lua" : {
136
+ " issues" : [ " gh-5059" , " gh-5346" ],
137
+ },
138
+ {...},
139
+ {...},
140
+ }
141
+ }
142
+ ```
143
+
144
+ ## Test composition
145
+
146
+ Each test consists of the following files:
147
+
148
+ * Test file: ` <name>.test.lua ` , ` <name>_test.lua ` , ` <name>.test.py ` , or ` <name>.test.sql ` .
149
+ * Reference file: ` <name>.result ` .
150
+ * Skip condition file: ` <name>.skipcond ` .
151
+
152
+ Reference file contains saved test output.
153
+ It is required for tests with non-TAP13 output.
154
+ Running ` test-run.py ` with ` --update-result ` option will update
155
+ the ` .result ` files with new test output.
156
+
157
+ The optional skip condition file is a Python script.
158
+ In the local Python environment of a test run there's a ` self ` object,
159
+ which is an instance of the [ ` Test ` class] ( ./lib/test.py ) .
160
+ Set ` self.skip = 1 ` to skip this test.
161
+
162
+
163
+ ## Test execution
164
+
165
+ Running a test begins with executing the ` .skipcond ` file.
166
+ If ` self.skip ` is set to ` 1 ` , test-run skips this test
167
+ and reports TODO.
168
+
169
+ Next, the test file is executed and the output is written to a ` .reject ` file.
170
+ If the output is TAP13-compatible, test-run validates it.
171
+ Otherwise, test-run compares it with the ` .result ` file.
172
+ If there's a difference between ` .reject ` and ` .result ` , the test fails and
173
+ the last 15 lines of diff are printed to output.
174
+
175
+ Whenever a test fails, the ` .reject ` file is saved in the ` <vardir>/rejects/<suite> `
176
+ subdirectory given in options or set locally as ` var/rejects/<suite> ` by default.
177
+ If the test is considered successful, the ` .reject ` file is deleted.
178
+
179
+ ## Test configuration
180
+
181
+ Test configuration file contains configuration for multiple runs.
182
+ For each test section, system runs a separate test and compares the result to the common ` .result ` file.
183
+ For example, we need to run a test with different DB engines (` "*" ` means the default
50
184
configuration):
51
185
52
186
``` json
@@ -62,15 +196,15 @@ configuration):
62
196
}
63
197
```
64
198
65
- In test case we can get configuration from inspector:
199
+ In the test case we can get configuration from the inspector:
66
200
67
201
``` lua
68
202
engine = test_run :get_cfg (' engine' )
69
203
-- first run engine is 'memtx'
70
204
-- second run engine is 'sophia'
71
205
```
72
206
73
- "engine" value has a special meaning for * .test.sql files: if it is "memtx" or
207
+ "engine" value has a special meaning for ` *.test.sql ` files: if it is "memtx" or
74
208
"vinyl", then the corresponding default engine will be set before executing
75
209
commands from a test file. An engine is set with the following commands:
76
210
@@ -79,11 +213,13 @@ UPDATE "_session_settings" SET "value" = 'memtx|vinyl' WHERE "name" = 'sql_defau
79
213
pragma sql_default_engine= ' memtx|vinyl'
80
214
```
81
215
82
- If the first fails, then the second will be executed. When both fails, fail the test.
216
+ If the first fails, then the second will be executed. When both fail, the test fails.
217
+
218
+ ## Writing various types of tests
83
219
84
- #### Python
220
+ ### Python tests
85
221
86
- Files: ` <name>.test.py ` , ` <name>.result ` and ` <name>.skipcond ` (optionaly ).
222
+ Files: ` <name>.test.py ` , ` <name>.result ` and ` <name>.skipcond ` (optionally ).
87
223
88
224
Environment:
89
225
@@ -166,14 +302,14 @@ box.info.lsn
166
302
...
167
303
```
168
304
169
- #### Lua
305
+ ### Lua
170
306
171
307
Files: ` <name>.test.lua ` , ` <name>.result ` and ` <name>.skipcond ` (optionaly).
172
308
Tests interact only with ` AdminConnection ` . Supports some preprocessor functions (eg ` delimiter ` )
173
309
174
310
** Delimiter example:**
175
311
176
- ```
312
+ ``` lua
177
313
env = require (' test_run' )
178
314
test_run = env .new ()
179
315
box .schema .space .create (' temp' )
194
330
195
331
** Delimiter result:**
196
332
197
- ```
333
+ ``` yaml
198
334
env = require('test_run')
199
335
test_run = env.new()
200
336
box.schema.space.create('temp')
@@ -255,14 +391,14 @@ function echo(...) \
255
391
end
256
392
```
257
393
258
- #### SQL
394
+ ### SQL
259
395
260
396
* .test.sql files are just SQL statements written line-by-line.
261
397
262
398
It is possible to mix SQL and Lua commands using ` \set language lua ` and `\set
263
399
language sql` commands.
264
400
265
- ##### Interaction with the test environment
401
+ ## Interaction with the test environment
266
402
267
403
In lua test you can use ` test_run ` module to interact with the test
268
404
environment.
@@ -337,7 +473,7 @@ test_run:cmd('setopt delimiter ""');
337
473
join (test_run , 30 )
338
474
```
339
475
340
- ### pretest_clean()
476
+ ## pretest_clean()
341
477
342
478
Nothing will be done before a Python test and for ` core = unittest `
343
479
test suites.
@@ -353,7 +489,7 @@ The following files will be removed:
353
489
* ` *.inprogress `
354
490
* ` [0-9]*/ `
355
491
356
- ### Tags
492
+ ## Tags
357
493
358
494
Usage:
359
495
@@ -409,7 +545,7 @@ Unsupported features:
409
545
* Marking unit tests with tags.
410
546
* Multiline comments (use singleline ones for now).
411
547
412
- ### Used By
548
+ ## Projects that use test-run
413
549
414
550
- [ Tarantool] ( https://github.com/tarantool/tarantool ) - in-memory database and application server
415
551
- [ memcached] ( https://github.com/tarantool/memcached ) - Memcached protocol 'wrapper' for Tarantool
0 commit comments