Skip to content

Commit d2e70b2

Browse files
authored
chore: add compatibility test workflow (#594)
* chore: add compatibility test workflow Signed-off-by: Gaius <[email protected]>
1 parent ac65c1b commit d2e70b2

File tree

6 files changed

+179
-64
lines changed

6 files changed

+179
-64
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Compatibility E2E Test
2+
3+
on:
4+
push:
5+
branches: [main, release-*]
6+
pull_request:
7+
branches: [main, release-*]
8+
9+
env:
10+
GO_VERSION: 1.15
11+
KIND_VERSION: v0.11.1
12+
CONTAINERD_VERSION: v1.5.2
13+
GOPROXY: https://goproxy.io,direct
14+
KIND_CONFIG_PATH: test/testdata/kind/config.yaml
15+
DRAGONFLY_E2E_TEST_MODE: compatibility
16+
DRAGONFLY_DFDAEMON_IMAGE: dragonflyoss/dfdaemon:v0.4.0
17+
DRAGONFLY_CHARTS_PATH: deploy/helm-charts/charts/dragonfly
18+
DRAGONFLY_CHARTS_CONFIG_PATH: test/testdata/charts/compatibility-config.yaml
19+
DRAGONFLY_FILE_SERVER_PATH: test/testdata/k8s/file-server.yaml
20+
21+
jobs:
22+
skip_check:
23+
runs-on: ubuntu-latest
24+
outputs:
25+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
26+
steps:
27+
- name: Skip Check
28+
id: skip_check
29+
uses: fkirc/skip-duplicate-actions@master
30+
with:
31+
github_token: ${{ secrets.GITHUB_TOKEN }}
32+
paths_ignore: '["**.md", "**.png", "**.jpg", "**.svg"]'
33+
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]'
34+
35+
e2e_tests:
36+
runs-on: ubuntu-latest
37+
needs: skip_check
38+
if: needs.skip_check.outputs.noop != 'true'
39+
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v2
43+
with:
44+
submodules: recursive
45+
46+
- name: Install Go
47+
uses: actions/setup-go@v2
48+
with:
49+
go-version: ${{ env.GO_VERSION }}
50+
51+
- name: Get dependencies
52+
run: |
53+
go mod vendor
54+
go get github.com/onsi/ginkgo/ginkgo
55+
mkdir -p /tmp/artifact
56+
57+
- name: Setup Kind
58+
uses: engineerd/[email protected]
59+
with:
60+
version: ${{ env.KIND_VERSION }}
61+
config: ${{ env.KIND_CONFIG_PATH }}
62+
63+
- name: Build images
64+
run: |
65+
make docker-build-manager
66+
make docker-build-cdn
67+
make docker-build-scheduler
68+
docker pull ${{ env.DRAGONFLY_DFDAEMON_IMAGE }}
69+
70+
- name: Prepare kind environment
71+
run: |
72+
make kind-load-manager
73+
make kind-load-cdn
74+
make kind-load-scheduler
75+
kind load docker-image ${{ env.DRAGONFLY_DFDAEMON_IMAGE }}
76+
77+
- name: Setup dragonfly
78+
run: |
79+
helm install --wait --timeout 10m --dependency-update --create-namespace --namespace dragonfly-system -f ${{ env.DRAGONFLY_CHARTS_CONFIG_PATH }} dragonfly ${{ env.DRAGONFLY_CHARTS_PATH }}
80+
kubectl apply -f ${{ env.DRAGONFLY_FILE_SERVER_PATH }}
81+
kubectl wait po file-server-0 --namespace dragonfly-e2e --for=condition=ready --timeout=10m
82+
83+
- name: Run compatibility E2E test
84+
run: make actions-e2e-test-coverage
85+
86+
- name: Upload coverage to Codecov
87+
uses: codecov/codecov-action@v1
88+
with:
89+
token: ${{ secrets.CODECOV_TOKEN }}
90+
files: ./coverage.txt
91+
flags: compatibility-e2etests
92+
93+
- name: Upload Logs
94+
uses: actions/upload-artifact@v2
95+
if: failure()
96+
with:
97+
name: dragonfly-logs
98+
path: /tmp/artifact/

.github/workflows/e2e.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ env:
1111
KIND_VERSION: v0.11.1
1212
CONTAINERD_VERSION: v1.5.2
1313
GOPROXY: https://goproxy.io,direct
14+
KIND_CONFIG_PATH: test/testdata/kind/config.yaml
15+
DRAGONFLY_CHARTS_PATH: deploy/helm-charts/charts/dragonfly
16+
DRAGONFLY_CHARTS_CONFIG_PATH: test/testdata/charts/config.yaml
17+
DRAGONFLY_FILE_SERVER_PATH: test/testdata/k8s/file-server.yaml
1418

