Skip to content
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

refactor: refactor the e2e file server #3741

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/compatibility-e2e-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
KIND_CONFIG_PATH: test/testdata/kind/config-v2.yaml
DRAGONFLY_CHARTS_CONFIG_PATH: test/testdata/charts/config-v2.yaml
DRAGONFLY_CHARTS_PATH: deploy/helm-charts/charts/dragonfly
DRAGONFLY_FILE_SERVER_PATH: test/testdata/k8s/file-server.yaml
DRAGONFLY_FILE_SERVER_PATH: test/testdata/k8s/dufs.yaml

jobs:
compatibility_e2e_tests:
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:

- name: Get dependencies
run: |
go install github.com/onsi/ginkgo/v2/ginkgo@v2.12.0
go install github.com/onsi/ginkgo/v2/ginkgo@v2.22.1
mkdir -p /tmp/artifact

- name: Setup buildx
Expand Down Expand Up @@ -136,8 +136,9 @@ jobs:
- name: Setup dragonfly
run: |
helm install --wait --timeout 15m --dependency-update --create-namespace --namespace dragonfly-system --set ${{ matrix.chart-name }}.image.tag=${{ matrix.image-tag }} --set ${{ matrix.chart-name }}.image.repository=dragonflyoss/${{ matrix.image }} -f ${{ env.DRAGONFLY_CHARTS_CONFIG_PATH }} dragonfly ${{ env.DRAGONFLY_CHARTS_PATH }}
mkdir -p /tmp/artifact/dufs && chmod 777 /tmp/artifact/dufs
kubectl apply -f ${{ env.DRAGONFLY_FILE_SERVER_PATH }}
kubectl wait po file-server-0 --namespace dragonfly-e2e --for=condition=ready --timeout=10m
kubectl wait po dufs-0 --namespace dragonfly-e2e --for=condition=ready --timeout=10m

- name: Run E2E test
run: |
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/e2e-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ on:
schedule:
- cron: '0 4 * * *'

permissions:
permissions:
contents: read

env:
KIND_VERSION: v0.12.0
CONTAINERD_VERSION: v1.5.2
KIND_CONFIG_PATH: test/testdata/kind/config-v2.yaml
DRAGONFLY_CHARTS_PATH: deploy/helm-charts/charts/dragonfly
DRAGONFLY_FILE_SERVER_PATH: test/testdata/k8s/file-server.yaml
DRAGONFLY_FILE_SERVER_PATH: test/testdata/k8s/dufs.yaml

jobs:
e2e_tests:
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:

- name: Get dependencies
run: |
go install github.com/onsi/ginkgo/v2/ginkgo@v2.12.0
go install github.com/onsi/ginkgo/v2/ginkgo@v2.22.1
mkdir -p /tmp/artifact

- name: Setup buildx
Expand Down Expand Up @@ -123,8 +123,9 @@ jobs:
- name: Setup dragonfly
run: |
helm install --wait --timeout 15m --dependency-update --create-namespace --namespace dragonfly-system -f ${{ matrix.charts-config }} dragonfly ${{ env.DRAGONFLY_CHARTS_PATH }}
mkdir -p /tmp/artifact/dufs && chmod 777 /tmp/artifact/dufs
kubectl apply -f ${{ env.DRAGONFLY_FILE_SERVER_PATH }}
kubectl wait po file-server-0 --namespace dragonfly-e2e --for=condition=ready --timeout=10m
kubectl wait po dufs-0 --namespace dragonfly-e2e --for=condition=ready --timeout=10m

