Skip to content

fix(router): record ephemeral port substitutions on the ddev-router container, fixes #8644 - #8653

Merged
rfay merged 4 commits into
ddev:mainfrom
rfay:20260802_rfay_router_port_substitution_label
Aug 14, 2026
Merged

rfay merged 4 commits into
ddev:mainfrom
rfay:20260802_rfay_router_port_substitution_label

Conversation

@rfay

@rfay rfay commented Aug 2, 2026 •

Copy link
Copy Markdown
Member

TL;DR

When ddev-router has to fall back to an ephemeral port because a standard port was busy, record that substitution as a Docker label on the router container. That way a later ddev start — in a different process, after the port conflict has cleared — keeps using the substitute instead of recreating the router.

The Issue

When a standard router port (say 443) is busy at ddev-router creation time, the router is created bound to an ephemeral substitute (say 33000). The router binds substitutes as 33000:33000, so the container carries no trace of which standard port the ephemeral port stands in for. If the original occupant of 443 then goes away, a later ddev start of a different project sees 443 as free and expects the router to bind it directly — a port the running router does not have — so PortsMatch() fails and the router is recreated unnecessarily. That recreation churn is what made TestRouterNotRebuiltOnHostnameChange (added in #8561) fail intermittently in CI.

This supersedes the router-port-race portion of #8649 with a different mechanism (see below); the Windows CaptureUserOut() test-skip portion of that work is unrelated and stays in its own PR.

How This PR Solves The Issue

Record the substitution decision on the object whose lifetime bounds its validity: the router container itself, rather than in an in-process map that dies with the ddev process (and the router routinely outlives any single ddev invocation).

  • generateRouterCompose() writes a com.ddev.router-port-substitutions Docker label (e.g. 443=33000) onto the router, merging the previous router's label with substitutions decided by the current process and dropping entries whose ephemeral port the new router no longer binds.
  • GetAvailableRouterPort() consults the label (plus a small in-process cache bridging the gap until the label is written) when the proposed port looks free: if the running router still has the previously-substituted ephemeral port bound, it keeps using the substitute instead of handing out the now-free standard port, avoiding the spurious recreation.
  • Both GetAvailableRouterPort() and AllocateAvailablePortForRouter() now only trust the router's bound-port data (and, by extension, its substitution label) when router.State == "running". A router container that exists but isn't running — for example one that lost a TOCTOU port-bind race — still reports the port it tried to bind in its stale HostConfig, and would otherwise poison later allocations with a port that was never actually bound. This is the same fix applied in fix(router): only trust router's bound ports when it is actually running, fixes #8293 #8648 (open, targets main directly, fixes Add retry for "bind: address already in use" error in rootless #8293); it's included here because the new substitution-reuse check above sits on the exact same FindDdevRouter() result and inherits the identical vulnerability.

Also rewords the "Port X is busy" message to "Port X is not available", since the substitute can now be reported when the port is no longer busy, and updates the matching troubleshooting docs example.

Manual Testing Instructions

  1. Configure two projects with the same non-default, unprivileged router ports so no sudo is needed, e.g. ddev config --router-http-port=28080 --router-https-port=28443 in each.
  2. Occupy those ports (nc -l -k 28080 & / nc -l -k 28443 &, or any listener).
  3. ddev start project1. Expect Port 28080 is not available, using <N> instead, and docker inspect ddev-router --format '{{index .Config.Labels "com.ddev.router-port-substitutions"}}' to show 28080=<N>,28443=<M>.
  4. Kill the listeners so the standard ports look free again.
  5. ddev start project2 in a separate terminal/process. Expect ddev-router already running, pushing new config... (not Starting ddev-router...), the router container ID unchanged (docker inspect ddev-router --format '{{.Id}}'), and project2 to land on the same substitute ports as project1.
  6. ddev poweroff && ddev start project1: it returns directly to 28080/28443, and the label is gone.

Step 5 is the case the old in-process-map approach could not pass, since a fresh process starts with an empty map.

Automated Testing Overview

  • TestParseFormatRouterPortSubstitutions / TestKnownRouterPortSubstitutions: unit tests for the label serialization and label/in-process merge logic.
  • TestRouterPortSubstitutionPersistsAcrossProjects: integration test reproducing the cross-process race end-to-end — project1 gets a substitute under port contention, the conflict clears, the in-process cache is explicitly reset to simulate a new ddev process, and project2 must still adopt the same substitute from the router's label without a recreation. Gated on GOTEST_SHORT and the existing Lima/Colima/Rancher skip used by its sibling tests in this file.
  • Re-ran TestGlobalPortOverride, TestProjectPortOverride, TestRouterConfigOverride, TestAllocateAvailablePortForRouter, and TestUseEphemeralPort after the router.State == "running" guard; all pass.
  • make staticrequired reports 0 issues.

Release/Deployment Notes

Ephemeral port substitutions become sticky for the life of the router container: once a project is substituted onto an ephemeral port, it keeps that port even after the conflicting process goes away, until the router is recreated (e.g. ddev poweroff). Routers created by earlier DDEV versions have no label, so the first start after upgrade behaves as before; the label appears at the next router recreation.

@github-actions

github-actions Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

@rfay
rfay force-pushed the 20260802_rfay_router_port_substitution_label branch 2 times, most recently from 0c4c1fe to 2e87ece Compare August 11, 2026 16:17
@rfay
rfay marked this pull request as ready for review August 11, 2026 16:17
@rfay
rfay requested review from a team as code owners August 11, 2026 16:17
@rfay
rfay requested a review from stasadev August 11, 2026 16:17

@stasadev stasadev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Could you please ask Claude to rewrite those comments? They take a while to read and understand. It's not very useful when you're reading the code yourself - a wall of text just makes you want to skip it.

It also looks like it isn't respecting the conditions I added here:

ddev/CLAUDE.md

Lines 130 to 141 in f678fdb

#### Comments
Keep comments short. A comment earns its place only by saying something the code
does not already say — why a directive is ordered that way, why a workaround
exists, a non-obvious consequence.
- Do not restate the code, the function name, or the config directive below it
- Do not explain standard behavior of the language, webserver, or tooling
- Do not write multi-paragraph rationale essays; one to three lines is usually enough
- Do not repeat the same explanation in several files — explain it once and point
to that file
- Never re-describe in comments what a linked issue or commit message already covers

I wonder if there's a way to improve that.

rfay added a commit to rfay/ddev that referenced this pull request Aug 13, 2026
Follow-up to the previous commit, from reviewing it against the ddev#8653
comments it was written for.

- Drop "no blank line inside a comment block". It condemns about two dozen
  existing multi-paragraph comments, including the `dupStdin` doc in
  `pkg/dockerutil/stdin_dup.go` and the `pkg/config/state` package doc, and
  it's against Go convention for exported doc comments. The ddev#8653 comments
  were bad because of length, not paragraph structure; blank lines are what
  makes a long doc comment skimmable. Replaced with an explicit budget —
  three lines inside a function, eight for an exported doc comment.

- Add a before/after example. The section was all abstract prose, which is
  what was already being ignored; the pair comes from the ddev#8653 comment that
  prompted the review.

- Cut "these have been ignored in past PRs" and "full stop — not 'usually',
  always". Emphasis isn't a mechanism.

- Trim the Windows closing paragraph, which restated its own bullets.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@rfay

rfay commented Aug 13, 2026

Copy link
Copy Markdown
Member Author

The PR description is updated and has a TL;DR, and the comments seem better. Please take a casual look @stasadev , thanks, and good initiative.

@rfay
rfay force-pushed the 20260802_rfay_router_port_substitution_label branch from 2e87ece to 9afee53 Compare August 13, 2026 21:00
rfay and others added 4 commits August 13, 2026 15:19
…ontainer, for ddev#8644

## The Issue

- For ddev#8644

When a standard router port (say 443) is busy at router creation time, the
router is created bound to an ephemeral substitute (say 33000). The router
binds substitutes as `33000:33000`, so the container carries no trace of
which standard port the ephemeral port stands in for. If the original
occupant of 443 then goes away, a later `ddev start` of another project sees
443 as free and expects the router to bind it directly - a port the running
router does not have - so `PortsMatch()` fails and the router is recreated
unnecessarily. That recreation churn is what made
`TestRouterNotRebuiltOnHostnameChange` fail on macos-orbstack and exposed
the CaptureUserOut() hang on Windows.

## How This PR Solves The Issue

Record the substitution decision on the object whose lifetime bounds its
validity: the router container itself.

- `generateRouterCompose()` writes a `com.ddev.router-port-substitutions`
  Docker label (e.g. `443=33000`) onto the router, merging the previous
  router's label with substitutions decided by the current process and
  dropping entries whose ephemeral port the new router no longer binds.
- `GetAvailableRouterPort()` consults the label (plus the in-process map)
  when the proposed port looks free on the host: if the running router still
  has the previously-substituted ephemeral port bound, it keeps using the
  substitute instead of handing out the now-free standard port, avoiding the
  spurious recreation.

Because the record lives on the container, it works across separate ddev
invocations, not just within one process, and disappears naturally when the
router is recreated or removed (`ddev poweroff` returns projects to their
configured ports). The map is only consulted when the proposed port is
free; when it is still busy, allocation goes through
`AllocateAvailablePortForRouter()` as before, which honors
`EphemeralRouterPortsAssigned` and gives concurrent projects distinct
ephemeral ports.

Also rewords the "Port X is busy" message to "Port X is not available",
since with this change the substitute can be reported when the port is no
longer busy, and updates the matching troubleshooting docs example.

## Manual Testing Instructions

1. Occupy ports 80/443 (or whatever your configured router ports are) with
   a throwaway listener.
2. `ddev start` project1; note the "Port X is not available, using Y
   instead" message and `docker inspect ddev-router` showing the
   `com.ddev.router-port-substitutions` label.
3. Kill the listener so the standard port is free again.
4. `ddev start` project2 (a separate ddev process); the router is not
   recreated ("ddev-router already running, pushing new config...") and
   project2 adopts the same substitute port.
5. `ddev poweroff && ddev start`: projects return to the standard ports.

## Automated Testing Overview

- New unit tests (`TestParseFormatRouterPortSubstitutions`,
  `TestKnownRouterPortSubstitutions`) cover label serialization, malformed
  input, and label/in-process merging.
- Existing `TestRouterNotRebuiltOnHostnameChange` exercises the
  router-recreation logic with the new label in place (passes locally).

## Release/Deployment Notes

Ephemeral port substitutions become sticky for the life of the router
container: once a project is substituted onto an ephemeral port, it keeps
that port even after the conflicting process goes away, until the router is
recreated (e.g. `ddev poweroff`). Routers created by earlier DDEV versions
have no label, so the first start after upgrade behaves as before; the
label appears at the next router recreation.

Co-Authored-By: Claude Fable 5 <[email protected]>
…ution

Adds `TestRouterPortSubstitutionPersistsAcrossProjects`, which exercises the
race the previous commit's `RouterPortSubstitutionsLabel` closes: project1
starts while a standard router port is busy and gets an ephemeral
substitute; the conflicting listener is released; the in-process
`RouterPortEphemeralSubstitutions` cache is explicitly cleared to simulate a
brand-new ddev process (following the same pattern
`TestEphemeralPortsReusedOnRestart` already uses for
`EphemeralRouterPortsAssigned`); project2 then starts and must adopt the
same substitute recovered from the router's label, without the router being
recreated.

None of the existing router tests cover this: `TestUseEphemeralPort` only
proves concurrent projects get distinct substitutes, and
`TestEphemeralPortsReusedOnRestart`'s process-reset trick only applies to
the *same* project restarting, never a different project inheriting a
substitution after the original conflict clears.

`RouterPortEphemeralSubstitutions` (previously unexported) is exported so
the external `ddevapp_test` package can reset it, matching how
`EphemeralRouterPortsAssigned` is already exported for the same reason.

Gated on `GOTEST_SHORT` like its sibling tests in this file (skipped when
set), and on the same Lima/Colima/Rancher Docker backends already skipped
elsewhere in this file for unreliable port release timing. Measured at
35.1s standalone, in line with `TestUseEphemeralPort` (34.7s) and
`TestEphemeralPortsReusedOnRestart` (32.8s).

Co-Authored-By: Claude Fable 5 <[email protected]>
## The Issue

Related to ddev#8648 (open, targets `main` directly, not yet merged), which
fixes ddev#8293: a `ddev-router` container that exists but isn't running - for
example one that lost a TOCTOU port-bind race, or crashed - still reports
the port it *tried* to bind in its `HostConfig.PortBindings`. The prior code
in `AllocateAvailablePortForRouter()` and `GetAvailableRouterPort()` treated
any container found by `FindDdevRouter()` as a trustworthy source of bound
ports regardless of its state, so a dead container's stale, never-actually-
bound port kept getting reoffered on every subsequent call.

This branch's earlier commits added a second, related trust decision on top
of the same `FindDdevRouter()` result: `GetAvailableRouterPort()` now also
checks the router's `RouterPortSubstitutionsLabel` (via
`knownRouterPortSubstitutions()`) to decide whether a proposed port that
looks free should still be treated as substituted. That check inherits the
identical vulnerability - a non-running router's label and stale
`HostConfig` entries could combine to convince a new project to reuse a
port that was never actually bound.

