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 committed Nov 2, 2023
1 parent 34b2dfd commit bd61947
Show file tree
Hide file tree
Showing 2 changed files with 18 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 @@ -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)
}
}
}
Expand Down
19 changes: 17 additions & 2 deletions smoke/tests/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit bd61947

Please sign in to comment.