فهرست منبع

c8d/integration: Adjust TestSaveCheckTimes

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 <pawel.gronowski@docker.com>
Paweł Gronowski 1 سال پیش
والد
کامیت
05523e289b
1فایلهای تغییر یافته به همراه7 افزوده شده و 1 حذف شده
  1. 7 1
      integration/image/save_test.go

+ 7 - 1
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) {