Skip to content

Commit 8bffd11

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

7 files changed

Lines changed: 290 additions & 33 deletions

File tree

.github/scripts/build-all-images.sh

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
#!/bin/bash
22
set -e
33

4-
function get_image_tag() {
4+
get_image_tag() {
55
version=$(grep "^VERSION := " ./Makefile)
6-
version=${version#VERSION := }
6+
version="${version#VERSION := }"
77

88
git_sha=$(git rev-parse --short HEAD || echo "HEAD")
9-
export IMAGE_TAG=${version}-${git_sha}
9+
export IMAGE_TAG="${version}-${git_sha}"
1010
}
1111

12-
function build_images() {
12+
build_images() {
1313
images=(
14-
${IMG_REPO}/dataset-controller:${IMAGE_TAG}
15-
${IMG_REPO}/application-controller:${IMAGE_TAG}
16-
${IMG_REPO}/alluxioruntime-controller:${IMAGE_TAG}
17-
${IMG_REPO}/jindoruntime-controller:${IMAGE_TAG}
18-
${IMG_REPO}/goosefsruntime-controller:${IMAGE_TAG}
19-
${IMG_REPO}/juicefsruntime-controller:${IMAGE_TAG}
20-
${IMG_REPO}/thinruntime-controller:${IMAGE_TAG}
21-
${IMG_REPO}/efcruntime-controller:${IMAGE_TAG}
22-
${IMG_REPO}/vineyardruntime-controller:${IMAGE_TAG}
23-
${IMG_REPO}/fluid-csi:${IMAGE_TAG}
24-
${IMG_REPO}/fluid-webhook:${IMAGE_TAG}
25-
${IMG_REPO}/fluid-crd-upgrader:${IMAGE_TAG}
14+
"${IMG_REPO}/dataset-controller:${IMAGE_TAG}"
15+
"${IMG_REPO}/application-controller:${IMAGE_TAG}"
16+
"${IMG_REPO}/alluxioruntime-controller:${IMAGE_TAG}"
17+
"${IMG_REPO}/jindoruntime-controller:${IMAGE_TAG}"
18+
"${IMG_REPO}/goosefsruntime-controller:${IMAGE_TAG}"
19+
"${IMG_REPO}/juicefsruntime-controller:${IMAGE_TAG}"
20+
"${IMG_REPO}/thinruntime-controller:${IMAGE_TAG}"
21+
"${IMG_REPO}/efcruntime-controller:${IMAGE_TAG}"
22+
"${IMG_REPO}/vineyardruntime-controller:${IMAGE_TAG}"
23+
"${IMG_REPO}/fluid-csi:${IMAGE_TAG}"
24+
"${IMG_REPO}/fluid-webhook:${IMAGE_TAG}"
25+
"${IMG_REPO}/fluid-crd-upgrader:${IMAGE_TAG}"
2626
)
2727

2828
make docker-build-all
2929

30-
for img in ${images[@]}; do
31-
echo "Loading image $img to kind cluster..."
32-
kind load docker-image $img --name ${KIND_CLUSTER}
30+
for img in "${images[@]}"; do
31+
echo "Loading image ${img} to kind cluster..."
32+
kind load docker-image "${img}" --name "${KIND_CLUSTER}"
3333
done
3434
}
3535

36-
function cleanup_docker_caches() {
36+
cleanup_docker_caches() {
3737
echo ">>> System disk usage after building fluid images"
3838
df -h
3939
echo ">>> Cleaning docker caches..."

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
#!/bin/bash
2-
set -e
1+
#! /bin/bash
32

4-
function get_image_tag() {
3+
get_image_tag() {
4+
local version=""
55
version=$(grep "^VERSION := " ./Makefile)
6-
version=${version#VERSION := }
6+
version="${version#VERSION := }"
77

8+
local git_sha=""
89
git_sha=$(git rev-parse --short HEAD || echo "HEAD")
9-
export IMAGE_TAG=${version}-${git_sha}
10+
export IMAGE_TAG="${version}-${git_sha}"
1011
}
1112

12-
function deploy_fluid() {
13-
echo "Replacing image tags in values.yaml with $IMAGE_TAG"
14-
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
13+
deploy_fluid() {
14+
echo "Replacing image tags in values.yaml with ${IMAGE_TAG}"
15+
sed -i -E "s/version: &defaultVersion .+$/version: \&defaultVersion ${IMAGE_TAG}/g" charts/fluid/fluid/values.yaml
16+
kubectl create ns fluid-system || true
17+
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
1718
}
1819

19-
function main() {
20+
main() {
2021
get_image_tag
21-
if [[ -z "$IMAGE_TAG" ]];then
22+
if [[ -z "${IMAGE_TAG}" ]]; then
2223
echo "Failed to get image tag, exiting..."
2324
exit 1
2425
fi
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
#!/bin/bash
2+
set -o pipefail
3+
4+
5+
syslog() {
6+
echo ">>> ${1}"
7+
return 0
8+
}
9+
10+
panic() {
11+
local err_msg="${1}"
12+
syslog "backward compatibility test failed: ${err_msg}"
13+
exit 1
14+
}
15+
16+
check_control_plane_status() {
17+
echo "=== Unique image tags used by Fluid control plane ==="
18+
kubectl get pod -n fluid-system -o jsonpath='
19+
{range .items[*]}{range .spec.containers[*]}{.image}{"\n"}{end}{range .spec.initContainers[*]}{.image}{"\n"}{end}{end}' \
20+
| sed 's/.*://' \
21+
| sort -u
22+
23+
# Timeout counter (30 minutes = 360*5 seconds)
24+
local timeout=360
25+
local counter=0
26+
local status_interval=36
27+
28+
while true; do
29+
total_pods=$(kubectl get pod -n fluid-system --no-headers | grep -cv "Completed")
30+
running_pods=$(kubectl get pod -n fluid-system --no-headers | grep -c "Running")
31+
not_running_pods=$((total_pods - running_pods))
32+
33+
if ((counter % status_interval == 0)); then
34+
syslog "[Status Check $((counter / status_interval))] Pod status: ${running_pods}/${total_pods} running (${not_running_pods} not ready)"
35+
if [[ "${not_running_pods}" -gt 0 ]]; then
36+
echo "=== Not running pods ==="
37+
kubectl get pods -n fluid-system \
38+
--field-selector=status.phase!=Running \
39+
-o=custom-columns='NAME:.metadata.name,STATUS:.status.phase,REASON:.status.reason'
40+
fi
41+
fi
42+
43+
if [[ "${total_pods}" -ne 0 ]] && [[ "${total_pods}" -eq "${running_pods}" ]]; then
44+
break
45+
fi
46+
47+
if [[ "${counter}" -ge "${timeout}" ]]; then
48+
panic "Timeout waiting for control plane after ${counter} checks!"
49+
fi
50+
51+
sleep 5
52+
((counter++))
53+
done
54+
syslog "Fluid control plane is ready after ${counter} checks!"
55+
}
56+
57+
wait_dataset_bound() {
58+
local dataset_name="${1}"
59+
local deadline=180
60+
local log_interval=4 # log every 20s (4 iterations * 5s)
61+
local counter=0
62+
63+
syslog "Waiting for dataset ${dataset_name} to be Bound..."
64+
65+
while true; do
66+
# We don't use 'set -e' here so we can handle the case where the object or field is missing
67+
last_state=$(kubectl get dataset "${dataset_name}" -n default -ojsonpath='{.status.phase}' 2>/dev/null || echo "Unknown")
68+
69+
if [[ "${last_state}" == "Bound" ]]; then
70+
break
71+
fi
72+
73+
if [[ $((counter % log_interval)) -eq 0 ]]; then
74+
syslog "checking dataset.status.phase==Bound (elapsed: $((counter * 5))s, current state: ${last_state})"
75+
fi
76+
77+
((counter++))
78+
if [[ $((counter * 5)) -ge "${deadline}" ]]; then
79+
panic "timeout for ${deadline}s waiting for dataset ${dataset_name} to become bound!"
80+
fi
81+
82+
sleep 5
83+
done
84+
syslog "Found dataset ${dataset_name} status.phase==Bound"
85+
}
86+
87+
wait_job_completed() {
88+
local job_name="${1}"
89+
local deadline=600 # 10 minutes
90+
local counter=0
91+
while true; do
92+
# Handle missing fields gracefully
93+
succeed=$(kubectl get job "${job_name}" -ojsonpath='{.status.succeeded}' 2>/dev/null || echo "0")
94+
failed=$(kubectl get job "${job_name}" -ojsonpath='{.status.failed}' 2>/dev/null || echo "0")
95+
96+
# Ensure variables are treated as integers
97+
[[ -z "${succeed}" ]] && succeed=0
98+
[[ -z "${failed}" ]] && failed=0
99+
100+
if [[ "${failed}" -gt 0 ]]; then
101+
panic "job ${job_name} failed when accessing data"
102+
fi
103+
if [[ "${succeed}" -gt 0 ]]; then
104+
break
105+
fi
106+
107+
((counter++))
108+
if [[ $((counter * 5)) -ge "${deadline}" ]]; then
109+
panic "timeout for ${deadline}s waiting for job ${job_name} completion!"
110+
fi
111+
sleep 5
112+
done
113+
syslog "Found succeeded job ${job_name}"
114+
}
115+
116+
setup_old_fluid() {
117+
syslog "Setting up older version of Fluid from charts"
118+
helm repo add fluid https://fluid-cloudnative.github.io/charts
119+
helm repo update fluid
120+
121+
# We ignore errors in case namespace exists
122+
kubectl create ns fluid-system || true
123+
124+
helm install fluid fluid/fluid --namespace fluid-system --wait
125+
check_control_plane_status
126+
}
127+
128+
create_dataset() {
129+
syslog "Creating alluxio dataset..."
130+
kubectl apply -f test/gha-e2e/alluxio/dataset.yaml
131+
# give it 15s to let the CRDs and controllers settle
132+
sleep 15
133+
wait_dataset_bound "zookeeper"
134+
}
135+
136+
upgrade_fluid() {
137+
syslog "Upgrading Fluid to the locally built current version..."
138+
./.github/scripts/deploy-fluid-to-kind.sh
139+
check_control_plane_status
140+
}
141+
142+
verify_backward_compatibility() {
143+
syslog "Verifying backward compatibility..."
144+
# Ensure the dataset created earlier is still bound
145+
wait_dataset_bound "zookeeper"
146+
147+
# create job to access data over the runtime
148+
kubectl apply -f test/gha-e2e/alluxio/job.yaml
149+
wait_job_completed "fluid-test"
150+
151+
# Clean up
152+
kubectl delete -f test/gha-e2e/alluxio/
153+
}
154+
155+
main() {
156+
syslog "[BACKWARD COMPATIBILITY TEST STARTS AT $(date)]"
157+
158+
setup_old_fluid
159+
create_dataset
160+
upgrade_fluid
161+
verify_backward_compatibility
162+
163+
syslog "[BACKWARD COMPATIBILITY TEST SUCCEEDED AT $(date)]"
164+
}
165+
166+
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

.github/workflows/pr-quota-limit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
issues: write
1717
steps:
1818
- name: Check PR quota
19-
// Use action version v7.0.1
19+
# Use action version v7.0.1
2020
uses: actions/github-script@60a0d8304218317a38b4124020f343a0d555a1eb
2121
with:
2222
script: |

.github/workflows/project-check.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@ jobs:
1717
staticcheck:
1818
runs-on: ubuntu-latest
1919
steps:
20+
- name: Set up Go
21+
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
22+
with:
23+
go-version: ${{ env.GO_VERSION }}
2024
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2125
- uses: dominikh/staticcheck-action@024238d2898c874f26d723e7d0ff4308c35589a2 # v1
26+
with:
27+
install-go: false
28+
version: "2025.1.1"
2229

2330
lint:
2431
runs-on: ubuntu-latest

pkg/ddc/alluxio/ufs_internal.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ import (
3737
"k8s.io/client-go/util/retry"
3838
)
3939

40+
// usedStorageBytesInternal returns the number of bytes currently used by Alluxio storage.
41+
// This method is intended for internal use by the AlluxioEngine.
42+
// It currently returns (0, nil) as a placeholder; the actual implementation should query
43+
// the Alluxio cluster to compute the used storage capacity.
4044
func (e *AlluxioEngine) usedStorageBytesInternal() (value int64, err error) {
4145
return
4246
}

0 commit comments

Comments
 (0)