1519
jobs:
1620
skip_check:
@@ -45,15 +49,28 @@ jobs:
4549
- name: Get dependencies
4650
run: |
4751
go mod vendor
52+
go get github.com/onsi/ginkgo/ginkgo
4853
mkdir -p /tmp/artifact
4954
5055
- name: Setup Kind
5156
uses: engineerd/[email protected]
5257
with:
5358
version: ${{ env.KIND_VERSION }}
54-
config: ./test/testdata/kind/config.yaml
59+
config: ${{ env.KIND_CONFIG_PATH }}
5560

56-
- name: Run E2E tests
61+
- name: Build images
62+
run: make docker-build
63+
64+
- name: Prepare kind environment
65+
run: make kind-load
66+
67+
- name: Setup dragonfly
68+
run: |
69+
helm install --wait --timeout 10m --dependency-update --create-namespace --namespace dragonfly-system -f ${{ env.DRAGONFLY_CHARTS_CONFIG_PATH }} dragonfly ${{ env.DRAGONFLY_CHARTS_PATH }}
70+
kubectl apply -f ${{ env.DRAGONFLY_FILE_SERVER_PATH }}
71+
kubectl wait po file-server-0 --namespace dragonfly-e2e --for=condition=ready --timeout=10m
72+
73+
- name: Run E2E test
5774
run: make actions-e2e-test-coverage
5875

5976
- name: Upload coverage to Codecov

Makefile

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -190,35 +190,25 @@ test-coverage:
190190
@cat cover.out >> coverage.txt
191191
.PHONY: test-coverage
192192

