From 8aaf526877b3ec41fa8ad83f6ba4d4d6cabeb416 Mon Sep 17 00:00:00 2001 From: qiaozp <47812250+chivalryq@users.noreply.github.com> Date: Thu, 21 Jul 2022 21:09:31 -0500 Subject: [PATCH] Chore: upgrade kind in tests, fix flaky test (#4105) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Chore: upgrade kind in tests, fix some hacky test. Signed-off-by: qiaozp * longer wait Signed-off-by: qiaozp * make e2e-multicluster test timeout 20m Signed-off-by: qiaozp * switch to kind v0.14.0 Signed-off-by: 伊灵 --- .github/workflows/apiserver-test.yaml | 6 ++-- .github/workflows/e2e-multicluster-test.yml | 6 ++-- .github/workflows/e2e-rollout-test.yml | 6 ++-- .github/workflows/e2e-test.yml | 6 ++-- .github/workflows/go.yml | 2 +- .github/workflows/unit-test.yml | 2 +- .../templates/test/test-application.yaml | 12 ------- makefiles/e2e.mk | 2 +- .../multicluster_standalone_test.go | 13 ++++---- .../multicluster_test.go | 6 ++-- .../testdata/app/example-envbinding-app.yaml | 5 +-- .../standalone/app-with-publish-version.yaml | 8 ++--- .../testdata/app/standalone/app.yaml | 6 ++-- .../testdata/app/standalone/deployment.yaml | 10 +++--- .../app/standalone/policy-zero-replica.yaml | 2 +- .../testdata/app/standalone/policy.yaml | 2 +- .../app/standalone/workflow-suspend.yaml | 2 +- .../testdata/app/standalone/workflow.yaml | 2 +- test/e2e-test/app_resourcetracker_test.go | 24 ++++++++------ test/e2e-test/application_test.go | 12 +++---- test/e2e-test/health_scope_test.go | 18 ++++++++++- test/e2e-test/resource_policy_test.go | 6 ++-- test/e2e-test/suite_test.go | 31 +++++++++++++++++-- test/e2e-test/testdata/app/app1.yaml | 5 +-- test/e2e-test/testdata/app/app2.yaml | 5 +-- test/e2e-test/testdata/app/app3.yaml | 5 +-- test/e2e-test/testdata/app/app4.yaml | 5 +-- test/e2e-test/testdata/app/app6.yaml | 17 ---------- test/e2e-test/testdata/app/app7.yaml | 2 +- .../testdata/app/app_healthscope.yaml | 14 +++------ .../app/app_healthscope_unhealthy.yaml | 7 ++--- .../e2e-test/testdata/app/app_suspending.yaml | 3 +- .../testdata/app/app_wait_suspend.yaml | 2 +- .../rollout/cloneset/app-remove-ingress.yaml | 17 ---------- .../cloneset/app-with-ingress-source.yaml | 23 -------------- .../cloneset/app-with-ingress-target.yaml | 23 -------------- 36 files changed, 123 insertions(+), 194 deletions(-) delete mode 100644 test/e2e-test/testdata/app/app6.yaml delete mode 100644 test/e2e-test/testdata/rollout/cloneset/app-remove-ingress.yaml delete mode 100644 test/e2e-test/testdata/rollout/cloneset/app-with-ingress-source.yaml delete mode 100644 test/e2e-test/testdata/rollout/cloneset/app-with-ingress-target.yaml diff --git a/.github/workflows/apiserver-test.yaml b/.github/workflows/apiserver-test.yaml index 3f8a63d8a..3498fc2df 100644 --- a/.github/workflows/apiserver-test.yaml +++ b/.github/workflows/apiserver-test.yaml @@ -19,9 +19,9 @@ env: # Common versions GO_VERSION: '1.17' GOLANGCI_VERSION: 'v1.38' - KIND_VERSION: 'v0.7.0' - KIND_IMAGE_VERSION: '[\"v1.20.7\"]' - KIND_IMAGE_VERSIONS: '[\"v1.18.20\",\"v1.20.7\",\"v1.22.7\"]' + KIND_VERSION: 'v0.14.0' + KIND_IMAGE_VERSION: '[\"v1.20.15\"]' + KIND_IMAGE_VERSIONS: '[\"v1.18.20\",\"v1.20.15\",\"v1.22.9\"]' jobs: diff --git a/.github/workflows/e2e-multicluster-test.yml b/.github/workflows/e2e-multicluster-test.yml index d5ef20438..b89e483e8 100644 --- a/.github/workflows/e2e-multicluster-test.yml +++ b/.github/workflows/e2e-multicluster-test.yml @@ -17,9 +17,9 @@ env: # Common versions GO_VERSION: '1.17' GOLANGCI_VERSION: 'v1.38' - KIND_VERSION: 'v0.7.0' - KIND_IMAGE_VERSION: '[\"v1.20.7\"]' - KIND_IMAGE_VERSIONS: '[\"v1.18.20\",\"v1.20.7\",\"v1.22.7\"]' + KIND_VERSION: 'v0.14.0' + KIND_IMAGE_VERSION: '[\"v1.20.15\"]' + KIND_IMAGE_VERSIONS: '[\"v1.18.20\",\"v1.20.15\",\"v1.22.9\"]' jobs: diff --git a/.github/workflows/e2e-rollout-test.yml b/.github/workflows/e2e-rollout-test.yml index d27dc4e3f..781a3c668 100644 --- a/.github/workflows/e2e-rollout-test.yml +++ b/.github/workflows/e2e-rollout-test.yml @@ -17,9 +17,9 @@ env: # Common versions GO_VERSION: '1.17' GOLANGCI_VERSION: 'v1.38' - KIND_VERSION: 'v0.7.0' - KIND_IMAGE_VERSION: '[\"v1.20.7\"]' - KIND_IMAGE_VERSIONS: '[\"v1.18.20\",\"v1.20.7\",\"v1.22.7\"]' + KIND_VERSION: 'v0.14.0' + KIND_IMAGE_VERSION: '[\"v1.20.15\"]' + KIND_IMAGE_VERSIONS: '[\"v1.18.20\",\"v1.20.15\",\"v1.22.9\"]' jobs: diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 938413b27..cfaccef28 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -17,9 +17,9 @@ env: # Common versions GO_VERSION: '1.17' GOLANGCI_VERSION: 'v1.38' - KIND_VERSION: 'v0.7.0' - KIND_IMAGE_VERSION: '[\"v1.20.7\"]' - KIND_IMAGE_VERSIONS: '[\"v1.18.20\",\"v1.20.7\",\"v1.22.7\"]' + KIND_VERSION: 'v0.14.0' + KIND_IMAGE_VERSION: '[\"v1.20.15\"]' + KIND_IMAGE_VERSIONS: '[\"v1.18.20\",\"v1.20.15\",\"v1.22.9\"]' jobs: diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 5315c38d4..b8247ec08 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -15,7 +15,7 @@ env: # Common versions GO_VERSION: '1.17' GOLANGCI_VERSION: 'v1.38' - KIND_VERSION: 'v0.7.0' + KIND_VERSION: 'v0.14.0' jobs: diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index d594bf6db..b1d854b8a 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -15,7 +15,7 @@ env: # Common versions GO_VERSION: '1.17' GOLANGCI_VERSION: 'v1.38' - KIND_VERSION: 'v0.7.0' + KIND_VERSION: 'v0.14.0' jobs: diff --git a/charts/vela-core/templates/test/test-application.yaml b/charts/vela-core/templates/test/test-application.yaml index ea98c4c03..ce140a85a 100644 --- a/charts/vela-core/templates/test/test-application.yaml +++ b/charts/vela-core/templates/test/test-application.yaml @@ -13,12 +13,6 @@ spec: properties: image: {{ .Values.imageRegistry }}{{ .Values.test.app.repository }}:{{ .Values.test.app.tag }} port: 8000 - traits: - - type: ingress - properties: - domain: testsvc.example.com - http: - "/": 8000 --- apiVersion: v1 kind: Pod @@ -52,12 +46,6 @@ spec: kubectl -n {{ include "systemDefinitionNamespace" . }} wait --for=condition=available deployments helm-test-express-server --timeout 3m echo "deployment being available" - # wait for ingress being created - while ! [ `kubectl -n {{ include "systemDefinitionNamespace" . }} get ing helm-test-express-server | grep -v NAME | wc -l` = 1 ]; do - echo "waiting for ingress being created" - sleep 1 - done - echo "Application and its components are created" diff --git a/makefiles/e2e.mk b/makefiles/e2e.mk index ac8b70a51..acd83bb56 100644 --- a/makefiles/e2e.mk +++ b/makefiles/e2e.mk @@ -85,7 +85,7 @@ e2e-rollout-test: .PHONY: e2e-multicluster-test e2e-multicluster-test: - go test -v -coverpkg=./... -coverprofile=/tmp/e2e_multicluster_test.out ./test/e2e-multicluster-test + go test -v -coverpkg=./... -timeout=20m -coverprofile=/tmp/e2e_multicluster_test.out ./test/e2e-multicluster-test @$(OK) tests pass .PHONY: e2e-cleanup diff --git a/test/e2e-multicluster-test/multicluster_standalone_test.go b/test/e2e-multicluster-test/multicluster_standalone_test.go index 133911cbb..7cafab449 100644 --- a/test/e2e-multicluster-test/multicluster_standalone_test.go +++ b/test/e2e-multicluster-test/multicluster_standalone_test.go @@ -145,7 +145,7 @@ var _ = Describe("Test multicluster standalone scenario", func() { g.Expect(k8sClient.Status().Update(hubCtx, _app)).Should(Succeed()) }, 15*time.Second).Should(Succeed()) - // test application can run without external policies and workflow since they are recorded in the application revision + By("Test application can run without external policies and workflow since they are recorded in the application revision") _app := &v1beta1.Application{} Eventually(func(g Gomega) { deploys := &v1.DeploymentList{} @@ -156,14 +156,13 @@ var _ = Describe("Test multicluster standalone scenario", func() { g.Expect(_app.Status.Phase).Should(Equal(oamcomm.ApplicationRunning)) }, 30*time.Second).Should(Succeed()) - // update application without updating publishVersion + By("Update application without updating publishVersion. App should not re-run workflow") Eventually(func(g Gomega) { g.Expect(k8sClient.Get(hubCtx, appKey, _app)).Should(Succeed()) _app.Spec.Policies[0].Properties = &runtime.RawExtension{Raw: []byte(fmt.Sprintf(`{"clusters":["local"],"namespace":"%s"}`, nsLocal.Name))} g.Expect(k8sClient.Update(hubCtx, _app)).Should(Succeed()) }, 10*time.Second).Should(Succeed()) - // application should no re-run workflow time.Sleep(10 * time.Second) Eventually(func(g Gomega) { g.Expect(k8sClient.Get(hubCtx, appKey, _app)).Should(Succeed()) @@ -173,7 +172,7 @@ var _ = Describe("Test multicluster standalone scenario", func() { g.Expect(len(apprevs.Items)).Should(Equal(1)) }, 10*time.Second).Should(Succeed()) - // update application with publishVersion + By("Update application with publishVersion") applyFile("policy.yaml") applyFile("workflow.yaml") Eventually(func(g Gomega) { @@ -191,7 +190,7 @@ var _ = Describe("Test multicluster standalone scenario", func() { g.Expect(k8sClient.List(hubCtx, deploys, client.InNamespace(nsLocal.Name))).Should(Succeed()) g.Expect(len(deploys.Items)).Should(Equal(1)) g.Expect(deploys.Items[0].Spec.Replicas).Should(Equal(pointer.Int32(3))) - }, 30*time.Second).Should(Succeed()) + }, 2*time.Minute, time.Second).Should(Succeed()) }) It("Test rollback application with publish version", func() { @@ -205,7 +204,7 @@ var _ = Describe("Test multicluster standalone scenario", func() { Eventually(func(g Gomega) { g.Expect(k8sClient.Get(hubCtx, appKey, app)).Should(Succeed()) g.Expect(app.Status.Phase).Should(Equal(oamcomm.ApplicationRunning)) - }, 30*time.Second).Should(Succeed()) + }, 60*time.Second).Should(Succeed()) By("Update Application to first failed version") Eventually(func(g Gomega) { @@ -213,7 +212,7 @@ var _ = Describe("Test multicluster standalone scenario", func() { app.Annotations[oam.AnnotationPublishVersion] = "alpha2" app.Spec.Components[0].Properties = &runtime.RawExtension{Raw: []byte(`{"image":"busybox:bad"}`)} g.Expect(k8sClient.Update(hubCtx, app)).Should(Succeed()) - }, 30*time.Second).Should(Succeed()) + }, 60*time.Second).Should(Succeed()) Eventually(func(g Gomega) { g.Expect(k8sClient.Get(hubCtx, appKey, app)).Should(Succeed()) diff --git a/test/e2e-multicluster-test/multicluster_test.go b/test/e2e-multicluster-test/multicluster_test.go index 299bf6128..8b33c0166 100644 --- a/test/e2e-multicluster-test/multicluster_test.go +++ b/test/e2e-multicluster-test/multicluster_test.go @@ -255,7 +255,7 @@ var _ = Describe("Test multicluster scenario", func() { deploys = &appsv1.DeploymentList{} g.Expect(k8sClient.List(workerCtx, deploys, client.InNamespace(prodNamespace))).Should(Succeed()) g.Expect(len(deploys.Items)).Should(Equal(2)) - }, time.Minute).Should(Succeed()) + }, 4*time.Minute, time.Second).Should(Succeed()) Expect(hubDeployName).Should(Equal("data-worker")) // delete application By("delete application") @@ -455,7 +455,7 @@ var _ = Describe("Test multicluster scenario", func() { Components: []common.ApplicationComponent{{ Name: "test-busybox", Type: "webservice", - Properties: &runtime.RawExtension{Raw: []byte(`{"image":"busybox","cmd":["sleep","86400"]}`)}, + Properties: &runtime.RawExtension{Raw: []byte(`{"image":"crccheck/hello-world"}`)}, }}, Policies: []v1beta1.AppPolicy{{ Name: "topology-local", @@ -481,7 +481,7 @@ var _ = Describe("Test multicluster scenario", func() { g.Expect(k8sClient.Get(hubCtx, types.NamespacedName{Name: "test-busybox-v2", Namespace: testNamespace}, &appsv1.Deployment{})).Should(Succeed()) err := k8sClient.Get(hubCtx, types.NamespacedName{Name: "test-busybox", Namespace: testNamespace}, &appsv1.Deployment{}) g.Expect(kerrors.IsNotFound(err)).Should(BeTrue()) - }, time.Minute).Should(Succeed()) + }, 2*time.Minute, 2*time.Second).Should(Succeed()) By("Re-publish application to v1") _, err := execCommand("up", appKey.Name, "-n", appKey.Namespace, "--revision", appKey.Name+"-v1", "--publish-version", "v1.0") diff --git a/test/e2e-multicluster-test/testdata/app/example-envbinding-app.yaml b/test/e2e-multicluster-test/testdata/app/example-envbinding-app.yaml index 4e77d8bf3..ef132a6f4 100644 --- a/test/e2e-multicluster-test/testdata/app/example-envbinding-app.yaml +++ b/test/e2e-multicluster-test/testdata/app/example-envbinding-app.yaml @@ -17,10 +17,7 @@ spec: - name: data-worker type: worker properties: - image: busybox - cmd: - - sleep - - '1000000' + image: crccheck/hello-world policies: - name: example-multi-env-policy type: env-binding diff --git a/test/e2e-multicluster-test/testdata/app/standalone/app-with-publish-version.yaml b/test/e2e-multicluster-test/testdata/app/standalone/app-with-publish-version.yaml index dd2d7e95d..70f6cb1c6 100644 --- a/test/e2e-multicluster-test/testdata/app/standalone/app-with-publish-version.yaml +++ b/test/e2e-multicluster-test/testdata/app/standalone/app-with-publish-version.yaml @@ -1,21 +1,21 @@ apiVersion: core.oam.dev/v1beta1 kind: Application metadata: - name: podinfo + name: hello-world annotations: app.oam.dev/publishVersion: alpha1 spec: components: - - name: podinfo + - name: hello-world type: ref-objects properties: objects: - resource: deployment - name: podinfo + name: hello-world-ref policies: - type: topology name: topology-worker properties: clusters: ["cluster-worker"] workflow: - ref: deploy-podinfo \ No newline at end of file + ref: deploy-hello-world \ No newline at end of file diff --git a/test/e2e-multicluster-test/testdata/app/standalone/app.yaml b/test/e2e-multicluster-test/testdata/app/standalone/app.yaml index 0f7acf2af..4703c1330 100644 --- a/test/e2e-multicluster-test/testdata/app/standalone/app.yaml +++ b/test/e2e-multicluster-test/testdata/app/standalone/app.yaml @@ -4,12 +4,12 @@ metadata: name: podinfo spec: components: - - name: podinfo + - name: hello-world type: ref-objects properties: objects: - resource: deployment - name: podinfo + name: hello-world-ref - resource: configmap labelSelector: app: podinfo @@ -23,4 +23,4 @@ spec: properties: clusters: ["cluster-worker"] workflow: - ref: deploy-podinfo \ No newline at end of file + ref: deploy-hello-world \ No newline at end of file diff --git a/test/e2e-multicluster-test/testdata/app/standalone/deployment.yaml b/test/e2e-multicluster-test/testdata/app/standalone/deployment.yaml index ef72da84b..ad89f0d92 100644 --- a/test/e2e-multicluster-test/testdata/app/standalone/deployment.yaml +++ b/test/e2e-multicluster-test/testdata/app/standalone/deployment.yaml @@ -1,17 +1,17 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: podinfo + name: hello-world-ref spec: replicas: 0 selector: matchLabels: - app: podinfo + app: hello-world template: metadata: labels: - app: podinfo + app: hello-world spec: containers: - - image: stefanprodan/podinfo:6.0.2 - name: podinfo \ No newline at end of file + - image: crccheck/hello-world + name: hello-world \ No newline at end of file diff --git a/test/e2e-multicluster-test/testdata/app/standalone/policy-zero-replica.yaml b/test/e2e-multicluster-test/testdata/app/standalone/policy-zero-replica.yaml index d1ca4000e..7066d5b11 100644 --- a/test/e2e-multicluster-test/testdata/app/standalone/policy-zero-replica.yaml +++ b/test/e2e-multicluster-test/testdata/app/standalone/policy-zero-replica.yaml @@ -5,7 +5,7 @@ metadata: type: override properties: components: - - name: podinfo + - name: hello-world traits: - type: scaler properties: diff --git a/test/e2e-multicluster-test/testdata/app/standalone/policy.yaml b/test/e2e-multicluster-test/testdata/app/standalone/policy.yaml index 8f6d3053c..8e63df4ab 100644 --- a/test/e2e-multicluster-test/testdata/app/standalone/policy.yaml +++ b/test/e2e-multicluster-test/testdata/app/standalone/policy.yaml @@ -5,7 +5,7 @@ metadata: type: override properties: components: - - name: podinfo + - name: hello-world traits: - type: scaler properties: diff --git a/test/e2e-multicluster-test/testdata/app/standalone/workflow-suspend.yaml b/test/e2e-multicluster-test/testdata/app/standalone/workflow-suspend.yaml index 87af3f7a5..7c81faa79 100644 --- a/test/e2e-multicluster-test/testdata/app/standalone/workflow-suspend.yaml +++ b/test/e2e-multicluster-test/testdata/app/standalone/workflow-suspend.yaml @@ -1,7 +1,7 @@ apiVersion: core.oam.dev/v1alpha1 kind: Workflow metadata: - name: deploy-podinfo + name: deploy-hello-world steps: - type: deploy name: deploy-worker diff --git a/test/e2e-multicluster-test/testdata/app/standalone/workflow.yaml b/test/e2e-multicluster-test/testdata/app/standalone/workflow.yaml index 869e50a3b..b555d3984 100644 --- a/test/e2e-multicluster-test/testdata/app/standalone/workflow.yaml +++ b/test/e2e-multicluster-test/testdata/app/standalone/workflow.yaml @@ -1,7 +1,7 @@ apiVersion: core.oam.dev/v1alpha1 kind: Workflow metadata: - name: deploy-podinfo + name: deploy-hello-world steps: - type: deploy name: deploy-worker diff --git a/test/e2e-test/app_resourcetracker_test.go b/test/e2e-test/app_resourcetracker_test.go index 9a0636ad8..d29425c40 100644 --- a/test/e2e-test/app_resourcetracker_test.go +++ b/test/e2e-test/app_resourcetracker_test.go @@ -174,7 +174,7 @@ var _ = Describe("Test application cross namespace resource", func() { { Name: componentName, Type: "worker", - Properties: &runtime.RawExtension{Raw: []byte(`{"image": "nginx:latest"}`)}, + Properties: &runtime.RawExtension{Raw: []byte(`{"image": "crccheck/hello-world"}`)}, Traits: []common.ApplicationTrait{ { Type: "cluster-scope-trait", @@ -211,7 +211,7 @@ var _ = Describe("Test application cross namespace resource", func() { { Name: componentName, Type: "worker", - Properties: &runtime.RawExtension{Raw: []byte(`{"image": "nginx:latest"}`)}, + Properties: &runtime.RawExtension{Raw: []byte(`{"image": "crccheck/hello-world"}`)}, Traits: []common.ApplicationTrait{ // remove the cluster-scoped trait and keep the // cross-namespaced trait. @@ -244,7 +244,7 @@ var _ = Describe("Test application cross namespace resource", func() { Eventually(func() error { RequestReconcileNow(ctx, app) return k8sClient.Get(ctx, client.ObjectKey{Name: "pv-" + componentName, Namespace: namespace}, pv) - }, 20*time.Second, 2*time.Second).Should(SatisfyAll(&util.NotFoundMatcher{})) + }, 120*time.Second, 1*time.Second).Should(SatisfyAll(&util.NotFoundMatcher{})) }) It("Test application have cross-namespace workload", func() { @@ -987,7 +987,7 @@ var _ = Describe("Test application cross namespace resource", func() { { Name: componentName, Type: "cross-worker", - Properties: &runtime.RawExtension{Raw: []byte(`{"cmd":["sleep","1000"],"image":"busybox"}`)}, + Properties: &runtime.RawExtension{Raw: []byte(`{"image":"crccheck/hello-world"}`)}, Traits: []common.ApplicationTrait{ { Type: "cross-scaler", @@ -1033,8 +1033,11 @@ var _ = Describe("Test application cross namespace resource", func() { trait := mts.Items[0] deploys := new(appsv1.DeploymentList) err = k8sClient.List(ctx, deploys, opts...) - if err != nil || len(deploys.Items) != 1 { - return fmt.Errorf("error to list deploy") + if err != nil { + return fmt.Errorf("error to list deploy: %v", err) + } + if len(deploys.Items) != 1 { + return fmt.Errorf("more than one deploy, actual %d", len(deploys.Items)) } deploy := deploys.Items[0] for _, resource := range resourceTracker.Spec.ManagedResources { @@ -1084,8 +1087,11 @@ var _ = Describe("Test application cross namespace resource", func() { } deploys := new(appsv1.DeploymentList) err = k8sClient.List(ctx, deploys, opts...) - if err != nil || len(deploys.Items) != 1 { - return fmt.Errorf("error to list deploy") + if err != nil { + return fmt.Errorf("error to list deploy: %v", err) + } + if len(deploys.Items) != 1 { + return fmt.Errorf("more than one deploy, actual %d", len(deploys.Items)) } deploy := deploys.Items[0] if resourceTracker.Spec.ManagedResources[0].Name != deploy.Name { @@ -1136,7 +1142,7 @@ var _ = Describe("Test application cross namespace resource", func() { { Name: componentName, Type: "cross-worker", - Properties: &runtime.RawExtension{Raw: []byte(`{"cmd":["sleep","1000"],"image":"busybox"}`)}, + Properties: &runtime.RawExtension{Raw: []byte(`{"image":"crccheck/hello-world"}`)}, }, }, }, diff --git a/test/e2e-test/application_test.go b/test/e2e-test/application_test.go index a42a156d8..c7db90ddd 100644 --- a/test/e2e-test/application_test.go +++ b/test/e2e-test/application_test.go @@ -201,11 +201,11 @@ var _ = Describe("Application Normal tests", func() { return fmt.Errorf("expect replicas %v != real %v", replicas, workload.Status.ReadyReplicas) } if workload.Spec.Template.Spec.Containers[0].Image != image { - return fmt.Errorf("expect replicas %v != real %v", image, workload.Spec.Template.Spec.Containers[0].Image) + return fmt.Errorf("expect image %v != real %v", image, workload.Spec.Template.Spec.Containers[0].Image) } return nil }, - time.Second*60, time.Millisecond*500).Should(BeNil()) + time.Second*120, time.Millisecond*500).Should(BeNil()) } BeforeEach(func() { @@ -225,22 +225,22 @@ var _ = Describe("Application Normal tests", func() { It("Test app created normally", func() { applyApp("app1.yaml") By("Apply the application rollout go directly to the target") - verifyWorkloadRunningExpected("myweb", 1, "stefanprodan/podinfo:4.0.3") + verifyWorkloadRunningExpected("myweb", 1, "crccheck/hello-world") By("Update app with trait") updateApp("app2.yaml") By("Apply the application rollout go directly to the target") - verifyWorkloadRunningExpected("myweb", 2, "stefanprodan/podinfo:4.0.3") + verifyWorkloadRunningExpected("myweb", 2, "crccheck/hello-world") By("Update app with trait updated") updateApp("app3.yaml") By("Apply the application rollout go directly to the target") - verifyWorkloadRunningExpected("myweb", 3, "stefanprodan/podinfo:4.0.3") + verifyWorkloadRunningExpected("myweb", 3, "crccheck/hello-world") By("Update app with trait and workload image updated") updateApp("app4.yaml") By("Apply the application rollout go directly to the target") - verifyWorkloadRunningExpected("myweb", 1, "stefanprodan/podinfo:5.0.2") + verifyWorkloadRunningExpected("myweb", 1, "hello-world") }) It("Test app have component with multiple same type traits", func() { diff --git a/test/e2e-test/health_scope_test.go b/test/e2e-test/health_scope_test.go index f21962cc4..3de2765d5 100644 --- a/test/e2e-test/health_scope_test.go +++ b/test/e2e-test/health_scope_test.go @@ -80,6 +80,8 @@ var _ = Describe("HealthScope", func() { var healthyAppName, unhealthyAppName string Expect(utilcommon.ReadYamlToObject("testdata/app/app_healthscope.yaml", &newApp)).Should(BeNil()) newApp.Namespace = namespace + convertToLegacyIngressTrait(&newApp) + Eventually(func() error { return k8sClient.Create(ctx, newApp.DeepCopy()) }, 10*time.Second, 500*time.Millisecond).Should(Succeed()) @@ -101,6 +103,7 @@ var _ = Describe("HealthScope", func() { newApp = v1beta1.Application{} Expect(utilcommon.ReadYamlToObject("testdata/app/app_healthscope_unhealthy.yaml", &newApp)).Should(BeNil()) newApp.Namespace = namespace + convertToLegacyIngressTrait(&newApp) Eventually(func() error { return k8sClient.Create(ctx, newApp.DeepCopy()) }, 10*time.Second, 500*time.Millisecond).Should(Succeed()) @@ -133,7 +136,7 @@ var _ = Describe("HealthScope", func() { k8sClient.Get(ctx, healthScopeObject, healthScope) return healthScope.Status.ScopeHealthCondition }, - time.Second*60, time.Millisecond*500).Should(Equal(v1alpha2.ScopeHealthCondition{ + time.Second*120, time.Millisecond*500).Should(Equal(v1alpha2.ScopeHealthCondition{ HealthStatus: v1alpha2.StatusHealthy, Total: int64(2), HealthyWorkloads: int64(2), @@ -205,3 +208,16 @@ var _ = Describe("HealthScope", func() { }, time.Second*30, time.Millisecond*500).Should(Succeed()) }) }) + +// convertToLegacyIngressTrait convert app's gateway trait to ingress +func convertToLegacyIngressTrait(app *v1beta1.Application) { + if noNetworkingV1 { + for i := range app.Spec.Components { + for j := range app.Spec.Components[i].Traits { + if app.Spec.Components[i].Traits[j].Type == "gateway" { + app.Spec.Components[i].Traits[j].Type = "ingress" + } + } + } + } +} diff --git a/test/e2e-test/resource_policy_test.go b/test/e2e-test/resource_policy_test.go index 48685f3a8..d276f0344 100644 --- a/test/e2e-test/resource_policy_test.go +++ b/test/e2e-test/resource_policy_test.go @@ -63,7 +63,7 @@ var _ = Describe("Application Resource-Related Policy Tests", func() { Eventually(func(g Gomega) { g.Expect(k8sClient.Get(ctx, appKey, app)).Should(Succeed()) g.Expect(app.Status.Phase).Should(Equal(common2.ApplicationRunning)) - }, 30*time.Second).Should(Succeed()) + }, 120*time.Second).Should(Succeed()) By("test state-keep") deploy := &v13.Deployment{} @@ -118,7 +118,7 @@ var _ = Describe("Application Resource-Related Policy Tests", func() { Eventually(func(g Gomega) { g.Expect(k8sClient.Get(ctx, appKey, app)).Should(Succeed()) g.Expect(app.Status.Phase).Should(Equal(common2.ApplicationRunning)) - }, 30*time.Second).Should(Succeed()) + }, 120*time.Second).Should(Succeed()) By("upgrade to v2 (same component)") Eventually(func(g Gomega) { @@ -217,7 +217,7 @@ var _ = Describe("Application Resource-Related Policy Tests", func() { Eventually(func(g Gomega) { g.Expect(k8sClient.Get(ctx, appKey, app)).Should(Succeed()) g.Expect(app.Status.Phase).Should(Equal(common2.ApplicationWorkflowSuspending)) - }, 30*time.Second).Should(Succeed()) + }, 60*time.Second).Should(Succeed()) By("test suspending app state-keep") deploy := &v13.Deployment{} diff --git a/test/e2e-test/suite_test.go b/test/e2e-test/suite_test.go index 96d85e2e8..1fc104eb4 100644 --- a/test/e2e-test/suite_test.go +++ b/test/e2e-test/suite_test.go @@ -25,19 +25,20 @@ import ( "testing" "time" - "github.com/oam-dev/kubevela/apis/standard.oam.dev/v1alpha1" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - kruise "github.com/openkruise/kruise-api/apps/v1alpha1" + "github.com/pkg/errors" + networkv1 "k8s.io/api/networking/v1" rbac "k8s.io/api/rbac/v1" crdv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" clientgoscheme "k8s.io/client-go/kubernetes/scheme" + k8sutils "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/controller-runtime/pkg/envtest/printer" @@ -48,6 +49,7 @@ import ( core "github.com/oam-dev/kubevela/apis/core.oam.dev" commontypes "github.com/oam-dev/kubevela/apis/core.oam.dev/common" "github.com/oam-dev/kubevela/apis/core.oam.dev/v1alpha2" + "github.com/oam-dev/kubevela/apis/standard.oam.dev/v1alpha1" "github.com/oam-dev/kubevela/pkg/oam/util" // +kubebuilder:scaffold:imports ) @@ -58,6 +60,10 @@ var manualscalertrait v1alpha2.TraitDefinition var roleName = "oam-example-com" var roleBindingName = "oam-role-binding" +var ( + noNetworkingV1 bool +) + // A DefinitionExtension is an Object type for xxxDefinitin.spec.extension type DefinitionExtension struct { Alias string `json:"alias,omitempty"` @@ -104,6 +110,8 @@ var _ = BeforeSuite(func(done Done) { } By("Finished setting up test environment") + detectAPIVersion() + // Create manual scaler trait definition manualscalertrait = v1alpha2.TraitDefinition{ ObjectMeta: metav1.ObjectMeta{ @@ -219,3 +227,20 @@ func RequestReconcileNow(ctx context.Context, o client.Object) { func randomNamespaceName(basic string) string { return fmt.Sprintf("%s-%s", basic, strconv.FormatInt(rand.Int63(), 16)) } + +// detectAPIVersion helps detect legacy GVK +func detectAPIVersion() { + err := k8sClient.Create(context.Background(), &networkv1.Ingress{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-ingress", + }, + Spec: networkv1.IngressSpec{ + IngressClassName: k8sutils.StringPtr("nginx"), + Rules: []networkv1.IngressRule{}, + }, + }) + var noKindMatchErr = &meta.NoKindMatchError{} + if err != nil && errors.As(err, &noKindMatchErr) { + noNetworkingV1 = true + } +} diff --git a/test/e2e-test/testdata/app/app1.yaml b/test/e2e-test/testdata/app/app1.yaml index 194ba53c0..74fd07663 100644 --- a/test/e2e-test/testdata/app/app1.yaml +++ b/test/e2e-test/testdata/app/app1.yaml @@ -7,7 +7,4 @@ spec: - name: myweb type: worker properties: - image: "stefanprodan/podinfo:4.0.3" - cmd: - - ./podinfo - - stress-cpu=1 \ No newline at end of file + image: crccheck/hello-world \ No newline at end of file diff --git a/test/e2e-test/testdata/app/app2.yaml b/test/e2e-test/testdata/app/app2.yaml index 008560d35..f6e79d45c 100644 --- a/test/e2e-test/testdata/app/app2.yaml +++ b/test/e2e-test/testdata/app/app2.yaml @@ -7,10 +7,7 @@ spec: - name: myweb type: worker properties: - image: "stefanprodan/podinfo:4.0.3" - cmd: - - ./podinfo - - stress-cpu=1 + image: crccheck/hello-world traits: - type: scaler properties: diff --git a/test/e2e-test/testdata/app/app3.yaml b/test/e2e-test/testdata/app/app3.yaml index 263f94a5a..41a8f0995 100644 --- a/test/e2e-test/testdata/app/app3.yaml +++ b/test/e2e-test/testdata/app/app3.yaml @@ -7,10 +7,7 @@ spec: - name: myweb type: worker properties: - image: "stefanprodan/podinfo:4.0.3" - cmd: - - ./podinfo - - stress-cpu=1 + image: crccheck/hello-world traits: - type: scaler properties: diff --git a/test/e2e-test/testdata/app/app4.yaml b/test/e2e-test/testdata/app/app4.yaml index 12765c5ef..90cda8a04 100644 --- a/test/e2e-test/testdata/app/app4.yaml +++ b/test/e2e-test/testdata/app/app4.yaml @@ -7,10 +7,7 @@ spec: - name: myweb type: worker properties: - image: "stefanprodan/podinfo:5.0.2" - cmd: - - ./podinfo - - stress-cpu=1 + image: hello-world traits: - type: scaler properties: diff --git a/test/e2e-test/testdata/app/app6.yaml b/test/e2e-test/testdata/app/app6.yaml deleted file mode 100644 index 5334fa468..000000000 --- a/test/e2e-test/testdata/app/app6.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: core.oam.dev/v1beta1 -kind: Application -metadata: - name: test-rolling -spec: - components: - - name: metrics-provider - type: worker - properties: - cmd: - - ./podinfo - - stress-cpu=3.0 - image: stefanprodan/podinfo:4.0.6 - port: 8080 - rolloutPlan: - rolloutStrategy: "IncreaseFirst" - targetSize: 3 diff --git a/test/e2e-test/testdata/app/app7.yaml b/test/e2e-test/testdata/app/app7.yaml index 2abb59bcb..96931a44d 100644 --- a/test/e2e-test/testdata/app/app7.yaml +++ b/test/e2e-test/testdata/app/app7.yaml @@ -7,7 +7,7 @@ spec: - name: myworker type: worker properties: - image: nginx + image: crccheck/hello-world traits: - type: config properties: diff --git a/test/e2e-test/testdata/app/app_healthscope.yaml b/test/e2e-test/testdata/app/app_healthscope.yaml index 8b1410eb1..56e9e78c5 100644 --- a/test/e2e-test/testdata/app/app_healthscope.yaml +++ b/test/e2e-test/testdata/app/app_healthscope.yaml @@ -7,13 +7,10 @@ spec: - name: my-server-1 type: webservice properties: - cmd: - - node - - server.js - image: oamdev/testapp:v1 + image: crccheck/hello-world port: 8080 traits: - - type: ingress + - type: gateway properties: domain: test.my.domain http: @@ -21,13 +18,10 @@ spec: - name: my-server-2 type: webservice properties: - cmd: - - node - - server.js - image: oamdev/testapp:v1 + image: crccheck/hello-world port: 8080 traits: - - type: ingress + - type: gateway properties: domain: test.my.domain http: diff --git a/test/e2e-test/testdata/app/app_healthscope_unhealthy.yaml b/test/e2e-test/testdata/app/app_healthscope_unhealthy.yaml index f2ab3efd1..6842341b5 100644 --- a/test/e2e-test/testdata/app/app_healthscope_unhealthy.yaml +++ b/test/e2e-test/testdata/app/app_healthscope_unhealthy.yaml @@ -15,13 +15,10 @@ spec: - name: my-server type: webservice properties: - cmd: - - node - - server.js - image: oamdev/testapp:v1 + image: crccheck/hello-world port: 8080 traits: - - type: ingress + - type: gateway properties: domain: test.my.domain http: diff --git a/test/e2e-test/testdata/app/app_suspending.yaml b/test/e2e-test/testdata/app/app_suspending.yaml index e244322bc..f580300e6 100644 --- a/test/e2e-test/testdata/app/app_suspending.yaml +++ b/test/e2e-test/testdata/app/app_suspending.yaml @@ -7,8 +7,7 @@ spec: - name: busybox type: webservice properties: - image: busybox - cmd: ["sleep", "86400"] + image: crccheck/hello-world traits: - type: scaler properties: diff --git a/test/e2e-test/testdata/app/app_wait_suspend.yaml b/test/e2e-test/testdata/app/app_wait_suspend.yaml index 33f9d1539..a5482732e 100644 --- a/test/e2e-test/testdata/app/app_wait_suspend.yaml +++ b/test/e2e-test/testdata/app/app_wait_suspend.yaml @@ -7,7 +7,7 @@ spec: - name: wait-suspend-comp type: webservice properties: - image: nginx + image: crccheck/hello-world port: 80 workflow: steps: diff --git a/test/e2e-test/testdata/rollout/cloneset/app-remove-ingress.yaml b/test/e2e-test/testdata/rollout/cloneset/app-remove-ingress.yaml deleted file mode 100644 index 92b597cf4..000000000 --- a/test/e2e-test/testdata/rollout/cloneset/app-remove-ingress.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: core.oam.dev/v1beta1 -kind: Application -metadata: - name: test-e2e-rolling - annotations: - "app.oam.dev/rollout-template": "true" -spec: - components: - - name: metrics-provider - type: clonesetservice - properties: - cmd: - - ./podinfo - - stress-cpu=1 - image: stefanprodan/podinfo:5.0.2 - port: 8080 - updateStrategyType: InPlaceOnly \ No newline at end of file diff --git a/test/e2e-test/testdata/rollout/cloneset/app-with-ingress-source.yaml b/test/e2e-test/testdata/rollout/cloneset/app-with-ingress-source.yaml deleted file mode 100644 index 4e87d7a5c..000000000 --- a/test/e2e-test/testdata/rollout/cloneset/app-with-ingress-source.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: core.oam.dev/v1beta1 -kind: Application -metadata: - name: test-e2e-rolling - annotations: - "app.oam.dev/rollout-template": "true" -spec: - components: - - name: metrics-provider - type: clonesetservice - properties: - cmd: - - ./podinfo - - stress-cpu=1 - image: stefanprodan/podinfo:4.0.3 - port: 8080 - updateStrategyType: InPlaceOnly - traits: - - type: ingress - properties: - domain: test.example.com - http: - "/": 8080 \ No newline at end of file diff --git a/test/e2e-test/testdata/rollout/cloneset/app-with-ingress-target.yaml b/test/e2e-test/testdata/rollout/cloneset/app-with-ingress-target.yaml deleted file mode 100644 index 2464d76d8..000000000 --- a/test/e2e-test/testdata/rollout/cloneset/app-with-ingress-target.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: core.oam.dev/v1beta1 -kind: Application -metadata: - name: test-e2e-rolling - annotations: - "app.oam.dev/rollout-template": "true" -spec: - components: - - name: metrics-provider - type: clonesetservice - properties: - cmd: - - ./podinfo - - stress-cpu=1 - image: stefanprodan/podinfo:5.0.2 - port: 8080 - updateStrategyType: InPlaceOnly - traits: - - type: ingress - properties: - domain: test-1.example.com - http: - "/": 8080 \ No newline at end of file