This test depended on the container to die after running the `true` command,
but this condition failed frequently on Windows 2025.
=== Failed
=== FAIL: github.com/docker/docker/integration/container TestRemoveContainerWithVolume (32.68s)
remove_test.go:61: timeout hit after 10s: waiting for container State.Status to be 'exited', currently 'running'
While this may be revealing an actual issue (and we should have a test for
that), it's irrelevant for this test, which;
- creates and starts a container with an anonymous volume
- verifies the anonymous volume was created
- removes the container
- verifies the anonymous volume was removed
We can force-remove the container to kill, and removed it; we probably
could've sufficed with "container create" (without starting), but it's
good to add extra coverage, in case running the container impacts whether
we're able to remove the volume.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -6,8 +6,6 @@ import ( |
| 6 | 6 |
|
| 7 | 7 |
cerrdefs "github.com/containerd/errdefs" |
| 8 | 8 |
containertypes "github.com/docker/docker/api/types/container" |
| 9 |
- "github.com/docker/docker/api/types/filters" |
|
| 10 |
- "github.com/docker/docker/api/types/volume" |
|
| 11 | 9 |
"github.com/docker/docker/integration/internal/container" |
| 12 | 10 |
"gotest.tools/v3/assert" |
| 13 | 11 |
is "gotest.tools/v3/assert/cmp" |
| ... | ... |
@@ -57,24 +55,24 @@ func TestRemoveContainerWithVolume(t *testing.T) {
|
| 57 | 57 |
|
| 58 | 58 |
prefix, slash := getPrefixAndSlashFromDaemonPlatform() |
| 59 | 59 |
|
| 60 |
- cID := container.Run(ctx, t, apiClient, container.WithCmd("true"), container.WithVolume(prefix+slash+"srv"))
|
|
| 61 |
- poll.WaitOn(t, container.IsInState(ctx, apiClient, cID, containertypes.StateExited)) |
|
| 60 |
+ cID := container.Run(ctx, t, apiClient, container.WithVolume(prefix+slash+"srv")) |
|
| 62 | 61 |
|
| 63 | 62 |
ctrInspect, err := apiClient.ContainerInspect(ctx, cID) |
| 64 | 63 |
assert.NilError(t, err) |
| 65 | 64 |
assert.Check(t, is.Equal(1, len(ctrInspect.Mounts))) |
| 66 | 65 |
volName := ctrInspect.Mounts[0].Name |
| 67 | 66 |
|
| 67 |
+ _, err = apiClient.VolumeInspect(ctx, volName) |
|
| 68 |
+ assert.NilError(t, err) |
|
| 69 |
+ |
|
| 68 | 70 |
err = apiClient.ContainerRemove(ctx, cID, containertypes.RemoveOptions{
|
| 71 |
+ Force: true, |
|
| 69 | 72 |
RemoveVolumes: true, |
| 70 | 73 |
}) |
| 71 | 74 |
assert.NilError(t, err) |
| 72 | 75 |
|
| 73 |
- volumes, err := apiClient.VolumeList(ctx, volume.ListOptions{
|
|
| 74 |
- Filters: filters.NewArgs(filters.Arg("name", volName)),
|
|
| 75 |
- }) |
|
| 76 |
- assert.NilError(t, err) |
|
| 77 |
- assert.Check(t, is.Equal(0, len(volumes.Volumes))) |
|
| 76 |
+ _, err = apiClient.VolumeInspect(ctx, volName) |
|
| 77 |
+ assert.ErrorType(t, err, cerrdefs.IsNotFound, "Expected anonymous volume to be removed") |
|
| 78 | 78 |
} |
| 79 | 79 |
|
| 80 | 80 |
func TestRemoveContainerRunning(t *testing.T) {
|