From bd619476fb9ab4babd8ca969f8ba200f7de2ef27 Mon Sep 17 00:00:00 2001 From: Yan Song Date: Thu, 2 Nov 2023 03:47:55 +0000 Subject: [PATCH] smoke: add basic nydusify copy test Signed-off-by: Yan Song --- smoke/tests/compatibility_test.go | 2 +- smoke/tests/image_test.go | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/smoke/tests/compatibility_test.go b/smoke/tests/compatibility_test.go index a757af9b528..f3d349d2b6d 100644 --- a/smoke/tests/compatibility_test.go +++ b/smoke/tests/compatibility_test.go @@ -86,7 +86,7 @@ func (c *CompatibilityTestSuite) TestConvertImages() test.Generator { image := c.prepareImage(c.t, scenario.GetString(paramImage)) return scenario.Str(), func(t *testing.T) { imageTest := &ImageTestSuite{T: t} - imageTest.TestConvertImage(t, *ctx, image) + imageTest.TestConvertAndCopyImage(t, *ctx, image) } } } diff --git a/smoke/tests/image_test.go b/smoke/tests/image_test.go index c7c9e730dfb..91b9eb42ecd 100644 --- a/smoke/tests/image_test.go +++ b/smoke/tests/image_test.go @@ -63,12 +63,12 @@ func (i *ImageTestSuite) TestConvertImages() test.Generator { image := i.prepareImage(i.T, scenario.GetString(paramImage)) return scenario.Str(), func(t *testing.T) { - i.TestConvertImage(t, *ctx, image) + i.TestConvertAndCopyImage(t, *ctx, image) } } } -func (i *ImageTestSuite) TestConvertImage(t *testing.T, ctx tool.Context, source string) { +func (i *ImageTestSuite) TestConvertAndCopyImage(t *testing.T, ctx tool.Context, source string) { // Prepare work directory ctx.PrepareWorkDir(t) @@ -119,6 +119,21 @@ func (i *ImageTestSuite) TestConvertImage(t *testing.T, ctx tool.Context, source nydusifyPath, logLevel, source, target, ctx.Binary.Builder, ctx.Binary.Nydusd, filepath.Join(ctx.Env.WorkDir, "check"), ) tool.RunWithoutOutput(t, checkCmd) + + // Copy image + targetCopied := fmt.Sprintf("%s_copied", target) + copyCmd := fmt.Sprintf( + "%s %s copy --source %s --target %s --nydus-image %s --work-dir %s", + ctx.Binary.Nydusify, logLevel, target, targetCopied, ctx.Binary.Builder, ctx.Env.WorkDir, + ) + tool.RunWithoutOutput(t, copyCmd) + + // Check copied image + checkCmd = fmt.Sprintf( + "%s %s check --source %s --target %s --nydus-image %s --nydusd %s --work-dir %s", + nydusifyPath, logLevel, source, targetCopied, ctx.Binary.Builder, ctx.Binary.Nydusd, filepath.Join(ctx.Env.WorkDir, "check"), + ) + tool.RunWithoutOutput(t, checkCmd) } func (i *ImageTestSuite) prepareImage(t *testing.T, image string) string {