Skip to content

Commit b6cd0d7

Browse files
authored
Merge pull request #5 from hisoka-io/fix-flaky-cache-timing-assert
flaky-test fix
2 parents c556385 + 10b75b0 commit b6cd0d7

164 files changed

Lines changed: 1259 additions & 4902 deletions

File tree

Some content is hidden

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

.config/nextest.toml

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,14 @@
1-
# nextest config for the raven workspace. Loaded by `cargo nextest run`.
2-
# Does NOT affect `cargo test` invocations.
3-
#
4-
# Why this exists: 109+ release-mode test binaries. `cargo test` runs
5-
# binaries SEQUENTIALLY (parallelism only within a binary via
6-
# --test-threads). nextest builds all binaries first, then runs them
7-
# all in parallel processes, saturating cores across binaries. On this
8-
# 16-core box that translates to a 2-4× wall-time reduction on full
9-
# workspace test runs.
10-
#
11-
# Usage:
12-
# cargo nextest run # all default tests
13-
# cargo nextest run --release # release-mode (matches CI)
14-
# cargo nextest run -p raven-railgun-cli # single crate
15-
# cargo nextest run --features chaos-tests # include chaos
16-
# cargo nextest run --no-fail-fast # don't bail on first failure
17-
#
18-
# Doc tests are NOT run by nextest; use `cargo test --doc` for those.
1+
# nextest config for the raven workspace; does not affect `cargo test`.
192

203
[profile.default]
21-
# Retry once on flake (network-touching tests, port-bind races); a real
22-
# bug surfaces after the second pass too.
4+
# absorb network/port-bind flake; a real bug fails the retry too
235
retries = 1
24-
# Surface progress as tests run, not just at the end. Helps when a
25-
# single binary stalls a long run.
266
status-level = "pass"
277
final-status-level = "fail"
28-
# Capture both stdout and stderr; surface only on failure.
298
failure-output = "immediate"
309
success-output = "never"
31-
32-
# Slow-test detection. Tests over 60s in release mode are exceptional
33-
# (only chaos children + production-cell #[ignore]'d ones). Surface
34-
# them so the slow-tail is visible.
3510
slow-timeout = { period = "60s", terminate-after = 5 }
3611

37-
# CI profile: stricter — no retries (fail loudly so flakes get fixed),
38-
# JSON output for parsing. Activate via `cargo nextest run --profile ci`.
3912
[profile.ci]
4013
retries = 0
4114
status-level = "all"
@@ -44,16 +17,8 @@ failure-output = "final"
4417
success-output = "never"
4518
slow-timeout = { period = "120s", terminate-after = 3 }
4619

47-
# Test groups: serialize tests that fight on global resources. Each
48-
# group is allowed ONE test at a time across the whole run.
49-
#
50-
# - chaos-subprocess: tests that fork+SIGKILL a child binary. They share
51-
# the same child-binary executable, port binds, /tmp dirs, and have
52-
# long teardown. Running them concurrent triggers race conditions
53-
# that the production code does not have to handle.
54-
# - flock-tests: tests that take an flock on a shared data_dir layout.
55-
# Rare, but already-once a real source of flake.
56-
20+
# serialize tests that contend on shared global resources (child binary,
21+
# port binds, /tmp dirs, flock on a shared data_dir): one at a time
5722
[test-groups]
5823
chaos-subprocess = { max-threads = 1 }
5924
flock-tests = { max-threads = 1 }

.dockerignore

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
# Docker build context filter. Build context is the repo root
2-
# (the railgun adapter path-depends on ../../crates/inspire).
1+
# Build context is the repo root (the adapter path-depends on ../../crates/inspire).
32

4-
# Build outputs.
53
target/
64
**/target/
75

8-
# Secrets + local-only AI/context. NEVER ship to the daemon or image.
6+
# secrets + local-only AI/context; never ship to the daemon or image
97
run/
108
no-commit/
119
.claude/
@@ -16,17 +14,14 @@ CLAUDE.*.md
1614
MEMORY.md
1715
.mcp.json
1816

19-
# VCS internals. The submodule SOURCE under crates/inspire/ is kept;
20-
# only the gitlink/.git metadata is dropped.
17+
# drop the gitlink metadata but keep the crates/inspire source
2118
.git/
2219
**/.git
2320

