Skip to content

fix: reduce flaky tests by preventing container auto-removal and parallel --all interference#1753

Open
kasc0206 wants to merge 1 commit into
apple:mainfrom
kasc0206:fix/flaky-tests-container-timing
Open

fix: reduce flaky tests by preventing container auto-removal and parallel --all interference#1753
kasc0206 wants to merge 1 commit into
apple:mainfrom
kasc0206:fix/flaky-tests-container-timing

Conversation

@kasc0206

@kasc0206 kasc0206 commented Jun 19, 2026

Copy link
Copy Markdown

Summary

Fix 5 flaky tests identified during Release mode testing (892 tests, 887 pass, 5 flaky).

Root Cause Analysis

TestCLIStop (4 failures): doLongRun defaults to autoRemove: true (--rm flag).
When a container crashes between creation and inspect/stop, --rm auto-deletes it,
causing subsequent container inspect / container stop to fail with "container not found".

TestCLIRemove (3 failures): Tests use delete --all / delete --all --force,
which operate on ALL containers. When multiple tests run in parallel, they delete
each other's containers.

TestCLIProgressAuto (1 failure): testExplicitAnsiProgress expects ANSI escape
sequences on stderr, but ANSI output is only emitted when stderr is a TTY. When
running with output redirected (CI, swift test > file), progress falls back to plain text.

Changes

File Change
TestCLIStop.swift 4 tests: doLongRun(name:)doLongRun(name:, autoRemove: false)
TestCLIRemove.swift delete --alldelete <specific-names> to avoid cross-test interference
TestCLIRemove.swift delete --all --forcedelete --force <name>
TestCLIProgressAuto.swift Guard ANSI assertion with isatty(STDERR_FILENO) check

Notes

  • Commit is signed with SSH (ED25519)
  • Branch has been rebased onto latest upstream/main to keep a clean history

@kasc0206 kasc0206 force-pushed the fix/flaky-tests-container-timing branch from 2b90ac2 to 3e83760 Compare June 20, 2026 23:53
…llel --all interference

Fix 5 flaky tests in Release mode:

TestCLIStop (4 tests):
- Change doLongRun to use autoRemove: false so containers persist
  even if they crash, preventing 'container not found' errors on
  subsequent inspect/stop calls.

TestCLIRemove (3 tests):
- Replace 'delete --all' and 'delete --all --force' with specific
  container names to prevent parallel test interference.

TestCLIProgressAuto (1 test):
- Guard ANSI assertion with isatty(STDERR_FILENO) check since
  progress falls back to plain text when output is redirected.
@kasc0206 kasc0206 force-pushed the fix/flaky-tests-container-timing branch from 3e83760 to 1ef0fe3 Compare June 20, 2026 23:56
@kasc0206

Copy link
Copy Markdown
Author

Hi @dcantah @crosbymichael, could you please review this PR when you have a moment?

This fixes 5 flaky tests identified in Release mode testing:

  • TestCLIStop (4 tests): Container auto-removal (--rm) caused 'container not found' errors
  • TestCLIRemove (3 tests): Parallel --all interference between tests
  • TestCLIProgressAuto (1 test): ANSI progress assert fails when output is redirected

The commit is SSH-signed and rebased onto the latest main.

cc @adityaramani @jglogan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant