Skip to content

Commit 26bd48c

Browse files
author
suhan.zcy
committed
e2e: add the e2e tests for rate limit of download, upload and prefetch
Signed-off-by: suhan.zcy <suhan.zcy@antgroup.com>
1 parent 547ebe2 commit 26bd48c

File tree

3 files changed

+395
-0
lines changed

3 files changed

+395
-0
lines changed
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: E2E Test With Rate Limit(API v2 - Rust Client)
2+
3+
on:
4+
push:
5+
branches: [main, release-*]
6+
paths-ignore: ["**.md", "**.png", "**.jpg", "**.svg", "**/docs/**"]
7+
pull_request:
8+
branches: [main, release-*]
9+
paths-ignore: ["**.md", "**.png", "**.jpg", "**.svg", "**/docs/**"]
10+
schedule:
11+
- cron: '0 4 * * *'
12+
13+
permissions:
14+
contents: read
15+
16+
env:
17+
KIND_VERSION: v0.12.0
18+
CONTAINERD_VERSION: v1.5.2
19+
KIND_CONFIG_PATH: test/testdata/kind/config-v2.yaml
20+
DRAGONFLY_CHARTS_PATH: deploy/helm-charts/charts/dragonfly
21+
DRAGONFLY_FILE_SERVER_PATH: test/testdata/k8s/file-server.yaml
22+
23+
jobs:
24+
e2e_tests:
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 60
27+
strategy:
28+
matrix:
29+
module:
30+
- "normal"
31+
include:
32+
- module: normal
33+
charts-config: test/testdata/charts/config-v2-rate-limit.yaml
34+
skip: ""
35+
focus: "Download With RateLimit"
36+
37+
steps:
38+
- name: Free Disk Space (Ubuntu)
39+
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be
40+
with:
41+
tool-cache: false
42+
android: true
43+
dotnet: true
44+
haskell: true
45+
large-packages: true
46+
docker-images: true
47+
swap-storage: true
48+
49+
- name: Checkout code
50+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
51+
with:
52+
submodules: recursive
53+
fetch-depth: 0
54+
55+
- name: Install Go
56+
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a
57+
with:
58+
go-version-file: go.mod
59+
60+
- name: Get dependencies
61+
run: |
62+
go install github.com/onsi/ginkgo/v2/ginkgo@v2.12.0
63+
mkdir -p /tmp/artifact
64+
65+
- name: Setup buildx
66+
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db
67+
id: buildx
68+
with:
69+
install: true
70+
71+
- name: Cache Docker layers
72+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
73+
with:
74+
path: /tmp/.buildx-cache
75+
key: ${{ runner.os }}-buildx-${{ github.sha }}
76+
restore-keys: |
77+
${{ runner.os }}-buildx-
78+
79+
- name: Pull Rust Client Image
80+
run: |
81+
cd client-rs
82+
CLIENT_TAG=$(git describe --tags $(git rev-parse HEAD))
83+
docker pull dragonflyoss/client:$CLIENT_TAG
84+
docker tag dragonflyoss/client:$CLIENT_TAG dragonflyoss/client:latest
85+
docker pull dragonflyoss/dfinit:$CLIENT_TAG
86+
docker tag dragonflyoss/dfinit:$CLIENT_TAG dragonflyoss/dfinit:latest
87+
88+
- name: Build Scheduler Image
89+
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355
90+
with:
91+
context: .
92+
file: build/images/scheduler/Dockerfile
93+
push: false
94+
load: true
95+
tags: dragonflyoss/scheduler:latest
96+
cache-from: type=local,src=/tmp/.buildx-cache
97+
cache-to: type=local,dest=/tmp/.buildx-cache-new
98+
99+
- name: Build Manager Image
100+
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355
101+
with:
102+
context: .
103+
file: build/images/manager/Dockerfile
104+
push: false
105+
load: true
106+
tags: dragonflyoss/manager:latest
107+
cache-from: type=local,src=/tmp/.buildx-cache
108+
cache-to: type=local,dest=/tmp/.buildx-cache-new
109+
110+
- name: Setup Kind
111+
uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3
112+
with:
113+
version: ${{ env.KIND_VERSION }}
114+
config: ${{ env.KIND_CONFIG_PATH }}
115+
cluster_name: kind
116+
117+
- name: Kind load images
118+
run: |
119+
kind load docker-image dragonflyoss/manager:latest
120+
kind load docker-image dragonflyoss/scheduler:latest
121+
kind load docker-image dragonflyoss/client:latest
122+
kind load docker-image dragonflyoss/dfinit:latest
123+
124+
- name: Setup dragonfly
125+
run: |
126+
helm install --wait --timeout 15m --dependency-update --create-namespace --namespace dragonfly-system -f ${{ matrix.charts-config }} dragonfly ${{ env.DRAGONFLY_CHARTS_PATH }}
127+
kubectl apply -f ${{ env.DRAGONFLY_FILE_SERVER_PATH }}
128+
kubectl wait po file-server-0 --namespace dragonfly-e2e --for=condition=ready --timeout=10m
129+
130+
- name: Run E2E test
131+
run: |
132+
ginkgo -v -r --race --fail-fast --cover --trace --show-node-events --skip=${{ matrix.skip }} --focus=${{ matrix.focus }} test/e2e/v2
133+
cat coverprofile.out >> coverage.txt
134+
135+
- name: Move cache
136+
run: |
137+
rm -rf /tmp/.buildx-cache
138+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
139+
140+
- name: Upload coverage to Codecov
141+
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303
142+
with:
143+
token: ${{ secrets.CODECOV_TOKEN }}
144+
files: ./coverage.txt
145+
flags: e2etests
146+
147+
- name: Upload Logs
148+
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b
149+
if: always()
150+
with:
151+
name: ${{ matrix.module }}-e2e-tests-logs
152+
path: |
153+
/tmp/artifact/**

test/e2e/v2/rate_limit_test.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2024 The Dragonfly Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package e2e
18+
19+
import (
20+
"fmt"
21+
"time"
22+
23+
. "github.com/onsi/ginkgo/v2" //nolint
24+
. "github.com/onsi/gomega" //nolint
25+
26+
"d7y.io/dragonfly/v2/test/e2e/v2/util"
27+
)
28+
29+
var _ = Describe("Download With RateLimit", func() {
30+
Context("/bin/kubectl file", func() {
31+
It("should be ok", Label("download", "rateLimit"), func() {
32+
clientPod, err := util.ClientExec()
33+
fmt.Println(err)
34+
Expect(err).NotTo(HaveOccurred())
35+
36+
start := time.Now()
37+
out, err := clientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -H 'X-Dragonfly-Tag: download-rate-limit' %s --output %s", util.GetFileURL("/bin/kubectl"), util.GetOutputPath("kubectl-proxy"))).CombinedOutput()
38+
elapsed := time.Since(start)
39+
fmt.Println(err)
40+
Expect(err).NotTo(HaveOccurred())
41+
// The download rate limit is 1MiB/s, and the file size is about 44MiB, so the download time should be greater than 44s.
42+
Expect(elapsed).Should(BeNumerically(">", 44*time.Second))
43+
fmt.Println(string(out))
44+
45+
fileMetadata := util.FileMetadata{
46+
ID: "6b94aa169d11ba67c1852f14c4df39e5ebf84d1c0d7a6f6ad0ba2f3547883f4f",
47+
Sha256: "327b4022d0bfd1d5e9c0701d4a3f989a536f7e6e865e102dcd77c7e7adb31f9a",
48+
}
49+
50+
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, fileMetadata.ID)
51+
Expect(err).NotTo(HaveOccurred())
52+
Expect(fileMetadata.Sha256).To(Equal(sha256sum))
53+
54+
sha256sum, err = util.CalculateSha256ByOutput([]*util.PodExec{clientPod}, util.GetOutputPath("kubectl-proxy"))
55+
Expect(err).NotTo(HaveOccurred())
56+
Expect(fileMetadata.Sha256).To(Equal(sha256sum))
57+
})
58+
})
59+
})
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
manager:
2+
image:
3+
repository: dragonflyoss/manager
4+
tag: latest
5+
replicas: 1
6+
resources:
7+
requests:
8+
cpu: "0"
9+
memory: "0"
10+
limits:
11+
cpu: "1"
12+
memory: "2Gi"
13+
extraVolumeMounts:
14+
- name: logs
15+
mountPath: "/var/log/"
16+
- name: artifact
17+
mountPath: /tmp/artifact
18+
extraVolumes:
19+
- name: logs
20+
emptyDir: { }
21+
- name: artifact
22+
hostPath:
23+
path: /tmp/artifact
24+
metrics:
25+
enable: true
26+
config:
27+
console: false
28+
verbose: true
29+
job:
30+
rateLimit:
31+
fillInterval: 1m
32+
capacity: 100
33+
quantum: 100
34+
35+
scheduler:
36+
image:
37+
repository: dragonflyoss/scheduler
38+
tag: latest
39+
replicas: 3
40+
resources:
41+
requests:
42+
cpu: "0"
43+
memory: "0"
44+
limits:
45+
cpu: "2"
46+
memory: "4Gi"
47+
service:
48+
type: NodePort
49+
nodePort: 30802
50+
extraVolumeMounts:
51+
- name: logs
52+
mountPath: "/var/log/"
53+
- name: artifact
54+
mountPath: /tmp/artifact
55+
extraVolumes:
56+
- name: logs
57+
emptyDir: { }
58+
- name: artifact
59+
hostPath:
60+
path: /tmp/artifact
61+
metrics:
62+
enable: true
63+
enableHost: true
64+
config:
65+
console: false
66+
verbose: true
67+
scheduler:
68+
gc:
69+
hostGCInterval: 2m
70+
71+
seedClient:
72+
enable: true
73+
replicas: 3
74+
image:
75+
repository: dragonflyoss/client
76+
tag: latest
77+
resources:
78+
requests:
79+
cpu: "0"
80+
memory: "0"
81+
limits:
82+
cpu: "2"
83+
memory: "4Gi"
84+
extraVolumeMounts:
85+
- name: logs
86+
mountPath: "/var/log/"
87+
- name: artifact
88+
mountPath: /tmp/artifact
89+
extraVolumes:
90+
- name: logs
91+
emptyDir: { }
92+
- name: artifact
93+
hostPath:
94+
path: /tmp/artifact
95+
config:
96+
download:
97+
rateLimit: 1MiB
98+
upload:
99+
rateLimit: 1MiB
100+
dynconfig:
101+
refreshInterval: 1s
102+
scheduler:
103+
announceInterval: 1s
104+
log:
105+
level: info
106+
proxy:
107+
prefetch: true
108+
prefetchRateLimit: 1MiB
109+
registryMirror:
110+
addr: https://index.docker.io
111+
rules:
112+
- regex: blobs/sha256.*
113+
- regxe: file-server.*
114+
115+
client:
116+
enable: true
117+
image:
118+
repository: dragonflyoss/client
119+
tag: latest
120+
resources:
121+
requests:
122+
cpu: "0"
123+
memory: "0"
124+
limits:
125+
cpu: "2"
126+
memory: "4Gi"
127+
# Allow client daemonSet to create a pod on master node for testing when the daemon goes offline.
128+
tolerations:
129+
- key: "node-role.kubernetes.io/master"
130+
operator: "Exists"
131+
effect: "NoSchedule"
132+
extraVolumeMounts:
133+
- name: logs
134+
mountPath: "/var/log/"
135+
- name: artifact
136+
mountPath: /tmp/artifact
137+
extraVolumes:
138+
- name: logs
139+
emptyDir: { }
140+
- name: artifact
141+
hostPath:
142+
path: /tmp/artifact
143+
dfinit:
144+
enable: true
145+
image:
146+
repository: dragonflyoss/dfinit
147+
tag: latest
148+
config:
149+
containerRuntime:
150+
containerd:
151+
configPath: /etc/containerd/config.toml
152+
registries:
153+
- hostNamespace: docker.io
154+
serverAddr: https://index.docker.io
155+
capabilities: ["pull", "resolve"]
156+
- hostNamespace: ghcr.io
157+
serverAddr: https://ghcr.io
158+
capabilities: ["pull", "resolve"]
159+
config:
160+
download:
161+
rateLimit: 1MiB
162+
upload:
163+
rateLimit: 1MiB
164+
dynconfig:
165+
refreshInterval: 1s
166+
scheduler:
167+
announceInterval: 1s
168+
log:
169+
level: info
170+
proxy:
171+
prefetch: false
172+
prefetchRateLimit: 1MiB
173+
registryMirror:
174+
addr: https://index.docker.io
175+
rules:
176+
- regex: blobs/sha256.*
177+
- regxe: file-server.*
178+
179+
dfdaemon:
180+
enable: false
181+
182+
seedPeer:
183+
enable: false

0 commit comments

Comments
 (0)