1071 lines
38 KiB
Go
1071 lines
38 KiB
Go
/*
|
|
* 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"
|
|
"time"
|
|
|
|
. "github.com/onsi/ginkgo/v2" //nolint
|
|
. "github.com/onsi/gomega" //nolint
|
|
|
|
"d7y.io/dragonfly/v2/test/e2e/util"
|
|
)
|
|
|
|
var _ = Describe("Download Using Proxy", func() {
|
|
Context("1MiB file", 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("download should be ok", Label("proxy", "download"), func() {
|
|
clientPod, err := util.ClientExec()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := clientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -H 'X-Dragonfly-Tag: proxy' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, testFile.GetTaskID(util.WithTaskIDTag("proxy")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
sha256sum, err = util.CalculateSha256ByOutput([]*util.PodExec{clientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
seedClientPods := make([]*util.PodExec, 3)
|
|
for i := range 3 {
|
|
seedClientPods[i], err = util.SeedClientExec(i)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
}
|
|
|
|
sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, testFile.GetTaskID(util.WithTaskIDTag("proxy")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("10MiB file", func() {
|
|
var (
|
|
testFile *util.File
|
|
err error
|
|
)
|
|
|
|
BeforeEach(func() {
|
|
testFile, err = util.GetFileServer().GenerateFile(util.FileSize10MiB)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile).NotTo(BeNil())
|
|
})
|
|
|
|
AfterEach(func() {
|
|
err = util.GetFileServer().DeleteFile(testFile.GetInfo())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
})
|
|
|
|
It("download should be ok", Label("proxy", "download"), func() {
|
|
clientPod, err := util.ClientExec()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := clientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -H 'X-Dragonfly-Tag: proxy' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, testFile.GetTaskID(util.WithTaskIDTag("proxy")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
sha256sum, err = util.CalculateSha256ByOutput([]*util.PodExec{clientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
seedClientPods := make([]*util.PodExec, 3)
|
|
for i := range 3 {
|
|
seedClientPods[i], err = util.SeedClientExec(i)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
}
|
|
|
|
sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, testFile.GetTaskID(util.WithTaskIDTag("proxy")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("100MiB file", func() {
|
|
var (
|
|
testFile *util.File
|
|
err error
|
|
)
|
|
|
|
BeforeEach(func() {
|
|
testFile, err = util.GetFileServer().GenerateFile(util.FileSize100MiB)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile).NotTo(BeNil())
|
|
})
|
|
|
|
AfterEach(func() {
|
|
err = util.GetFileServer().DeleteFile(testFile.GetInfo())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
})
|
|
|
|
It("download should be ok", Label("proxy", "download"), func() {
|
|
clientPod, err := util.ClientExec()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := clientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -H 'X-Dragonfly-Tag: proxy' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, testFile.GetTaskID(util.WithTaskIDTag("proxy")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
sha256sum, err = util.CalculateSha256ByOutput([]*util.PodExec{clientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
seedClientPods := make([]*util.PodExec, 3)
|
|
for i := range 3 {
|
|
seedClientPods[i], err = util.SeedClientExec(i)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
}
|
|
|
|
sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, testFile.GetTaskID(util.WithTaskIDTag("proxy")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("500MiB file", func() {
|
|
var (
|
|
testFile *util.File
|
|
err error
|
|
)
|
|
|
|
BeforeEach(func() {
|
|
testFile, err = util.GetFileServer().GenerateFile(util.FileSize500MiB)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile).NotTo(BeNil())
|
|
})
|
|
|
|
AfterEach(func() {
|
|
err = util.GetFileServer().DeleteFile(testFile.GetInfo())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
})
|
|
|
|
It("download should be ok", Label("proxy", "download"), func() {
|
|
clientPod, err := util.ClientExec()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := clientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -H 'X-Dragonfly-Tag: proxy' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, testFile.GetTaskID(util.WithTaskIDTag("proxy")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
sha256sum, err = util.CalculateSha256ByOutput([]*util.PodExec{clientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
seedClientPods := make([]*util.PodExec, 3)
|
|
for i := range 3 {
|
|
seedClientPods[i], err = util.SeedClientExec(i)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
}
|
|
|
|
sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, testFile.GetTaskID(util.WithTaskIDTag("proxy")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("1GiB file", func() {
|
|
var (
|
|
testFile *util.File
|
|
err error
|
|
)
|
|
|
|
BeforeEach(func() {
|
|
testFile, err = util.GetFileServer().GenerateFile(util.FileSize1GiB)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile).NotTo(BeNil())
|
|
})
|
|
|
|
AfterEach(func() {
|
|
err = util.GetFileServer().DeleteFile(testFile.GetInfo())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
})
|
|
|
|
It("download should be ok", Label("proxy", "download"), func() {
|
|
clientPod, err := util.ClientExec()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := clientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -H 'X-Dragonfly-Tag: proxy' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, testFile.GetTaskID(util.WithTaskIDTag("proxy")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
sha256sum, err = util.CalculateSha256ByOutput([]*util.PodExec{clientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
seedClientPods := make([]*util.PodExec, 3)
|
|
for i := range 3 {
|
|
seedClientPods[i], err = util.SeedClientExec(i)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
}
|
|
|
|
sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, testFile.GetTaskID(util.WithTaskIDTag("proxy")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("1MiB file and set range header bytes=-100", 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("download should be ok", Label("proxy", "download", "range: bytes=-100"), func() {
|
|
clientPod, err := util.ClientExec()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := clientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -r -100 -H 'X-Dragonfly-Tag: proxy-bytes-100' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, testFile.GetTaskID(util.WithTaskIDTag("proxy-bytes-100")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
sha256sum, err = util.CalculateSha256ByOutput([]*util.PodExec{clientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetRangeSha256("-100", testFile.GetInfo().Size())).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
seedClientPods := make([]*util.PodExec, 3)
|
|
for i := range 3 {
|
|
seedClientPods[i], err = util.SeedClientExec(i)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
}
|
|
|
|
sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, testFile.GetTaskID(util.WithTaskIDTag("proxy-bytes-100")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("1MiB file and set range header bytes=0-100", 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("download should be ok", Label("proxy", "download", "range: bytes=0-100"), func() {
|
|
clientPod, err := util.ClientExec()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := clientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -r 0-100 -H 'X-Dragonfly-Tag: proxy-bytes-0-100' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, testFile.GetTaskID(util.WithTaskIDTag("proxy-bytes-0-100")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
sha256sum, err = util.CalculateSha256ByOutput([]*util.PodExec{clientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetRangeSha256("0-100", testFile.GetInfo().Size())).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
seedClientPods := make([]*util.PodExec, 3)
|
|
for i := range 3 {
|
|
seedClientPods[i], err = util.SeedClientExec(i)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
}
|
|
|
|
sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, testFile.GetTaskID(util.WithTaskIDTag("proxy-bytes-0-100")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("1MiB file and set range header bytes=100-", 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("download should be ok", Label("proxy", "download", "range: bytes=100-"), func() {
|
|
clientPod, err := util.ClientExec()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := clientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -r 100- -H 'X-Dragonfly-Tag: proxy-bytes-100-' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, testFile.GetTaskID(util.WithTaskIDTag("proxy-bytes-100-")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
sha256sum, err = util.CalculateSha256ByOutput([]*util.PodExec{clientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetRangeSha256("100-", testFile.GetInfo().Size())).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
seedClientPods := make([]*util.PodExec, 3)
|
|
for i := range 3 {
|
|
seedClientPods[i], err = util.SeedClientExec(i)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
}
|
|
|
|
sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, testFile.GetTaskID(util.WithTaskIDTag("proxy-bytes-100-")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("1MiB file and set range header bytes=100-500", 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("download should be ok", Label("proxy", "download", "range: bytes=100-500"), func() {
|
|
clientPod, err := util.ClientExec()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := clientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -r 100-500 -H 'X-Dragonfly-Tag: proxy-bytes-100-500' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, testFile.GetTaskID(util.WithTaskIDTag("proxy-bytes-100-500")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
sha256sum, err = util.CalculateSha256ByOutput([]*util.PodExec{clientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetRangeSha256("100-500", testFile.GetInfo().Size())).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
seedClientPods := make([]*util.PodExec, 3)
|
|
for i := range 3 {
|
|
seedClientPods[i], err = util.SeedClientExec(i)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
}
|
|
|
|
sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, testFile.GetTaskID(util.WithTaskIDTag("proxy-bytes-100-500")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("1MiB file and set range header bytes=0-1048575", 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("download should be ok", Label("proxy", "download", "range: bytes=0-1048575"), func() {
|
|
clientPod, err := util.ClientExec()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := clientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -r 0-1048575 -H 'X-Dragonfly-Tag: proxy-bytes-0-1048575' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, testFile.GetTaskID(util.WithTaskIDTag("proxy-bytes-0-1048575")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
sha256sum, err = util.CalculateSha256ByOutput([]*util.PodExec{clientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetRangeSha256("0-1048575", testFile.GetInfo().Size())).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
seedClientPods := make([]*util.PodExec, 3)
|
|
for i := range 3 {
|
|
seedClientPods[i], err = util.SeedClientExec(i)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
}
|
|
|
|
sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, testFile.GetTaskID(util.WithTaskIDTag("proxy-bytes-0-1048575")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("1MiB file and set range header bytes=100-10240", 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("download should be ok", Label("proxy", "download", "range: bytes=100-10240"), func() {
|
|
clientPod, err := util.ClientExec()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := clientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -r 100-10240 -H 'X-Dragonfly-Tag: proxy-bytes-100-10240' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, testFile.GetTaskID(util.WithTaskIDTag("proxy-bytes-100-10240")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
sha256sum, err = util.CalculateSha256ByOutput([]*util.PodExec{clientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetRangeSha256("100-10240", testFile.GetInfo().Size())).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
seedClientPods := make([]*util.PodExec, 3)
|
|
for i := range 3 {
|
|
seedClientPods[i], err = util.SeedClientExec(i)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
}
|
|
|
|
sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, testFile.GetTaskID(util.WithTaskIDTag("proxy-bytes-100-10240")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("/bin/kubectl file and set range header bytes=100-1024", 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("download should be ok", Label("proxy", "download", "range: bytes=100-1024"), func() {
|
|
clientPod, err := util.ClientExec()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := clientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -r 100-1024 -H 'X-Dragonfly-Tag: proxy-bytes-100-1024' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{clientPod}, testFile.GetTaskID(util.WithTaskIDTag("proxy-bytes-100-1024")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
sha256sum, err = util.CalculateSha256ByOutput([]*util.PodExec{clientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetRangeSha256("100-1024", testFile.GetInfo().Size())).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
seedClientPods := make([]*util.PodExec, 3)
|
|
for i := range 3 {
|
|
seedClientPods[i], err = util.SeedClientExec(i)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
}
|
|
|
|
sha256sum, err = util.CalculateSha256ByTaskID(seedClientPods, testFile.GetTaskID(util.WithTaskIDTag("proxy-bytes-100-1024")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
})
|
|
|
|
var _ = Describe("Download Using Prefetch Proxy", func() {
|
|
Context("1MiB file", 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("download should be ok", Label("prefetch-proxy", "download"), func() {
|
|
seedClientPod, err := util.SeedClientExec(0)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := seedClientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -H 'X-Dragonfly-Tag: prefetch-proxy' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{seedClientPod}, testFile.GetTaskID(util.WithTaskIDTag("prefetch-proxy")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
sha256sum, err = util.CalculateSha256ByOutput([]*util.PodExec{seedClientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("10MiB file", func() {
|
|
var (
|
|
testFile *util.File
|
|
err error
|
|
)
|
|
|
|
BeforeEach(func() {
|
|
testFile, err = util.GetFileServer().GenerateFile(util.FileSize10MiB)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile).NotTo(BeNil())
|
|
})
|
|
|
|
AfterEach(func() {
|
|
err = util.GetFileServer().DeleteFile(testFile.GetInfo())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
})
|
|
|
|
It("download should be ok", Label("prefetch-proxy", "download"), func() {
|
|
seedClientPod, err := util.SeedClientExec(0)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := seedClientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -H 'X-Dragonfly-Tag: prefetch-proxy' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{seedClientPod}, testFile.GetTaskID(util.WithTaskIDTag("prefetch-proxy")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
sha256sum, err = util.CalculateSha256ByOutput([]*util.PodExec{seedClientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("100MiB file", func() {
|
|
var (
|
|
testFile *util.File
|
|
err error
|
|
)
|
|
|
|
BeforeEach(func() {
|
|
testFile, err = util.GetFileServer().GenerateFile(util.FileSize100MiB)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile).NotTo(BeNil())
|
|
})
|
|
|
|
AfterEach(func() {
|
|
err = util.GetFileServer().DeleteFile(testFile.GetInfo())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
})
|
|
|
|
It("download should be ok", Label("prefetch-proxy", "download"), func() {
|
|
seedClientPod, err := util.SeedClientExec(0)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := seedClientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -H 'X-Dragonfly-Tag: prefetch-proxy' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{seedClientPod}, testFile.GetTaskID(util.WithTaskIDTag("prefetch-proxy")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
sha256sum, err = util.CalculateSha256ByOutput([]*util.PodExec{seedClientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("500MiB file", func() {
|
|
var (
|
|
testFile *util.File
|
|
err error
|
|
)
|
|
|
|
BeforeEach(func() {
|
|
testFile, err = util.GetFileServer().GenerateFile(util.FileSize500MiB)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile).NotTo(BeNil())
|
|
})
|
|
|
|
AfterEach(func() {
|
|
err = util.GetFileServer().DeleteFile(testFile.GetInfo())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
})
|
|
|
|
It("download should be ok", Label("prefetch-proxy", "download"), func() {
|
|
seedClientPod, err := util.SeedClientExec(0)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := seedClientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -H 'X-Dragonfly-Tag: prefetch-proxy' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{seedClientPod}, testFile.GetTaskID(util.WithTaskIDTag("prefetch-proxy")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
sha256sum, err = util.CalculateSha256ByOutput([]*util.PodExec{seedClientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("1GiB file", func() {
|
|
var (
|
|
testFile *util.File
|
|
err error
|
|
)
|
|
|
|
BeforeEach(func() {
|
|
testFile, err = util.GetFileServer().GenerateFile(util.FileSize1GiB)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile).NotTo(BeNil())
|
|
})
|
|
|
|
AfterEach(func() {
|
|
err = util.GetFileServer().DeleteFile(testFile.GetInfo())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
})
|
|
|
|
It("download should be ok", Label("prefetch-proxy", "download"), func() {
|
|
seedClientPod, err := util.SeedClientExec(0)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := seedClientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -H 'X-Dragonfly-Tag: prefetch-proxy' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByTaskID([]*util.PodExec{seedClientPod}, testFile.GetTaskID(util.WithTaskIDTag("prefetch-proxy")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
|
|
sha256sum, err = util.CalculateSha256ByOutput([]*util.PodExec{seedClientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("1MiB file and set range header bytes=-100", 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("download should be ok", Label("prefetch-proxy", "download", "range: bytes=-100"), func() {
|
|
seedClientPod, err := util.SeedClientExec(0)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := seedClientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -r -100 -H 'X-Dragonfly-Tag: prefetch-proxy-bytes-100' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByOutput([]*util.PodExec{seedClientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetRangeSha256("-100", testFile.GetInfo().Size())).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
sha256sum, err = util.CalculateSha256ByTaskID([]*util.PodExec{seedClientPod}, testFile.GetTaskID(util.WithTaskIDTag("prefetch-proxy-bytes-100")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("1MiB file and set range header bytes=0-100", 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("download should be ok", Label("prefetch-proxy", "download", "range: bytes=0-100"), func() {
|
|
seedClientPod, err := util.SeedClientExec(0)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := seedClientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -r 0-100 -H 'X-Dragonfly-Tag: prefetch-proxy-bytes-0-100' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByOutput([]*util.PodExec{seedClientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetRangeSha256("0-100", testFile.GetInfo().Size())).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
sha256sum, err = util.CalculateSha256ByTaskID([]*util.PodExec{seedClientPod}, testFile.GetTaskID(util.WithTaskIDTag("prefetch-proxy-bytes-0-100")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("1MiB file and set range header bytes=100-", 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("download should be ok", Label("prefetch-proxy", "download", "range: bytes=100-"), func() {
|
|
seedClientPod, err := util.SeedClientExec(0)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := seedClientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -r 100- -H 'X-Dragonfly-Tag: prefetch-proxy-bytes-100-' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByOutput([]*util.PodExec{seedClientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetRangeSha256("100-", testFile.GetInfo().Size())).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
sha256sum, err = util.CalculateSha256ByTaskID([]*util.PodExec{seedClientPod}, testFile.GetTaskID(util.WithTaskIDTag("prefetch-proxy-bytes-100-")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("1MiB file and set range header bytes=100-1048575", 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("download should be ok", Label("prefetch-proxy", "download", "range: bytes=100-1048575"), func() {
|
|
seedClientPod, err := util.SeedClientExec(0)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := seedClientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -r 100-1048575 -H 'X-Dragonfly-Tag: prefetch-proxy-bytes-100-1048575' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByOutput([]*util.PodExec{seedClientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetRangeSha256("100-1048575", testFile.GetInfo().Size())).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
sha256sum, err = util.CalculateSha256ByTaskID([]*util.PodExec{seedClientPod}, testFile.GetTaskID(util.WithTaskIDTag("prefetch-proxy-bytes-100-1048575")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("1MiB file and set range header bytes=0-1048575", 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("download should be ok", Label("prefetch-proxy", "download", "range: bytes=0-1048575"), func() {
|
|
seedClientPod, err := util.SeedClientExec(0)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := seedClientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -r 0-1048575 -H 'X-Dragonfly-Tag: prefetch-proxy-bytes-0-1048575' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByOutput([]*util.PodExec{seedClientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetRangeSha256("0-1048575", testFile.GetInfo().Size())).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
sha256sum, err = util.CalculateSha256ByTaskID([]*util.PodExec{seedClientPod}, testFile.GetTaskID(util.WithTaskIDTag("prefetch-proxy-bytes-0-1048575")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("1MiB file and set range header bytes=100-10240", 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("download should be ok", Label("prefetch-proxy", "download", "range: bytes=100-10240"), func() {
|
|
seedClientPod, err := util.SeedClientExec(0)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := seedClientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -r 100-10240 -H 'X-Dragonfly-Tag: prefetch-proxy-bytes-100-10240' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByOutput([]*util.PodExec{seedClientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetRangeSha256("100-10240", testFile.GetInfo().Size())).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
sha256sum, err = util.CalculateSha256ByTaskID([]*util.PodExec{seedClientPod}, testFile.GetTaskID(util.WithTaskIDTag("prefetch-proxy-bytes-100-10240")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
|
|
Context("1MiB file and set range header bytes=100-1024", 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("download should be ok", Label("prefetch-proxy", "download", "range: bytes=100-1024"), func() {
|
|
seedClientPod, err := util.SeedClientExec(0)
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
out, err := seedClientPod.Command("sh", "-c", fmt.Sprintf("curl -x 127.0.0.1:4001 -r 100-1024 -H 'X-Dragonfly-Tag: prefetch-proxy-bytes-100-1024' %s --output %s", testFile.GetDownloadURL(), testFile.GetOutputPath())).CombinedOutput()
|
|
fmt.Println(err)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
fmt.Println(string(out))
|
|
|
|
sha256sum, err := util.CalculateSha256ByOutput([]*util.PodExec{seedClientPod}, testFile.GetOutputPath())
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetRangeSha256("100-1024", testFile.GetInfo().Size())).To(Equal(sha256sum))
|
|
|
|
time.Sleep(1 * time.Second)
|
|
sha256sum, err = util.CalculateSha256ByTaskID([]*util.PodExec{seedClientPod}, testFile.GetTaskID(util.WithTaskIDTag("prefetch-proxy-bytes-100-1024")))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(testFile.GetSha256()).To(Equal(sha256sum))
|
|
})
|
|
})
|
|
})
|