Skip to content

Commit

Permalink
smoke: add integration test for batch chunk mode
Browse files Browse the repository at this point in the history
Signed-off-by: Wenhao Ren <[email protected]>
  • Loading branch information
hangvane authored and jiangliu committed Jun 15, 2023
1 parent 2ec92e1 commit 3ab3a75
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions smoke/tests/compatibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (c *CompatibilityTestSuite) TestConvertImages() test.Generator {
ctx.Build.Compressor = "lz4_block"
ctx.Build.ChunkSize = "0x100000"
ctx.Build.OCIRef = false
ctx.Build.BatchSize = "0"

image := c.prepareImage(c.t, scenario.GetString(paramImage))
return scenario.Str(), func(t *testing.T) {
Expand Down
24 changes: 19 additions & 5 deletions smoke/tests/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import (
)

const (
paramZran = "zran"
paramZran = "zran"
paramBatch = "batch"
)

type ImageTestSuite struct {
Expand All @@ -30,10 +31,16 @@ func (i *ImageTestSuite) TestConvertImages() test.Generator {
Dimension(paramImage, []interface{}{"nginx:latest"}).
Dimension(paramFSVersion, []interface{}{"5", "6"}).
Dimension(paramZran, []interface{}{false, true}).
Dimension(paramBatch, []interface{}{"0", "0x100000"}).
Skip(
func(param *tool.DescartesItem) bool {
// Zran not work with rafs v6.
return param.GetString(paramFSVersion) == "5" && param.GetBool(paramZran)
// Zran and Batch not work with rafs v5.
if param.GetString(paramFSVersion) == "5" && (param.GetBool(paramZran) || param.GetString(paramBatch) != "0") {
return true
}

// Zran and Batch can not work together.
return param.GetBool(paramZran) && param.GetString(paramBatch) != "0"
})

return func() (name string, testCase test.Case) {
Expand All @@ -45,6 +52,7 @@ func (i *ImageTestSuite) TestConvertImages() test.Generator {
ctx := tool.DefaultContext(i.T)
ctx.Build.FSVersion = scenario.GetString(paramFSVersion)
ctx.Build.OCIRef = scenario.GetBool(paramZran)
ctx.Build.BatchSize = scenario.GetString(paramBatch)

image := i.prepareImage(i.T, scenario.GetString(paramImage))
return scenario.Str(), func(t *testing.T) {
Expand All @@ -64,6 +72,12 @@ func (i *ImageTestSuite) TestConvertImage(t *testing.T, ctx tool.Context, source
if ctx.Build.OCIRef {
enableOCIRef = "--oci-ref"
}

enableBatchSize := ""
if ctx.Build.BatchSize != "0" {
enableBatchSize = "--batch-size " + ctx.Build.BatchSize
}

target := fmt.Sprintf("%s-nydus-%s", source, uuid.NewString())
fsVersion := fmt.Sprintf("--fs-version %s", ctx.Build.FSVersion)
logLevel := "--log-level warn"
Expand All @@ -78,8 +92,8 @@ func (i *ImageTestSuite) TestConvertImage(t *testing.T, ctx tool.Context, source

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

Expand Down
6 changes: 6 additions & 0 deletions smoke/tests/native_layer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (n *NativeLayerTestSuite) TestMakeLayers() test.Generator {
Dimension(paramCacheCompressed, []interface{}{true, false}).
Dimension(paramRafsMode, []interface{}{"direct", "cached"}).
Dimension(paramEnablePrefetch, []interface{}{false, true}).
Dimension(paramBatch, []interface{}{"0", "0x100000"}).
Skip(func(param *tool.DescartesItem) bool {

// rafs v6 not support cached mode nor dummy cache
Expand All @@ -53,6 +54,11 @@ func (n *NativeLayerTestSuite) TestMakeLayers() test.Generator {
return true
}

// Batch not work with rafs v5.
if param.GetString(paramFSVersion) == "5" && param.GetString(paramBatch) != "0" {
return true
}

return false
})

Expand Down
1 change: 1 addition & 0 deletions smoke/tests/tool/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type BuildContext struct {
ChunkSize string
OCIRef bool
OCIRefGzip bool
BatchSize string
}

type RuntimeContext struct {
Expand Down

0 comments on commit 3ab3a75

Please sign in to comment.