mirror of
https://github.com/docker/compose.git
synced 2026-11-20 23:22:29 +00:00
ci(e2e): run e2e against the containerd image store
The e2e suite only ran on graphdriver daemons, where the different kinds of image digests coincide — the blind spot that let #13636, #13998 and #14005 through. Add one matrix entry enabling the containerd image store, plus TestUpIdempotentContainerdStore: two consecutive `up` runs with no change must not recreate any container. The test is red on this configuration (the com.docker.compose.image label is written from the index digest on the pulling run, then compared against the per-platform manifest digest on the next run) and skipped until the next commit resolves the pull-path digest. Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
This commit is contained in:
parent
1615bf352f
commit
d98c41ba07
3 changed files with 112 additions and 2 deletions
29
.github/workflows/ci.yml
vendored
29
.github/workflows/ci.yml
vendored
|
|
@ -165,7 +165,7 @@ jobs:
|
|||
|
||||
e2e:
|
||||
runs-on: ubuntu-latest
|
||||
name: e2e (${{ matrix.mode }}, ${{ matrix.channel }})
|
||||
name: e2e (${{ matrix.mode }}, ${{ matrix.channel }}${{ matrix.store && format(', {0}', matrix.store) || '' }})
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
|
@ -185,12 +185,23 @@ jobs:
|
|||
- mode: standalone
|
||||
engine: 28
|
||||
channel: oldstable
|
||||
|
||||
# containerd image store (non-graphdriver digest behavior)
|
||||
- mode: plugin
|
||||
engine: 29
|
||||
channel: stable
|
||||
store: containerd
|
||||
steps:
|
||||
- name: Prepare
|
||||
run: |
|
||||
mode=${{ matrix.mode }}
|
||||
engine=${{ matrix.engine }}
|
||||
echo "MODE_ENGINE_PAIR=${mode}-${engine}" >> $GITHUB_ENV
|
||||
store=${{ matrix.store }}
|
||||
pair="${mode}-${engine}"
|
||||
if [ -n "$store" ]; then
|
||||
pair="${pair}-${store}"
|
||||
fi
|
||||
echo "MODE_ENGINE_PAIR=${pair}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
|
@ -206,6 +217,20 @@ jobs:
|
|||
- name: Check Docker Version
|
||||
run: docker --version
|
||||
|
||||
- name: Enable containerd image store
|
||||
if: ${{ matrix.store == 'containerd' }}
|
||||
run: |
|
||||
sudo mkdir -p /etc/docker
|
||||
if [ -s /etc/docker/daemon.json ]; then
|
||||
jq -s '.[0] * .[1]' /etc/docker/daemon.json <(echo '{"features": {"containerd-snapshotter": true}}') \
|
||||
| sudo tee /etc/docker/daemon.json.new > /dev/null
|
||||
sudo mv /etc/docker/daemon.json.new /etc/docker/daemon.json
|
||||
else
|
||||
echo '{"features": {"containerd-snapshotter": true}}' | sudo tee /etc/docker/daemon.json > /dev/null
|
||||
fi
|
||||
sudo systemctl restart docker.service
|
||||
docker info -f '{{json .DriverStatus}}' | grep -q io.containerd.snapshotter.v1
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
|
||||
|
||||
|
|
|
|||
4
pkg/e2e/fixtures/image-identity/compose.yaml
Normal file
4
pkg/e2e/fixtures/image-identity/compose.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
services:
|
||||
app:
|
||||
image: alpine:3.20
|
||||
command: ["sleep", "infinity"]
|
||||
81
pkg/e2e/image_identity_test.go
Normal file
81
pkg/e2e/image_identity_test.go
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
Copyright 2020 Docker Compose CLI authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
// TestUpIdempotentContainerdStore reproduces the scenario described in
|
||||
// https://github.com/docker/compose/pull/13998 : under the containerd image
|
||||
// store, a multi-platform image pulled by the first `up` gets its
|
||||
// `com.docker.compose.image` label set from the raw digest returned by
|
||||
// `image inspect` (the manifest-list/index digest). On the next `up`, the
|
||||
// image is now local, so compose recomputes the label from the per-platform
|
||||
// manifest digest instead. Those two digests differ for the very same image,
|
||||
// so compose believes the image changed and recreates the container even
|
||||
// though nothing did.
|
||||
//
|
||||
// `up` MUST be idempotent: running it twice in a row without any change
|
||||
// must not recreate any container.
|
||||
func TestUpIdempotentContainerdStore(t *testing.T) {
|
||||
// TODO(image-identity): temporary skip — this test is red by design until
|
||||
// the canonical content-digest producer lands (next commit of this PR).
|
||||
// Remove this skip in that commit; the test is the acceptance criterion.
|
||||
t.Skip("skipped until the canonical image content-digest producer lands (see PR commits)")
|
||||
|
||||
c := NewCLI(t)
|
||||
requireContainerdStore(t, c)
|
||||
|
||||
const projectName = "compose-e2e-image-identity-idempotent"
|
||||
const image = "alpine:3.20"
|
||||
const composeFile = "./fixtures/image-identity/compose.yaml"
|
||||
|
||||
t.Cleanup(func() {
|
||||
c.cleanupWithDown(t, projectName)
|
||||
c.RunDockerOrExitError(t, "rmi", "-f", image)
|
||||
})
|
||||
|
||||
// Start from an image that was never pulled locally: the first `up`
|
||||
// below will pull it, exercising the multi-platform pull path.
|
||||
c.RunDockerOrExitError(t, "rmi", "-f", image)
|
||||
|
||||
c.RunDockerComposeCmd(t, "-f", composeFile, "--project-name", projectName, "up", "-d")
|
||||
containerID := c.RunDockerCmd(t, "inspect", fmt.Sprintf("%s-app-1", projectName), "-f", "{{.Id}}").Stdout()
|
||||
|
||||
res := c.RunDockerComposeCmd(t, "-f", composeFile, "--project-name", projectName, "up", "-d")
|
||||
assert.Check(t, !strings.Contains(res.Combined(), "Recreate"), "second `up` should not recreate anything, got: %s", res.Combined())
|
||||
|
||||
newContainerID := c.RunDockerCmd(t, "inspect", fmt.Sprintf("%s-app-1", projectName), "-f", "{{.Id}}").Stdout()
|
||||
assert.Equal(t, containerID, newContainerID, "container should not have been recreated by an idempotent `up`")
|
||||
}
|
||||
|
||||
// requireContainerdStore skips the test unless the docker daemon backing the
|
||||
// CLI instance uses the containerd image store (`io.containerd.snapshotter.v1`
|
||||
// driver), which is a prerequisite for the image identity bug this test
|
||||
// covers.
|
||||
func requireContainerdStore(t *testing.T, c *CLI) {
|
||||
t.Helper()
|
||||
res := c.RunDockerCmd(t, "info", "-f", "{{json .DriverStatus}}")
|
||||
if !strings.Contains(res.Stdout(), "io.containerd.snapshotter.v1") {
|
||||
t.Skip("Skipping test: daemon is not using the containerd image store")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue