Skip to content

Commit

Permalink
fix: e2e tests (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
SparkYuan committed Dec 7, 2023
1 parent cc705cc commit 3386d90
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test/e2e/kusionctl_test.go
Expand Up @@ -19,7 +19,7 @@ var _ = ginkgo.Describe("Kusion Configuration Commands", func() {
ginkgo.Context("kusion build testing", func() {
ginkgo.It("kusion build", func() {
// kusion build testing
path := filepath.Join(GetWorkDir(), "konfig", "example", "multi-stack", "dev")
path := filepath.Join(GetWorkDir(), "konfig", "example", "service-multi-stack", "dev")
output, err := ExecKusionWithWorkDir("kusion build", path)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
gomega.Expect(output).To(gomega.ContainSubstring("Generating Intent"))
Expand All @@ -29,7 +29,7 @@ var _ = ginkgo.Describe("Kusion Configuration Commands", func() {
ginkgo.Context("kusion deps testing", func() {
ginkgo.It("kusion deps", func() {
// kusion deps testing
path := filepath.Join(GetWorkDir(), "konfig", "example", "multi-stack", "dev")
path := filepath.Join(GetWorkDir(), "konfig", "example", "service-multi-stack", "dev")
output, err := ExecKusionWithWorkDir("kusion deps --focus main.k", path)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
gomega.Expect(output).To(gomega.ContainSubstring("catalog/models/schema/v1"))
Expand All @@ -39,44 +39,44 @@ var _ = ginkgo.Describe("Kusion Configuration Commands", func() {

var _ = ginkgo.Describe("kusion Runtime Commands", func() {
ginkgo.It("kusion preview", func() {
path := filepath.Join(GetWorkDir(), "konfig", "example", "multi-stack", "dev")
path := filepath.Join(GetWorkDir(), "konfig", "example", "service-multi-stack", "dev")
_, err := ExecKusionWithWorkDir("kusion preview -d", path)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
})

ginkgo.It("kusion apply", func() {
ginkgo.By("kusion apply", func() {
path := filepath.Join(GetWorkDir(), "konfig", "example", "multi-stack", "dev")
path := filepath.Join(GetWorkDir(), "konfig", "example", "service-multi-stack", "dev")
_, err := ExecKusionWithWorkDir("kusion apply -y=true --watch=true", path)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
})

ginkgo.By("wait multi-stack deploy", func() {
ginkgo.By("wait service-multi-stack deploy", func() {
homedir := os.Getenv("HOME")
configPath := fmt.Sprintf("%s/.kube/config", homedir)
clusterConfig, err := clientcmd.BuildConfigFromFlags("", configPath)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
clusterClient := kubernetes.NewForConfigOrDie(clusterConfig)
gomega.Eventually(func() bool {
_, err := clusterClient.AppsV1().Deployments("multi-stack").Get(context.TODO(), "multi-stack-dev-helloworld", metav1.GetOptions{})
_, err := clusterClient.AppsV1().Deployments("service-multi-stack").Get(context.TODO(), "service-multi-stack-dev-echoserver", metav1.GetOptions{})
return err == nil
}, 300*time.Second, 5*time.Second).Should(gomega.Equal(true))
})

ginkgo.By("kusion destroy", func() {
path := filepath.Join(GetWorkDir(), "konfig", "example", "multi-stack", "dev")
path := filepath.Join(GetWorkDir(), "konfig", "example", "service-multi-stack", "dev")
_, err := ExecKusionWithWorkDir("kusion destroy -y=true", path)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
})

ginkgo.By("wait multi-stack destroy", func() {
ginkgo.By("wait service-multi-stack destroy", func() {
homedir := os.Getenv("HOME")
configPath := fmt.Sprintf("%s/.kube/config", homedir)
clusterConfig, err := clientcmd.BuildConfigFromFlags("", configPath)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
clusterClient := kubernetes.NewForConfigOrDie(clusterConfig)
gomega.Eventually(func() bool {
_, err := clusterClient.CoreV1().Namespaces().Get(context.TODO(), "multi-stack", metav1.GetOptions{})
_, err := clusterClient.CoreV1().Namespaces().Get(context.TODO(), "service-multi-stack", metav1.GetOptions{})
return apierrors.IsNotFound(err)
}, 300*time.Second, 5*time.Second).Should(gomega.Equal(true))
})
Expand Down

0 comments on commit 3386d90

Please sign in to comment.