diff --git a/contrib/nydusify/tests/e2e_test.go b/contrib/nydusify/tests/e2e_test.go index af5ffd7e343..880643052b4 100644 --- a/contrib/nydusify/tests/e2e_test.go +++ b/contrib/nydusify/tests/e2e_test.go @@ -9,74 +9,75 @@ import ( "testing" ) -func testBasicConvert(t *testing.T) { +func testBasicConvert(t *testing.T, imageVersion string) { registry := NewRegistry(t) defer registry.Destroy(t) - registry.Build(t, "image-basic") - nydusify := NewNydusify(registry, "image-basic", "image-basic-nydus", "", "") + nydusify := NewNydusify(registry, "image-basic", "image-basic-nydus", "", "", imageVersion) nydusify.Convert(t) nydusify.Check(t) } -func testConvertWithCache(t *testing.T) { +func testConvertWithCache(t *testing.T, imageVersion string) { registry := NewRegistry(t) defer registry.Destroy(t) registry.Build(t, "image-basic") - nydusify1 := NewNydusify(registry, "image-basic", "image-basic-nydus-1", "cache:v1", "") + nydusify1 := NewNydusify(registry, "image-basic", "image-basic-nydus-1", "cache:v1", "", imageVersion) nydusify1.Convert(t) nydusify1.Check(t) - - nydusify2 := NewNydusify(registry, "image-basic", "image-basic-nydus-2", "cache:v1", "") + nydusify2 := NewNydusify(registry, "image-basic", "image-basic-nydus-2", "cache:v1", "", imageVersion) nydusify2.Convert(t) nydusify2.Check(t) registry.Build(t, "image-from-1") - nydusify3 := NewNydusify(registry, "image-from-1", "image-from-nydus-1", "cache:v1", "") + nydusify3 := NewNydusify(registry, "image-from-1", "image-from-nydus-1", "cache:v1", "", imageVersion) nydusify3.Convert(t) nydusify3.Check(t) registry.Build(t, "image-from-2") - nydusify4 := NewNydusify(registry, "image-from-2", "image-from-nydus-2", "cache:v1", "") + nydusify4 := NewNydusify(registry, "image-from-2", "image-from-nydus-2", "cache:v1", "", imageVersion) nydusify4.Convert(t) nydusify4.Check(t) } -func testConvertWithChunkDict(t *testing.T) { +func testConvertWithChunkDict(t *testing.T, imageVersion string) { registry := NewRegistry(t) defer registry.Destroy(t) registry.Build(t, "chunk-dict-1") // build chunk-dict-1 bootstrap - nydusify1 := NewNydusify(registry, "chunk-dict-1", "nydus:chunk-dict-1", "", "") + nydusify1 := NewNydusify(registry, "chunk-dict-1", "nydus:chunk-dict-1", "", "", imageVersion) nydusify1.Convert(t) nydusify1.Check(t) chunkDictOpt := fmt.Sprintf("bootstrap:registry:%s/%s", registry.Host(), "nydus:chunk-dict-1") // build without build-cache registry.Build(t, "image-basic") - nydusify2 := NewNydusify(registry, "image-basic", "nydus:image-basic", "", chunkDictOpt) + nydusify2 := NewNydusify(registry, "image-basic", "nydus:image-basic", "", chunkDictOpt, imageVersion) nydusify2.Convert(t) nydusify2.Check(t) // build with build-cache registry.Build(t, "image-from-1") - nydusify3 := NewNydusify(registry, "image-from-1", "nydus:image-from-1", "nydus:cache_v1", chunkDictOpt) + nydusify3 := NewNydusify(registry, "image-from-1", "nydus:image-from-1", "nydus:cache_v1", chunkDictOpt, imageVersion) nydusify3.Convert(t) nydusify3.Check(t) // change chunk dict registry.Build(t, "chunk-dict-2") - nydusify4 := NewNydusify(registry, "chunk-dict-2", "nydus:chunk-dict-2", "", "") + nydusify4 := NewNydusify(registry, "chunk-dict-2", "nydus:chunk-dict-2", "", "", imageVersion) nydusify4.Convert(t) nydusify4.Check(t) chunkDictOpt = fmt.Sprintf("bootstrap:registry:%s/%s", registry.Host(), "nydus:chunk-dict-2") registry.Build(t, "image-from-2") - nydusify5 := NewNydusify(registry, "image-from-2", "nydus:image-from-2", "nydus:cache_v1", chunkDictOpt) + nydusify5 := NewNydusify(registry, "image-from-2", "nydus:image-from-2", "nydus:cache_v1", chunkDictOpt, imageVersion) nydusify5.Convert(t) nydusify5.Check(t) } func TestSmoke(t *testing.T) { - testBasicConvert(t) - testConvertWithCache(t) - testConvertWithChunkDict(t) + imageVersions := [2]string{"5", "6"} + for _, v := range imageVersions { + testBasicConvert(t, v) + testConvertWithCache(t, v) + testConvertWithChunkDict(t, v) + } } diff --git a/contrib/nydusify/tests/image_test.go b/contrib/nydusify/tests/image_test.go index 18b6be7dac9..f50a6624abb 100644 --- a/contrib/nydusify/tests/image_test.go +++ b/contrib/nydusify/tests/image_test.go @@ -34,17 +34,18 @@ func transfer(t *testing.T, ref string) { run(t, fmt.Sprintf("docker push %s/%s", host, ref), true) } -func convert(t *testing.T, ref string) { +func convert(t *testing.T, ref string, imageVersion string) { registry := NewRegistry(t) defer registry.Destroy(t) transfer(t, ref) - nydusify := NewNydusify(registry, ref, fmt.Sprintf("%s-nydus", ref), "", "") + nydusify := NewNydusify(registry, ref, fmt.Sprintf("%s-nydus", ref), "", "", imageVersion) nydusify.Convert(t) nydusify.Check(t) } func TestDockerHubImage(t *testing.T) { for _, ref := range list { - convert(t, ref) + convert(t, ref, "5") + convert(t, ref, "6") } } diff --git a/contrib/nydusify/tests/nydusify.go b/contrib/nydusify/tests/nydusify.go index df67fe92a93..8a9165f1901 100644 --- a/contrib/nydusify/tests/nydusify.go +++ b/contrib/nydusify/tests/nydusify.go @@ -42,9 +42,10 @@ type Nydusify struct { backendType string backendConfig string chunkDictArgs string + imageVersion string } -func NewNydusify(registry *Registry, source, target, cache string, chunkDictArgs string) *Nydusify { +func NewNydusify(registry *Registry, source, target, cache string, chunkDictArgs string, imageVersion string) *Nydusify { host := registry.Host() backendType := "registry" @@ -60,6 +61,9 @@ func NewNydusify(registry *Registry, source, target, cache string, chunkDictArgs if os.Getenv("BACKEND_CONFIG") != "" { backendConfig = os.Getenv("BACKEND_CONFIG") } + if len(imageVersion) == 0 { + imageVersion = "5" + } return &Nydusify{ Registry: registry, @@ -69,6 +73,7 @@ func NewNydusify(registry *Registry, source, target, cache string, chunkDictArgs backendType: backendType, backendConfig: backendConfig, chunkDictArgs: chunkDictArgs, + imageVersion: imageVersion, } } @@ -128,6 +133,7 @@ func (nydusify *Nydusify) Convert(t *testing.T) { Insecure: false, Platform: "linux/amd64", }, + ImageVersion: nydusify.imageVersion, } cvt, err := converter.New(opt)