mirror of
https://github.com/kubevela/kubevela.git
synced 2026-02-14 18:10:21 +00:00
add rudr env test cases and refine rudr run:workload
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"github.com/cloud-native-application/rudrx/e2e"
|
||||
"testing"
|
||||
|
||||
"github.com/cloud-native-application/rudrx/e2e"
|
||||
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
@@ -18,5 +19,5 @@ var _ = ginkgo.BeforeSuite(func() {
|
||||
|
||||
func TestComponent(t *testing.T) {
|
||||
gomega.RegisterFailHandler(ginkgo.Fail)
|
||||
ginkgo.RunSpecs(t, "Command Suite")
|
||||
ginkgo.RunSpecs(t, "Workload Suite")
|
||||
}
|
||||
|
||||
@@ -2,16 +2,39 @@ package e2e
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cloud-native-application/rudrx/e2e"
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var (
|
||||
//TODO(zzxwill) Need to change env name after [issue#82](https://github.com/cloud-native-application/RudrX/issues/82) is fixed.
|
||||
envName = "default"
|
||||
applicationName = "app-testworkloadrun-basic"
|
||||
)
|
||||
|
||||
var _ = ginkgo.Describe("Component", func() {
|
||||
var _ = ginkgo.Describe("Workload", func() {
|
||||
ginkgo.Context("env init", func() {
|
||||
ginkgo.It("should print env initiation successful message", func() {
|
||||
cli := fmt.Sprintf("rudr env:init %s --namespace %s", envName, envName)
|
||||
output, err := e2e.Exec(cli)
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||
expectedOutput := fmt.Sprintf("Create env succeed, current env is %s", envName)
|
||||
gomega.Expect(output).To(gomega.ContainSubstring(expectedOutput))
|
||||
})
|
||||
})
|
||||
|
||||
ginkgo.Context("env sw", func() {
|
||||
ginkgo.It("should show env switch message", func() {
|
||||
cli := fmt.Sprintf("rudr env:sw %s", envName)
|
||||
output, err := e2e.Exec(cli)
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||
expectedOutput := fmt.Sprintf("Switch env succeed, current env is %s", envName)
|
||||
gomega.Expect(output).To(gomega.ContainSubstring(expectedOutput))
|
||||
})
|
||||
})
|
||||
|
||||
ginkgo.Context("run", func() {
|
||||
ginkgo.It("should print successful creation information", func() {
|
||||
cli := fmt.Sprintf("rudr containerized:run %s -p 80 --image nginx:1.9.4", applicationName)
|
||||
|
||||
23
e2e/env/env_suite_test.go
vendored
Normal file
23
e2e/env/env_suite_test.go
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cloud-native-application/rudrx/e2e"
|
||||
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var rudrPath string
|
||||
|
||||
var _ = ginkgo.BeforeSuite(func() {
|
||||
p, err := e2e.GetCliBinary()
|
||||
rudrPath = p
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||
})
|
||||
|
||||
func TestComponent(t *testing.T) {
|
||||
gomega.RegisterFailHandler(ginkgo.Fail)
|
||||
ginkgo.RunSpecs(t, "Env Suite")
|
||||
}
|
||||
89
e2e/env/env_test.go
vendored
Normal file
89
e2e/env/env_test.go
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cloud-native-application/rudrx/e2e"
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var (
|
||||
envName = "env-hello"
|
||||
envName2 = "env-world"
|
||||
)
|
||||
|
||||
var _ = ginkgo.Describe("Env", func() {
|
||||
ginkgo.Context("env init", func() {
|
||||
ginkgo.It("should print env initiation successful message", func() {
|
||||
cli := fmt.Sprintf("rudr env:init %s --namespace %s", envName, envName)
|
||||
output, err := e2e.Exec(cli)
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||
expectedOutput := fmt.Sprintf("Create env succeed, current env is %s", envName)
|
||||
gomega.Expect(output).To(gomega.ContainSubstring(expectedOutput))
|
||||
})
|
||||
})
|
||||
|
||||
ginkgo.Context("env init another one", func() {
|
||||
ginkgo.It("should print env initiation successful message", func() {
|
||||
cli := fmt.Sprintf("rudr env:init %s --namespace %s", envName2, envName2)
|
||||
output, err := e2e.Exec(cli)
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||
expectedOutput := fmt.Sprintf("Create env succeed, current env is %s", envName2)
|
||||
gomega.Expect(output).To(gomega.ContainSubstring(expectedOutput))
|
||||
})
|
||||
})
|
||||
|
||||
ginkgo.Context("env show", func() {
|
||||
ginkgo.It("should show detailed env message", func() {
|
||||
cli := fmt.Sprintf("rudr env %s", envName)
|
||||
output, err := e2e.Exec(cli)
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||
expectedOutput := fmt.Sprintf("%s\t%s", envName, envName)
|
||||
gomega.Expect(output).To(gomega.ContainSubstring("NAME"))
|
||||
gomega.Expect(output).To(gomega.ContainSubstring("NAMESPACE"))
|
||||
gomega.Expect(output).To(gomega.ContainSubstring(expectedOutput))
|
||||
})
|
||||
})
|
||||
|
||||
ginkgo.Context("env sw", func() {
|
||||
ginkgo.It("should show env switch message", func() {
|
||||
cli := fmt.Sprintf("rudr env:sw %s", envName)
|
||||
output, err := e2e.Exec(cli)
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||
expectedOutput := fmt.Sprintf("Switch env succeed, current env is %s", envName)
|
||||
gomega.Expect(output).To(gomega.ContainSubstring(expectedOutput))
|
||||
})
|
||||
})
|
||||
|
||||
ginkgo.Context("env list", func() {
|
||||
ginkgo.It("should list all envs", func() {
|
||||
output, err := e2e.Exec("rudr env")
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||
gomega.Expect(output).To(gomega.ContainSubstring("NAME"))
|
||||
gomega.Expect(output).To(gomega.ContainSubstring("NAMESPACE"))
|
||||
gomega.Expect(output).To(gomega.ContainSubstring(envName))
|
||||
gomega.Expect(output).To(gomega.ContainSubstring(envName2))
|
||||
})
|
||||
})
|
||||
|
||||
ginkgo.Context("env delete", func() {
|
||||
ginkgo.It("should delete all envs", func() {
|
||||
cli := fmt.Sprintf("rudr env:delete %s", envName2)
|
||||
output, err := e2e.Exec(cli)
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||
expectedOutput := fmt.Sprintf("%s deleted", envName2)
|
||||
gomega.Expect(output).To(gomega.ContainSubstring(expectedOutput))
|
||||
})
|
||||
})
|
||||
|
||||
ginkgo.Context("env delete currently using one", func() {
|
||||
ginkgo.It("should delete all envs", func() {
|
||||
cli := fmt.Sprintf("rudr env:delete %s", envName)
|
||||
output, err := e2e.Exec(cli)
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||
expectedOutput := fmt.Sprintf("Error: you can't delete current using env %s", envName)
|
||||
gomega.Expect(output).To(gomega.ContainSubstring(expectedOutput))
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user