- name: Run E2E test
run: |
Expand Down
76 changes: 36 additions & 40 deletions test/e2e/v2/concurrency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,34 @@ import (

var _ = Describe("Download Concurrency", func() {
Context("ab", func() {
var (
testFile *util.File
err error
)

BeforeEach(func() {
testFile, err = util.GetFileServer().GenerateFile(util.FileSize1MiB)
Expect(err).NotTo(HaveOccurred())
Expect(testFile).NotTo(BeNil())
})

AfterEach(func() {
err = util.GetFileServer().DeleteFile(testFile.GetInfo())
Expect(err).NotTo(HaveOccurred())
})

It("concurrent 100 should be ok", Label("concurrent", "100"), func() {
clientPod, err := util.ClientExec()
fmt.Println(err)
Expect(err).NotTo(HaveOccurred())

out, err := clientPod.Command("sh", "-c", fmt.Sprintf("ab -c 100 -n 200 -X 127.0.0.1:4001 %s", util.GetFileURL("/bin/unshare"))).CombinedOutput()
out, err := clientPod.Command("sh", "-c", fmt.Sprintf("ab -c 100 -n 200 -X 127.0.0.1:4001 %s", testFile.GetDownloadURL())).CombinedOutput()
fmt.Println(string(out))
Expect(err).NotTo(HaveOccurred())

fileMetadata := util.FileMetadata{
ID: "14b31801ea6990788057b965fbc51e44bf73800462915fdfa0fda8182acca4d6",
Sha256: "fc44bbbba20490450c73530db3d1b935f893f38d7d8084ca132952a765ff5ff6",
}

sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, fileMetadata.ID)
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, testFile.GetTaskID())
Expect(err).NotTo(HaveOccurred())
Expect(fileMetadata.Sha256).To(Equal(sha256sum))
Expect(testFile.GetSha256()).To(Equal(sha256sum))

seedClientPods := make([]*util.PodExec, 3)
for i := 0; i < 3; i++ {
Expand All @@ -52,28 +63,23 @@ var _ = Describe("Download Concurrency", func() {
Expect(err).NotTo(HaveOccurred())
}

sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, fileMetadata.ID)
sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, testFile.GetTaskID())
Expect(err).NotTo(HaveOccurred())
Expect(fileMetadata.Sha256).To(Equal(sha256sum))
Expect(testFile.GetSha256()).To(Equal(sha256sum))
})

It("concurrent 200 should be ok", Label("concurrent", "200"), func() {
clientPod, err := util.ClientExec()
fmt.Println(err)
Expect(err).NotTo(HaveOccurred())

out, err := clientPod.Command("sh", "-c", fmt.Sprintf("ab -c 200 -n 400 -X 127.0.0.1:4001 %s", util.GetFileURL("/bin/loginctl"))).CombinedOutput()
out, err := clientPod.Command("sh", "-c", fmt.Sprintf("ab -c 200 -n 400 -X 127.0.0.1:4001 %s", testFile.GetDownloadURL())).CombinedOutput()
fmt.Println(string(out))
Expect(err).NotTo(HaveOccurred())

fileMetadata := util.FileMetadata{
ID: "958e177b56be708c9d7ec193ae8cef399b39faff8234af33efa4cbe097d1fc5f",
Sha256: "dc102987a36be20846821ac74648534863ff0fe8897d4250273a6ffc80481d91",
}

sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, fileMetadata.ID)
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, testFile.GetTaskID())
Expect(err).NotTo(HaveOccurred())
Expect(fileMetadata.Sha256).To(Equal(sha256sum))
Expect(testFile.GetSha256()).To(Equal(sha256sum))

seedClientPods := make([]*util.PodExec, 3)
for i := 0; i < 3; i++ {
Expand All @@ -82,28 +88,23 @@ var _ = Describe("Download Concurrency", func() {
Expect(err).NotTo(HaveOccurred())
}

sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, fileMetadata.ID)
sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, testFile.GetTaskID())
Expect(err).NotTo(HaveOccurred())
Expect(fileMetadata.Sha256).To(Equal(sha256sum))
Expect(testFile.GetSha256()).To(Equal(sha256sum))
})

It("concurrent 500 should be ok", Label("concurrent", "500"), func() {
clientPod, err := util.ClientExec()
fmt.Println(err)
Expect(err).NotTo(HaveOccurred())

out, err := clientPod.Command("sh", "-c", fmt.Sprintf("ab -c 500 -n 1000 -X 127.0.0.1:4001 %s", util.GetFileURL("/bin/realpath"))).CombinedOutput()
out, err := clientPod.Command("sh", "-c", fmt.Sprintf("ab -c 500 -n 1000 -X 127.0.0.1:4001 %s", testFile.GetDownloadURL())).CombinedOutput()
fmt.Println(string(out))
Expect(err).NotTo(HaveOccurred())

fileMetadata := util.FileMetadata{
ID: "dd573cf9c3e1a79402b8423abcd1ba987c1b1ee9c49069d139d71106a260b055",
Sha256: "54e54b7ff54ef70d4db2adcd24a27e3b9af3cd99fc0213983bac1e8035429be6",
}

sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, fileMetadata.ID)
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, testFile.GetTaskID())
Expect(err).NotTo(HaveOccurred())
Expect(fileMetadata.Sha256).To(Equal(sha256sum))
Expect(testFile.GetSha256()).To(Equal(sha256sum))

seedClientPods := make([]*util.PodExec, 3)
for i := 0; i < 3; i++ {
Expand All @@ -112,28 +113,23 @@ var _ = Describe("Download Concurrency", func() {
Expect(err).NotTo(HaveOccurred())
}

sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, fileMetadata.ID)
sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, testFile.GetTaskID())
Expect(err).NotTo(HaveOccurred())
Expect(fileMetadata.Sha256).To(Equal(sha256sum))
Expect(testFile.GetSha256()).To(Equal(sha256sum))
})

It("concurrent 1000 should be ok", Label("concurrent", "1000"), func() {
clientPod, err := util.ClientExec()
fmt.Println(err)
Expect(err).NotTo(HaveOccurred())

out, err := clientPod.Command("sh", "-c", fmt.Sprintf("ab -c 1000 -n 2000 -X 127.0.0.1:4001 %s", util.GetFileURL("/bin/lnstat"))).CombinedOutput()
out, err := clientPod.Command("sh", "-c", fmt.Sprintf("ab -c 1000 -n 2000 -X 127.0.0.1:4001 %s", testFile.GetDownloadURL())).CombinedOutput()
fmt.Println(string(out))
Expect(err).NotTo(HaveOccurred())

fileMetadata := util.FileMetadata{
ID: "f1957adc26ec326800ced850d72e583a03be0999ba80d9aa2e3ba57ef4ddaf17",
Sha256: "87c09b7c338f258809ca2d436bbe06ac94a3166b3f3e1125a86f35d9a9aa1d2f",
}

sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, fileMetadata.ID)
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, testFile.GetTaskID())
Expect(err).NotTo(HaveOccurred())
Expect(fileMetadata.Sha256).To(Equal(sha256sum))
Expect(testFile.GetSha256()).To(Equal(sha256sum))

seedClientPods := make([]*util.PodExec, 3)
for i := 0; i < 3; i++ {
Expand All @@ -142,9 +138,9 @@ var _ = Describe("Download Concurrency", func() {
Expect(err).NotTo(HaveOccurred())
}

sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, fileMetadata.ID)
sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, testFile.GetTaskID())
Expect(err).NotTo(HaveOccurred())
Expect(fileMetadata.Sha256).To(Equal(sha256sum))
Expect(testFile.GetSha256()).To(Equal(sha256sum))
})
})
})
Loading
Loading