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>
This commit is contained in:
Paweł Gronowski 2023-11-24 13:58:27 +01:00
parent cfdca8dc1d
commit 05523e289b
No known key found for this signature in database
GPG key ID: B85EFCFE26DEF92A

View file

@ -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) {