24-
# Node / wasm-pack scratch.
2521
**/node_modules/
2622
**/pkg-node/
2723
**/pkg-bundler/
2824

29-
# Editor / OS cruft.
3025
**/.DS_Store
3126
**/*.swp
3227
**/.idea/

.github/workflows/ci.yml

Lines changed: 9 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ jobs:
7373
railgun-static:
7474
name: railgun adapter (fmt + check + clippy)
7575
runs-on: ubuntu-latest
76-
# fmt + cargo check + clippy land in ~5-8 min on the 2-vCPU runner
77-
# because they skip codegen + link. Cap at 30 min so a hung tool
78-
# surfaces fast instead of blocking the matrix.
76+
# cap so a hung tool surfaces instead of blocking the matrix
7977
timeout-minutes: 30
8078
steps:
8179
- uses: actions/checkout@v4
@@ -107,26 +105,8 @@ jobs:
107105
run: cargo clippy --manifest-path adapters/railgun/Cargo.toml --workspace --all-targets -- -D warnings
108106

109107
railgun-tests:
110-
# Test execution is the wall-time floor of CI: the 9-crate adapter +
111-
# raven-inspire submodule build, under `release`, took ~48 min on a
112-
# 2-vCPU runner. Four stacked optimisations bring it under ~20 min:
113-
#
114-
# 1. `[profile.ci-test]` in adapters/railgun/Cargo.toml
115-
# (lto=off, codegen-units=16, opt-level=2) — saturates both
116-
# cores during codegen and drops the ~120-binary thin-LTO link
117-
# pass.
118-
# 2. lld linker via RUSTFLAGS — parallel symbol resolution, ~25%
119-
# off the link phase vs the default bfd ld.
120-
# 3. sccache w/ GHA-cache backend — caches individual rustc
121-
# invocations across runs. Cold = no win; warm = ~70-80% hit
122-
# on the inspire dep closure (the dominant cost).
123-
# 4. Matrix split — three parallel runners by package group.
124-
# Wall time = max(shard), not sum.
125-
#
126-
# Each shard groups packages so the per-shard test count is roughly
127-
# balanced (engine=45, cli=23, rest=40 integration-test files).
128-
# `fail-fast: false` lets a single shard fail without cancelling the
129-
# others, which speeds debugging.
108+
# split into three balanced shards (ci-test profile + lld + sccache)
109+
# to keep the adapter + inspire test build under the time budget
130110
name: railgun tests (${{ matrix.shard.name }})
131111
needs: railgun-static
132112
runs-on: ubuntu-latest
@@ -149,24 +129,13 @@ jobs:
149129
-p raven-railgun-ppoi-mirror
150130
-p raven-railgun-core
151131
env:
152-
# sccache: official Mozilla wrapper. GHA backend ships with the
153-
# action; `SCCACHE_GHA_ENABLED=true` is consumed by the action
154-
# itself. Setting RUSTC_WRAPPER here makes cargo route every rustc
155-
# invocation through sccache for the rest of the job.
156132
RUSTC_WRAPPER: sccache
157133
SCCACHE_GHA_ENABLED: "true"
158-
# lld linker. `.cargo/config.toml` carries the same flag for local
159-
# dev; setting it via RUSTFLAGS overrides any nested config that
160-
# would re-pin the default ld. -D warnings is preserved from the
161-
# workflow-level env to keep build-time lint posture identical.
134+
# re-declare -D warnings since RUSTFLAGS overrides the workflow-level env
162135
RUSTFLAGS: "-D warnings -C link-arg=-fuse-ld=lld"
163136
steps:
164137
- name: free disk space
165-
# The adapter workspace's target/ tree (10 inner crates, full
166-
# test build with --all-targets) exceeds the runner's default
167-
# ~14 GiB free budget. Strip pre-installed tooling that the
168-
# Rust build path does not touch (CodeQL, Android SDK, .NET,
169-
# Haskell, Docker pre-pulls) to free ~30 GiB.
138+
# adapter target/ tree overruns the runner's default free budget
170139
run: |
171140
sudo rm -rf /usr/share/dotnet
172141
sudo rm -rf /usr/local/lib/android
@@ -182,33 +151,14 @@ jobs:
182151
- name: install lld linker
183152
run: sudo apt-get update && sudo apt-get install -y lld
184153
- name: install sccache
185-
# v0.0.10 ships sccache 0.10+ which uses the GHA cache service
186-
# v2 endpoint. v0.0.6 still pinned sccache 0.8.x against the
187-
# decommissioned classic /artifactcache endpoint and 400'd on
188-
# every run.
154+
# v0.0.10 ships sccache 0.10+ for the GHA cache v2 endpoint
189155
uses: mozilla-actions/sccache-action@v0.0.10
190156
- uses: Swatinem/rust-cache@v2
191157
with:
192-
# Shared cache across all three matrix shards so the second
193-
# and third shards reuse the first shard's saved target/ tree.
194-
# Without this, each shard would rebuild raven-inspire cold.
158+
# shared so shards reuse the first shard's target/ instead of rebuilding inspire cold
195159
shared-key: "railgun-tests"
196160
- uses: taiki-e/install-action@nextest
197161
- name: cargo nextest (ci-test profile)
198-
# `ci-test` profile (see adapters/railgun/Cargo.toml): inherits
199-
# release semantics for runtime perf (so the InsPIRe respond
200-
# path stays under nextest's 120s slow-test ceiling) but with
201-
# lto=off + codegen-units=16 for compile parallelism.
202-
#
203-
# `--profile ci` selects the nextest profile in
204-
# adapters/railgun/.config/nextest.toml: retries=0, JSON-only
205-
# failure output, 120s slow-timeout × 3 strikes, test-groups
206-
# serialising chaos-child / flock / arcswap stress tests.
207-
#
208-
# Doc-tests skipped: the adapter workspace has zero `///`
209-
# Rust doctests today; `cargo test --doc` would re-build every
210-
# dep from scratch for no coverage. Re-add the step if a real
211-
# doctest lands later.
212162
run: |
213163
cargo nextest run \
214164
--manifest-path adapters/railgun/Cargo.toml \
@@ -217,10 +167,6 @@ jobs:
217167
--cargo-profile ci-test \
218168
--profile ci
219169
- name: sccache stats
220-
# Surface cache-hit rate so we can tell whether the warm-run
221-
# speedup is materialising. First run will show ~0% hit; second
222-
# run on the same branch should show >50% hit on the inspire
223-
# dep closure.
224170
run: sccache --show-stats
225171
if: always()
226172

