mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-20 04:56:39 +00:00
+2








7103f8ff52
* Feat(rollout): fill rolloutBatches if empty when scale up/down (#2569) * Feat: fill rolloutBatches if empty * Fix: fix unit-test * Test: add more test Fix: lint Fix: fix lint * Update release.yml (#2537) * Feat: add registry, merge registry and cap center (#2528) * Feat: add registry command * Refactor: comp/trait command combine with registry * Feat: refactor `vela comp/trait` * Fix: import * Fix: fix if type is autodetects.core.oam.dev * Fix: fix list from url * Fix: test * Feat: add test * Fix: remove dup test * Fix: test * Fix: test * Fix: fix label filter * Fix: reviewable * Fix test * fix personal repo in test * Fix test * Fix test * add some boundary check * reviewable * Fix: fix nocalhost trait (#2577) * fix incorrect addon status (#2576) * Fix(cli): client-side throttling in vela CLI (#2581) * fix cli throttling * fix import * set to a lower value * remove addon with no defs (#2574) * Feat: vela logs support multicluster (#2593) * Feat: add basic multiple cluster logs * fix context * Fix select style * Fix select style * remove useless env * fix naming * Feat: vela cluster support use ocm to join/list/detach cluster (#2599) * Feat: add render component and apply component remaining (#2587) * Feat: add render component and apply component remaining * fix ut * fix e2e * allow import package in custom status cue template (#2585) Co-authored-by: chwetion <chwetion@foxmail.com> * Fix: abnormal aux name (#2612) * Feat: store workflow step def properties in cm (#2592) * Fix: fix notification def * Feat: store workflow step def properties in cm * fix ci * fix data race * Fix: change Initializer to Application for addon Observability (#2615) In this doc, updated the Observability implementation from initializer to Application. I also store definitions as it's not well stored in vela-templates/addons/observability * Fix: fix backport param (#2611) * Fix: add owner reference in workflow context cm (#2573) * Fix: add owner reference in workflow context cm * fix ci * delete useless test case * Fix: op.delete bugs (#2622) * Fix: op.delete some bugs * Fix: app status update error Fix: make reviewable * Fix: show reconcile error log (#2626) * Feat: add reconcile timeout configuration for vela-core (#2630) * Fix: patch status retry while conflict happens (#2629) * Fix: allow definition schema cm can be same name in different definition type (#2618) * Fix: fix definition schema cm name * fix ut * fix ut * fix show * add switch default case * Feat: remove envbinding policy into workflow (#2556) Fix: add more test * Feat: add vela prob to test cluster (#2635) * Fix: upgrade stern lib to avoid panic for vela logs (#2650) * Fix: filter loggable workload in vela logs (#2651) * Fix: filter loggable workload in vela logs * reviewable * Feat: add vela exec for multi cluster (#2299) fix support vela exec * Fix: health check will check for multiclusters (#2645) * Fix: minor fix for vela cli printing (#2655) * Fix: minor fix for vela cli printing * add dockerfile go mod cache * Feat: support apiserver-related multicluster features (#2625) * Feat: remove envbinding policy into workflow Feat: add support for env change (env gc) Fix: fix rollout timeout setting bug * Feat: support disable trait and env without workflow * Fix: add hint for replaced value Co-authored-by: wyike <wangyike_wyk@163.com> Co-authored-by: basefas <basefas@hotmail.com> Co-authored-by: qiaozp <47812250+chivalryq@users.noreply.github.com> Co-authored-by: Tianxin Dong <dongtianxin.tx@alibaba-inc.com> Co-authored-by: yangsoon <yangsoonlx@gmail.com> Co-authored-by: Chwetion <137953601@qq.com> Co-authored-by: chwetion <chwetion@foxmail.com> Co-authored-by: Jian.Li <74582607+leejanee@users.noreply.github.com> Co-authored-by: Zheng Xi Zhou <zzxwill@gmail.com> Co-authored-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>
181 lines
6.5 KiB
Go
181 lines
6.5 KiB
Go
/*
|
|
Copyright 2021 The KubeVela Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package e2e
|
|
|
|
import (
|
|
context2 "context"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/Netflix/go-expect"
|
|
"github.com/onsi/ginkgo"
|
|
"github.com/onsi/gomega"
|
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
|
|
|
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1alpha2"
|
|
"github.com/oam-dev/kubevela/e2e"
|
|
"github.com/oam-dev/kubevela/pkg/utils/common"
|
|
)
|
|
|
|
var (
|
|
envName = "env-application"
|
|
workloadType = "webservice"
|
|
applicationName = "app-basic"
|
|
traitAlias = "scaler"
|
|
appNameForInit = "initmyapp"
|
|
jsonAppFile = `{"name":"nginx-vela","services":{"nginx":{"type":"webservice","image":"nginx:1.9.4","port":80}}}`
|
|
appbasicJsonAppFile = `{"name":"app-basic","services":{"app-basic":{"type":"webservice","image":"nginx:1.9.4","port":80}}}`
|
|
appbasicAddTraitJsonAppFile = `{"name":"app-basic","services":{"app-basic":{"type":"webservice","image":"nginx:1.9.4","port":80,"scaler":{"replicas":2}}}}`
|
|
)
|
|
|
|
var _ = ginkgo.Describe("Test Vela Application", func() {
|
|
e2e.JsonAppFileContext("json appfile apply", jsonAppFile)
|
|
e2e.EnvSetContext("env set", "default")
|
|
e2e.DeleteEnvFunc("env delete", envName)
|
|
e2e.EnvInitContext("env init", envName)
|
|
e2e.EnvSetContext("env set", envName)
|
|
e2e.JsonAppFileContext("deploy app-basic", appbasicJsonAppFile)
|
|
ApplicationExecContext("exec -- COMMAND", applicationName)
|
|
e2e.JsonAppFileContext("update app-basic, add scaler trait with replicas 2", appbasicAddTraitJsonAppFile)
|
|
e2e.ComponentListContext("ls", applicationName, workloadType, traitAlias)
|
|
ApplicationStatusContext("status", applicationName, workloadType)
|
|
ApplicationStatusDeeplyContext("status", applicationName, workloadType, envName)
|
|
// ApplicationPortForwardContext("port-forward", applicationName)
|
|
e2e.WorkloadDeleteContext("delete", applicationName)
|
|
|
|
ApplicationInitIntercativeCliContext("test vela init app", appNameForInit, workloadType)
|
|
e2e.WorkloadDeleteContext("delete", appNameForInit)
|
|
})
|
|
|
|
var ApplicationStatusContext = func(context string, applicationName string, workloadType string) bool {
|
|
return ginkgo.Context(context, func() {
|
|
ginkgo.It("should get status for the application", func() {
|
|
cli := fmt.Sprintf("vela status %s", applicationName)
|
|
output, err := e2e.Exec(cli)
|
|
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
|
gomega.Expect(output).To(gomega.ContainSubstring(applicationName))
|
|
// TODO(roywang) add more assertion to check health status
|
|
})
|
|
})
|
|
}
|
|
|
|
var ApplicationStatusDeeplyContext = func(context string, applicationName, workloadType, envName string) bool {
|
|
return ginkgo.Context(context, func() {
|
|
ginkgo.It("should get status of the service", func() {
|
|
ginkgo.By("init new k8s client")
|
|
k8sclient, err := common.NewK8sClient()
|
|
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
|
|
|
ginkgo.By("check Application reconciled ready")
|
|
app := &v1alpha2.Application{}
|
|
gomega.Eventually(func() bool {
|
|
_ = k8sclient.Get(context2.Background(), client.ObjectKey{Name: applicationName, Namespace: "default"}, app)
|
|
return app.Status.LatestRevision != nil
|
|
}, 180*time.Second, 1*time.Second).Should(gomega.BeTrue())
|
|
|
|
cli := fmt.Sprintf("vela status %s", applicationName)
|
|
output, err := e2e.LongTimeExec(cli, 120*time.Second)
|
|
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
|
gomega.Expect(output).To(gomega.ContainSubstring("Checking health status"))
|
|
// TODO(zzxwill) need to check workloadType after app status is refined
|
|
})
|
|
})
|
|
}
|
|
|
|
var ApplicationExecContext = func(context string, appName string) bool {
|
|
return ginkgo.Context(context, func() {
|
|
ginkgo.It("should get output of exec /bin/ls", func() {
|
|
gomega.Eventually(func() string {
|
|
cli := fmt.Sprintf("vela exec %s -- /bin/ls ", appName)
|
|
output, err := e2e.Exec(cli)
|
|
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
|
return output
|
|
}, 90*time.Second, 5*time.Second).Should(gomega.ContainSubstring("bin"))
|
|
})
|
|
})
|
|
}
|
|
|
|
var ApplicationPortForwardContext = func(context string, appName string) bool {
|
|
return ginkgo.Context(context, func() {
|
|
ginkgo.It("should get output of port-forward successfully", func() {
|
|
cli := fmt.Sprintf("vela port-forward %s 80:80 ", appName)
|
|
output, err := e2e.ExecAndTerminate(cli)
|
|
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
|
gomega.Expect(output).To(gomega.ContainSubstring("Forward successfully"))
|
|
})
|
|
})
|
|
}
|
|
|
|
var ApplicationInitIntercativeCliContext = func(context string, appName string, workloadType string) bool {
|
|
return ginkgo.Context(context, func() {
|
|
ginkgo.It("should init app through interactive questions", func() {
|
|
cli := "vela init"
|
|
output, err := e2e.InteractiveExec(cli, func(c *expect.Console) {
|
|
data := []struct {
|
|
q, a string
|
|
}{
|
|
{
|
|
q: "What would you like to name your application (required): ",
|
|
a: appName,
|
|
},
|
|
{
|
|
q: "webservice",
|
|
a: workloadType,
|
|
},
|
|
{
|
|
q: "What would you like to name this webservice (required): ",
|
|
a: "mysvc",
|
|
},
|
|
{
|
|
q: "If addRevisionLabel is true, the appRevision label will be added to the underlying pods (optional, default is false):",
|
|
a: "N",
|
|
},
|
|
{
|
|
q: "Which image would you like to use for your service ",
|
|
a: "nginx:latest",
|
|
},
|
|
{
|
|
q: "Which port do you want customer traffic sent to ",
|
|
a: "",
|
|
},
|
|
{
|
|
q: "Specify image pull policy for your service ",
|
|
a: "Always",
|
|
},
|
|
{
|
|
q: "Number of CPU units for the service, like `0.5` (0.5 CPU core), `1` (1 CPU core) (optional):",
|
|
a: "0.5",
|
|
},
|
|
{
|
|
q: "Specifies the attributes of the memory resource required for the container. (optional):",
|
|
a: "200M",
|
|
},
|
|
}
|
|
for _, qa := range data {
|
|
_, err := c.ExpectString(qa.q)
|
|
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
|
_, err = c.SendLine(qa.a)
|
|
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
|
}
|
|
c.ExpectEOF()
|
|
})
|
|
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
|
gomega.Expect(output).To(gomega.ContainSubstring("Checking Status"))
|
|
})
|
|
})
|
|
}
|