193-
# Install github actions E2E tests environment
194-
install-actions-e2e-test:
195-
@./hack/install-e2e-test.sh actions
196-
.PHONY: install-actions-e2e-test
197-
198-
# Run github actions E2E tests
199-
actions-e2e-test: install-actions-e2e-test
200-
@ginkgo -v -r --failFast test/e2e --trace --progress
201-
.PHONY: actions-e2e-test
202-
203193
# Run github actions E2E tests with coverage
204-
actions-e2e-test-coverage: install-actions-e2e-test
205-
@ginkgo -v -r --failFast -cover test/e2e --trace --progress
194+
actions-e2e-test-coverage:
195+
@ginkgo -v -r --race --failFast -cover test/e2e --trace --progress
206196
@cat test/e2e/*.coverprofile >> coverage.txt
207197
.PHONY: actions-e2e-test-coverage
208198

209199
# Install E2E tests environment
210200
install-e2e-test:
211-
@./hack/install-e2e-test.sh local
201+
@./hack/install-e2e-test.sh
212202
.PHONY: install-e2e-test
213203

214204
# Run E2E tests
215205
e2e-test: install-e2e-test
216-
@ginkgo -v -r --failFast test/e2e --trace --progress
206+
@ginkgo -v -r --race --failFast test/e2e --trace --progress
217207
.PHONY: e2e-test
218208

219209
# Run E2E tests with coverage
220210
e2e-test-coverage: install-e2e-test
221-
@ginkgo -v -r --failFast -cover test/e2e --trace --progress
211+
@ginkgo -v -r --race --failFast -cover test/e2e --trace --progress
222212
@cat test/e2e/*.coverprofile >> coverage.txt
223213
.PHONY: e2e-test-coverage
224214

@@ -295,8 +285,6 @@ help:
295285
@echo "make build-dfget-man-page generate dfget man page"
296286
@echo "make test run unittests"
297287
@echo "make test-coverage run tests with coverage"
298-
@echo "make install-actions-e2e-test install github actions E2E tests environment"
299-
@echo "make actions-e2e-test run github actons E2E tests"
300288
@echo "make actions-e2e-test-coverage run github actons E2E tests with coverage"
301289
@echo "make install-e2e-test install E2E tests environment"
302290
@echo "make e2e-test run e2e tests"

hack/install-e2e-test.sh

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ install-apache-bench() {
6060
fi
6161
}
6262

63-
install-local() {
63+
print_step_info() {
64+
echo "-----------------------------"
65+
echo $1
66+
echo "-----------------------------"
67+
}
68+
69+
main() {
6470
print_step_info "start kind create cluster"
6571
install-kind
6672

@@ -83,40 +89,4 @@ install-local() {
8389
install-apache-bench
8490
}
8591

86-
install-actions() {
87-
print_step_info "start building docker images"
88-
make docker-build
89-
90-
print_step_info "start loading image for kind"
91-
make kind-load
92-
93-
print_step_info "start helm install dragonfly"
94-
install-helm
95-
96-
print_step_info "start install file server"
97-
install-file-server
98-
99-
print_step_info "start install ginkgo"
100-
install-ginkgo
101-
102-
print_step_info "start install apache bench"
103-
install-apache-bench
104-
}
105-
106-
print_step_info() {
107-
echo "-----------------------------"
108-
echo $1
109-
echo "-----------------------------"
110-
}
111-
112-
main() {
113-
case "${1-}" in
114-
local)
115-
install-local
116-
;;
117-
actions)
118-
install-actions
119-
esac
120-
}
121-
12292
main "$@"

test/e2e/e2e_test.go

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package e2e
1818

1919
import (
2020
"fmt"
21+
"os"
2122
"strings"
2223
"testing"
2324

@@ -34,23 +35,33 @@ const (
3435
dragonflyNamespace = "dragonfly-system"
3536
)
3637

38+
const (
39+
compatibilityTestMode = "compatibility"
40+
)
41+
3742
var _ = BeforeSuite(func() {
38-
out, err := e2eutil.GitCommand("rev-parse", "--short", "HEAD").CombinedOutput()
43+
rawGitCommit, err := e2eutil.GitCommand("rev-parse", "--short", "HEAD").CombinedOutput()
3944
Expect(err).NotTo(HaveOccurred())
40-
gitCommit := strings.Fields(string(out))[0]
45+
gitCommit := strings.Fields(string(rawGitCommit))[0]
4146
fmt.Printf("git merge commit: %s\n", gitCommit)
4247

43-
out, err = e2eutil.KubeCtlCommand("-n", dragonflyNamespace, "get", "pod", "-l", "component=dfdaemon",
48+
rawPodName, err := e2eutil.KubeCtlCommand("-n", dragonflyNamespace, "get", "pod", "-l", "component=dfdaemon",
4449
"-o", "jsonpath='{range .items[*]}{.metadata.name}{end}'").CombinedOutput()
45-
podName := strings.Trim(string(out), "'")
50+
podName := strings.Trim(string(rawPodName), "'")
4651
Expect(err).NotTo(HaveOccurred())
47-
4852
Expect(strings.HasPrefix(podName, "dragonfly-dfdaemon-")).Should(BeTrue())
53+
4954
pod := e2eutil.NewPodExec(dragonflyNamespace, podName, "dfdaemon")
50-
out, err = pod.Command("dfget", "version").CombinedOutput()
55+
rawDfgetVersion, err := pod.Command("dfget", "version").CombinedOutput()
5156
Expect(err).NotTo(HaveOccurred())
52-
dfgetGitCommit := strings.Fields(string(out))[7]
53-
fmt.Printf("dfget merge commit: %s\n", gitCommit)
57+
dfgetGitCommit := strings.Fields(string(rawDfgetVersion))[7]
58+
fmt.Printf("dfget merge commit: %s\n", dfgetGitCommit)
59+
60+
mode := os.Getenv("DRAGONFLY_E2E_TEST_MODE")
61+
if mode == compatibilityTestMode {
62+
Expect(gitCommit).NotTo(Equal(dfgetGitCommit))
63+
return
64+
}
5465

5566
Expect(gitCommit).To(Equal(dfgetGitCommit))
5667
})
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
scheduler:
2+
image: d7yio/scheduler
3+
tag: latest
4+
5+
cdn:
6+
image: d7yio/cdn
7+
tag: latest
8+
9+
dfdaemon:
10+
image: dragonflyoss/dfdaemon
11+
tag: v0.4.0
12+
config:
13+
proxy:
14+
defaultFilter: "Expires&Signature"
15+
security:
16+
insecure: true
17+
tcpListen:
18+
namespace: /run/dragonfly/net
19+
listen: 0.0.0.0
20+
# if you want to change port, please update hostPort in $.Values.dfdaemon.hostPort
21+
# port in configmap is generated from $.Values.dfdaemon.hostPort
22+
# port: 65001
23+
registryMirror:
24+
url: https://index.docker.io
25+
proxies:
26+
- regx: blobs/sha256.*
27+
- regx: file-server
28+
29+
manager:
30+
image: d7yio/manager
31+
tag: latest

0 commit comments

Comments
 (0)