Migrated TestAPIImagesDelete from the legacy integration-cli suite
(docker_api_images_test.go) to the new integration test framework under
integration/image/remove_test.go.
This update:
- Fixes ENV instruction syntax to use "ENV FOO=bar"
- Adds error type check using errdefs.IsNotFound for cleaner assertions
- Ensures consistent cleanup handling
Signed-off-by: Aditya Mishra <mishraaditya675@gmail.com>
Add WithAPIVersion and WithAPIVersionFromEnv to be more clear on
the intent, and to align with other related options and fields.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
These tests were failing because the "docker run" did not print the
ID of the container, and instead detached immediately without printing;
```
=== Failed
=== FAIL: amd64.integration-cli TestDockerCLICommitSuite/TestCommitAfterContainerIsDone (0.27s)
docker_cli_commit_test.go:32: assertion failed:
Command: /usr/local/cli-integration/docker wait
ExitCode: 1
Error: exit status 1
Stdout:
Stderr: invalid container name or ID: value is empty
Failures:
ExitCode was 1 expected 0
Expected no error
--- FAIL: TestDockerCLICommitSuite/TestCommitAfterContainerIsDone (0.27s)
=== FAIL: amd64.integration-cli TestDockerCLICommitSuite/TestCommitWithoutPause (0.20s)
docker_cli_commit_test.go:47: assertion failed:
Command: /usr/local/cli-integration/docker wait
ExitCode: 1
Error: exit status 1
Stdout:
Stderr: invalid container name or ID: value is empty
Failures:
ExitCode was 1 expected 0
Expected no error
--- FAIL: TestDockerCLICommitSuite/TestCommitWithoutPause (0.20s)
```
What happens is that it starts a container with only `stdin` attached, but
no `stdout`, and the behavior changed between versions of the CLI, which
may be either a bugfix or a regression;
docker 28 cli doesn't stay attached:
```bash
Status: Downloaded newer image for docker:28-cli
/ # docker run -i -a stdin busybox echo foo
/ #
```
docker 27 cli stays attached, but has the "three strikes, you're out" handling:
```bash
docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock docker:27-cli sh
Status: Downloaded newer image for docker:27-cli
/ # docker run -i -a stdin busybox echo foo
9dbb29080a72225593885bc4880d8f4f22f36803100179f9725468bda1d52b4f
^C^C^C
got 3 SIGTERM/SIGINTs, forcefully exiting
/ # ^C
```
docker 26 cli (and older) don't forward the signal to the container, and detach-keys don't work (or in this case, are handled by the CLI container)?:
```bash
docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock docker:26-cli sh
Status: Downloaded newer image for docker:26-cli
/ # docker run -i -a stdin busybox echo foo
21963ce1b9a7bb7eccef3618693b09a106fb29084b484e31c69cd4a26ee44777
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C
<CTRL>p,q
```
As these tests were not testing that part, I simplified the tests, but
we should probably look into the change of behavior to see if it was
intentional (and if it was correct).
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Use a cancelReadCloser to automatically close the reader when the context
is cancelled. Consumers are still recommended to manually close the reader,
but the cancelReadCloser makes the Close idempotent.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Migrate TestAPIStatsContainerNotFound from the deprecated integration-cli
test suite to the modern integration test framework in integration/container.
The test verifies that the container stats API returns a NotFound error
for non-existent containers, testing both streaming and non-streaming modes.
Changes made:
- Migrated test to integration/container/stats_test.go using standard
Go testing patterns
- Refactored to use test array pattern for better test organization
- Removed test from integration-cli/docker_api_stats_test.go
- Removed unused imports from integration-cli file
- Removed Windows skip as it may not be necessary
Signed-off-by: Salim Dohri <dohri.salim@gmail.com>
Now that we're raising the minimum API version, we can also update
the CLI used in our integration-cli tests.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Use a more idiomatic name so that it can be used as `client.New()`.
We should look if we want `New()` to have different / updated defaults
i.e., enable `WithEnv` as default, and have an opt-out and have API-
version negotiation enabled by default (with an opt-out option).
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Remove the go-routines and just fetch the result for non-streaming stats.
Also check for the result to be valid for some tests.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The `ExecCreateResult` was embedding the `container.ExecCreateRespons`,
which in itself was an alias for `common.IDResponse`. This type has a
single field (`ID`) currently, but the embedding made it awkward to use,
for example, when mocking a `ExecCreateResult` using struct-literals:
func execCreateWithID(_ string, _ client.ExecCreateOptions) (client.ExecCreateResult, error) {
return client.ExecCreateResult{ExecCreateResponse: container.ExecCreateResponse{ID: "execid"}}, nil
}
This patch defines it as a local type with the `ID` as field.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This change moves the api/types/versions package out into client and daemon versions.
Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>