Skip to content

Commit 281760c

Browse files
committed
final updates to the docs on running unit tests in status-go
1 parent 37b0141 commit 281760c

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

10 Notes/Running Unit Tests for status-go.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ The obvious
121121
make test
122122
```
123123
124-
is a mistery to me as looking at the source code, it looks it has no chance to succeed without some extra steps.
124+
a number of tests will most certainly. To understand the root cause, let's investigate a bit.
125125
126-
`make test` uses `_assets/scripts/run_unit_tests.sh`, where we find the following fragment:
126+
`make test` uses `_assets/scripts/run_unit_tests.sh` under the hood, where we find the following fragment:
127127
128128
```bash
129129
if [[ $HAS_PROTOCOL_PACKAGE == 'false' ]]; then
@@ -144,14 +144,14 @@ else
144144
fi
145145
```
146146
147-
From the comments, we see that the `else` branch will be used. It is split into two parts:
147+
From the comments, we see that the `else` branch is currently used when running the tests. It splits running tests into two parts:
148148
149149
1. All the tests except for the tests for `status-go/protocol` module, those are faster, which is reflected in the the shorter timeout: `DEFAULT_TIMEOUT_MINUTES=5`.
150-
2. The `protocol tests` - slower (`PROTOCOL_TIMEOUT_MINUTES=45`). By default `UNIT_TEST_COUNT=1`.
150+
2. The `protocol tests` - there are many of them (over 900) and can take longer to run (`PROTOCOL_TIMEOUT_MINUTES=45`). By default `UNIT_TEST_COUNT=1`, which means it tries to run the protocol tests only once.
151151
152-
For our regular development, we may not like to run all tests. In particular, the `protocol` tests seem to be less relevant to our use case of message history archives. Thus, in what follows I am skipping the longer protocol tests.
152+
> The timeout variables `DEFAULT_TIMEOUT_MINUTES` and `PROTOCOL_TIMEOUT_MINUTES` are used as the value of the `-timeout` option passed down to `go test`. It limits the time all the tests are allowing to take.
153153
154-
Now, if you run `make test` the tests will fail:
154+
We may observe more or less failures, depending on the run, but one test will consistently fail, even if we modify the script to only run non-protocol tests: `TestBasicWakuV2`:
155155
156156
```bash
157157
=== RUN TestBasicWakuV2
@@ -163,7 +163,7 @@ Now, if you run `make test` the tests will fail:
163163
--- FAIL: TestBasicWakuV2 (0.00s)
164164
```
165165
166-
Indeed, we can confirm it by running just the `TestBasicWakuV2`:
166+
Let's try to run this test without using the `run_unit_tests.sh` script to confirm the problem:
167167
168168
```bash
169169
gotestsum --packages="./messaging/waku" -f testname --rerun-fails -- \
@@ -174,7 +174,7 @@ gotestsum --packages="./messaging/waku" -f testname --rerun-fails -- \
174174
175175
and we will get the same error.
176176
177-
If we look into source code of `messaging/waku/waku_test.go`, and scroll down a bit (!!), we will find the following comment:
177+
If we look into source code of `messaging/waku/waku_test.go` where `TestBasicWakuV2` is defined, and scroll down a bit (!!), we will find the following comment:
178178
179179
```go
180180
// In order to run these tests, you must run an nwaku node
@@ -257,7 +257,7 @@ PASS messaging/waku
257257
DONE 14 tests, 1 skipped in 33.720s
258258
```
259259
260-
Now, we should also be able to successfully run all the tests using `make test`:
260+
Now, we should also be able to successfully run all the non-protocol tests using `make test`:
261261
262262
```bash
263263
make test
@@ -341,25 +341,25 @@ DONE 2 tests in 0.307s
341341
342342
### Running "protocol" tests
343343
344-
I only run all the tests (including `protocol` tests) using `make test` once. Got most of the test pass, but not all. To get a better feedback and to track progress, I prefer to run them using `gotestsum` command:
344+
When runing all the tests (including `protocol` tests) using `make test`, most of the tests pass, but not all. As already indicated above, in order to get a better feedback and to track progress, I prefer to run them using `gotestsum` command:
345345
346346
```bash
347347
gotestsum --packages="./protocol" -f testname --rerun-fails -- -count 1 -timeout "45m" -tags "gowaku_no_rln gowaku_skip_migrations" | tee "test_1.log"
348348
349349
DONE 964 tests, 5 skipped in 1159.570s
350350
```
351351
352-
Redirecting output to a file is pretty much needed as `protocol` tests generate more output.
352+
Redirecting output to a file using `tee` is pretty much needed as `protocol` tests may generate a lot of log messages.
353353
354-
Here just for the record - an example failing session:
354+
Here - just for the record - an example failing session:
355355
356356
```bash
357357
gotestsum --packages="./protocol" -f testname --rerun-fails -- -count 1 -timeout "45m" -tags "gowaku_no_rln gowaku_skip_migrations" | tee "test_1.log
358358
359359
DONE 3 runs, 968 tests, 5 skipped, 6 failures in 1194.882s
360360
```
361361
362-
So, the reason I recorded it, is that the output can be pretty misleading if you are seeing this output for the first time. The `6 failures` is actually $1$ (one) failing test:
362+
So, the reason I recorded it here, is that the output can be pretty misleading if you are seeing this output for the first time. The `6 failures` is actually $1$ (one) failing test:
363363
364364
```bash
365365
TestMessengerCommunitiesTokenPermissionsSuite/TestAnnouncementsChannelPermissions
@@ -416,3 +416,5 @@ DONE 2 tests in 1.453s
416416
...
417417
DONE 3 runs, 6 tests, 4 failures in 27.876s
418418
```
419+
420+
Thus, being able to run all the tests successfully a number of time, we should be allowed to conclude that our setup is correct.

0 commit comments

Comments
 (0)