Skip to content

Implement container reaper and shutdown hook functionality.#19

Merged
gustavofreze merged 1 commit intomainfrom
feature/develop
Apr 14, 2026
Merged

Implement container reaper and shutdown hook functionality.#19
gustavofreze merged 1 commit intomainfrom
feature/develop

Conversation

@gustavofreze
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings April 14, 2026 00:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces infrastructure to improve container lifecycle management (shutdown hooks + a reaper container) and updates tests/tooling to support persistent containers across processes (e.g., mutation testing).

Changes:

  • Added ShutdownHook to make shutdown registration injectable/testable and wired it through container startup.
  • Added ContainerReaper + DockerReaper command and changed runIfNotExists() to return a “shared” wrapper (Reused) that no-ops remove() / stopOnShutdown().
  • Added Infection mutation-testing configuration and extended unit tests to validate new behaviors and command composition.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
tests/Unit/MySQLDockerContainerTest.php Adds assertions for generated docker commands, JDBC URL port behavior, granted-host/database setup behavior, and shutdown-hook delegation.
tests/Unit/Mocks/TestableMySQLDockerContainer.php Allows injecting a ShutdownHook into test container construction.
tests/Unit/Mocks/TestableGenericDockerContainer.php Wires ContainerReaper + ShutdownHook into test container construction.
tests/Unit/Mocks/ClientMock.php Adds mock support for DockerPull.
tests/Unit/Internal/Containers/ShutdownHookTest.php Unit test for ShutdownHook via namespaced override of register_shutdown_function.
tests/Unit/Internal/Containers/Overrides/register_shutdown_function_spy.php Spy override to capture registered shutdown callbacks.
tests/Unit/Internal/Containers/Overrides/file_exists_outside_docker.php Override to force “outside Docker” branch for deterministic tests.
tests/Unit/Internal/Containers/ContainerReaperTest.php Adds a test covering the “outside Docker” early-return behavior.
tests/Unit/GenericDockerContainerTest.php Updates shutdown-hook test and adds new Reused/reaper-related tests and pull assertions.
tests/Unit/FlywayDockerContainerTest.php Updates names, adds a wall-clock wait assertion, and checks readiness/pull command execution.
src/Waits/ContainerWaitForDependency.php Refactors polling loop logic for readiness/timeout checks.
src/Internal/Containers/Started.php Injects ShutdownHook and routes stopOnShutdown() through it.
src/Internal/Containers/ShutdownHook.php New wrapper around register_shutdown_function().
src/Internal/Containers/Reused.php New shared-wrapper implementation that no-ops removal/shutdown stop.
src/Internal/Containers/ContainerReaper.php New reaper orchestration that starts a per-container reaper when in Docker.
src/Internal/Containers/ContainerLookup.php Passes ShutdownHook into Started instances.
src/Internal/Commands/DockerReaper.php New docker command to start the reaper sidecar container.
src/Internal/Commands/DockerList.php Tightens container-name filtering to an anchored regex.
src/Internal/CommandHandler/ContainerCommandHandler.php Requires a ShutdownHook and threads it into lookups.
src/GenericDockerContainer.php Adds ContainerReaper, makes pullImage() synchronous, and wraps runIfNotExists() results in Reused.
src/FlywayDockerContainer.php Reorders withValidateMigrationNaming() (functional no-op change).
src/DockerContainer.php Documents new “shared” semantics for runIfNotExists().
infection.json.dist Adds Infection configuration.
composer.json Adds Infection dependency and scripts, plus plugin allowlist.

Comment thread tests/Unit/MySQLDockerContainerTest.php
Comment thread tests/Unit/MySQLDockerContainerTest.php
Comment thread tests/Unit/MySQLDockerContainerTest.php
Comment thread tests/Unit/FlywayDockerContainerTest.php
Comment thread tests/Unit/GenericDockerContainerTest.php
Comment thread tests/Unit/Internal/Containers/ContainerReaperTest.php
Comment thread src/Internal/Commands/DockerList.php
Comment thread src/Internal/Containers/ContainerReaper.php
Comment thread tests/Unit/GenericDockerContainerTest.php
Comment thread tests/Unit/MySQLDockerContainerTest.php
@gustavofreze gustavofreze merged commit ac45796 into main Apr 14, 2026
10 checks passed
@gustavofreze gustavofreze deleted the feature/develop branch April 14, 2026 00:54
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.

2 participants