Skip to content

Commit

Permalink
smoke: add basic nydusify copy test
Browse files Browse the repository at this point in the history
Signed-off-by: Yan Song <yansong.ys@antgroup.com>
  • Loading branch information
imeoer authored and bergwolf committed Nov 2, 2023
1 parent cf9dbdd commit 1c9c819
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion smoke/tests/compatibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,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, false)
}
}
}
Expand Down
23 changes: 21 additions & 2 deletions smoke/tests/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,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, true)
}
}
}

func (i *ImageTestSuite) TestConvertImage(t *testing.T, ctx tool.Context, source string) {
func (i *ImageTestSuite) TestConvertAndCopyImage(t *testing.T, ctx tool.Context, source string, testCopy bool) {

// Prepare work directory
ctx.PrepareWorkDir(t)
Expand Down Expand Up @@ -94,6 +94,25 @@ 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)

if !testCopy {
return
}

// 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 {
Expand Down

0 comments on commit 1c9c819

Please sign in to comment.