## How This PR Solves The Issue

Adopt the same fix ddev#8648 applies upstream: both `AllocateAvailablePortForRouter()`
and `GetAvailableRouterPort()` now only trust `FindDdevRouter()`'s bound-ports
result when `router.State == "running"`. This protects the pre-existing
"already bound" check and, as a side effect requiring no additional code,
also protects the new substitution-reuse check: `routerPortsAlreadyBound`
stays empty whenever the router isn't running, so the
`nodeps.ArrayContainsString(routerPortsAlreadyBound, ephemeralPort)` guard on
the substitution-reuse path correctly declines to trust a stale label from a
dead container, falling through to fresh negotiation instead.

`generateRouterCompose()`'s own use of `knownRouterPortSubstitutions()` (to
carry a substitution forward into a recreated router) is deliberately left
unguarded by container state: it only runs during an actual recreation, and
its existing pruning against the active projects' real configured ports -
themselves only ever set through the now-guarded decision points - is the
correct safety net there, not the old router's liveness.

## Manual Testing Instructions

Same recipe as ddev#8648: start a project so `ddev-router` binds an ephemeral
port, kill the router container directly (not via `ddev stop`) so it's left
`exited` while still holding that port in its config, then start another
project needing an ephemeral port and confirm it picks a fresh one instead
of reusing the dead container's port.

