-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(e2e): add backward compatibility e2e tests #5681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| #!/bin/bash | ||
| set -o pipefail | ||
|
|
||
|
|
||
| syslog() { | ||
| echo ">>> ${1}" | ||
| return 0 | ||
| } | ||
|
|
||
| panic() { | ||
|
Check warning on line 10 in .github/scripts/gha-backward-compatibility.sh
|
||
| local err_msg="${1}" | ||
| syslog "backward compatibility test failed: ${err_msg}" | ||
| exit 1 | ||
| } | ||
|
|
||
| check_control_plane_status() { | ||
|
Check warning on line 16 in .github/scripts/gha-backward-compatibility.sh
|
||
| echo "=== Unique image tags used by Fluid control plane ===" | ||
| kubectl get pod -n fluid-system -o jsonpath=' | ||
| {range .items[*]}{range .spec.containers[*]}{.image}{"\n"}{end}{range .spec.initContainers[*]}{.image}{"\n"}{end}{end}' \ | ||
| | sed 's/.*://' \ | ||
| | sort -u | ||
|
|
||
| # Timeout counter (30 minutes = 360*5 seconds) | ||
| local timeout=360 | ||
| local counter=0 | ||
| local status_interval=36 | ||
|
|
||
| while true; do | ||
| total_pods=$(kubectl get pod -n fluid-system --no-headers | grep -cv "Completed") | ||
| running_pods=$(kubectl get pod -n fluid-system --no-headers | grep -c "Running") | ||
| not_running_pods=$((total_pods - running_pods)) | ||
|
|
||
| if ((counter % status_interval == 0)); then | ||
| syslog "[Status Check $((counter / status_interval))] Pod status: ${running_pods}/${total_pods} running (${not_running_pods} not ready)" | ||
| if [[ "${not_running_pods}" -gt 0 ]]; then | ||
| echo "=== Not running pods ===" | ||
| kubectl get pods -n fluid-system \ | ||
| --field-selector=status.phase!=Running \ | ||
| -o=custom-columns='NAME:.metadata.name,STATUS:.status.phase,REASON:.status.reason' | ||
| fi | ||
| fi | ||
|
|
||
| if [[ "${total_pods}" -ne 0 ]] && [[ "${total_pods}" -eq "${running_pods}" ]]; then | ||
| break | ||
| fi | ||
|
|
||
| if [[ "${counter}" -ge "${timeout}" ]]; then | ||
| panic "Timeout waiting for control plane after ${counter} checks!" | ||
| fi | ||
|
|
||
| sleep 5 | ||
| ((counter++)) | ||
| done | ||
| syslog "Fluid control plane is ready after ${counter} checks!" | ||
| } | ||
|
|
||
| wait_dataset_bound() { | ||
|
Check warning on line 57 in .github/scripts/gha-backward-compatibility.sh
|
||
| local dataset_name="${1}" | ||
| local deadline=180 | ||
| local log_interval=4 # log every 20s (4 iterations * 5s) | ||
| local counter=0 | ||
|
|
||
| syslog "Waiting for dataset ${dataset_name} to be Bound..." | ||
|
|
||
| while true; do | ||
| # We don't use 'set -e' here so we can handle the case where the object or field is missing | ||
| last_state=$(kubectl get dataset "${dataset_name}" -n default -ojsonpath='{.status.phase}' 2>/dev/null || echo "Unknown") | ||
|
|
||
| if [[ "${last_state}" == "Bound" ]]; then | ||
| break | ||
| fi | ||
|
|
||
| if [[ $((counter % log_interval)) -eq 0 ]]; then | ||
| syslog "checking dataset.status.phase==Bound (elapsed: $((counter * 5))s, current state: ${last_state})" | ||
| fi | ||
|
|
||
| ((counter++)) | ||
| if [[ $((counter * 5)) -ge "${deadline}" ]]; then | ||
| panic "timeout for ${deadline}s waiting for dataset ${dataset_name} to become bound!" | ||
| fi | ||
|
|
||
| sleep 5 | ||
| done | ||
| syslog "Found dataset ${dataset_name} status.phase==Bound" | ||
| } | ||
|
|
||
| wait_job_completed() { | ||
|
Check warning on line 87 in .github/scripts/gha-backward-compatibility.sh
|
||
| local job_name="${1}" | ||
| local deadline=600 # 10 minutes | ||
| local counter=0 | ||
| while true; do | ||
| # Handle missing fields gracefully | ||
| succeed=$(kubectl get job "${job_name}" -ojsonpath='{.status.succeeded}' 2>/dev/null || echo "0") | ||
| failed=$(kubectl get job "${job_name}" -ojsonpath='{.status.failed}' 2>/dev/null || echo "0") | ||
|
|
||
| # Ensure variables are treated as integers | ||
| [[ -z "${succeed}" ]] && succeed=0 | ||
| [[ -z "${failed}" ]] && failed=0 | ||
|
|
||
| if [[ "${failed}" -gt 0 ]]; then | ||
| panic "job ${job_name} failed when accessing data" | ||
| fi | ||
| if [[ "${succeed}" -gt 0 ]]; then | ||
| break | ||
| fi | ||
|
|
||
| ((counter++)) | ||
| if [[ $((counter * 5)) -ge "${deadline}" ]]; then | ||
| panic "timeout for ${deadline}s waiting for job ${job_name} completion!" | ||
| fi | ||
| sleep 5 | ||
| done | ||
| syslog "Found succeeded job ${job_name}" | ||
| } | ||
|
|
||
| setup_old_fluid() { | ||
|
Check warning on line 116 in .github/scripts/gha-backward-compatibility.sh
|
||
| syslog "Setting up older version of Fluid from charts" | ||
| helm repo add fluid https://fluid-cloudnative.github.io/charts | ||
| helm repo update fluid | ||
|
|
||
| # We ignore errors in case namespace exists | ||
| kubectl create ns fluid-system || true | ||
|
|
||
| helm install fluid fluid/fluid --namespace fluid-system --wait | ||
| check_control_plane_status | ||
| } | ||
|
|
||
| create_dataset() { | ||
|
Check warning on line 128 in .github/scripts/gha-backward-compatibility.sh
|
||
| syslog "Creating alluxio dataset..." | ||
| kubectl apply -f test/gha-e2e/alluxio/dataset.yaml | ||
| # give it 15s to let the CRDs and controllers settle | ||
| sleep 15 | ||
| wait_dataset_bound "zookeeper" | ||
| } | ||
|
|
||
| upgrade_fluid() { | ||
|
Check warning on line 136 in .github/scripts/gha-backward-compatibility.sh
|
||
| syslog "Upgrading Fluid to the locally built current version..." | ||
| ./.github/scripts/deploy-fluid-to-kind.sh | ||
| check_control_plane_status | ||
| } | ||
|
|
||
| verify_backward_compatibility() { | ||
|
Check warning on line 142 in .github/scripts/gha-backward-compatibility.sh
|
||
| syslog "Verifying backward compatibility..." | ||
| # Ensure the dataset created earlier is still bound | ||
| wait_dataset_bound "zookeeper" | ||
|
|
||
| # create job to access data over the runtime | ||
| kubectl apply -f test/gha-e2e/alluxio/job.yaml | ||
| wait_job_completed "fluid-test" | ||
|
|
||
| # Clean up | ||
| kubectl delete -f test/gha-e2e/alluxio/ | ||
| } | ||
|
|
||
| main() { | ||
|
Check warning on line 155 in .github/scripts/gha-backward-compatibility.sh
|
||
| syslog "[BACKWARD COMPATIBILITY TEST STARTS AT $(date)]" | ||
|
|
||
| setup_old_fluid | ||
| create_dataset | ||
| upgrade_fluid | ||
| verify_backward_compatibility | ||
|
|
||
| syslog "[BACKWARD COMPATIBILITY TEST SUCCEEDED AT $(date)]" | ||
| } | ||
|
|
||
| main | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| name: E2E Backward Compatibility Check | ||
| on: | ||
| pull_request: | ||
| branches: [master, release-*] | ||
| paths-ignore: | ||
| - "docs/**" | ||
| - "addons/**" | ||
| - "sdk/**" | ||
| - "static/**" | ||
|
|
||
| permissions: | ||
| contents: read | ||
| actions: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| GO_VERSION: 1.24.12 | ||
|
|
||
| jobs: | ||
| backward-compat-test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| kubernetes-version: | ||
| ["v1.33.2", "v1.30.13", "v1.28.15", "v1.24.17", "v1.22.17"] | ||
| env: | ||
| GOPATH: ${{ github.workspace }} | ||
| GO111MODULE: auto | ||
| KIND_CLUSTER: fluid-cluster | ||
| defaults: | ||
| run: | ||
| working-directory: ${{ env.GOPATH }}/src/github.com/fluid-cloudnative/fluid | ||
|
|
||
| steps: | ||
| - name: Set up Go | ||
| uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 | ||
| with: | ||
| go-version: ${{ env.GO_VERSION }} | ||
|
|
||
| - name: Set up Helm | ||
| uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4.3.1 | ||
|
|
||
| - name: Checkout code | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| path: ${{ env.GOPATH }}/src/github.com/fluid-cloudnative/fluid | ||
|
|
||
| - name: Create k8s Kind Cluster | ||
| uses: helm/kind-action@92086f6be054225fa813e0a4b13787fc9088faab # v1.13.0 | ||
| with: | ||
| version: v0.29.0 | ||
| node_image: kindest/node:${{ matrix.kubernetes-version }} | ||
| cluster_name: ${{ env.KIND_CLUSTER }} | ||
| kubectl_version: ${{ matrix.kubernetes-version }} | ||
|
|
||
| - name: Build current fluid docker images | ||
| env: | ||
| IMG_REPO: fluidcloudnative | ||
| run: | | ||
| echo ">>> System disk usage before build fluid images" | ||
| df -h | ||
| ./.github/scripts/build-all-images.sh | ||
|
|
||
| - name: Run backward compatibility e2e tests | ||
| timeout-minutes: 40 | ||
| run: | | ||
| bash ./.github/scripts/gha-backward-compatibility.sh | ||
|
|
||
| - name: Dump environment | ||
| if: ${{ !cancelled() }} | ||
| uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 | ||
| with: | ||
| name: gha-backward-compat-logs-${{ github.job }}-${{ matrix.kubernetes-version }} | ||
| path: "src/github.com/fluid-cloudnative/fluid/e2e-tmp/testcase-*.tgz" | ||
| retention-days: 14 |
Uh oh!
There was an error while loading. Please reload this page.