diff --git a/.github/workflows/apiserver-test.yaml b/.github/workflows/apiserver-test.yaml index 7af16943e..d475d4cc6 100644 --- a/.github/workflows/apiserver-test.yaml +++ b/.github/workflows/apiserver-test.yaml @@ -84,9 +84,8 @@ jobs: - name: Cleanup for e2e tests run: | make e2e-cleanup - make e2e-setup-core - make vela-cli + make e2e-setup-core bin/vela addon enable fluxcd timeout 600s bash -c -- 'while true; do kubectl get ns flux-system; if [ $? -eq 0 ] ; then break; else sleep 5; fi;done' kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=vela-core,app.kubernetes.io/instance=kubevela -n vela-system --timeout=600s diff --git a/.github/workflows/e2e-multicluster-test.yml b/.github/workflows/e2e-multicluster-test.yml index 8c156d019..a6a4ff0f4 100644 --- a/.github/workflows/e2e-multicluster-test.yml +++ b/.github/workflows/e2e-multicluster-test.yml @@ -76,17 +76,13 @@ jobs: - name: Load Image to kind cluster (Hub) run: make kind-load - - name: Load Image to kind cluster (Worker) - run: | - make kind-load-runtime-cluster - - name: Cleanup for e2e tests run: | make e2e-cleanup + make vela-cli make e2e-setup-core make make setup-runtime-e2e-cluster - make vela-cli - name: Run e2e multicluster tests run: | diff --git a/Makefile b/Makefile index 2f7569ae0..7a009449d 100644 --- a/Makefile +++ b/Makefile @@ -83,7 +83,7 @@ endif # load docker image to the kind cluster -kind-load: +kind-load: kind-load-runtime-cluster docker build -t $(VELA_CORE_TEST_IMAGE) -f Dockerfile.e2e . kind load docker-image $(VELA_CORE_TEST_IMAGE) || { echo >&2 "kind not installed or error loading image: $(VELA_CORE_TEST_IMAGE)"; exit 1; } @@ -91,6 +91,7 @@ kind-load-runtime-cluster: /bin/sh hack/e2e/build_runtime_rollout.sh docker build -t $(VELA_RUNTIME_ROLLOUT_TEST_IMAGE) -f runtime/rollout/e2e/Dockerfile.e2e runtime/rollout/e2e/ rm -rf runtime/rollout/e2e/tmp + kind load docker-image $(VELA_RUNTIME_ROLLOUT_TEST_IMAGE) || { echo >&2 "kind not installed or error loading image: $(VELA_RUNTIME_ROLLOUT_TEST_IMAGE)"; exit 1; } kind load docker-image $(VELA_RUNTIME_ROLLOUT_TEST_IMAGE) --name=$(RUNTIME_CLUSTER_NAME) || { echo >&2 "kind not installed or error loading image: $(VELA_RUNTIME_ROLLOUT_TEST_IMAGE)"; exit 1; } # Run tests diff --git a/charts/vela-core/templates/defwithtemplate/rollout.yaml b/charts/vela-core/templates/defwithtemplate/rollout.yaml deleted file mode 100644 index 2c037daf1..000000000 --- a/charts/vela-core/templates/defwithtemplate/rollout.yaml +++ /dev/null @@ -1,52 +0,0 @@ -# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file. -# Definition source cue file: vela-templates/definitions/internal/rollout.cue -apiVersion: core.oam.dev/v1beta1 -kind: TraitDefinition -metadata: - annotations: - definition.oam.dev/description: Rollout the component. - name: rollout - namespace: {{.Values.systemDefinitionNamespace}} -spec: - manageWorkload: true - schematic: - cue: - template: | - outputs: rollout: { - apiVersion: "standard.oam.dev/v1alpha1" - kind: "Rollout" - metadata: { - name: context.name - namespace: context.namespace - } - spec: { - if parameter.targetRevision != _|_ { - targetRevisionName: parameter.targetRevision - } - if parameter.targetRevision == _|_ { - targetRevisionName: context.revision - } - componentName: context.name - rolloutPlan: { - rolloutStrategy: "IncreaseFirst" - if parameter.rolloutBatches != _|_ { - rolloutBatches: parameter.rolloutBatches - } - targetSize: parameter.targetSize - if parameter["batchPartition"] != _|_ { - batchPartition: parameter.batchPartition - } - } - } - } - parameter: { - targetRevision?: string - targetSize: int - rolloutBatches?: [...rolloutBatch] - batchPartition?: int - } - rolloutBatch: replicas: int - status: - customStatus: 'message: context.outputs.rollout.status.rollingState' - healthPolicy: 'isHealth: context.outputs.rollout.status.batchRollingState == "batchReady"' - diff --git a/charts/vela-core/values.yaml b/charts/vela-core/values.yaml index 3eb78817a..f3c8250b9 100644 --- a/charts/vela-core/values.yaml +++ b/charts/vela-core/values.yaml @@ -6,7 +6,7 @@ replicaCount: 1 # Valid applyOnceOnly values: true/false/on/off/force applyOnceOnly: "off" -disableCaps: "" +disableCaps: "rollout" imageRegistry: "" image: diff --git a/charts/vela-minimal/templates/defwithtemplate/rollout.yaml b/charts/vela-minimal/templates/defwithtemplate/rollout.yaml deleted file mode 100644 index 2c037daf1..000000000 --- a/charts/vela-minimal/templates/defwithtemplate/rollout.yaml +++ /dev/null @@ -1,52 +0,0 @@ -# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file. -# Definition source cue file: vela-templates/definitions/internal/rollout.cue -apiVersion: core.oam.dev/v1beta1 -kind: TraitDefinition -metadata: - annotations: - definition.oam.dev/description: Rollout the component. - name: rollout - namespace: {{.Values.systemDefinitionNamespace}} -spec: - manageWorkload: true - schematic: - cue: - template: | - outputs: rollout: { - apiVersion: "standard.oam.dev/v1alpha1" - kind: "Rollout" - metadata: { - name: context.name - namespace: context.namespace - } - spec: { - if parameter.targetRevision != _|_ { - targetRevisionName: parameter.targetRevision - } - if parameter.targetRevision == _|_ { - targetRevisionName: context.revision - } - componentName: context.name - rolloutPlan: { - rolloutStrategy: "IncreaseFirst" - if parameter.rolloutBatches != _|_ { - rolloutBatches: parameter.rolloutBatches - } - targetSize: parameter.targetSize - if parameter["batchPartition"] != _|_ { - batchPartition: parameter.batchPartition - } - } - } - } - parameter: { - targetRevision?: string - targetSize: int - rolloutBatches?: [...rolloutBatch] - batchPartition?: int - } - rolloutBatch: replicas: int - status: - customStatus: 'message: context.outputs.rollout.status.rollingState' - healthPolicy: 'isHealth: context.outputs.rollout.status.batchRollingState == "batchReady"' - diff --git a/charts/vela-minimal/values.yaml b/charts/vela-minimal/values.yaml index 14d379594..2d0517b5b 100644 --- a/charts/vela-minimal/values.yaml +++ b/charts/vela-minimal/values.yaml @@ -6,7 +6,7 @@ replicaCount: 1 # Valid applyOnceOnly values: true/false/on/off/force applyOnceOnly: "off" -disableCaps: "manualscalertrait,containerizedwokrload,envbinding" +disableCaps: "manualscalertrait,containerizedwokrload,envbinding,rollout" imageRegistry: "" image: diff --git a/vela-templates/definitions/internal/trait/rollout.cue b/e2e/addon/mock/testdata/rollout/definitions/rollout.cue similarity index 74% rename from vela-templates/definitions/internal/trait/rollout.cue rename to e2e/addon/mock/testdata/rollout/definitions/rollout.cue index d44211ca0..521831163 100644 --- a/vela-templates/definitions/internal/trait/rollout.cue +++ b/e2e/addon/mock/testdata/rollout/definitions/rollout.cue @@ -44,9 +44,13 @@ template: { } parameter: { + // +usage=Specify the target revision, it should be set if you want to rollback. such as: componentname-v1 targetRevision?: string - targetSize: int + // +usage=Specify the count of replicas. + targetSize: int + // +usage=Specify the rollout batches, The total number of replicas of all batches needs to be equal to number of targetSize. rolloutBatches?: [...rolloutBatch] + // +usage=Specify the batch partition in current deploying. It is used to control batch processes. batchPartition?: int } diff --git a/e2e/addon/mock/testdata/rollout/metadata.yaml b/e2e/addon/mock/testdata/rollout/metadata.yaml new file mode 100644 index 000000000..c6f74081d --- /dev/null +++ b/e2e/addon/mock/testdata/rollout/metadata.yaml @@ -0,0 +1,21 @@ +name: rollout +version: 1.2.3 +description: Provides basic batch publishing capability. +url: https://kubevela.io/docs/end-user/traits/rollout + +tags: + - extended_workload + - rollout + +deployTo: + runtimeCluster: true + +dependencies: + # install controller by helm. + - name: fluxcd + +# set invisible means this won't be list and will be enabled when depended on +# for example, terraform-alibaba depends on terraform which is invisible, +# when terraform-alibaba is enabled, terraform will be enabled automatically +# default: false +invisible: false diff --git a/e2e/addon/mock/testdata/rollout/readme.md b/e2e/addon/mock/testdata/rollout/readme.md new file mode 100644 index 000000000..c7b9cd8d7 --- /dev/null +++ b/e2e/addon/mock/testdata/rollout/readme.md @@ -0,0 +1,7 @@ + +# Supported workload type + +Rollout Trait supports following component types: webservice态worker and cloneset. + +When using webservice/worker as Workload type with Rollout Trait, Workload's name will be controllerRevision's name. And when Workload's type is cloneset, because of clonset support in-place update Workload's name will always be component's name. + diff --git a/e2e/addon/mock/testdata/rollout/schemas/trait-uischema-rollout.yaml b/e2e/addon/mock/testdata/rollout/schemas/trait-uischema-rollout.yaml new file mode 100644 index 000000000..abfb35b46 --- /dev/null +++ b/e2e/addon/mock/testdata/rollout/schemas/trait-uischema-rollout.yaml @@ -0,0 +1,10 @@ +- jsonKey: batchPartition + sort: 1 +- jsonKey: targetSize + sort: 3 +- jsonKey: rolloutBatches + sort: 5 +- jsonKey: targetRevision + sort: 7 + validate: + pattern: ^[a-z0-9]+\-v\d{1,5}$ \ No newline at end of file diff --git a/makefiles/e2e.mk b/makefiles/e2e.mk index 12287e9ff..1d85a38d6 100644 --- a/makefiles/e2e.mk +++ b/makefiles/e2e.mk @@ -4,7 +4,10 @@ e2e-setup-core: sh ./hack/e2e/modify_charts.sh helm upgrade --install --create-namespace --namespace vela-system --set image.pullPolicy=IfNotPresent --set image.repository=vela-core-test --set applicationRevisionLimit=5 --set dependCheckWait=10s --set image.tag=$(GIT_COMMIT) --wait kubevela ./charts/vela-core kubectl wait --for=condition=Available deployment/kubevela-vela-core -n vela-system --timeout=180s + helm upgrade --install --namespace vela-system --wait oam-rollout --set image.repository=vela-runtime-rollout-test --set image.tag=$(GIT_COMMIT) ./runtime/rollout/charts go run ./e2e/addon/mock & + sleep 15 + bin/vela addon enable rollout .PHONY: setup-runtime-e2e-cluster setup-runtime-e2e-cluster: @@ -16,10 +19,14 @@ e2e-setup: sh ./hack/e2e/modify_charts.sh helm upgrade --install --create-namespace --namespace vela-system --set image.pullPolicy=IfNotPresent --set image.repository=vela-core-test --set applicationRevisionLimit=5 --set dependCheckWait=10s --set image.tag=$(GIT_COMMIT) --wait kubevela ./charts/vela-core helm upgrade --install --create-namespace --namespace oam-runtime-system --set image.pullPolicy=IfNotPresent --set image.repository=vela-core-test --set dependCheckWait=10s --set image.tag=$(GIT_COMMIT) --wait oam-runtime ./charts/oam-runtime + helm upgrade --install --namespace vela-system --wait oam-rollout --set image.repository=vela-runtime-rollout-test --set image.tag=$(GIT_COMMIT) ./runtime/rollout/charts + go run ./e2e/addon/mock & + sleep 15 bin/vela addon enable fluxcd bin/vela addon enable terraform bin/vela addon enable terraform-alibaba ALICLOUD_ACCESS_KEY=xxx ALICLOUD_SECRET_KEY=yyy ALICLOUD_REGION=cn-beijing + bin/vela addon enable rollout ginkgo version ginkgo -v -r e2e/setup diff --git a/runtime/rollout/charts/values.yaml b/runtime/rollout/charts/values.yaml index a5e2da75b..ff4227954 100644 --- a/runtime/rollout/charts/values.yaml +++ b/runtime/rollout/charts/values.yaml @@ -7,7 +7,7 @@ replicaCount: 1 image: repository: oamdev/vela-rollout tag: latest - pullPolicy: Always + pullPolicy: IfNotPresent imagePullSecrets: [] nameOverride: ""