Repository navigation
refactor(docker): DockerEngineService is the Docker engine seam, with an in-memory engine fake and its contract suite - #2534
Merged
Conversation
Owner
Author
|
Test evidence:
Pending a person: review the diff in tuicr ( |
…factory, with an in-memory engine fake and its contract suite DockerEngineService builds the docker SDK client with a ClientFactory, docker.DockerClient unless DockerEngineService.install gives it another. The endpoint check and the mapping of a failure to DockerDaemonUnavailableError stay on the service's path. devops_cli/docker/sdk.py names the SDK calls that devops-cli makes as Protocols. DockerEngineFake is an in-memory engine behind those calls, with the docker_daemon fixture. The contract suite runs eight scenarios over the fake and over a real docker.DockerClient that reads the Engine API's answers, recorded from Docker Engine 29.9.2 and replayed on a Unix socket that the test binds.
…fake tests/test_docker_engine.py builds no MagicMock client and reaches no private name of the service. The docker_engine factory installs a test's own client through DockerEngineService.install and no longer patches get_instance.
…tderr, and the replay socket stays under the test's own directory The engine reads stdout and stderr from two pipes, so a scenario compares the lines of one log as a sorted list. The replay server and the recorder bind their socket under the temporary directory that pytest keeps short, and end a connection whose client stops reading a stream. The exec scenario runs in `/`. The SDK Protocols name the built-in `list` where a method of the same name would hide it.
…ed engine, and the support plugins load on a base without the seam A contract case runs DockerEngineService with its default factory against the recorded engine, and reads the same daemon facts as over the fake. The Protocols are one-line stubs, as in k8s/api.py. The scenarios import the Protocol only for typing, so the fail-to-pass replay loads the support plugins on a base without the module.
dan-petty
force-pushed
the
refactor/1316-docker-engine-seam
branch
from
October 28, 2026 20:55
1db3289 to
b928d8a
Compare
dan-petty
marked this pull request as ready for review
October 28, 2026 21:01
dan-petty
pushed a commit
that referenced
this pull request
Oct 28, 2026
🤖 I have created a release *beep* *boop* --- ## [0.11.3](v0.11.2...v0.11.3) (2026-10-28) ### Bug Fixes * **roadmap:** refine wraps no link in the model's code, and wraps each reference and link that GitHub makes from its text ([#2540](#2540)) ([2d38f8d](2d38f8d)), closes [#2525](#2525) ### Code Refactoring * **docker:** DockerEngineService is the Docker engine seam, with an in-memory engine fake and its contract suite ([#2534](#2534)) ([1244cbf](1244cbf)), closes [#1316](#1316) * **security:** one keyring seam owns the keyring and the Secret Service, with a shared fake and its contract suite ([#2532](#2532)) ([866d2cb](866d2cb)), closes [#1318](#1318) * **telemetry:** OTLP export goes through one exporter seam, and tests read exported spans and metrics from a shared fake ([#2541](#2541)) ([8da35e6](8da35e6)), closes [#1319](#1319) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DockerEngineServiceis the one way to the Docker engine, but its tests reached past it: thedocker_enginefixture set the private_clientof a service and patchedget_instance, andtests/test_docker_engine.pybuilt 48MagicMockobjects and patcheddocker.DockerClient14 times. No shared fake of the engine existed, and nothing held a double to what the docker SDK does over a real engine.DockerEngineServicebuilds its SDK client with aClientFactory,docker.DockerClientunlessDockerEngineService.installgives it another. The endpoint check and the mapping of a failure toDockerDaemonUnavailableErrorstay on the service's path. A factory, not an installed client, because the SDK readsGET /versionin its constructor, so an engine that does not answer fails there.src/devops_cli/docker/sdk.pynames the SDK calls that devops-cli makes as Protocols, with the signatures the SDK gives them.client()returns anEngineClient, andget_container,create_containerandlist_imagesreturn the models.DockerEngineFake(tests/support/fakes/docker_engine.py) is an in-memory engine behind those calls, with thedocker_daemonfixture. It raises the SDK'sNotFound,ImageNotFoundandAPIErrorwith the SDK's own text, refuses a keyword that the SDK does not take, can be unreachable, and keeps each call.tests/docker/test_engine_contract.pyruns eight scenarios over the fake and over a realdocker.DockerClientthat reads the Engine API's answers, recorded from Docker Engine 29.9.2 (API 1.56) and replayed byRecordedEngineon a Unix socket that the test binds. Two more cases run through the service: with its default factory it builds the SDK's own client of a recorded endpoint and reads the same daemon facts as over the fake, and an engine that does not answer fails with the same text over both.tests/support/docker_engine_recording.pyrecords again on a host with a local engine; it sends every prune with a filter that matches nothing, and keeps only the objects the scenarios make, with documentation addresses.tests/test_docker_engine.pyruns on the fake, with noMagicMockclient and no private name of the service. Thedocker_enginefactory installs a test's own client throughinstall; the tests of other packages move to the fake in test(ci): devops ci, test, devcontainer, workspace, install-tools, uv, branches and pipeline are tested over edge fakes, with no lazy patch targets or PYTEST_CURRENT_TEST checks #1325, test(cli): the infra commands are thin adapters tested over edge fakes, with no internal patches or private imports #1327, test(telemetry): telemetry, server, ui, output and docs tests run on edge fakes, and the dashboard suite splits by behaviour #1334 and test(infra): infrastructure tests run on edge fakes #1335.docs/TESTING.mddescribes the seam, the fake and the contract suite.The fake mirrors the SDK in one place where the service is wrong: docker-py's
logstakes nodemux, socontainer_log_streamfails on every real engine. That defect is #2520; this change does not change the method.Closes #1316
Change:
openspec/changes/archive/2026-10-28-1316-docker-engine-seam/