Skip to content

Commit

Permalink
refactor: refactor the e2e file server
Browse files Browse the repository at this point in the history
Signed-off-by: suhan.zcy <[email protected]>
  • Loading branch information
suhan.zcy committed Jan 6, 2025
1 parent 14cf937 commit cf94832
Show file tree
Hide file tree
Showing 12 changed files with 1,332 additions and 492 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/compatibility-e2e-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ env:
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_V2_PATH: test/testdata/k8s/file-server-v2.yaml

jobs:
compatibility_e2e_tests:
Expand Down Expand Up @@ -137,6 +138,7 @@ jobs:
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 }}
kubectl apply -f ${{ env.DRAGONFLY_FILE_SERVER_PATH }}
kubectl apply -f ${{ env.DRAGONFLY_FILE_SERVER_V2_PATH }}
kubectl wait po file-server-0 --namespace dragonfly-e2e --for=condition=ready --timeout=10m
- name: Run E2E test
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/e2e-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
schedule:
- cron: '0 4 * * *'

permissions:
permissions:
contents: read

env:
Expand All @@ -19,6 +19,7 @@ env:
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_V2_PATH: test/testdata/k8s/file-server-v2.yaml

jobs:
e2e_tests:
Expand Down Expand Up @@ -124,10 +125,12 @@ jobs:
run: |
helm install --wait --timeout 15m --dependency-update --create-namespace --namespace dragonfly-system -f ${{ matrix.charts-config }} dragonfly ${{ env.DRAGONFLY_CHARTS_PATH }}
kubectl apply -f ${{ env.DRAGONFLY_FILE_SERVER_PATH }}
kubectl apply -f ${{ env.DRAGONFLY_FILE_SERVER_V2_PATH }}
kubectl wait po file-server-0 --namespace dragonfly-e2e --for=condition=ready --timeout=10m
- name: Run E2E test
run: |
ls -lah /tmp/artifact/
ginkgo -v -r --race --fail-fast --cover --trace --show-node-events --skip=${{ matrix.skip }} test/e2e/v2
cat coverprofile.out >> coverage.txt
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 = fs.PrepareFile(util.FileSize1MiB)
Expect(err).NotTo(HaveOccurred())
Expect(testFile).NotTo(BeNil())
})

AfterEach(func() {
err = fs.CleanFile(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

0 comments on commit cf94832

Please sign in to comment.