diff --git a/smoke/tests/image_test.go b/smoke/tests/image_test.go index 4ca45fed99f..ff785b38df5 100644 --- a/smoke/tests/image_test.go +++ b/smoke/tests/image_test.go @@ -15,8 +15,9 @@ import ( ) const ( - paramZran = "zran" - paramBatch = "batch" + paramZran = "zran" + paramBatch = "batch" + paramEncrypt = "encrypt" ) type ImageTestSuite struct { @@ -32,15 +33,19 @@ func (i *ImageTestSuite) TestConvertImages() test.Generator { Dimension(paramFSVersion, []interface{}{"5", "6"}). Dimension(paramZran, []interface{}{false, true}). Dimension(paramBatch, []interface{}{"0", "0x100000"}). + Dimension(paramEncrypt, []interface{}{false, true}). Skip( func(param *tool.DescartesItem) bool { // Zran and Batch not work with rafs v5. - if param.GetString(paramFSVersion) == "5" && (param.GetBool(paramZran) || param.GetString(paramBatch) != "0") { + if param.GetString(paramFSVersion) == "5" && (param.GetBool(paramZran)) || + param.GetString(paramBatch) != "0" || (param.GetBool(paramEncrypt)) { return true } // Zran and Batch can not work together. - return param.GetBool(paramZran) && param.GetString(paramBatch) != "0" + // Zran and Encrpt can not work together. + return (param.GetBool(paramZran) && param.GetString(paramBatch) != "0") || + (param.GetBool(paramZran) && param.GetBool(paramEncrypt)) }) return func() (name string, testCase test.Case) { @@ -53,6 +58,7 @@ func (i *ImageTestSuite) TestConvertImages() test.Generator { ctx.Build.FSVersion = scenario.GetString(paramFSVersion) ctx.Build.OCIRef = scenario.GetBool(paramZran) ctx.Build.BatchSize = scenario.GetString(paramBatch) + ctx.Build.Encrypt = scenario.GetBool(paramEncrypt) image := i.prepareImage(i.T, scenario.GetString(paramImage)) return scenario.Str(), func(t *testing.T) { @@ -78,6 +84,11 @@ func (i *ImageTestSuite) TestConvertImage(t *testing.T, ctx tool.Context, source enableBatchSize = "--batch-size " + ctx.Build.BatchSize } + enableEncrypt := "" + if ctx.Build.Encrypt { + enableEncrypt = "--encrypt" + } + target := fmt.Sprintf("%s-nydus-%s", source, uuid.NewString()) fsVersion := fmt.Sprintf("--fs-version %s", ctx.Build.FSVersion) logLevel := "--log-level warn" @@ -92,8 +103,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 %s --nydus-image %s --work-dir %s %s", - ctx.Binary.Nydusify, logLevel, source, target, fsVersion, enableOCIRef, enableBatchSize, ctx.Binary.Builder, ctx.Env.WorkDir, compressor, + "%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, ) tool.RunWithoutOutput(t, convertCmd) diff --git a/smoke/tests/native_layer_test.go b/smoke/tests/native_layer_test.go index 17f1e2939c8..99f1031b309 100644 --- a/smoke/tests/native_layer_test.go +++ b/smoke/tests/native_layer_test.go @@ -42,6 +42,7 @@ func (n *NativeLayerTestSuite) TestMakeLayers() test.Generator { Dimension(paramRafsMode, []interface{}{"direct", "cached"}). Dimension(paramEnablePrefetch, []interface{}{false, true}). Dimension(paramBatch, []interface{}{"0", "0x100000"}). + Dimension(paramEncrypt, []interface{}{false, true}). Skip(func(param *tool.DescartesItem) bool { // rafs v6 not support cached mode nor dummy cache @@ -54,8 +55,8 @@ func (n *NativeLayerTestSuite) TestMakeLayers() test.Generator { return true } - // Batch not work with rafs v5. - if param.GetString(paramFSVersion) == "5" && param.GetString(paramBatch) != "0" { + // Batch or encrypt not work with rafs v5. + if param.GetString(paramFSVersion) == "5" && (param.GetString(paramBatch) != "0" || param.GetBool(paramEncrypt)) { return true } diff --git a/smoke/tests/tool/context.go b/smoke/tests/tool/context.go index 80a0f5e16ce..9e714eb0cf0 100644 --- a/smoke/tests/tool/context.go +++ b/smoke/tests/tool/context.go @@ -29,6 +29,7 @@ type BuildContext struct { OCIRef bool OCIRefGzip bool BatchSize string + Encrypt bool } type RuntimeContext struct { diff --git a/smoke/tests/zran_layer_test.go b/smoke/tests/zran_layer_test.go index a8938f539e6..819cb530536 100644 --- a/smoke/tests/zran_layer_test.go +++ b/smoke/tests/zran_layer_test.go @@ -24,7 +24,7 @@ type ZranTestSuite struct { t *testing.T } -func (z *ZranTestSuite) TestMakeLayers() test.Generator { +func (z *EncryptTestSuite) TestMakeLayers() test.Generator { scenarios := tool.DescartesIterator{} scenarios. @@ -50,7 +50,7 @@ func (z *ZranTestSuite) TestMakeLayers() test.Generator { } } -func (z *ZranTestSuite) testMakeLayers(ctx tool.Context, t *testing.T) { +func (z *EncryptTestSuite) testMakeLayers(ctx tool.Context, t *testing.T) { // Prepare work directory ctx.PrepareWorkDir(t) @@ -77,5 +77,5 @@ func (z *ZranTestSuite) testMakeLayers(ctx tool.Context, t *testing.T) { } func TestZranLayer(t *testing.T) { - test.Run(t, &ZranTestSuite{t: t}) + test.Run(t, &EncryptTestSuite{t: t}) }