## Automated Testing Overview

Re-ran `TestGlobalPortOverride`, `TestProjectPortOverride`,
`TestRouterConfigOverride`, `TestAllocateAvailablePortForRouter`,
`TestUseEphemeralPort`, and this branch's
`TestRouterPortSubstitutionPersistsAcrossProjects` - all pass with the guard
in place. `make staticrequired` reports 0 issues.

## Release/Deployment Notes

None. Internal port-allocation logic only.

Co-Authored-By: Claude Fable 5 <[email protected]>
…n Windows

`TestRouterPortSubstitutionPersistsAcrossProjects` wraps `app2.Start()` in
`util.CaptureUserOut()`, the exact pattern ddev#8649 identified as unsafe on
Windows: the helper redirects output to an `os.Pipe()` that isn't drained
until `getOutput()` is called, so a full `Start()` emitting enough
`DDEV_DEBUG` output before returning can deadlock the write. Same root
cause as the existing `TestDdevLogs` and `TestRouterNotRebuiltOnHostnameChange`
Windows skips; this test needs the identical guard.

Co-Authored-By: Claude Fable 5 <[email protected]>
@rfay
rfay force-pushed the 20260802_rfay_router_port_substitution_label branch from 9afee53 to b5fd5d7 Compare August 13, 2026 21:19
@stasadev

