Skip to content

Commit

Permalink
tests: add encrypt integration test
Browse files Browse the repository at this point in the history
Add image encryption test integration case to Smoke test.

Signed-off-by: taohong <[email protected]>
  • Loading branch information
taoohong committed Jul 4, 2023
1 parent 7103c7c commit 0314971
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
23 changes: 17 additions & 6 deletions smoke/tests/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import (
)

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

type ImageTestSuite struct {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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"
Expand All @@ -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)

Expand Down
5 changes: 3 additions & 2 deletions smoke/tests/native_layer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

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 {
OCIRef bool
OCIRefGzip bool
BatchSize string
Encrypt bool
}

type RuntimeContext struct {
Expand Down

0 comments on commit 0314971

Please sign in to comment.