Skip to content

Commit e1da069

Browse files
feat(e2e): add backward compatibility e2e tests
Signed-off-by: Monika Jakhar <jakharmonika364@gmail.com>
1 parent a69c888 commit e1da069

3 files changed

Lines changed: 225 additions & 2 deletions

File tree

.github/scripts/deploy-fluid-to-kind.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ function get_image_tag() {
1212
function deploy_fluid() {
1313
echo "Replacing image tags in values.yaml with $IMAGE_TAG"
1414
sed -i -E "s/version: &defaultVersion v[0-9]\.[0-9]\.[0-9]-[a-z0-9]+$/version: \&defaultVersion $IMAGE_TAG/g" charts/fluid/fluid/values.yaml
15-
kubectl create ns fluid-system
16-
helm install --create-namespace --set runtime.jindo.smartdata.imagePrefix=registry-cn-hongkong.ack.aliyuncs.com/acs --set runtime.jindo.fuse.imagePrefix=registry-cn-hongkong.ack.aliyuncs.com/acs fluid charts/fluid/fluid
15+
kubectl create ns fluid-system || true
16+
helm upgrade --install --namespace fluid-system --create-namespace --set runtime.jindo.smartdata.imagePrefix=registry-cn-hongkong.ack.aliyuncs.com/acs --set runtime.jindo.fuse.imagePrefix=registry-cn-hongkong.ack.aliyuncs.com/acs fluid charts/fluid/fluid
1717
}
1818

1919
function main() {
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#!/bin/bash
2+
3+
function syslog() {
4+
echo ">>> $1"
5+
}
6+
7+
function panic() {
8+
err_msg=$1
9+
syslog "backward compatibility test failed: $err_msg"
10+
exit 1
11+
}
12+
13+
function check_control_plane_status() {
14+
echo "=== Unique image tags used by Fluid control plane ==="
15+
kubectl get pod -n fluid-system -o jsonpath='
16+
{range .items[*]}{range .spec.containers[*]}{.image}{"\n"}{end}{range .spec.initContainers[*]}{.image}{"\n"}{end}{end}' \
17+
| sed 's/.*://' \
18+
| sort -u
19+
20+
# Timeout counter (30 minutes = 360*5 seconds)
21+
local timeout=360
22+
local counter=0
23+
local status_interval=36
24+
25+
while true; do
26+
total_pods=$(kubectl get pod -n fluid-system --no-headers | grep -cv "Completed")
27+
running_pods=$(kubectl get pod -n fluid-system --no-headers | grep -c "Running")
28+
not_running_pods=$(($total_pods - $running_pods))
29+
30+
if ((counter % status_interval == 0)); then
31+
syslog "[Status Check $((counter/status_interval))] Pod status: $running_pods/$total_pods running ($not_running_pods not ready)"
32+
if [[ $not_running_pods -gt 0 ]]; then
33+
echo "=== Not running pods ==="
34+
kubectl get pods -n fluid-system \
35+
--field-selector=status.phase!=Running \
36+
-o=custom-columns='NAME:.metadata.name,STATUS:.status.phase,REASON:.status.reason'
37+
fi
38+
fi
39+
40+
if [[ $total_pods -ne 0 ]] && [[ $total_pods -eq $running_pods ]]; then
41+
break
42+
fi
43+
44+
if ((counter >= timeout)); then
45+
panic "Timeout waiting for control plane after $counter checks!"
46+
fi
47+
48+
sleep 5
49+
((counter++))
50+
done
51+
syslog "Fluid control plane is ready after $counter checks!"
52+
}
53+
54+
function wait_dataset_bound() {
55+
local dataset_name=$1
56+
local deadline=180
57+
local log_interval=0
58+
local log_times=0
59+
while true; do
60+
last_state=$(kubectl get dataset $dataset_name -ojsonpath='{@.status.phase}')
61+
if [[ $log_interval -eq 3 ]]; then
62+
log_times=$(expr $log_times + 1)
63+
syslog "checking dataset.status.phase==Bound (already $(expr $log_times \* $log_interval \* 5)s, last state: $last_state)"
64+
if [[ "$(expr $log_times \* $log_interval \* 5)" -ge "$deadline" ]]; then
65+
panic "timeout for ${deadline}s waiting for dataset bound!"
66+
fi
67+
log_interval=0
68+
fi
69+
70+
if [[ "$last_state" == "Bound" ]]; then
71+
break
72+
fi
73+
log_interval=$(expr $log_interval + 1)
74+
sleep 5
75+
done
76+
syslog "Found dataset $dataset_name status.phase==Bound"
77+
}
78+
79+
function wait_job_completed() {
80+
local job_name=$1
81+
while true; do
82+
succeed=$(kubectl get job $job_name -ojsonpath='{@.status.succeeded}')
83+
failed=$(kubectl get job $job_name -ojsonpath='{@.status.failed}')
84+
if [[ "$failed" -ne "0" ]]; then
85+
panic "job $job_name failed when accessing data"
86+
fi
87+
if [[ "$succeed" -eq "1" ]]; then
88+
break
89+
fi
90+
sleep 5
91+
done
92+
syslog "Found succeeded job $job_name"
93+
}
94+
95+
function setup_old_fluid() {
96+
syslog "Setting up older version of Fluid from charts"
97+
helm repo add fluid https://fluid-cloudnative.github.io/charts
98+
helm repo update fluid
99+
100+
# We ignore errors in case namespace exists
101+
kubectl create ns fluid-system || true
102+
103+
helm install fluid fluid/fluid --namespace fluid-system
104+
check_control_plane_status
105+
}
106+
107+
function create_dataset() {
108+
syslog "Creating alluxio dataset..."
109+
kubectl apply -f test/gha-e2e/alluxio/dataset.yaml
110+
wait_dataset_bound zookeeper
111+
}
112+
113+
function upgrade_fluid() {
114+
syslog "Upgrading Fluid to the locally built current version..."
115+
./.github/scripts/deploy-fluid-to-kind.sh
116+
check_control_plane_status
117+
}
118+
119+
function verify_backward_compatibility() {
120+
syslog "Verifying backward compatibility..."
121+
# Ensure the dataset created earlier is still bound
122+
wait_dataset_bound zookeeper
123+
124+
# create job to access data over the runtime
125+
kubectl apply -f test/gha-e2e/alluxio/job.yaml
126+
wait_job_completed fluid-test
127+
128+
# Clean up
129+
kubectl delete -f test/gha-e2e/alluxio/
130+
}
131+
132+
function main() {
133+
set -e
134+
syslog "[BACKWARD COMPATIBILITY TEST STARTS AT $(date)]"
135+
136+
setup_old_fluid
137+
create_dataset
138+
upgrade_fluid
139+
verify_backward_compatibility
140+
141+
syslog "[BACKWARD COMPATIBILITY TEST SUCCEEDED AT $(date)]"
142+
}
143+
144+
main
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: E2E Backward Compatibility Check
2+
on:
3+
pull_request:
4+
branches: [master, release-*]
5+
paths-ignore:
6+
- "docs/**"
7+
- "addons/**"
8+
- "sdk/**"
9+
- "static/**"
10+
11+
permissions:
12+
contents: read
13+
actions: read
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
env:
20+
GO_VERSION: 1.24.12
21+
22+
jobs:
23+
backward-compat-test:
24+
runs-on: ubuntu-latest
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
kubernetes-version:
29+
["v1.33.2", "v1.30.13", "v1.28.15", "v1.24.17", "v1.22.17"]
30+
env:
31+
GOPATH: ${{ github.workspace }}
32+
GO111MODULE: auto
33+
KIND_CLUSTER: fluid-cluster
34+
defaults:
35+
run:
36+
working-directory: ${{ env.GOPATH }}/src/github.com/fluid-cloudnative/fluid
37+
38+
steps:
39+
- name: Set up Go
40+
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
41+
with:
42+
go-version: ${{ env.GO_VERSION }}
43+
44+
- name: Set up Helm
45+
uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4.3.1
46+
47+
- name: Checkout code
48+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
49+
with:
50+
path: ${{ env.GOPATH }}/src/github.com/fluid-cloudnative/fluid
51+
52+
- name: Create k8s Kind Cluster
53+
uses: helm/kind-action@92086f6be054225fa813e0a4b13787fc9088faab # v1.13.0
54+
with:
55+
version: v0.29.0
56+
node_image: kindest/node:${{ matrix.kubernetes-version }}
57+
cluster_name: ${{ env.KIND_CLUSTER }}
58+
kubectl_version: ${{ matrix.kubernetes-version }}
59+
60+
- name: Build current fluid docker images
61+
env:
62+
IMG_REPO: fluidcloudnative
63+
run: |
64+
echo ">>> System disk usage before build fluid images"
65+
df -h
66+
./.github/scripts/build-all-images.sh
67+
68+
- name: Run backward compatibility e2e tests
69+
timeout-minutes: 40
70+
run: |
71+
bash ./.github/scripts/gha-backward-compatibility.sh
72+
73+
- name: Dump environment
74+
if: ${{ !cancelled() }}
75+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
76+
with:
77+
name: gha-backward-compat-logs-${{ github.job }}-${{ matrix.kubernetes-version }}
78+
path: "src/github.com/fluid-cloudnative/fluid/e2e-tmp/testcase-*.tgz"
79+
retention-days: 14

0 commit comments

Comments
 (0)