stasadev commented Aug 14, 2026 •

Copy link
Copy Markdown
Member

and the comments seem better.

I meant comments in the code itself. I still see a lot of long sentences in this PR.

I guess the change simply wasn't pushed.

@rfay

rfay commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

Yes, focused mostly on the comments in the code. Hope they're better now.

@rfay
rfay merged commit 851f739 into ddev:main Aug 14, 2026
47 checks passed
@rfay
rfay deleted the 20260802_rfay_router_port_substitution_label branch August 14, 2026 13:41
Comment thread pkg/ddevapp/router.go
Comment on lines +40 to +55
// RouterPortSubstitutionsLabel is the name of a Docker label set on the
// ddev-router container recording which ephemeral host port was substituted
// for each standard (proposed) router port, in the form "80=33000,443=33001".
// The router binds ephemeral substitutes as <port>:<port>, so without this
// label the container carries no trace of which standard port an ephemeral
// port stands in for. Storing the record on the router container gives it
// exactly the router's lifetime: it survives across ddev invocations and
// disappears when the router is recreated or removed.
//
// It closes a race: when a standard port (say 80) is busy at router creation
// time, the router is created bound to an ephemeral substitute. If the
// original occupant of port 80 then goes away, a later project would see
// port 80 as free and expect the router to bind it directly - a port the
// running router does not have - forcing an unnecessary router recreation.
// See GetAvailableRouterPort().
const RouterPortSubstitutionsLabel = "com.ddev.router-port-substitutions"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still see the wall of text...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shorter wall, easier to jump over :)

