Skip to content

Commit 6d2fb11

Browse files
authored
Stability fixes (#2860)
1 parent 100c0a9 commit 6d2fb11

File tree

41 files changed

+3112
-239
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3112
-239
lines changed

.agents/skills/testing/SKILL.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
name: testing
3+
description: "Running and debugging tests in the Golem workspace. Use when writing tests, running specific tests, filtering tests, debugging test failures, or understanding test infrastructure."
4+
---
5+
6+
# Testing in Golem
7+
8+
Tests use [test-r](https://test-r.vigoo.dev). Each test file **must** import `test_r::test` or the tests will silently not run:
9+
10+
```rust
11+
use test_r::test;
12+
13+
#[test]
14+
fn my_test() {
15+
// ...
16+
}
17+
```
18+
19+
## Choosing the Right Test Command
20+
21+
**Do not run `cargo make test`** — it runs all tests and takes a very long time.
22+
23+
| Change Type | Test Command |
24+
|-------------|--------------|
25+
| Core logic, utilities | `cargo make unit-tests` |
26+
| Worker executor functionality | `cargo make worker-executor-tests` |
27+
| Service integration | `cargo make integration-tests` |
28+
| CLI changes | `cargo make cli-tests` |
29+
30+
**Whenever tests are modified, always run the affected tests to verify they still pass before considering the task complete.**
31+
32+
For running specific tests during development:
33+
```shell
34+
cargo test -p <crate> -- <test_name> --report-time
35+
```
36+
37+
## Test Filtering Rules (test-r)
38+
39+
This project uses `test-r` which supports **multiple filter arguments after `--`**. Filters are OR-matched (a test runs if it matches any filter). Each filter is a **substring match**, not a regex.
40+
41+
```shell
42+
# Run a single specific test:
43+
cargo test -p <crate> -- <test_name> --report-time
44+
45+
# Run multiple specific tests (filters go AFTER --, not before):
46+
cargo test -p <crate> -- test_name_1 test_name_2 test_name_3 --report-time
47+
48+
# WRONG - multiple filters before -- causes "unexpected argument" error:
49+
# cargo test -p <crate> test1 test2 -- --report-time
50+
51+
# WRONG - regex patterns don't work (filters are substring matches, not regex):
52+
# cargo test -p <crate> -- "test_a|test_b" --report-time
53+
# cargo test -p <crate> -- "test_.*pattern" --report-time
54+
```
55+
56+
**Note:** `--list` in test-r ignores filters and always lists all tests. Do not use `--list` to verify that filters are working. Instead, do a real run and check the `filtered out` count in the result line.
57+
58+
## Debugging Test Failures
59+
60+
Use `--nocapture` when debugging tests:
61+
```shell
62+
cargo test -p <crate> -- <test> --nocapture
63+
```
64+
65+
**Always save test output to a file** when running worker executor tests, integration tests, or CLI tests. These tests are slow and produce potentially thousands of lines of logs. Never pipe output directly to `grep`, `head`, `tail`, etc. — if you need to examine different parts of the output, you would have to re-run the entire slow test. Instead:
66+
```shell
67+
cargo test -p <crate> -- <test> --nocapture > tmp/test_output.txt 2>&1
68+
# Then search/inspect the saved file as needed
69+
grep -n "pattern" tmp/test_output.txt
70+
```
71+
72+
**Handling hanging tests:** Load the `debugging-hanging-tests` skill for a step-by-step workflow.
73+
74+
## Test Components
75+
76+
Worker executor tests and integration tests use pre-compiled WASM files from the `test-components/` directory. These are checked into the repository and **rebuilding them is not automated**. Do not attempt to rebuild test components — use the existing compiled WASM files, EXCEPT if the test component itself has an AGENTS.md file with instructions of how to do so.
77+
78+
Load the `modifying-test-components` skill when rebuilding is needed.
79+
80+
## Timeouts
81+
82+
Add a `#[timeout]` attribute for tests that should fail rather than hang:
83+
84+
```rust
85+
use test_r::test;
86+
use test_r::timeout;
87+
88+
#[test]
89+
#[timeout("30s")]
90+
async fn my_test() {
91+
// ...
92+
}
93+
```
94+
95+
Choose a timeout generous enough for normal execution but short enough to fail quickly when hung (30s–60s for most tests, up to 120s for complex integration tests).

.github/workflows/ci.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ jobs:
158158
if: always()
159159
with:
160160
report-path: "**/target/ctrf-*.json"
161+
upload-artifact: 'true'
162+
artifact-name: unit-tests-report
161163
summary: true
162164
summary-report: true
163165
failed-report: true
@@ -230,6 +232,8 @@ jobs:
230232
if: always()
231233
with:
232234
report-path: "**/target/ctrf-*.json"
235+
upload-artifact: 'true'
236+
artifact-name: worker-executor-tests-${{ matrix.group.name }}-report
233237
summary: true
234238
summary-report: true
235239
failed-report: true
@@ -339,6 +343,8 @@ jobs:
339343
if: always()
340344
with:
341345
report-path: "**/target/ctrf-*.json"
346+
upload-artifact: 'true'
347+
artifact-name: '${{ matrix.group.name }}-report'
342348
summary: true
343349
summary-report: true
344350
failed-report: true

AGENTS.md

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,9 @@ Always run `cargo make build` before starting work to ensure all dependencies ar
2626

2727
## Testing
2828

29-
Tests use [test-r](https://test-r.vigoo.dev). **Important:** Each test file must import `test_r::test` or tests will not run:
29+
Tests use [test-r](https://test-r.vigoo.dev). **Important:** Each test file must import `test_r::test` or tests will not run.
3030

31-
```rust
32-
use test_r::test;
33-
34-
#[test]
35-
fn my_test() {
36-
// ...
37-
}
38-
```
39-
40-
**Do not run `cargo make test`** - it runs all tests and takes a very long time. Instead, choose the appropriate test command:
31+
**Do not run `cargo make test`** — it runs all tests and takes a very long time. Instead, choose the appropriate test command:
4132

4233
| Change Type | Test Command |
4334
|-------------|--------------|
@@ -46,18 +37,11 @@ fn my_test() {
4637
| Service integration | `cargo make integration-tests` |
4738
| CLI changes | `cargo make cli-tests` |
4839

49-
**Whenever tests are modified, always run the affected tests to verify they still pass before considering the task complete.**
40+
For specific tests: `cargo test -p <crate> -- <test_name> --report-time`
5041

51-
For specific tests during development:
52-
```shell
53-
cargo test -p <crate> <test_module> -- --report-time
54-
```
55-
56-
## Test Components
57-
58-
Worker executor tests and integration tests use pre-compiled WASM files from the `test-components/` directory. These are checked into the repository and **rebuilding them is not automated**. Do not attempt to rebuild test components - use the existing compiled WASM files, EXCEPT if the test component itself has an AGENTS.md file with instructions of how to do so.
42+
**Whenever tests are modified, always run the affected tests to verify they still pass before considering the task complete.**
5943

60-
Load the `modifying-test-components` skill when rebuilding is needed.
44+
Load the `testing` skill for detailed guidance on test filtering, debugging failures, test components, and timeouts.
6145

6246
## Running Locally
6347

@@ -74,6 +58,7 @@ Load these skills for guided workflows on complex tasks:
7458
|-------|-------------|
7559
| `modifying-http-endpoints` | Adding or modifying REST API endpoints (covers OpenAPI regeneration, golem-client rebuild, type mappings) |
7660
| `adding-dependencies` | Adding or updating crate dependencies (covers workspace dependency management, versioning, features) |
61+
| `testing` | Running and debugging tests (covers test filtering, debugging failures, test components, timeouts) |
7762
| `debugging-hanging-tests` | Diagnosing worker executor or integration tests that hang indefinitely |
7863
| `modifying-test-components` | Building or modifying test WASM components, or rebuilding after SDK changes |
7964
| `modifying-wit-interfaces` | Adding or modifying WIT interfaces and synchronizing across sub-projects |
@@ -101,22 +86,6 @@ This runs `rustfmt` and `clippy` with automatic fixes. Load `pre-pr-checklist` s
10186

10287
All crate dependencies must have their versions specified in the root workspace `Cargo.toml` under `[workspace.dependencies]`. Workspace members must reference them using `x = { workspace = true }` in their own `Cargo.toml` rather than specifying versions directly.
10388

104-
## Debugging Tests
105-
106-
Use `--nocapture` when debugging tests to allow debugger attachment:
107-
```shell
108-
cargo test -p <crate> <test> -- --nocapture
109-
```
110-
111-
**Always save test output to a file** when running worker executor tests, integration tests, or CLI tests. These tests are slow and produce potentially thousands of lines of logs. Never pipe output directly to `grep`, `head`, `tail`, etc. — if you need to examine different parts of the output, you would have to re-run the entire slow test. Instead:
112-
```shell
113-
cargo test -p <crate> <test> -- --nocapture > tmp/test_output.txt 2>&1
114-
# Then search/inspect the saved file as needed
115-
grep -n "pattern" tmp/test_output.txt
116-
```
117-
118-
**Handling hanging tests:** Load the `debugging-hanging-tests` skill for a step-by-step workflow.
119-
12089
## Project Structure
12190

12291
- `golem-worker-executor/` - Worker execution engine

Cargo.lock

Lines changed: 24 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ system-interface = "0.27.3"
239239
tap = "1.0.1"
240240
tempfile = "3.18.0"
241241
terminal_size = "0.4.2"
242-
test-r = { version = "3.0.0", default-features = true }
242+
test-r = { version = "3.0.3", default-features = true }
243243
testcontainers = { version = "0.23.3" }
244244
testcontainers-modules = { version = "0.11.6", features = ["postgres", "redis", "minio", "mysql", ] }
245245
textwrap = "0.16.1"

golem-common/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ semver = { workspace = true, optional = true }
132132
[dev-dependencies]
133133
anyhow = { workspace = true }
134134
assert2 = { workspace = true }
135+
futures = { workspace = true }
135136
pretty_assertions = { workspace = true }
136137
proptest = { workspace = true }
137138
test-r = { workspace = true }

0 commit comments

Comments
 (0)