@@ -269,14 +215,8 @@ jobs:
269215
run: cargo check --manifest-path crates/binary-fuse-filter/Cargo.toml --target wasm32-unknown-unknown
270216

271217
sdk-tests:
272-
# Fresh-clone-build gate: the TypeScript SDK at adapters/railgun/sdk
273-
# depends on the wasm-pack output of raven-inspire-client-wasm
274-
# (gitignored). A fresh clone must:
275-
# 1. Build the wasm-pack pkg-node + pkg-bundler outputs.
276-
# 2. Stay under the 500 KB gzipped bundle ceiling
277-
# (adapters/railgun/scripts/check-wasm-bundle-size.sh).
278-
# 3. `pnpm install` resolve cleanly against pnpm-lock.yaml.
279-
# 4. `pnpm test` pass against the freshly built pkg-node.
218+
# fresh-clone gate: SDK depends on the gitignored wasm-pack output,
219+
# so this rebuilds it, enforces the bundle ceiling, then runs tests
280220
name: sdk tests (typescript + wasm-pack)
281221
runs-on: ubuntu-latest
282222
steps:

.gitignore

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ target/
1414
no-commit/
1515
.claude/
1616
.agent/
17-
CLAUDE.md
17+
CLAUDE.*
1818
MEMORY.md
1919
tmp/
2020
.code-review-graph/
21-
22-
# Cargo lock is committed for binaries + workspaces
23-
# (keep default: commit Cargo.lock)
21+
.mcp.json
22+
run/

