From 439086fb1b29a022286474744fd6f4be732653b6 Mon Sep 17 00:00:00 2001 From: Austin Vazquez Date: Mon, 19 Aug 2024 17:14:53 +0000 Subject: [PATCH 1/2] Fix image prune filter until test rmi cleanup not running. Signed-off-by: Austin Vazquez --- cmd/nerdctl/image_prune_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/nerdctl/image_prune_test.go b/cmd/nerdctl/image_prune_test.go index 0f9f423a4d7..d0772b8a33f 100644 --- a/cmd/nerdctl/image_prune_test.go +++ b/cmd/nerdctl/image_prune_test.go @@ -107,7 +107,12 @@ func TestImagePruneFilterUntil(t *testing.T) { base := testutil.NewBase(t) imageName := testutil.Identifier(t) - t.Cleanup(func() { base.Cmd("rmi", "--force", imageName) }) + teardown := func() { + // Image should have been pruned; but cleanup on failure. + base.Cmd("rmi", "--force", imageName).Run() + } + t.Cleanup(teardown) + teardown() dockerfile := fmt.Sprintf(`FROM %s CMD ["echo", "nerdctl-test-image-prune-filter-until"]`, testutil.CommonImage) From 6362afc1693bf6d5076fab9608ff120e33ea6b3d Mon Sep 17 00:00:00 2001 From: Austin Vazquez Date: Sat, 17 Aug 2024 18:22:00 +0000 Subject: [PATCH 2/2] Remove Docker incompat from image prune and build tests Signed-off-by: Austin Vazquez --- cmd/nerdctl/builder_build_test.go | 1 - cmd/nerdctl/image_prune_test.go | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cmd/nerdctl/builder_build_test.go b/cmd/nerdctl/builder_build_test.go index f187fe6441b..774bf02d5b2 100644 --- a/cmd/nerdctl/builder_build_test.go +++ b/cmd/nerdctl/builder_build_test.go @@ -462,7 +462,6 @@ RUN ["cat", "/hello_from_dir2.txt"]`, testutil.CommonImage, filename) // https://github.com/docker/buildx/pull/1482 func TestBuildSourceDateEpoch(t *testing.T) { testutil.RequiresBuild(t) - testutil.DockerIncompatible(t) // Needs buildx v0.10 (https://github.com/docker/buildx/pull/1489) base := testutil.NewBase(t) imageName := testutil.Identifier(t) defer base.Cmd("rmi", imageName).AssertOK() diff --git a/cmd/nerdctl/image_prune_test.go b/cmd/nerdctl/image_prune_test.go index d0772b8a33f..17d7ec038a9 100644 --- a/cmd/nerdctl/image_prune_test.go +++ b/cmd/nerdctl/image_prune_test.go @@ -102,10 +102,10 @@ func TestImagePruneFilterUntil(t *testing.T) { testutil.RequiresBuild(t) testutil.RegisterBuildCacheCleanup(t) - // Docker image's created timestamp is set based on base image creation time. - testutil.DockerIncompatible(t) - base := testutil.NewBase(t) + // For deterministically testing the filter, set the image's created timestamp to 2 hours in the past. + base.Env = append(base.Env, fmt.Sprintf("SOURCE_DATE_EPOCH=%d", time.Now().Add(-2*time.Hour).Unix())) + imageName := testutil.Identifier(t) teardown := func() { // Image should have been pruned; but cleanup on failure.