I really appreciate the prodding on this, and think it's an important place to make progress on our use of AI, not just in controlling the AI, but in making sure that we approve of both the comment and the content.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, look at this:

ddev/CLAUDE.md

Lines 184 to 215 in 851f739

Too long — three paragraphs of background where one sentence and a pointer
would do:
```go
// RouterPortSubstitutionsLabel is the name of a Docker label set on the
// ddev-router container recording which ephemeral host port was substituted
// for each standard (proposed) router port, in the form "80=33000,443=33001".
// The router binds ephemeral substitutes as <port>:<port>, so without this
// label the container carries no trace of which standard port an ephemeral
// port stands in for. Storing the record on the router container gives it
// exactly the router's lifetime: it survives across ddev invocations and
// disappears when the router is recreated or removed.
//
// It closes a race: when a standard port (say 80) is busy at router creation
// time, the router is created bound to an ephemeral substitute. If the
// original occupant of port 80 then goes away, a later project would see
// port 80 as free and expect the router to bind it directly - a port the
// running router does not have - forcing an unnecessary router recreation.
// See GetAvailableRouterPort().
```
Right — what it holds, the one fact that isn't obvious, and who to read next:
```go
// RouterPortSubstitutionsLabel records which ephemeral port stands in for
// which standard router port, as "80=33000,443=33001".
//
// The router binds ephemeral substitutes as <port>:<port>, so nothing else on
// the container says that 33000 is really port 80. Used by
// GetAvailableRouterPort() to keep a substitute after the process occupying
// the standard port goes away.
```

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 // RouterPortSubstitutionsLabel records which ephemeral port stands in for 
 // which standard router port, as "80=33000,443=33001". 
 // 
 // The router binds ephemeral substitutes as <port>:<port>, so nothing else on 
 // the container says that 33000 is really port 80. Used by 
 // GetAvailableRouterPort() to keep a substitute after the process occupying 
 // the standard port goes away. 

I thought you wanted to rewrite it to this, like it's described in the CLAUDE.md

But there is no commit for that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if I got confused and lost a commit. Most of them looked much better when I took a look.

rfay added a commit that referenced this pull request Aug 18, 2026
stasadev added a commit to stasadev/ddev that referenced this pull request Oct 7, 2026
…hand

## Short Summary (TL;DR)

The all-project-types job is the only CI job that runs tests with `GOTEST_SHORT` unset, and it ran a hand-kept list that had fallen behind, so 16 tests that skip or shrink under `GOTEST_SHORT` never ran in full anywhere. The list is now generated from the tests themselves, so it can't fall behind again.

## The Issue

Found while working on ddev#7904, which changes `TestDebugRebuildCmd`: CI logs show `--- SKIP: TestDebugRebuildCmd` in every job, because Buildkite and `test-reusable.yml` set `GOTEST_SHORT=16` and apache-fpm sets `5`.

The list came from ddev#6693 and broke in three ways:

