Skip to content

Commit ac4bc17

Browse files
author
Mark Pollack
committed
Document the concurrent-run isolation rules: port blocks and IT_M2_REPO
1 parent 0ff1afc commit ac4bc17

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

‎integration-testing/README.md‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ print nothing themselves. They read the environment below and nothing else.
158158

159159
| Variable | Set for | Value |
160160
|---|---|---|
161-
| `MVNW`, `ACP_VERSION`, `CACHE`, `IT_ROOT` | `build.sh` | the Maven wrapper, the SDK version under test, `integration-testing/.cache`, `integration-testing/` |
161+
| `MVNW`, `ACP_VERSION`, `CACHE`, `IT_ROOT` | `build.sh` | the Maven wrapper (pinned to `IT_M2_REPO`), the SDK version under test, `integration-testing/.cache`, `integration-testing/` |
162162
| the language's `env` in `matrix.json` | `build.sh`, and every process of a cell that uses the language | e.g. `TS_SDK`, `PY_SDK`, `RUST_SDK` + `CARGO_TARGET_DIR`, `KOTLIN_SDK`: the peer checkout (and build dir) for the ref under test |
163163
| `STEPS` | client | comma-separated step ids, in order |
164164
| `AGENT_CMD` | client, stdio only | a shell command line that starts the agent |
@@ -338,8 +338,24 @@ language too, run on the same host at the same time.
338338

339339
- **Ports.** Never a fixed port. An agent binds exactly the `--port` it is given: the runner takes
340340
`${PORT}` from a range reserved for the scenario (`IT_PORT_RANGE`, 100 ports per scenario from
341-
20000, below the Linux ephemeral range). `--port 0` must also work (print the bound port in
342-
`READY`). A client connects only to the `--url` it is given.
341+
the run's port block, below the Linux ephemeral range). `--port 0` must also work (print the
342+
bound port in `READY`). A client connects only to the `--url` it is given.
343+
- **Concurrent runs: ports.** Several checkouts may run `run-all.sh` on one host at once. Each
344+
run-all takes an exclusive 10,000-port block for its lifetime: the first of 20000, 30000, 40000
345+
and 50000 whose lock file (`${XDG_RUNTIME_DIR:-/tmp}/acp-it-ports-<base>.lock`) it can `flock`,
346+
held by a file descriptor until the run and everything it started exit (a kill releases it
347+
too); with all four taken it waits. `IT_PORT_BASE=<n>` overrides the choice (no lock). Scenario
348+
`i` gets `<base> + 100 * (i mod 100)`, 100 ports wide. `RunScenario.java` run directly, without
349+
`IT_PORT_RANGE`, uses an OS-chosen ephemeral port.
350+
- **Concurrent runs: Maven repository.** One knob, `IT_M2_REPO`, is the local repository for
351+
everything the suite resolves or installs: the SDK install, every program build (`${MVNW}` is
352+
`scripts/mvnw.sh`, the checkout's `./mvnw` with `-Dmaven.repo.local=$IT_M2_REPO`) and JBang
353+
(`JBANG_REPO` is set to it). Unset, it is `integration-testing/.cache/m2` (per checkout,
354+
git-ignored), so concurrent checkouts never see each other's `0.19.0-SNAPSHOT`; with `CI=true`
355+
it is `~/.m2/repository`, which the CI cache keeps. A cold per-checkout repository downloads
356+
the SDK's third-party dependencies once (a few minutes); copying another checkout's
357+
`.cache/m2` warms it, since the SNAPSHOT is reinstalled by every run. Never call `./mvnw` or
358+
`mvn` directly from a build; use `${MVNW}`.
343359
- **Files.** Never a fixed path. Temporary files go under `$TMPDIR`, which the runner sets for every
344360
process to `logs/<scenario>/tmp/`, or under the client's `{dir}` (created with a unique name).
345361
Nothing is written into `programs/<lang>/` at run time.
@@ -350,7 +366,7 @@ language too, run on the same host at the same time.
350366
in a `--prepared` run nothing else does either.
351367
- **Processes.** No daemons and no detached children: everything a program starts dies with it
352368
(a stdio client ends its agent; the runner kills each process tree at the end of a scenario).
353-
- **No shared mutable state**: no lock files, fixed sockets or named pipes, no global caches
369+
- **No shared mutable state** in programs: no lock files, fixed sockets or named pipes, no global caches
354370
written at run time.
355371

356372
### 8. CI

0 commit comments

Comments
 (0)