Skip to content

Commit

Permalink
Add smoke test
Browse files Browse the repository at this point in the history
Signed-off-by: Zhao Yuan <1627990440@qq.com>
  • Loading branch information
newthifans committed Nov 28, 2023
1 parent bbc9ae5 commit 8d255a4
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions smoke/tests/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,55 @@ func (i *ImageTestSuite) TestConvertAndCopyImage(t *testing.T, ctx tool.Context,
tool.RunWithoutOutput(t, checkCmd)
}

func (i *ImageTestSuite) TestCompactImages() test.Generator {

scenarios := tool.DescartesIterator{}
scenarios.Dimension(paramImage, []interface{}{"nginx:latest"})

return func() (name string, testCase test.Case) {
if !scenarios.HasNext() {
return
}
scenario := scenarios.Next()
ctx := tool.DefaultContext(i.T)


image := i.prepareImage(i.T, scenario.GetString(paramImage))
return scenario.Str(), func(t *testing.T) {
i.TestCompact(t, *ctx, image)
}
}
}

func (i *ImageTestSuite) TestCompact(t *testing.T, ctx tool.Context, source string) {

// Prepare work directory
ctx.PrepareWorkDir(t)
defer ctx.Destroy(t)

target := fmt.Sprintf("%s-nydus-%s", source, uuid.NewString())
fsVersion := fmt.Sprintf("--fs-version %s", ctx.Build.FSVersion)
logLevel := "--log-level warn"

// Convert image
convertCmd := fmt.Sprintf(
"%s %s convert --source %s --target %s %s --nydus-image %s --work-dir %s",
ctx.Binary.Nydusify, logLevel, source, target, fsVersion, ctx.Binary.Builder, ctx.Env.WorkDir,
)
tool.RunWithoutOutput(t, convertCmd)

// Compact image
bootstrapPath := "/home/runner/work/image-service/chunkdict/image-service/contrib/nydusify/output/localhost:5000:redis:nydus6_7.0.2/nydus_bootstrap"
compactconfigPath := "/home/runner/compact.json"
backendcompactPath := "/home/runner/backend-config.json"

compactCmd := fmt.Sprintf(
"%s %s compact --bootstrap %s --compact-config %s --backend-config %s",
ctx.Binary.Builder, logLevel, bootstrapPath, compactconfigPath, backendcompactPath,
)
tool.RunWithoutOutput(t, compactCmd)
}

func (i *ImageTestSuite) prepareImage(t *testing.T, image string) string {
if i.preparedImages == nil {
i.preparedImages = make(map[string]string)
Expand Down

0 comments on commit 8d255a4

Please sign in to comment.