- ddev#7027 renamed `TestComposerCreateCmd` to `TestComposerCreateProjectCmd`, so that entry has matched nothing since.
- ddev#8028 added `GOTEST_SHORT` skips to `TestDebugRebuildCmd`, `TestDdevImportDB`, `TestDdevRestoreSnapshot`, `TestProcessHooks`, and `TestWebserverMariaMySQLDBClient`, and later PRs did the same for `TestEphemeralPortsReusedOnRestart` (ddev#7992), `TestRouterPortSubstitutionPersistsAcrossProjects` (ddev#8653), `TestSnapshotUncompressed` (ddev#8704), `TestDebugDeleteVolumeCmd` (ddev#8756), and `TestDdevExportDB` (ddev#8798), none of them updating the list.
- `TestComposerVersionConfig`, `TestHttpsRedirection`, `TestMysqlCommand`, `TestDdevStartMultipleHostnames`, and `TestProjectAutocompletionForExecCmd` already did less under `GOTEST_SHORT` when ddev#6693 wrote the list, and weren't on it.

## How This PR Solves The Issue

Tests use three `testcommon` helpers instead of reading `GOTEST_SHORT`: `SkipIfGotestShort(t)`, `IsGotestShort(t)`, and `UsesAllTestSites(t)`, a marker for tests that loop over every test site. `.github/workflows/all-project-types-tests.sh` finds the tests that call them and prints the `-run` pattern, and fails if a test other than `TestMain` reads `GOTEST_SHORT` itself.

The pattern is anchored, so prefix matches such as every `TestCmdStart*` test or `TestAutocompleteServiceForServiceFlag` no longer ride along; like `TestAppdirAlreadyInUse` and `TestConfigValidate`, which also leave the list, they don't depend on `GOTEST_SHORT` and run in every job. The `GOTEST_SHORT` branches that ddev#8028 made unreachable in `TestComposerCreateProjectCmd` and `TestDdevAllDatabases` are removed.

## Manual Testing Instructions

```bash
.github/workflows/all-project-types-tests.sh
# Expect ^(TestAutocompletionForDescribeCmd|...|TestWriteDrushConfig)\b with the 42 tests below
```

Adding `if os.Getenv("GOTEST_SHORT") != "" { t.Skip() }` to any test makes the script print that file and line and exit non-zero.

## Automated Testing Overview

In the all-project-types job, the "Compute TESTARGS" step of `prepare-testargs` should print a `-run '^(...)\b'` pattern with exactly these 42 tests, and the test log should show each of them running, none skipped because of `GOTEST_SHORT`:

```text
TestAutocompletionForDescribeCmd TestAutocompletionForStartCmd TestAutocompletionForStopCmd
TestAvailableUpdates TestCmdDescribe TestCmdDescribeAppFunction TestCmdDescribeAppUsingSitename
TestCmdList TestCmdStart TestCmdStop TestComposerCreateProjectCmd TestComposerVersionConfig
TestConfigDatabaseVersion TestDdevAllDatabases TestDdevExportDB TestDdevFullSiteSetup
TestDdevImportDB TestDdevImportFiles TestDdevImportFilesCustomUploadDir TestDdevImportFilesDir
TestDdevRestoreSnapshot TestDdevStartMultipleHostnames TestDdevUploadDirNoPackage
TestDdevXdebugEnabled TestDdevXhprofPrependEnabled TestDdevXhprofXhguiEnabled
TestDebugDeleteVolumeCmd TestDebugRebuildCmd TestEphemeralPortsReusedOnRestart TestGetApps
TestGetAppsEmpty TestHardenedStart TestHttpsRedirection TestMysqlCommand TestPHPConfig
TestPHPWebserverType TestProcessHooks TestProjectAutocompletionForExecCmd
TestRouterPortSubstitutionPersistsAcrossProjects TestSnapshotUncompressed
TestWebserverMariaMySQLDBClient TestWriteDrushConfig
```

Some of the 16 tests that never ran in full may fail after being skipped this long; this PR's run is where that should show up.

