-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(export): resolve issue with exporting specific images (#6471)
Signed-off-by: Yaroslav Pershin <62902094+iapershin@users.noreply.github.com>
- Loading branch information
Showing
7 changed files
with
188 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
project: werf-test-e2e-export-complex | ||
configVersion: 1 | ||
--- | ||
image: backend | ||
from: ubuntu:22.04 | ||
--- | ||
image: frombackend | ||
fromImage: backend | ||
--- | ||
image: frombackend2 | ||
fromImage: frombackend | ||
shell: | ||
install: date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package e2e_export_test | ||
|
||
import ( | ||
"strings" | ||
) | ||
|
||
type commonTestOptions struct { | ||
Platforms []string | ||
CustomLabels []string | ||
} | ||
|
||
func setupEnv() { | ||
SuiteData.WerfRepo = strings.Join([]string{SuiteData.RegistryLocalAddress, SuiteData.ProjectName}, "/") | ||
SuiteData.Stubs.SetEnv("WERF_REPO", SuiteData.WerfRepo) | ||
} | ||
|
||
func getExportArgs(imageName string, opts commonTestOptions) []string { | ||
exportArgs := []string{ | ||
"--tag", | ||
imageName, | ||
} | ||
if len(opts.Platforms) > 0 { | ||
for _, platform := range opts.Platforms { | ||
exportArgs = append(exportArgs, "--platform", platform) | ||
} | ||
} | ||
if len(opts.CustomLabels) > 0 { | ||
for _, label := range opts.CustomLabels { | ||
exportArgs = append(exportArgs, "--add-label", label) | ||
} | ||
} | ||
|
||
return exportArgs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package e2e_export_test | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/werf/werf/v2/test/pkg/utils" | ||
"github.com/werf/werf/v2/test/pkg/werf" | ||
) | ||
|
||
type complexTestOptions struct { | ||
Platforms []string | ||
ImageNames []string | ||
} | ||
|
||
var _ = Describe("Complex converge", Label("e2e", "converge", "complex"), func() { | ||
DescribeTable("should succeed and export images", | ||
func(opts complexTestOptions) { | ||
By("initializating") | ||
setupEnv() | ||
repoDirname := "repo0" | ||
By("state0: starting") | ||
{ | ||
fixtureRelPath := "complex/state0" | ||
|
||
By("state0: preparing test repo") | ||
SuiteData.InitTestRepo(repoDirname, fixtureRelPath) | ||
|
||
By("state0: running export") | ||
werfProject := werf.NewProject(SuiteData.WerfBinPath, SuiteData.GetTestRepoPath(repoDirname)) | ||
imageTemplate := `werf-export-%image%` | ||
tag := utils.GetRandomString(10) | ||
imageName := fmt.Sprintf("%s/%s:%s", SuiteData.RegistryLocalAddress, imageTemplate, tag) | ||
|
||
exportArgs := getExportArgs(imageName, commonTestOptions{ | ||
Platforms: opts.Platforms, | ||
}) | ||
|
||
exportOut := werfProject.Export(&werf.ExportOptions{ | ||
CommonOptions: werf.CommonOptions{ | ||
ExtraArgs: exportArgs, | ||
}, | ||
}) | ||
for _, imageName := range opts.ImageNames { | ||
Expect(exportOut).To(ContainSubstring(fmt.Sprintf("Exporting image %s", imageName))) | ||
} | ||
|
||
By("state0: checking result") | ||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) | ||
defer cancel() | ||
|
||
for _, imageName := range opts.ImageNames { | ||
b, err := SuiteData.ContainerRegistry.IsTagExist(ctx, fmt.Sprintf("%s/werf-export-%s:%s", SuiteData.RegistryLocalAddress, imageName, tag)) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(b).To(BeTrue()) | ||
} | ||
} | ||
}, | ||
Entry("base", complexTestOptions{ | ||
ImageNames: []string{ | ||
"backend", | ||
"frombackend", | ||
"frombackend2", | ||
}, | ||
}), | ||
Entry("multiplatform", complexTestOptions{ | ||
Platforms: []string{ | ||
"linux/amd64", | ||
}, | ||
ImageNames: []string{ | ||
"backend", | ||
"frombackend", | ||
"frombackend2", | ||
}, | ||
}), | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters