2
2
3
3
This directory contains Cylc functional tests.
4
4
5
+
5
6
## How To Run These Tests
6
7
7
8
``` console
9
+ # run all tests in this directory
8
10
$ etc/bin/run-functional-tests tests/f
9
11
10
- # 4 tests in parallel
11
- $ etc/bin/run-functional-tests tests/f
12
+ # run a specified test
13
+ $ etc/bin/run-functional-tests tests/f/cylc-cat-log/00-local.t
14
+
15
+ # run a specified test in debug mode
16
+ $ etc/bin/run-functional-tests -v tests/f/cylc-cat-log/00-local.t
17
+
18
+ # run tests with 5x parallelism
19
+ $ etc/bin/run-functional-tests -j 5 tests/f
12
20
13
21
# split the tests into 4 " chunks" and run the first chunk
14
22
$ CHUNK=' 1/4' etc/bin/run-functional-tests tests/f
@@ -20,6 +28,7 @@ $ etc/bin/run-functional-tests tests/f
20
28
$ coverage combine
21
29
```
22
30
31
+
23
32
## What Are Functional Tests?
24
33
25
34
These tests ensure end-to-end functionality is as expected.
@@ -30,6 +39,48 @@ cause many parts of the system (and other systems) to be activated.
30
39
This includes interaction with other systems (e.g. batch schedulers/job runners),
31
40
command line interfaces / outputs, etc.
32
41
42
+
43
+ ## How Are Tests Implemented
44
+
45
+ Tests are written in files with the ` .t ` extension. These are Bash scripts
46
+ (despite the file extension). The tests are run with a tool called ` prove `
47
+ which is invoked via the ` etc/bin/run-functional-tests ` command.
48
+
49
+ Each test file starts by sourcing the file ` lib/bash/test_header ` , this
50
+ contains various Bash functions which provide assertion functions, e.g.
51
+ ` run_ok ` (which asserts that the provided command succeeds).
52
+
53
+ Assertions run a command, then write either ` ok ` or ` not ok ` to stdout, prove
54
+ then scrapes this output to determine test outcome.
55
+
56
+ Each assertion (or subtest) needs a name, this is usually the first argument
57
+ to the function. You should use the prefix ` $TEST_NAME_BASE ` , e.g, this
58
+ assertion tests that the command ` sleep 10 ` succeeds
59
+ ` run_ok "${TEST_NAME_BASE}-sleep" sleep 10 ` . Note, some assertions infer the
60
+ test name for you from the arguments.
61
+
62
+ For the list of available assertions, and usage info, see the comments at the
63
+ top of ` lib/bash/test_header ` .
64
+
65
+ Each test file needs to declare the number of subtests within it, this is
66
+ done with the function ` set_test_number ` which must be run at the start of the
67
+ test.
68
+
69
+ Many tests install workflows for testing. These are installed into cylc-run as
70
+ usual under the prefix ` cylctb ` .
71
+
72
+
73
+ ## How To Debug Failing Tests
74
+
75
+ * Run the test using the ` -v ` argument, this will reveal which subtest(s)
76
+ failed.
77
+ * Some tests reveal extra debug info when you set ` CYLC_TEST_DEBUG=true ` .
78
+ * If the test fails, any workflows installed into the ` ~/cylc-run/cylctb??? `
79
+ directory will not be deleted, you can inspect the workflow logs there.
80
+ * In GitHub actions, the ` ~/cylc-run ` directory is uploaded as an "artifact"
81
+ where it can be downloaded for debugging.
82
+
83
+
33
84
## How To Run "Non-Generic" Tests?
34
85
35
86
Some tests require job runners (e.g. at, slurm, pbs), remote platforms or
@@ -62,6 +113,7 @@ $ etc/bin/run-functional-tests -p '_*at*' tests/f
62
113
$ etc/bin/run-functional-tests -p ' *' tests/f
63
114
```
64
115
116
+
65
117
## Test Platform Names
66
118
67
119
Each platform is named using this convention:
@@ -100,6 +152,7 @@ Define any test platforms in your global config e.g:
100
152
hosts = my_remote_host
101
153
```
102
154
155
+
103
156
## Test Global Config
104
157
105
158
Cylc supports a ` global-tests.cylc ` file which can be used to define some
@@ -108,6 +161,7 @@ top-level configurations to run tests with.
108
161
Do not use this file to define test platforms, put them in your regular global
109
162
config where they can also be used for interactive work.
110
163
164
+
111
165
## How To Configure "Non-Generic" Tests?
112
166
113
167
By default tests require the platform ` _local_background_indep_tcp ` .
@@ -143,6 +197,7 @@ export REQUIRE_PLATFORM='runner:*'
143
197
export REQUIRE_PLATFORM=' loc:remote runner:*'
144
198
```
145
199
200
+
146
201
## Guidelines
147
202
148
203
Don't write functional tests when you can write integration tests:
0 commit comments