adapters/railgun/.config/nextest.toml

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,14 @@
1-
# nextest config for the raven workspace. Loaded by `cargo nextest run`.
2-
# Does NOT affect `cargo test` invocations.
3-
#
4-
# Why this exists: 109+ release-mode test binaries. `cargo test` runs
5-
# binaries SEQUENTIALLY (parallelism only within a binary via
6-
# --test-threads). nextest builds all binaries first, then runs them
7-
# all in parallel processes, saturating cores across binaries. On this
8-
# 16-core box that translates to a 2-4× wall-time reduction on full
9-
# workspace test runs.
10-
#
11-
# Usage:
12-
# cargo nextest run # all default tests
13-
# cargo nextest run --release # release-mode (matches CI)
14-
# cargo nextest run -p raven-railgun-cli # single crate
15-
# cargo nextest run --features chaos-tests # include chaos
16-
# cargo nextest run --no-fail-fast # don't bail on first failure
17-
#
18-
# Doc tests are NOT run by nextest; use `cargo test --doc` for those.
1+
# nextest config for the railgun adapter workspace; does not affect `cargo test`.
192

203
[profile.default]
21-
# Retry once on flake (network-touching tests, port-bind races); a real
22-
# bug surfaces after the second pass too.
4+
# absorb network/port-bind flake; a real bug fails the retry too
235
retries = 1
24-
# Surface progress as tests run, not just at the end. Helps when a
25-
# single binary stalls a long run.
266
status-level = "pass"
277
final-status-level = "fail"
28-
# Capture both stdout and stderr; surface only on failure.
298
failure-output = "immediate"
309
success-output = "never"
31-
32-
# Slow-test detection. Tests over 60s in release mode are exceptional
33-
# (only chaos children + production-cell #[ignore]'d ones). Surface
34-
# them so the slow-tail is visible.
3510
slow-timeout = { period = "60s", terminate-after = 5 }
3611

37-
# CI profile: stricter — no retries (fail loudly so flakes get fixed),
38-
# JSON output for parsing. Activate via `cargo nextest run --profile ci`.
3912
[profile.ci]
4013
retries = 0
4114
status-level = "all"
@@ -44,16 +17,8 @@ failure-output = "final"
4417
success-output = "never"
4518
slow-timeout = { period = "120s", terminate-after = 3 }
4619

47-
# Test groups: serialize tests that fight on global resources. Each
48-
# group is allowed ONE test at a time across the whole run.
49-
#
50-
# - chaos-subprocess: tests that fork+SIGKILL a child binary. They share
51-
# the same child-binary executable, port binds, /tmp dirs, and have
52-
# long teardown. Running them concurrent triggers race conditions
53-
# that the production code does not have to handle.
54-
# - flock-tests: tests that take an flock on a shared data_dir layout.
55-
# Rare, but already-once a real source of flake.
56-
20+
# serialize tests that contend on shared global resources (child binary,
21+
# port binds, /tmp dirs, flock on a shared data_dir): one at a time
5722
[test-groups]
5823
chaos-subprocess = { max-threads = 1 }
5924
flock-tests = { max-threads = 1 }

