Skip to content

c8d/save: Add tests#48722

Merged
thaJeztah merged 1 commit intomoby:masterfrom
vvoland:c8d-save-addtests
Nov 5, 2024
Merged

c8d/save: Add tests#48722
thaJeztah merged 1 commit intomoby:masterfrom
vvoland:c8d-save-addtests

Conversation

@vvoland
Copy link
Copy Markdown
Contributor

@vvoland vvoland commented Oct 22, 2024

Test saving a shallow/partial image.

- How to verify it
TestImageMultiplatformSaveShallowWithNative and TestImageMultiplatformSaveShallowWithoutNative

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@vvoland vvoland added status/2-code-review area/testing containerd-integration Issues and PRs related to containerd integration labels Oct 22, 2024
@vvoland vvoland added this to the 28.0.0 milestone Oct 22, 2024
@vvoland vvoland self-assigned this Oct 22, 2024
Comment on lines +89 to +94
t.Run("export without specific platform", func(t *testing.T) {
// TODO(vvoland): https://github.com/docker/cli/issues/5476
t.Skip()
err = imgSvc.ExportImage(ctx, []string{img.Name}, nil, io.Discard)
assert.NilError(t, err)
})
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tests the issue reported in: docker/cli#5476

Comment thread daemon/containerd/image_save_test.go Outdated
Comment thread daemon/containerd/image_save_test.go Outdated
Comment thread daemon/containerd/image_save_test.go Outdated
Test saving a shallow/partial image

Signed-off-by: Paweł Gronowski <[email protected]>
@vvoland vvoland marked this pull request as ready for review October 28, 2024 13:59
@vvoland vvoland requested a review from thaJeztah October 28, 2024 13:59
is "gotest.tools/v3/assert/cmp"
)

func TestImageMultiplatformSaveShallowWithNative(t *testing.T) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we could somehow combine these two tests in a test-table. I went looking what the differences are, and this is the diff if I copy the other test's content here;

diff --git a/daemon/containerd/image_save_test.go b/daemon/containerd/image_save_test.go
index 13a9c86565..9fb565fc7b 100644
--- a/daemon/containerd/image_save_test.go
+++ b/daemon/containerd/image_save_test.go
@@ -35,9 +35,9 @@ func TestImageMultiplatformSaveShallowWithNative(t *testing.T) {
        // Mock the native platform.
        imgSvc.defaultPlatformOverride = platforms.Only(native)

-       idx, _, err := specialimage.PartialMultiPlatform(contentDir, "partial-with-native:latest", specialimage.PartialOpts{
-               Stored:  []ocispec.Platform{native},
-               Missing: []ocispec.Platform{arm64},
+       idx, _, err := specialimage.PartialMultiPlatform(contentDir, "partial-without-native:latest", specialimage.PartialOpts{
+               Stored:  []ocispec.Platform{arm64},
+               Missing: []ocispec.Platform{native},
        })
        assert.NilError(t, err)

@@ -45,16 +45,17 @@ func TestImageMultiplatformSaveShallowWithNative(t *testing.T) {
        assert.NilError(t, err)

        t.Run("export without specific platform", func(t *testing.T) {
+               t.Skip("TODO(vvoland): https://github.com/docker/cli/issues/5476")
                err = imgSvc.ExportImage(ctx, []string{img.Name}, nil, io.Discard)
                assert.NilError(t, err)
        })
        t.Run("export native", func(t *testing.T) {
                err = imgSvc.ExportImage(ctx, []string{img.Name}, &native, io.Discard)
-               assert.NilError(t, err)
+               assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
        })
-       t.Run("export missing", func(t *testing.T) {
+       t.Run("export arm64", func(t *testing.T) {
                err = imgSvc.ExportImage(ctx, []string{img.Name}, &arm64, io.Discard)
-               assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
+               assert.NilError(t, err)
        })
 }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but IMO that makes the test less clear. Separation also helps a bit with the TODO case which only fails in one of these tests.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separation also helps a bit with the TODO case which only fails in one of these tests.

Yeah, that's fair. I was considering the amount of boiler plating, and possibly having to keep those in sync, but it's not a blocker.

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

is "gotest.tools/v3/assert/cmp"
)

func TestImageMultiplatformSaveShallowWithNative(t *testing.T) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separation also helps a bit with the TODO case which only fails in one of these tests.

Yeah, that's fair. I was considering the amount of boiler plating, and possibly having to keep those in sync, but it's not a blocker.

Comment on lines +24 to +27
native := platforms.Platform{
OS: "linux",
Architecture: "amd64",
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering if we should have a really fictive platform for native (e.g. cpm/z80); I know we're mocking things, but to reduce risk of a test falling through an matching actual native platforms (which can differ where you're running).

(also not a blocker, mostly thinking out loud here)q

@thaJeztah thaJeztah merged commit ad8196f into moby:master Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/testing containerd-integration Issues and PRs related to containerd integration status/2-code-review

Projects

Development

Successfully merging this pull request may close these issues.

2 participants