Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4941 from werf/test-e2e-add-converge-test
test(e2e): add simple converge test
- Loading branch information
Showing
10 changed files
with
151 additions
and
7 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
6 changes: 6 additions & 0 deletions
6
test/e2e/converge/_fixtures/simple/state0/.helm/templates/configmap.yaml
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,6 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: test1 | ||
data: | ||
key1: value1 |
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,6 @@ | ||
project: werf-test-e2e-converge-simple | ||
configVersion: 1 | ||
|
||
--- | ||
image: main | ||
from: ubuntu:22.04 |
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,20 @@ | ||
package e2e_converge_test | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
|
||
"github.com/werf/werf/pkg/util" | ||
) | ||
|
||
func setupEnv() { | ||
SuiteData.Stubs.SetEnv("WERF_REPO", strings.Join([]string{os.Getenv("WERF_TEST_K8S_DOCKER_REGISTRY"), SuiteData.ProjectName}, "/")) | ||
|
||
if util.GetBoolEnvironmentDefaultFalse("WERF_TEST_K8S_DOCKER_REGISTRY_INSECURE") { | ||
SuiteData.Stubs.SetEnv("WERF_INSECURE_REGISTRY", "1") | ||
SuiteData.Stubs.SetEnv("WERF_SKIP_TLS_VERIFY_REGISTRY", "1") | ||
} else { | ||
SuiteData.Stubs.UnsetEnv("WERF_INSECURE_REGISTRY") | ||
SuiteData.Stubs.UnsetEnv("WERF_SKIP_TLS_VERIFY_REGISTRY") | ||
} | ||
} |
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,54 @@ | ||
package e2e_converge_test | ||
|
||
import ( | ||
"context" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/werf/kubedog/pkg/kube" | ||
"github.com/werf/werf/test/pkg/utils" | ||
"github.com/werf/werf/test/pkg/werf" | ||
) | ||
|
||
var _ = Describe("Simple converge", Label("e2e", "converge", "simple"), func() { | ||
var repoDirname string | ||
|
||
BeforeEach(func() { | ||
Expect(kube.Init(kube.InitOptions{})).To(Succeed()) | ||
}) | ||
|
||
AfterEach(func() { | ||
utils.RunSucceedCommand(SuiteData.GetTestRepoPath(repoDirname), SuiteData.WerfBinPath, "dismiss", "--with-namespace") | ||
}) | ||
|
||
It("should succeed and deploy expected resources", | ||
func() { | ||
By("initializing") | ||
repoDirname = "repo0" | ||
setupEnv() | ||
|
||
By("state0: starting") | ||
{ | ||
fixtureRelPath := "simple/state0" | ||
|
||
By("state0: preparing test repo") | ||
SuiteData.InitTestRepo(repoDirname, fixtureRelPath) | ||
werfProject := werf.NewProject(SuiteData.WerfBinPath, SuiteData.GetTestRepoPath(repoDirname)) | ||
|
||
By("state0: execute converge") | ||
combinedOut := werfProject.Converge(&werf.ConvergeOptions{}) | ||
|
||
By("state0: check converge output") | ||
Expect(combinedOut).To(ContainSubstring("STATUS: deployed")) | ||
Expect(combinedOut).To(ContainSubstring("REVISION: 1")) | ||
|
||
By("state0: check deployed resources in cluster") | ||
cm, err := kube.Client.CoreV1().ConfigMaps(werfProject.Namespace()).Get(context.Background(), "test1", metav1.GetOptions{}) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(cm.Data).To(Equal(map[string]string{"key1": "value1"})) | ||
} | ||
}, | ||
) | ||
}) |
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,35 @@ | ||
package e2e_converge_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
|
||
"github.com/werf/werf/test/pkg/suite_init" | ||
"github.com/werf/werf/test/pkg/utils" | ||
) | ||
|
||
func TestSuite(t *testing.T) { | ||
suite_init.MakeTestSuiteEntrypointFunc("E2E converge suite", suite_init.TestSuiteEntrypointFuncOptions{ | ||
RequiredSuiteTools: []string{"docker", "git"}, | ||
RequiredSuiteEnvs: []string{ | ||
"WERF_TEST_K8S_DOCKER_REGISTRY", | ||
}, | ||
})(t) | ||
} | ||
|
||
var SuiteData suite_init.SuiteData | ||
|
||
var ( | ||
_ = SuiteData.SetupStubs(suite_init.NewStubsData()) | ||
_ = SuiteData.SetupSynchronizedSuiteCallbacks(suite_init.NewSynchronizedSuiteCallbacksData()) | ||
_ = SuiteData.SetupWerfBinary(suite_init.NewWerfBinaryData(SuiteData.SynchronizedSuiteCallbacksData)) | ||
_ = SuiteData.SetupProjectName(suite_init.NewProjectNameData(SuiteData.StubsData)) | ||
_ = SuiteData.SetupTmp(suite_init.NewTmpDirData()) | ||
|
||
_ = SuiteData.SetupK8sDockerRegistry(suite_init.NewK8sDockerRegistryData(SuiteData.ProjectNameData, SuiteData.StubsData)) | ||
|
||
_ = AfterEach(func() { | ||
utils.RunSucceedCommand("", SuiteData.WerfBinPath, "host", "purge", "--force", "--project-name", SuiteData.ProjectName) | ||
}) | ||
) |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
project: werf-test-e2e-kube-run-complex | ||
project: werf-test-e2e-kube-run-simple | ||
configVersion: 1 | ||
|
||
--- | ||
|
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