adapters/railgun/Cargo.toml

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
# Standalone workspace. Excluded from the raven root workspace because it
2-
# pulls heavy transitive deps (axum + tokio + reqwest, once more crates land)
3-
# that would feature-unify into the wasm32 build of the core crates.
4-
#
5-
# Build everything:
6-
# cargo build --manifest-path adapters/railgun/Cargo.toml --release
7-
#
8-
# Run tests:
9-
# cargo test --manifest-path adapters/railgun/Cargo.toml
1+
# Standalone workspace, detached from the raven root so its heavy native
2+
# deps (axum, tokio, reqwest) don't feature-unify into the core wasm32 build.
103
[workspace]
114
resolver = "2"
125
members = [
@@ -119,27 +112,9 @@ codegen-units = 1
119112
strip = "symbols"
120113
opt-level = 3
121114

122-
# CI test profile: inherits release semantics (so InsPIRe respond paths
123-
# stay fast enough to keep per-test wall under nextest's 120s ci slow-
124-
# timeout) but disables link-time optimization, parallelises LLVM
125-
# codegen across all available cores, and skips symbol stripping.
126-
#
127-
# Why the deviation from `release`:
128-
# * `codegen-units = 1` forces single-unit LLVM codegen per crate.
129-
# On a 2-vCPU runner that serialises raven-inspire's large crates.
130-
# `codegen-units = 16` saturates both cores during codegen.
131-
# * `lto = "thin"` adds a link-time optimisation pass that runs on
132-
# EVERY one of the ~120 test binaries (each links the full
133-
# raven-inspire dep closure). Cumulative cost dominates the build.
134-
# `lto = "off"` removes the pass entirely.
135-
# * `opt-level = 2` keeps respond paths within ~1.3x of opt-level=3
136-
# wall (measured locally) while compiling materially faster than
137-
# opt-level=3 (LLVM skips the most-expensive inlining passes).
138-
# * `debug = "line-tables-only"` keeps panic backtraces resolvable
139-
# without the full DWARF cost of `debug = true`.
140-
#
141-
# Use only for test execution under nextest. The `release` profile is
142-
# still the source of truth for benchmarks + the production binaries.
115+
# Test-only profile: keep release-grade runtime perf so respond paths stay
116+
# under nextest's slow-timeout, but trade link/codegen optimisation for
117+
# compile parallelism. release stays the source of truth for benches + prod.
143118
[profile.ci-test]
144119
inherits = "release"
145120
lto = "off"

adapters/railgun/Dockerfile

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# Operator binary image for `raven-railgun`.
2-
#
3-
# Build context MUST be the repo root: the adapter path-depends on
4-
# ../../crates/inspire (a self-contained workspace submodule).
1+
# Operator binary image for raven-railgun. Build context MUST be the repo
2+
# root, since the adapter path-depends on ../../crates/inspire:
53
# docker build -t raven-railgun -f adapters/railgun/Dockerfile .
64

75
FROM rust:1.85-slim-bookworm AS build
@@ -11,9 +9,8 @@ RUN apt-get update \
119
&& rm -rf /var/lib/apt/lists/*
1210
WORKDIR /build
1311

14-
# Explicit allowlist COPY. The adapter's only external path-dep is
15-
# crates/inspire; nothing else from root is needed. This never pulls
16-
# run/ (secrets) or no-commit/ into a build layer.
12+
# allowlist COPY: crates/inspire is the only external path-dep, so nothing
13+
# else from root (run/ secrets, no-commit/) lands in a build layer
1714
COPY rust-toolchain.toml ./
1815
COPY crates/inspire ./crates/inspire
1916
COPY adapters/railgun ./adapters/railgun
@@ -24,8 +21,7 @@ RUN cargo build --release \
2421
RUN strip /build/adapters/railgun/target/release/raven-railgun || true
2522

2623
FROM debian:bookworm-slim AS runtime
27-
# bookworm-slim (not distroless): operators want sh + curl for the
28-
# healthcheck and docker exec. tini forwards SIGTERM to the binary.
24+
# slim, not distroless: operators want sh + curl for healthcheck/exec; tini forwards SIGTERM
2925
RUN apt-get update \
3026
&& apt-get install -y --no-install-recommends \
3127
ca-certificates libssl3 curl tini \
@@ -41,16 +37,11 @@ COPY --from=build /build/adapters/railgun/target/release/raven-railgun \
4137
/usr/local/bin/raven-railgun
4238
RUN strip /usr/local/bin/raven-railgun || true
4339

44-
# /srv/raven/data instance dirs, /srv/raven/snapshots export drop-zone,
45-
# /srv/raven/secrets operator-mounted (config + bearer + ed25519 key).
40+
# data: instance dirs; snapshots: export drop-zone; secrets: operator-mounted config + bearer + key
4641
VOLUME ["/srv/raven/data", "/srv/raven/snapshots", "/srv/raven/secrets"]
4742
EXPOSE 8080
4843
HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=60s \
4944
CMD curl -f http://localhost:8080/v1/health/ready || exit 1
5045
USER raven:raven
5146
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/raven-railgun"]
52-
53-
# serve-production --config <toml> selects the multi-instance path; the
54-
# TOML carries the bearer token, bind, RPC config, and per-instance
55-
# data_dirs. Override the argv or mount path via docker run as needed.
5647
CMD ["serve-production", "--config", "/srv/raven/secrets/mainnet.toml"]

0 commit comments

Comments
 (0)