🤖 Developed with assistance from [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
stasadev added a commit to stasadev/ddev that referenced this pull request Oct 8, 2026
…hand

## Short Summary (TL;DR)

The all-project-types job is the only CI job that runs tests with `GOTEST_SHORT` unset, and it ran a hand-kept list that had fallen behind, so 16 tests that skip or shrink under `GOTEST_SHORT` never ran in full anywhere. The list is now generated from the tests themselves, so it can't fall behind again.

## The Issue

Found while working on ddev#7904, which changes `TestDebugRebuildCmd`: CI logs show `--- SKIP: TestDebugRebuildCmd` in every job, because Buildkite and `test-reusable.yml` set `GOTEST_SHORT=16` and apache-fpm sets `5`.

The list came from ddev#6693 and broke in three ways:

- ddev#7027 renamed `TestComposerCreateCmd` to `TestComposerCreateProjectCmd`, so that entry has matched nothing since.
- ddev#8028 added `GOTEST_SHORT` skips to `TestDebugRebuildCmd`, `TestDdevImportDB`, `TestDdevRestoreSnapshot`, `TestProcessHooks`, and `TestWebserverMariaMySQLDBClient`, and later PRs did the same for `TestEphemeralPortsReusedOnRestart` (ddev#7992), `TestRouterPortSubstitutionPersistsAcrossProjects` (ddev#8653), `TestSnapshotUncompressed` (ddev#8704), `TestDebugDeleteVolumeCmd` (ddev#8756), and `TestDdevExportDB` (ddev#8798), none of them updating the list.
- `TestComposerVersionConfig`, `TestHttpsRedirection`, `TestMysqlCommand`, `TestDdevStartMultipleHostnames`, and `TestProjectAutocompletionForExecCmd` already did less under `GOTEST_SHORT` when ddev#6693 wrote the list, and weren't on it.

## How This PR Solves The Issue

Tests use three `testcommon` helpers instead of reading `GOTEST_SHORT`: `SkipIfGotestShort(t)`, `IsGotestShort(t)`, and `UsesAllTestSites(t)`, a marker for tests that loop over every test site. `.github/workflows/all-project-types-tests.sh` finds the tests that call them and prints the `-run` pattern, and fails if a test other than `TestMain` reads `GOTEST_SHORT` itself.

The pattern is anchored, so prefix matches such as every `TestCmdStart*` test or `TestAutocompleteServiceForServiceFlag` no longer ride along; like `TestAppdirAlreadyInUse` and `TestConfigValidate`, which also leave the list, they don't depend on `GOTEST_SHORT` and run in every job. The `GOTEST_SHORT` branches that ddev#8028 made unreachable in `TestComposerCreateProjectCmd` and `TestDdevAllDatabases` are removed.

## Manual Testing Instructions

```bash
.github/workflows/all-project-types-tests.sh
# Expect ^(TestAutocompletionForDescribeCmd|...|TestWriteDrushConfig)\b with the 42 tests below
```

Adding `if os.Getenv("GOTEST_SHORT") != "" { t.Skip() }` to any test makes the script print that file and line and exit non-zero.

## Automated Testing Overview

In the all-project-types job, the "Compute TESTARGS" step of `prepare-testargs` should print a `-run '^(...)\b'` pattern with exactly these 42 tests, and the test log should show each of them running, none skipped because of `GOTEST_SHORT`:

```text
TestAutocompletionForDescribeCmd TestAutocompletionForStartCmd TestAutocompletionForStopCmd
TestAvailableUpdates TestCmdDescribe TestCmdDescribeAppFunction TestCmdDescribeAppUsingSitename
TestCmdList TestCmdStart TestCmdStop TestComposerCreateProjectCmd TestComposerVersionConfig
TestConfigDatabaseVersion TestDdevAllDatabases TestDdevExportDB TestDdevFullSiteSetup
TestDdevImportDB TestDdevImportFiles TestDdevImportFilesCustomUploadDir TestDdevImportFilesDir
TestDdevRestoreSnapshot TestDdevStartMultipleHostnames TestDdevUploadDirNoPackage
TestDdevXdebugEnabled TestDdevXhprofPrependEnabled TestDdevXhprofXhguiEnabled
TestDebugDeleteVolumeCmd TestDebugRebuildCmd TestEphemeralPortsReusedOnRestart TestGetApps
TestGetAppsEmpty TestHardenedStart TestHttpsRedirection TestMysqlCommand TestPHPConfig
TestPHPWebserverType TestProcessHooks TestProjectAutocompletionForExecCmd
TestRouterPortSubstitutionPersistsAcrossProjects TestSnapshotUncompressed
TestWebserverMariaMySQLDBClient TestWriteDrushConfig
```

Some of the 16 tests that never ran in full may fail after being skipped this long; this PR's run is where that should show up.

🤖 Developed with assistance from [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add retry for "bind: address already in use" error in rootless

2 participants