diff --git a/.github/workflows/apiserver-test.yaml b/.github/workflows/apiserver-test.yaml index 3498fc2df..3f8a63d8a 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.14.0' - KIND_IMAGE_VERSION: '[\"v1.20.15\"]' - KIND_IMAGE_VERSIONS: '[\"v1.18.20\",\"v1.20.15\",\"v1.22.9\"]' + KIND_VERSION: 'v0.7.0' + KIND_IMAGE_VERSION: '[\"v1.20.7\"]' + KIND_IMAGE_VERSIONS: '[\"v1.18.20\",\"v1.20.7\",\"v1.22.7\"]' jobs: diff --git a/.github/workflows/e2e-multicluster-test.yml b/.github/workflows/e2e-multicluster-test.yml index b89e483e8..d5ef20438 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.14.0' - KIND_IMAGE_VERSION: '[\"v1.20.15\"]' - KIND_IMAGE_VERSIONS: '[\"v1.18.20\",\"v1.20.15\",\"v1.22.9\"]' + KIND_VERSION: 'v0.7.0' + KIND_IMAGE_VERSION: '[\"v1.20.7\"]' + KIND_IMAGE_VERSIONS: '[\"v1.18.20\",\"v1.20.7\",\"v1.22.7\"]' jobs: diff --git a/.github/workflows/e2e-rollout-test.yml b/.github/workflows/e2e-rollout-test.yml index 781a3c668..d27dc4e3f 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.14.0' - KIND_IMAGE_VERSION: '[\"v1.20.15\"]' - KIND_IMAGE_VERSIONS: '[\"v1.18.20\",\"v1.20.15\",\"v1.22.9\"]' + KIND_VERSION: 'v0.7.0' + KIND_IMAGE_VERSION: '[\"v1.20.7\"]' + KIND_IMAGE_VERSIONS: '[\"v1.18.20\",\"v1.20.7\",\"v1.22.7\"]' jobs: diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index cfaccef28..938413b27 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.14.0' - KIND_IMAGE_VERSION: '[\"v1.20.15\"]' - KIND_IMAGE_VERSIONS: '[\"v1.18.20\",\"v1.20.15\",\"v1.22.9\"]' + KIND_VERSION: 'v0.7.0' + KIND_IMAGE_VERSION: '[\"v1.20.7\"]' + KIND_IMAGE_VERSIONS: '[\"v1.18.20\",\"v1.20.7\",\"v1.22.7\"]' jobs: diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index b8247ec08..5315c38d4 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.14.0' + KIND_VERSION: 'v0.7.0' jobs: diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index b1d854b8a..d594bf6db 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.14.0' + KIND_VERSION: 'v0.7.0' jobs: diff --git a/charts/vela-core/templates/test/test-application.yaml b/charts/vela-core/templates/test/test-application.yaml index ce140a85a..ea98c4c03 100644 --- a/charts/vela-core/templates/test/test-application.yaml +++ b/charts/vela-core/templates/test/test-application.yaml @@ -13,6 +13,12 @@ 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 @@ -46,6 +52,12 @@ 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 acd83bb56..ac8b70a51 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=./... -timeout=20m -coverprofile=/tmp/e2e_multicluster_test.out ./test/e2e-multicluster-test + go test -v -coverpkg=./... -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 7cafab449..133911cbb 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()) - By("Test application can run without external policies and workflow since they are recorded in the application revision") + // 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,13 +156,14 @@ var _ = Describe("Test multicluster standalone scenario", func() { g.Expect(_app.Status.Phase).Should(Equal(oamcomm.ApplicationRunning)) }, 30*time.Second).Should(Succeed()) - By("Update application without updating publishVersion. App should not re-run workflow") + // update application without updating publishVersion 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()) @@ -172,7 +173,7 @@ var _ = Describe("Test multicluster standalone scenario", func() { g.Expect(len(apprevs.Items)).Should(Equal(1)) }, 10*time.Second).Should(Succeed()) - By("Update application with publishVersion") + // update application with publishVersion applyFile("policy.yaml") applyFile("workflow.yaml") Eventually(func(g Gomega) { @@ -190,7 +191,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))) - }, 2*time.Minute, time.Second).Should(Succeed()) + }, 30*time.Second).Should(Succeed()) }) It("Test rollback application with publish version", func() { @@ -204,7 +205,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)) - }, 60*time.Second).Should(Succeed()) + }, 30*time.Second).Should(Succeed()) By("Update Application to first failed version") Eventually(func(g Gomega) { @@ -212,7 +213,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()) - }, 60*time.Second).Should(Succeed()) + }, 30*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 8b33c0166..299bf6128 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)) - }, 4*time.Minute, time.Second).Should(Succeed()) + }, time.Minute).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":"crccheck/hello-world"}`)}, + Properties: &runtime.RawExtension{Raw: []byte(`{"image":"busybox","cmd":["sleep","86400"]}`)}, }}, 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()) - }, 2*time.Minute, 2*time.Second).Should(Succeed()) + }, time.Minute).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 ef132a6f4..4e77d8bf3 100644 --- a/test/e2e-multicluster-test/testdata/app/example-envbinding-app.yaml +++ b/test/e2e-multicluster-test/testdata/app/example-envbinding-app.yaml @@ -17,7 +17,10 @@ spec: - name: data-worker type: worker properties: - image: crccheck/hello-world + image: busybox + cmd: + - sleep + - '1000000' 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 70f6cb1c6..dd2d7e95d 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: hello-world + name: podinfo annotations: app.oam.dev/publishVersion: alpha1 spec: components: - - name: hello-world + - name: podinfo type: ref-objects properties: objects: - resource: deployment - name: hello-world-ref + name: podinfo policies: - type: topology name: topology-worker properties: clusters: ["cluster-worker"] workflow: - ref: deploy-hello-world \ No newline at end of file + ref: deploy-podinfo \ 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 4703c1330..0f7acf2af 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: hello-world + - name: podinfo type: ref-objects properties: objects: - resource: deployment - name: hello-world-ref + name: podinfo - resource: configmap labelSelector: app: podinfo @@ -23,4 +23,4 @@ spec: properties: clusters: ["cluster-worker"] workflow: - ref: deploy-hello-world \ No newline at end of file + ref: deploy-podinfo \ 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 ad89f0d92..ef72da84b 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: hello-world-ref + name: podinfo spec: replicas: 0 selector: matchLabels: - app: hello-world + app: podinfo template: metadata: labels: - app: hello-world + app: podinfo spec: containers: - - image: crccheck/hello-world - name: hello-world \ No newline at end of file + - image: stefanprodan/podinfo:6.0.2 + name: podinfo \ 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 7066d5b11..d1ca4000e 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: hello-world + - name: podinfo 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 8e63df4ab..8f6d3053c 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: hello-world + - name: podinfo 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 7c81faa79..87af3f7a5 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-hello-world + name: deploy-podinfo 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 b555d3984..869e50a3b 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-hello-world + name: deploy-podinfo 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 d29425c40..9a0636ad8 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": "crccheck/hello-world"}`)}, + Properties: &runtime.RawExtension{Raw: []byte(`{"image": "nginx:latest"}`)}, 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": "crccheck/hello-world"}`)}, + Properties: &runtime.RawExtension{Raw: []byte(`{"image": "nginx:latest"}`)}, 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) - }, 120*time.Second, 1*time.Second).Should(SatisfyAll(&util.NotFoundMatcher{})) + }, 20*time.Second, 2*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(`{"image":"crccheck/hello-world"}`)}, + Properties: &runtime.RawExtension{Raw: []byte(`{"cmd":["sleep","1000"],"image":"busybox"}`)}, Traits: []common.ApplicationTrait{ { Type: "cross-scaler", @@ -1033,11 +1033,8 @@ 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 { - 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)) + if err != nil || len(deploys.Items) != 1 { + return fmt.Errorf("error to list deploy") } deploy := deploys.Items[0] for _, resource := range resourceTracker.Spec.ManagedResources { @@ -1087,11 +1084,8 @@ var _ = Describe("Test application cross namespace resource", func() { } deploys := new(appsv1.DeploymentList) err = k8sClient.List(ctx, deploys, opts...) - 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)) + if err != nil || len(deploys.Items) != 1 { + return fmt.Errorf("error to list deploy") } deploy := deploys.Items[0] if resourceTracker.Spec.ManagedResources[0].Name != deploy.Name { @@ -1142,7 +1136,7 @@ var _ = Describe("Test application cross namespace resource", func() { { Name: componentName, Type: "cross-worker", - Properties: &runtime.RawExtension{Raw: []byte(`{"image":"crccheck/hello-world"}`)}, + Properties: &runtime.RawExtension{Raw: []byte(`{"cmd":["sleep","1000"],"image":"busybox"}`)}, }, }, }, diff --git a/test/e2e-test/application_test.go b/test/e2e-test/application_test.go index c7db90ddd..a42a156d8 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 image %v != real %v", image, workload.Spec.Template.Spec.Containers[0].Image) + return fmt.Errorf("expect replicas %v != real %v", image, workload.Spec.Template.Spec.Containers[0].Image) } return nil }, - time.Second*120, time.Millisecond*500).Should(BeNil()) + time.Second*60, 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, "crccheck/hello-world") + verifyWorkloadRunningExpected("myweb", 1, "stefanprodan/podinfo:4.0.3") By("Update app with trait") updateApp("app2.yaml") By("Apply the application rollout go directly to the target") - verifyWorkloadRunningExpected("myweb", 2, "crccheck/hello-world") + verifyWorkloadRunningExpected("myweb", 2, "stefanprodan/podinfo:4.0.3") By("Update app with trait updated") updateApp("app3.yaml") By("Apply the application rollout go directly to the target") - verifyWorkloadRunningExpected("myweb", 3, "crccheck/hello-world") + verifyWorkloadRunningExpected("myweb", 3, "stefanprodan/podinfo:4.0.3") 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, "hello-world") + verifyWorkloadRunningExpected("myweb", 1, "stefanprodan/podinfo:5.0.2") }) 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 3de2765d5..f21962cc4 100644 --- a/test/e2e-test/health_scope_test.go +++ b/test/e2e-test/health_scope_test.go @@ -80,8 +80,6 @@ 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()) @@ -103,7 +101,6 @@ 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()) @@ -136,7 +133,7 @@ var _ = Describe("HealthScope", func() { k8sClient.Get(ctx, healthScopeObject, healthScope) return healthScope.Status.ScopeHealthCondition }, - time.Second*120, time.Millisecond*500).Should(Equal(v1alpha2.ScopeHealthCondition{ + time.Second*60, time.Millisecond*500).Should(Equal(v1alpha2.ScopeHealthCondition{ HealthStatus: v1alpha2.StatusHealthy, Total: int64(2), HealthyWorkloads: int64(2), @@ -208,16 +205,3 @@ 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 d276f0344..48685f3a8 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)) - }, 120*time.Second).Should(Succeed()) + }, 30*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)) - }, 120*time.Second).Should(Succeed()) + }, 30*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)) - }, 60*time.Second).Should(Succeed()) + }, 30*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 1fc104eb4..96d85e2e8 100644 --- a/test/e2e-test/suite_test.go +++ b/test/e2e-test/suite_test.go @@ -25,20 +25,19 @@ 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" @@ -49,7 +48,6 @@ 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 ) @@ -60,10 +58,6 @@ 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"` @@ -110,8 +104,6 @@ var _ = BeforeSuite(func(done Done) { } By("Finished setting up test environment") - detectAPIVersion() - // Create manual scaler trait definition manualscalertrait = v1alpha2.TraitDefinition{ ObjectMeta: metav1.ObjectMeta{ @@ -227,20 +219,3 @@ 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 74fd07663..194ba53c0 100644 --- a/test/e2e-test/testdata/app/app1.yaml +++ b/test/e2e-test/testdata/app/app1.yaml @@ -7,4 +7,7 @@ spec: - name: myweb type: worker properties: - image: crccheck/hello-world \ No newline at end of file + image: "stefanprodan/podinfo:4.0.3" + cmd: + - ./podinfo + - stress-cpu=1 \ 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 f6e79d45c..008560d35 100644 --- a/test/e2e-test/testdata/app/app2.yaml +++ b/test/e2e-test/testdata/app/app2.yaml @@ -7,7 +7,10 @@ spec: - name: myweb type: worker properties: - image: crccheck/hello-world + image: "stefanprodan/podinfo:4.0.3" + cmd: + - ./podinfo + - stress-cpu=1 traits: - type: scaler properties: diff --git a/test/e2e-test/testdata/app/app3.yaml b/test/e2e-test/testdata/app/app3.yaml index 41a8f0995..263f94a5a 100644 --- a/test/e2e-test/testdata/app/app3.yaml +++ b/test/e2e-test/testdata/app/app3.yaml @@ -7,7 +7,10 @@ spec: - name: myweb type: worker properties: - image: crccheck/hello-world + image: "stefanprodan/podinfo:4.0.3" + cmd: + - ./podinfo + - stress-cpu=1 traits: - type: scaler properties: diff --git a/test/e2e-test/testdata/app/app4.yaml b/test/e2e-test/testdata/app/app4.yaml index 90cda8a04..12765c5ef 100644 --- a/test/e2e-test/testdata/app/app4.yaml +++ b/test/e2e-test/testdata/app/app4.yaml @@ -7,7 +7,10 @@ spec: - name: myweb type: worker properties: - image: hello-world + image: "stefanprodan/podinfo:5.0.2" + cmd: + - ./podinfo + - stress-cpu=1 traits: - type: scaler properties: diff --git a/test/e2e-test/testdata/app/app6.yaml b/test/e2e-test/testdata/app/app6.yaml new file mode 100644 index 000000000..5334fa468 --- /dev/null +++ b/test/e2e-test/testdata/app/app6.yaml @@ -0,0 +1,17 @@ +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 96931a44d..2abb59bcb 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: crccheck/hello-world + image: nginx 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 56e9e78c5..8b1410eb1 100644 --- a/test/e2e-test/testdata/app/app_healthscope.yaml +++ b/test/e2e-test/testdata/app/app_healthscope.yaml @@ -7,10 +7,13 @@ spec: - name: my-server-1 type: webservice properties: - image: crccheck/hello-world + cmd: + - node + - server.js + image: oamdev/testapp:v1 port: 8080 traits: - - type: gateway + - type: ingress properties: domain: test.my.domain http: @@ -18,10 +21,13 @@ spec: - name: my-server-2 type: webservice properties: - image: crccheck/hello-world + cmd: + - node + - server.js + image: oamdev/testapp:v1 port: 8080 traits: - - type: gateway + - type: ingress 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 6842341b5..f2ab3efd1 100644 --- a/test/e2e-test/testdata/app/app_healthscope_unhealthy.yaml +++ b/test/e2e-test/testdata/app/app_healthscope_unhealthy.yaml @@ -15,10 +15,13 @@ spec: - name: my-server type: webservice properties: - image: crccheck/hello-world + cmd: + - node + - server.js + image: oamdev/testapp:v1 port: 8080 traits: - - type: gateway + - type: ingress 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 f580300e6..e244322bc 100644 --- a/test/e2e-test/testdata/app/app_suspending.yaml +++ b/test/e2e-test/testdata/app/app_suspending.yaml @@ -7,7 +7,8 @@ spec: - name: busybox type: webservice properties: - image: crccheck/hello-world + image: busybox + cmd: ["sleep", "86400"] 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 a5482732e..33f9d1539 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: crccheck/hello-world + image: nginx 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 new file mode 100644 index 000000000..92b597cf4 --- /dev/null +++ b/test/e2e-test/testdata/rollout/cloneset/app-remove-ingress.yaml @@ -0,0 +1,17 @@ +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 new file mode 100644 index 000000000..4e87d7a5c --- /dev/null +++ b/test/e2e-test/testdata/rollout/cloneset/app-with-ingress-source.yaml @@ -0,0 +1,23 @@ +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 new file mode 100644 index 000000000..2464d76d8 --- /dev/null +++ b/test/e2e-test/testdata/rollout/cloneset/app-with-ingress-target.yaml @@ -0,0 +1,23 @@ +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