From 05523e289b757be9406c46bd3d00dd43ccc4a84d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Fri, 24 Nov 2023 13:58:27 +0100 Subject: [PATCH] c8d/integration: Adjust TestSaveCheckTimes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The graphdriver implementation sets the ModTime of all image content to match the `Created` time from the image config, whereas the containerd's archive export code just leaves it empty (zero). Adjust the test in the case where containerd integration is enabled to check if config file ModTime is equal to zero (UNIX epoch) instead. This behaviour is not a part of the Docker Image Specification and the intention behind introducing it was to make the `docker save` produce the same archive regardless of the time it was performed. It would also be a bit problematic with the OCI archive layout which can contain multiple images referencing the same content. Signed-off-by: Paweł Gronowski --- integration/image/save_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/integration/image/save_test.go b/integration/image/save_test.go index c13c68efba..87a18cbf97 100644 --- a/integration/image/save_test.go +++ b/integration/image/save_test.go @@ -22,6 +22,7 @@ import ( "github.com/opencontainers/go-digest" "gotest.tools/v3/assert" "gotest.tools/v3/assert/cmp" + is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/skip" ) @@ -76,7 +77,12 @@ func TestSaveCheckTimes(t *testing.T) { created, err := time.Parse(time.RFC3339, img.Created) assert.NilError(t, err) - assert.Equal(t, created.Format(time.RFC3339), info.ModTime().Format(time.RFC3339), "expected: %s, actual: %s", created, info.ModTime()) + if testEnv.UsingSnapshotter() { + // containerd archive export sets the mod time to zero. + assert.Check(t, is.Equal(info.ModTime(), time.Unix(0, 0))) + } else { + assert.Check(t, is.Equal(info.ModTime().Format(time.RFC3339), created.Format(time.RFC3339))) + } } func TestSaveRepoWithMultipleImages(t *testing.T) {