Skip to content

Commit ed5cd3c

Browse files
Merge pull request #6900 from oliver-sanders/dev-docs++
improve dev docs
2 parents df72a56 + 0957507 commit ed5cd3c

File tree

2 files changed

+61
-6
lines changed

2 files changed

+61
-6
lines changed

tests/flakyfunctional/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Flaky Functional Tests
22

3-
This directory contains tests that are sensitive to timing, server load, etc.
3+
This directory contains functional tests that are sensitive to timing, server
4+
load, etc.
5+
6+
For more information on functional tests, see ../functional/README.md.
47

58
## How To Run These Tests
69

710
```console
811
$ etc/bin/run-functional-tests tests/k
912

10-
# 4 tests in parallel
11-
$ etc/bin/run-functional-tests tests/k
12-
1313
# split the tests into 4 "chunks" and run the first chunk
1414
$ CHUNK='1/4' etc/bin/run-functional-tests tests/k
1515
```

tests/functional/README.md

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,21 @@
22

33
This directory contains Cylc functional tests.
44

5+
56
## How To Run These Tests
67

78
```console
9+
# run all tests in this directory
810
$ etc/bin/run-functional-tests tests/f
911

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
1220

1321
# split the tests into 4 "chunks" and run the first chunk
1422
$ CHUNK='1/4' etc/bin/run-functional-tests tests/f
@@ -20,6 +28,7 @@ $ etc/bin/run-functional-tests tests/f
2028
$ coverage combine
2129
```
2230

31+
2332
## What Are Functional Tests?
2433

2534
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.
3039
This includes interaction with other systems (e.g. batch schedulers/job runners),
3140
command line interfaces / outputs, etc.
3241

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+
3384
## How To Run "Non-Generic" Tests?
3485

3586
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
62113
$ etc/bin/run-functional-tests -p '*' tests/f
63114
```
64115

116+
65117
## Test Platform Names
66118

67119
Each platform is named using this convention:
@@ -100,6 +152,7 @@ Define any test platforms in your global config e.g:
100152
hosts = my_remote_host
101153
```
102154

155+
103156
## Test Global Config
104157

105158
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.
108161
Do not use this file to define test platforms, put them in your regular global
109162
config where they can also be used for interactive work.
110163

164+
111165
## How To Configure "Non-Generic" Tests?
112166

113167
By default tests require the platform `_local_background_indep_tcp`.
@@ -143,6 +197,7 @@ export REQUIRE_PLATFORM='runner:*'
143197
export REQUIRE_PLATFORM='loc:remote runner:*'
144198
```
145199

200+
146201
## Guidelines
147202

148203
Don't write functional tests when you can write integration tests:

0 commit comments

Comments
 (0)