|
| 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 | + |
| 22 | + . "github.com/onsi/ginkgo/v2" //nolint |
| 23 | + . "github.com/onsi/gomega" //nolint |
| 24 | + |
| 25 | + "d7y.io/dragonfly/v2/test/e2e/v2/util" |
| 26 | +) |
| 27 | + |
| 28 | +var _ = Describe("Download Concurrency", func() { |
| 29 | + Context("ab", func() { |
| 30 | + It("concurrent 100 should be ok", Label("concurrent", "100"), func() { |
| 31 | + clientPod, err := util.ClientExec() |
| 32 | + fmt.Println(err) |
| 33 | + Expect(err).NotTo(HaveOccurred()) |
| 34 | + |
| 35 | + 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() |
| 36 | + fmt.Println(string(out)) |
| 37 | + Expect(err).NotTo(HaveOccurred()) |
| 38 | + |
| 39 | + fileMetadata := util.FileMetadata{ |
| 40 | + ID: "423990483b62613df9671fb8f3cf48f4c46b9486debf65e62a765719547a00d2", |
| 41 | + Sha256: "fc44bbbba20490450c73530db3d1b935f893f38d7d8084ca132952a765ff5ff6", |
| 42 | + } |
| 43 | + |
| 44 | + sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, fileMetadata.ID) |
| 45 | + Expect(err).NotTo(HaveOccurred()) |
| 46 | + Expect(fileMetadata.Sha256).To(Equal(sha256sum)) |
| 47 | + |
| 48 | + seedClientPods := make([]*util.PodExec, 3) |
| 49 | + for i := 0; i < 3; i++ { |
| 50 | + seedClientPods[i], err = util.SeedClientExec(i) |
| 51 | + fmt.Println(err) |
| 52 | + Expect(err).NotTo(HaveOccurred()) |
| 53 | + } |
| 54 | + |
| 55 | + sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, fileMetadata.ID) |
| 56 | + Expect(err).NotTo(HaveOccurred()) |
| 57 | + Expect(fileMetadata.Sha256).To(Equal(sha256sum)) |
| 58 | + }) |
| 59 | + |
| 60 | + It("concurrent 200 should be ok", Label("concurrent", "200"), func() { |
| 61 | + clientPod, err := util.ClientExec() |
| 62 | + fmt.Println(err) |
| 63 | + Expect(err).NotTo(HaveOccurred()) |
| 64 | + |
| 65 | + 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() |
| 66 | + fmt.Println(string(out)) |
| 67 | + Expect(err).NotTo(HaveOccurred()) |
| 68 | + |
| 69 | + fileMetadata := util.FileMetadata{ |
| 70 | + ID: "f533d0d08acd4e6d57c0249e97aa08195deb41a470cf781cdfc15e4bf34a87e9", |
| 71 | + Sha256: "dc102987a36be20846821ac74648534863ff0fe8897d4250273a6ffc80481d91", |
| 72 | + } |
| 73 | + |
| 74 | + sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, fileMetadata.ID) |
| 75 | + Expect(err).NotTo(HaveOccurred()) |
| 76 | + Expect(fileMetadata.Sha256).To(Equal(sha256sum)) |
| 77 | + |
| 78 | + seedClientPods := make([]*util.PodExec, 3) |
| 79 | + for i := 0; i < 3; i++ { |
| 80 | + seedClientPods[i], err = util.SeedClientExec(i) |
| 81 | + fmt.Println(err) |
| 82 | + Expect(err).NotTo(HaveOccurred()) |
| 83 | + } |
| 84 | + |
| 85 | + sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, fileMetadata.ID) |
| 86 | + Expect(err).NotTo(HaveOccurred()) |
| 87 | + Expect(fileMetadata.Sha256).To(Equal(sha256sum)) |
| 88 | + }) |
| 89 | + |
| 90 | + It("concurrent 500 should be ok", Label("concurrent", "500"), func() { |
| 91 | + clientPod, err := util.ClientExec() |
| 92 | + fmt.Println(err) |
| 93 | + Expect(err).NotTo(HaveOccurred()) |
| 94 | + |
| 95 | + 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() |
| 96 | + fmt.Println(string(out)) |
| 97 | + Expect(err).NotTo(HaveOccurred()) |
| 98 | + |
| 99 | + fileMetadata := util.FileMetadata{ |
| 100 | + ID: "7eee7f3238d0e8c40ac822dbc156384c160d2b3ea0fab1bbddcbe91f31c7caae", |
| 101 | + Sha256: "54e54b7ff54ef70d4db2adcd24a27e3b9af3cd99fc0213983bac1e8035429be6", |
| 102 | + } |
| 103 | + |
| 104 | + sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, fileMetadata.ID) |
| 105 | + Expect(err).NotTo(HaveOccurred()) |
| 106 | + Expect(fileMetadata.Sha256).To(Equal(sha256sum)) |
| 107 | + |
| 108 | + seedClientPods := make([]*util.PodExec, 3) |
| 109 | + for i := 0; i < 3; i++ { |
| 110 | + seedClientPods[i], err = util.SeedClientExec(i) |
| 111 | + fmt.Println(err) |
| 112 | + Expect(err).NotTo(HaveOccurred()) |
| 113 | + } |
| 114 | + |
| 115 | + sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, fileMetadata.ID) |
| 116 | + Expect(err).NotTo(HaveOccurred()) |
| 117 | + Expect(fileMetadata.Sha256).To(Equal(sha256sum)) |
| 118 | + }) |
| 119 | + |
| 120 | + It("concurrent 2000 should be ok", Label("concurrent", "2000"), func() { |
| 121 | + clientPod, err := util.ClientExec() |
| 122 | + fmt.Println(err) |
| 123 | + Expect(err).NotTo(HaveOccurred()) |
| 124 | + |
| 125 | + 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() |
| 126 | + fmt.Println(string(out)) |
| 127 | + Expect(err).NotTo(HaveOccurred()) |
| 128 | + |
| 129 | + fileMetadata := util.FileMetadata{ |
| 130 | + ID: "90fd5db5089bee6c00a2eedd616df7b34cfe22894235bb6bbe44ac1e9a9051a6", |
| 131 | + Sha256: "87c09b7c338f258809ca2d436bbe06ac94a3166b3f3e1125a86f35d9a9aa1d2f", |
| 132 | + } |
| 133 | + |
| 134 | + sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, fileMetadata.ID) |
| 135 | + Expect(err).NotTo(HaveOccurred()) |
| 136 | + Expect(fileMetadata.Sha256).To(Equal(sha256sum)) |
| 137 | + |
| 138 | + seedClientPods := make([]*util.PodExec, 3) |
| 139 | + for i := 0; i < 3; i++ { |
| 140 | + seedClientPods[i], err = util.SeedClientExec(i) |
| 141 | + fmt.Println(err) |
| 142 | + Expect(err).NotTo(HaveOccurred()) |
| 143 | + } |
| 144 | + |
| 145 | + sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, fileMetadata.ID) |
| 146 | + Expect(err).NotTo(HaveOccurred()) |
| 147 | + Expect(fileMetadata.Sha256).To(Equal(sha256sum)) |
| 148 | + }) |
| 149 | + }) |
| 150 | +}) |
0 commit comments