Skip to content

Commit

Permalink
test: add concurrent download e2e testings (#3212)
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <gaius.qi@gmail.com>
  • Loading branch information
gaius-qi authored Apr 22, 2024
1 parent 2901df0 commit 4e89071
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client-rs
150 changes: 150 additions & 0 deletions test/e2e/v2/concurrency_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/*
* Copyright 2024 The Dragonfly Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package e2e

import (
"fmt"

. "github.com/onsi/ginkgo/v2" //nolint
. "github.com/onsi/gomega" //nolint

"d7y.io/dragonfly/v2/test/e2e/v2/util"
)

var _ = Describe("Download Concurrency", func() {
Context("ab", func() {
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()
fmt.Println(string(out))
Expect(err).NotTo(HaveOccurred())

fileMetadata := util.FileMetadata{
ID: "423990483b62613df9671fb8f3cf48f4c46b9486debf65e62a765719547a00d2",
Sha256: "fc44bbbba20490450c73530db3d1b935f893f38d7d8084ca132952a765ff5ff6",
}

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

seedClientPods := make([]*util.PodExec, 3)
for i := 0; i < 3; i++ {
seedClientPods[i], err = util.SeedClientExec(i)
fmt.Println(err)
Expect(err).NotTo(HaveOccurred())
}

sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, fileMetadata.ID)
Expect(err).NotTo(HaveOccurred())
Expect(fileMetadata.Sha256).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()
fmt.Println(string(out))
Expect(err).NotTo(HaveOccurred())

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

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

seedClientPods := make([]*util.PodExec, 3)
for i := 0; i < 3; i++ {
seedClientPods[i], err = util.SeedClientExec(i)
fmt.Println(err)
Expect(err).NotTo(HaveOccurred())
}

sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, fileMetadata.ID)
Expect(err).NotTo(HaveOccurred())
Expect(fileMetadata.Sha256).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()
fmt.Println(string(out))
Expect(err).NotTo(HaveOccurred())

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

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

seedClientPods := make([]*util.PodExec, 3)
for i := 0; i < 3; i++ {
seedClientPods[i], err = util.SeedClientExec(i)
fmt.Println(err)
Expect(err).NotTo(HaveOccurred())
}

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

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

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

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

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

seedClientPods := make([]*util.PodExec, 3)
for i := 0; i < 3; i++ {
seedClientPods[i], err = util.SeedClientExec(i)
fmt.Println(err)
Expect(err).NotTo(HaveOccurred())
}

sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, fileMetadata.ID)
Expect(err).NotTo(HaveOccurred())
Expect(fileMetadata.Sha256).To(Equal(sha256sum))
})
})
})
4 changes: 0 additions & 4 deletions test/e2e/v2/util/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ func KubeCtlCommand(arg ...string) *exec.Cmd {
return exec.Command("kubectl", arg...)
}

func ABCommand(arg ...string) *exec.Cmd {
return exec.Command("ab", arg...)
}

func GitCommand(arg ...string) *exec.Cmd {
return exec.Command("git", arg...)
}
Expand Down

0 comments on commit 4e89071

Please sign in to comment.