Skip to content

Commit

Permalink
test: add crc integration test
Browse files Browse the repository at this point in the history
Add image crc checksum test in integration case to smoke test.

Signed-off-by: Yang Kaiyong <[email protected]>
  • Loading branch information
Yang Kaiyong committed Feb 24, 2025
1 parent b93aae6 commit c5d46ba
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
17 changes: 14 additions & 3 deletions smoke/tests/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
paramZran = "zran"
paramBatch = "batch"
paramEncrypt = "encrypt"
paramCrc = "crc"
paramAmplifyIO = "amplify_io"
)

Expand All @@ -38,6 +39,7 @@ func (i *ImageTestSuite) TestConvertImages() test.Generator {
Dimension(paramZran, []interface{}{false, true}).
Dimension(paramBatch, []interface{}{"0", "0x100000"}).
Dimension(paramEncrypt, []interface{}{false, true}).
Dimension(paramCrc, []interface{}{false, true}).
Skip(
func(param *tool.DescartesItem) bool {
// Zran and Batch not work with rafs v5.
Expand All @@ -48,8 +50,10 @@ func (i *ImageTestSuite) TestConvertImages() test.Generator {

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

return func() (name string, testCase test.Case) {
Expand All @@ -63,6 +67,7 @@ func (i *ImageTestSuite) TestConvertImages() test.Generator {
ctx.Build.OCIRef = scenario.GetBool(paramZran)
ctx.Build.BatchSize = scenario.GetString(paramBatch)
ctx.Build.Encrypt = scenario.GetBool(paramEncrypt)
ctx.Build.CrcEnable = scenario.GetBool(paramCrc)

image := i.prepareImage(i.T, scenario.GetString(paramImage))
return scenario.Str(), func(t *testing.T) {
Expand Down Expand Up @@ -93,6 +98,11 @@ func (i *ImageTestSuite) TestConvertAndCopyImage(t *testing.T, ctx tool.Context,
enableEncrypt = "--encrypt"
}

enableCrc := ""
if ctx.Build.CrcEnable {
enableCrc = "--crc"
}

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

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

Expand Down
1 change: 1 addition & 0 deletions smoke/tests/native_layer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (n *NativeLayerTestSuite) TestMakeLayers() test.Generator {
Dimension(paramEnablePrefetch, []interface{}{false, true}).
Dimension(paramBatch, []interface{}{"0", "0x100000"}).
Dimension(paramEncrypt, []interface{}{false, true}).
Dimension(paramCrc, []interface{}{false, true}).
Dimension(paramAmplifyIO, []interface{}{uint64(0x100000)}).
Dimension(paramChunkDedupDb, []interface{}{"", "/tmp/cas.db"}).
Skip(func(param *tool.DescartesItem) bool {
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 @@ -29,6 +29,7 @@ type BuildContext struct {
OCIRefGzip bool
BatchSize string
Encrypt bool
CrcEnable bool
}

type RuntimeContext struct {
Expand Down

0 comments on commit c5d46ba

Please sign in to comment.