From daf307b5d569875b4ab9e209ee6a3df0df92daba Mon Sep 17 00:00:00 2001 From: Gaius Date: Thu, 14 Mar 2024 13:20:29 +0800 Subject: [PATCH] feat: rename e2eutil to util (#3122) Signed-off-by: Gaius --- test/e2e/concurrency_test.go | 18 ++++---- test/e2e/containerd_test.go | 6 +-- test/e2e/dfget_test.go | 52 +++++++++++----------- test/e2e/e2e_test.go | 36 +++++++-------- test/e2e/manager/preheat.go | 36 +++++++-------- test/e2e/{e2eutil => util}/artifact.go | 2 +- test/e2e/{e2eutil => util}/exec.go | 2 +- test/e2e/{e2eutil => util}/feature_gate.go | 2 +- test/e2e/{e2eutil => util}/file_server.go | 2 +- 9 files changed, 78 insertions(+), 78 deletions(-) rename test/e2e/{e2eutil => util}/artifact.go (99%) rename test/e2e/{e2eutil => util}/exec.go (99%) rename test/e2e/{e2eutil => util}/feature_gate.go (99%) rename test/e2e/{e2eutil => util}/file_server.go (98%) diff --git a/test/e2e/concurrency_test.go b/test/e2e/concurrency_test.go index b20062913..a326fab76 100644 --- a/test/e2e/concurrency_test.go +++ b/test/e2e/concurrency_test.go @@ -22,43 +22,43 @@ import ( . "github.com/onsi/ginkgo/v2" //nolint . "github.com/onsi/gomega" //nolint - "d7y.io/dragonfly/v2/test/e2e/e2eutil" + "d7y.io/dragonfly/v2/test/e2e/util" ) var _ = Describe("Download concurrency", func() { Context("ab", func() { It("concurrent 100 should be ok", Label("concurrent", "100"), func() { - url := e2eutil.GetFileURL(hostnameFilePath) + url := util.GetFileURL(hostnameFilePath) fmt.Println("download url " + url) - out, err := e2eutil.ABCommand("-c", "100", "-n", "200", "-X", proxy, url).CombinedOutput() + out, err := util.ABCommand("-c", "100", "-n", "200", "-X", proxy, url).CombinedOutput() fmt.Println(string(out)) Expect(err).NotTo(HaveOccurred()) }) It("concurrent 200 should be ok", Label("concurrent", "200"), func() { - url := e2eutil.GetFileURL(hostnameFilePath) + url := util.GetFileURL(hostnameFilePath) fmt.Println("download url " + url) - out, err := e2eutil.ABCommand("-c", "200", "-n", "400", "-X", proxy, url).CombinedOutput() + out, err := util.ABCommand("-c", "200", "-n", "400", "-X", proxy, url).CombinedOutput() fmt.Println(string(out)) Expect(err).NotTo(HaveOccurred()) }) It("concurrent 500 should be ok", Label("concurrent", "500"), func() { - url := e2eutil.GetFileURL(hostnameFilePath) + url := util.GetFileURL(hostnameFilePath) fmt.Println("download url " + url) - out, err := e2eutil.ABCommand("-c", "500", "-n", "1000", "-X", proxy, url).CombinedOutput() + out, err := util.ABCommand("-c", "500", "-n", "1000", "-X", proxy, url).CombinedOutput() fmt.Println(string(out)) Expect(err).NotTo(HaveOccurred()) }) It("concurrent 1000 should be ok", Label("concurrent", "1000"), func() { - url := e2eutil.GetFileURL(hostnameFilePath) + url := util.GetFileURL(hostnameFilePath) fmt.Println("download url " + url) - out, err := e2eutil.ABCommand("-c", "1000", "-n", "2000", "-X", proxy, url).CombinedOutput() + out, err := util.ABCommand("-c", "1000", "-n", "2000", "-X", proxy, url).CombinedOutput() fmt.Println(string(out)) Expect(err).NotTo(HaveOccurred()) }) diff --git a/test/e2e/containerd_test.go b/test/e2e/containerd_test.go index bcf62de6e..5045132e4 100644 --- a/test/e2e/containerd_test.go +++ b/test/e2e/containerd_test.go @@ -22,19 +22,19 @@ import ( . "github.com/onsi/ginkgo/v2" //nolint . "github.com/onsi/gomega" //nolint - "d7y.io/dragonfly/v2/test/e2e/e2eutil" + "d7y.io/dragonfly/v2/test/e2e/util" ) var _ = Describe("Containerd with CRI support", func() { Context("docker.io/library/busybox:latest image", func() { It("pull should be ok", Label("containerd", "pull"), func() { - out, err := e2eutil.CriCtlCommand("pull", "d7y.io/library/busybox:latest").CombinedOutput() + out, err := util.CriCtlCommand("pull", "d7y.io/library/busybox:latest").CombinedOutput() fmt.Println(string(out)) Expect(err).NotTo(HaveOccurred()) }) It("rmi should be ok", Label("containerd", "rmi"), func() { - out, err := e2eutil.CriCtlCommand("rmi", "d7y.io/library/busybox:latest").CombinedOutput() + out, err := util.CriCtlCommand("rmi", "d7y.io/library/busybox:latest").CombinedOutput() fmt.Println(string(out)) Expect(err).NotTo(HaveOccurred()) }) diff --git a/test/e2e/dfget_test.go b/test/e2e/dfget_test.go index b7d14dc24..924ab860c 100644 --- a/test/e2e/dfget_test.go +++ b/test/e2e/dfget_test.go @@ -27,7 +27,7 @@ import ( . "github.com/onsi/gomega" //nolint "d7y.io/dragonfly/v2/pkg/net/http" - "d7y.io/dragonfly/v2/test/e2e/e2eutil" + "d7y.io/dragonfly/v2/test/e2e/util" ) var _ = Describe("Download with dfget and proxy", func() { @@ -48,15 +48,15 @@ var _ = Describe("Download with dfget and proxy", func() { func getFileSizes() map[string]int { var ( details = map[string]int{} - files = e2eutil.GetFileList() + files = util.GetFileList() ) - if e2eutil.FeatureGates.Enabled(e2eutil.FeatureGateEmptyFile) { + if util.FeatureGates.Enabled(util.FeatureGateEmptyFile) { fmt.Printf("dfget-empty-file feature gate enabled\n") files = append(files, "/tmp/empty-file") } for _, path := range files { - out, err := e2eutil.DockerCommand("stat", "--printf=%s", path).CombinedOutput() + out, err := util.DockerCommand("stat", "--printf=%s", path).CombinedOutput() if err != nil { fmt.Printf("stat %s erro: %s, stdout: %s", path, err, string(out)) } @@ -96,7 +96,7 @@ func getRandomRange(size int) *http.Range { func singleDfgetTest(name, ns, label, podNamePrefix, container string) { It(name, Label("download", "normal"), func() { fileDetails := getFileSizes() - out, err := e2eutil.KubeCtlCommand("-n", ns, "get", "pod", "-l", label, + out, err := util.KubeCtlCommand("-n", ns, "get", "pod", "-l", label, "-o", "jsonpath='{range .items[*]}{.metadata.name}{end}'").CombinedOutput() podName := strings.Trim(string(out), "'") Expect(err).NotTo(HaveOccurred()) @@ -104,8 +104,8 @@ func singleDfgetTest(name, ns, label, podNamePrefix, container string) { Expect(strings.HasPrefix(podName, podNamePrefix)).Should(BeTrue()) // copy test tools into container - if e2eutil.FeatureGates.Enabled(e2eutil.FeatureGateRange) { - out, err = e2eutil.KubeCtlCommand("-n", ns, "cp", "-c", container, "/tmp/sha256sum-offset", + if util.FeatureGates.Enabled(util.FeatureGateRange) { + out, err = util.KubeCtlCommand("-n", ns, "cp", "-c", container, "/tmp/sha256sum-offset", fmt.Sprintf("%s:/bin/", podName)).CombinedOutput() if err != nil { fmt.Println(string(out)) @@ -113,7 +113,7 @@ func singleDfgetTest(name, ns, label, podNamePrefix, container string) { Expect(err).NotTo(HaveOccurred()) } - pod := e2eutil.NewPodExec(ns, podName, container) + pod := util.NewPodExec(ns, podName, container) // install curl out, err = pod.Command("apk", "add", "-U", "curl").CombinedOutput() @@ -125,25 +125,25 @@ func singleDfgetTest(name, ns, label, podNamePrefix, container string) { if size == 0 { continue } - url1 := e2eutil.GetFileURL(path) - url2 := e2eutil.GetNoContentLengthFileURL(path) + url1 := util.GetFileURL(path) + url2 := util.GetNoContentLengthFileURL(path) // make ranged requests to invoke prefetch feature - if e2eutil.FeatureGates.Enabled(e2eutil.FeatureGateRange) { + if util.FeatureGates.Enabled(util.FeatureGateRange) { rg1, rg2 := getRandomRange(size), getRandomRange(size) downloadSingleFile(ns, pod, path, url1, size, rg1, rg1.String()) - if e2eutil.FeatureGates.Enabled(e2eutil.FeatureGateNoLength) { + if util.FeatureGates.Enabled(util.FeatureGateNoLength) { downloadSingleFile(ns, pod, path, url2, size, rg2, rg2.String()) } - if e2eutil.FeatureGates.Enabled(e2eutil.FeatureGateOpenRange) { + if util.FeatureGates.Enabled(util.FeatureGateOpenRange) { rg3, rg4 := getRandomRange(size), getRandomRange(size) // set target length rg3.Length = int64(size) - rg3.Start rg4.Length = int64(size) - rg4.Start downloadSingleFile(ns, pod, path, url1, size, rg3, fmt.Sprintf("bytes=%d-", rg3.Start)) - if e2eutil.FeatureGates.Enabled(e2eutil.FeatureGateNoLength) { + if util.FeatureGates.Enabled(util.FeatureGateNoLength) { downloadSingleFile(ns, pod, path, url2, size, rg4, fmt.Sprintf("bytes=%d-", rg4.Start)) } } @@ -151,13 +151,13 @@ func singleDfgetTest(name, ns, label, podNamePrefix, container string) { downloadSingleFile(ns, pod, path, url1, size, nil, "") - if e2eutil.FeatureGates.Enabled(e2eutil.FeatureGateNoLength) { + if util.FeatureGates.Enabled(util.FeatureGateNoLength) { downloadSingleFile(ns, pod, path, url2, size, nil, "") } } }) It(name+" - recursive with dfget", Label("download", "recursive", "dfget"), func() { - if !e2eutil.FeatureGates.Enabled(e2eutil.FeatureGateRecursive) { + if !util.FeatureGates.Enabled(util.FeatureGateRecursive) { fmt.Println("feature gate recursive is disable, skip") return } @@ -169,12 +169,12 @@ func singleDfgetTest(name, ns, label, podNamePrefix, container string) { // sha256sum txt: /host/tmp/dragonfly-test.sha256sum.txt subDirs := []string{"bin", "lib64", "libexec", "sbin"} - out, err := e2eutil.KubeCtlCommand("-n", ns, "get", "pod", "-l", label, + out, err := util.KubeCtlCommand("-n", ns, "get", "pod", "-l", label, "-o", "jsonpath='{range .items[*]}{.metadata.name}{end}'").CombinedOutput() podName := strings.Trim(string(out), "'") Expect(err).NotTo(HaveOccurred()) fmt.Println("test in pod: " + podName) - pod := e2eutil.NewPodExec(ns, podName, container) + pod := util.NewPodExec(ns, podName, container) for _, dir := range subDirs { var dfget []string @@ -209,7 +209,7 @@ func singleDfgetTest(name, ns, label, podNamePrefix, container string) { sha256sum1 := strings.TrimSpace(string(out)) // get the original sha256sum in minio pod - minioPod := e2eutil.NewPodExec("dragonfly-e2e", "minio-0", "minio") + minioPod := util.NewPodExec("dragonfly-e2e", "minio-0", "minio") out, err = minioPod.Command("cat", "/host/tmp/dragonfly-test.sha256sum.txt").CombinedOutput() Expect(err).NotTo(HaveOccurred()) sha256sum2 := strings.TrimSpace(string(out)) @@ -222,7 +222,7 @@ func singleDfgetTest(name, ns, label, podNamePrefix, container string) { }) It(name+" - recursive with grpc", Label("download", "recursive", "grpc"), func() { - if !e2eutil.FeatureGates.Enabled(e2eutil.FeatureGateRecursive) { + if !util.FeatureGates.Enabled(util.FeatureGateRecursive) { fmt.Println("feature gate recursive is disable, skip") return } @@ -234,15 +234,15 @@ func singleDfgetTest(name, ns, label, podNamePrefix, container string) { // sha256sum txt: /host/tmp/dragonfly-test.sha256sum.txt subDirs := []string{"bin", "lib64", "libexec", "sbin"} - out, err := e2eutil.KubeCtlCommand("-n", ns, "get", "pod", "-l", label, + out, err := util.KubeCtlCommand("-n", ns, "get", "pod", "-l", label, "-o", "jsonpath='{range .items[*]}{.metadata.name}{end}'").CombinedOutput() podName := strings.Trim(string(out), "'") Expect(err).NotTo(HaveOccurred()) fmt.Println("test in pod: " + podName) - pod := e2eutil.NewPodExec(ns, podName, container) + pod := util.NewPodExec(ns, podName, container) // copy test tools into container - out, err = e2eutil.KubeCtlCommand("-n", ns, "cp", "-c", container, "/tmp/download-grpc-test", + out, err = util.KubeCtlCommand("-n", ns, "cp", "-c", container, "/tmp/download-grpc-test", fmt.Sprintf("%s:/bin/", podName)).CombinedOutput() if err != nil { fmt.Println(string(out)) @@ -269,7 +269,7 @@ func singleDfgetTest(name, ns, label, podNamePrefix, container string) { sha256sum1 := strings.TrimSpace(string(out)) // get the original sha256sum in minio pod - minioPod := e2eutil.NewPodExec("dragonfly-e2e", "minio-0", "minio") + minioPod := util.NewPodExec("dragonfly-e2e", "minio-0", "minio") out, err = minioPod.Command("cat", "/host/tmp/dragonfly-test.sha256sum.txt").CombinedOutput() Expect(err).NotTo(HaveOccurred()) sha256sum2 := strings.TrimSpace(string(out)) @@ -282,7 +282,7 @@ func singleDfgetTest(name, ns, label, podNamePrefix, container string) { }) } -func downloadSingleFile(ns string, pod *e2eutil.PodExec, path, url string, size int, rg *http.Range, rawRg string) { +func downloadSingleFile(ns string, pod *util.PodExec, path, url string, size int, rg *http.Range, rawRg string) { var ( sha256sum []string dfget []string @@ -320,7 +320,7 @@ func downloadSingleFile(ns string, pod *e2eutil.PodExec, path, url string, size url, size, rawRg, rg.Length) } // get original file digest - out, err := e2eutil.DockerCommand(sha256sum...).CombinedOutput() + out, err := util.DockerCommand(sha256sum...).CombinedOutput() fmt.Println("original sha256sum: " + string(out)) Expect(err).NotTo(HaveOccurred()) sha256sum1 := strings.Split(string(out), " ")[0] diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 562210a25..3c05d4f34 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -28,8 +28,8 @@ import ( . "github.com/onsi/ginkgo/v2" //nolint . "github.com/onsi/gomega" //nolint - "d7y.io/dragonfly/v2/test/e2e/e2eutil" _ "d7y.io/dragonfly/v2/test/e2e/manager" + "d7y.io/dragonfly/v2/test/e2e/util" ) var featureGatesFlag string @@ -41,21 +41,21 @@ func init() { var _ = AfterSuite(func() { for _, server := range servers { for i := 0; i < server.replicas; i++ { - out, err := e2eutil.KubeCtlCommand("-n", server.namespace, "get", "pod", "-l", fmt.Sprintf("component=%s", server.name), + out, err := util.KubeCtlCommand("-n", server.namespace, "get", "pod", "-l", fmt.Sprintf("component=%s", server.name), "-o", fmt.Sprintf("jsonpath='{.items[%d].metadata.name}'", i)).CombinedOutput() if err != nil { fmt.Printf("get pod error: %s, output: %s\n", err, string(out)) continue } podName := strings.Trim(string(out), "'") - pod := e2eutil.NewPodExec(server.namespace, podName, server.name) + pod := util.NewPodExec(server.namespace, podName, server.name) var ( retryCount = 0 maxRetryCount = 10 ) retry: - countOut, err := e2eutil.KubeCtlCommand("-n", server.namespace, "get", "pod", "-l", fmt.Sprintf("component=%s", server.name), + countOut, err := util.KubeCtlCommand("-n", server.namespace, "get", "pod", "-l", fmt.Sprintf("component=%s", server.name), "-o", fmt.Sprintf("jsonpath='{.items[%d].status.containerStatuses[0].restartCount}'", i)).CombinedOutput() if err != nil { fmt.Printf("get pod %s restart count error: %s, output: %s\n", podName, err, string(countOut)) @@ -86,17 +86,17 @@ var _ = AfterSuite(func() { } if count > 0 { - if err := e2eutil.UploadArtifactPrevStdout(server.namespace, podName, fmt.Sprintf("%s-%d", server.name, i), server.name); err != nil { + if err := util.UploadArtifactPrevStdout(server.namespace, podName, fmt.Sprintf("%s-%d", server.name, i), server.name); err != nil { fmt.Printf("upload pod %s artifact stdout file error: %v\n", podName, err) } } - if err := e2eutil.UploadArtifactStdout(server.namespace, podName, fmt.Sprintf("%s-%d", server.name, i), server.name); err != nil { + if err := util.UploadArtifactStdout(server.namespace, podName, fmt.Sprintf("%s-%d", server.name, i), server.name); err != nil { fmt.Printf("upload pod %s artifact prev stdout file error: %v\n", podName, err) } if server.pprofPort > 0 { - if out, err := e2eutil.UploadArtifactPProf(server.namespace, podName, + if out, err := util.UploadArtifactPProf(server.namespace, podName, fmt.Sprintf("%s-%d", server.name, i), server.name, server.pprofPort); err != nil { fmt.Printf("upload pod %s artifact pprof error: %v, output: %s\n", podName, err, out) } @@ -107,14 +107,14 @@ var _ = AfterSuite(func() { }) var _ = BeforeSuite(func() { - err := e2eutil.FeatureGates.Set(featureGatesFlag) + err := util.FeatureGates.Set(featureGatesFlag) Expect(err).NotTo(HaveOccurred()) - fmt.Printf("feature gates: %q, flags: %q\n", e2eutil.FeatureGates.String(), featureGatesFlag) + fmt.Printf("feature gates: %q, flags: %q\n", util.FeatureGates.String(), featureGatesFlag) mode := os.Getenv("DRAGONFLY_COMPATIBILITY_E2E_TEST_MODE") imageName := os.Getenv("DRAGONFLY_COMPATIBILITY_E2E_TEST_IMAGE") if mode != "" && imageName != "" { - rawImages, err := e2eutil.KubeCtlCommand("-n", dragonflyNamespace, "get", "pod", "-l", fmt.Sprintf("component=%s", mode), + rawImages, err := util.KubeCtlCommand("-n", dragonflyNamespace, "get", "pod", "-l", fmt.Sprintf("component=%s", mode), "-o", "jsonpath='{range .items[0]}{.spec.containers[0].image}{end}'").CombinedOutput() image := strings.Trim(string(rawImages), "'") Expect(err).NotTo(HaveOccurred()) @@ -124,25 +124,25 @@ var _ = BeforeSuite(func() { Expect(fmt.Sprintf("dragonflyoss/%s:%s", imageName, stableImageTag)).To(Equal(image)) } - rawGitCommit, err := e2eutil.GitCommand("rev-parse", "--short", "HEAD").CombinedOutput() + rawGitCommit, err := util.GitCommand("rev-parse", "--short", "HEAD").CombinedOutput() Expect(err).NotTo(HaveOccurred()) gitCommit := strings.Fields(string(rawGitCommit))[0] fmt.Printf("git merge commit: %s\n", gitCommit) - rawPodName, err := e2eutil.KubeCtlCommand("-n", dragonflyNamespace, "get", "pod", "-l", "component=dfdaemon", + rawPodName, err := util.KubeCtlCommand("-n", dragonflyNamespace, "get", "pod", "-l", "component=dfdaemon", "-o", "jsonpath='{range .items[*]}{.metadata.name}{end}'").CombinedOutput() podName := strings.Trim(string(rawPodName), "'") Expect(err).NotTo(HaveOccurred()) Expect(strings.HasPrefix(podName, "dragonfly-dfdaemon-")).Should(BeTrue()) - pod := e2eutil.NewPodExec(dragonflyNamespace, podName, "dfdaemon") + pod := util.NewPodExec(dragonflyNamespace, podName, "dfdaemon") rawDfgetVersion, err := pod.Command("dfget", "version").CombinedOutput() Expect(err).NotTo(HaveOccurred()) dfgetGitCommit := strings.Fields(string(rawDfgetVersion))[7] fmt.Printf("raw dfget version:\n%s\n", rawDfgetVersion) fmt.Printf("dfget merge commit: %s\n", dfgetGitCommit) - if !e2eutil.FeatureGates.Enabled(e2eutil.FeatureGateCommit) { + if !util.FeatureGates.Enabled(util.FeatureGateCommit) { return } if mode == dfdaemonCompatibilityTestMode { @@ -152,16 +152,16 @@ var _ = BeforeSuite(func() { Expect(gitCommit).To(Equal(dfgetGitCommit)) - if e2eutil.FeatureGates.Enabled(e2eutil.FeatureGateRange) { - out, err := e2eutil.DockerCopy("/bin/", "/tmp/sha256sum-offset").CombinedOutput() + if util.FeatureGates.Enabled(util.FeatureGateRange) { + out, err := util.DockerCopy("/bin/", "/tmp/sha256sum-offset").CombinedOutput() if err != nil { fmt.Println(string(out)) } Expect(err).NotTo(HaveOccurred()) } - if e2eutil.FeatureGates.Enabled(e2eutil.FeatureGateRecursive) { - out, err := e2eutil.DockerCopy("/bin/", "/tmp/download-grpc-test").CombinedOutput() + if util.FeatureGates.Enabled(util.FeatureGateRecursive) { + out, err := util.DockerCopy("/bin/", "/tmp/download-grpc-test").CombinedOutput() if err != nil { fmt.Println(string(out)) } diff --git a/test/e2e/manager/preheat.go b/test/e2e/manager/preheat.go index ba59bfd87..5f310d01d 100644 --- a/test/e2e/manager/preheat.go +++ b/test/e2e/manager/preheat.go @@ -35,24 +35,24 @@ import ( "d7y.io/dragonfly/v2/manager/types" "d7y.io/dragonfly/v2/pkg/idgen" "d7y.io/dragonfly/v2/pkg/structure" - "d7y.io/dragonfly/v2/test/e2e/e2eutil" + "d7y.io/dragonfly/v2/test/e2e/util" ) var _ = Describe("Preheat with manager", func() { Context("preheat", func() { It("preheat files should be ok", Label("preheat", "file"), func() { - var seedPeerPods [3]*e2eutil.PodExec + var seedPeerPods [3]*util.PodExec for i := 0; i < 3; i++ { seedPeerPods[i] = getSeedPeerExec(i) } fsPod := getFileServerExec() - for _, v := range e2eutil.GetFileList() { - url := e2eutil.GetFileURL(v) + for _, v := range util.GetFileList() { + url := util.GetFileURL(v) fmt.Println("download url: " + url) // get original file digest - out, err := e2eutil.DockerCommand("sha256sum", v).CombinedOutput() + out, err := util.DockerCommand("sha256sum", v).CombinedOutput() fmt.Println("original sha256sum: " + string(out)) Expect(err).NotTo(HaveOccurred()) sha256sum1 := strings.Split(string(out), " ")[0] @@ -104,7 +104,7 @@ var _ = Describe("Preheat with manager", func() { } ) - var seedPeerPods [3]*e2eutil.PodExec + var seedPeerPods [3]*util.PodExec for i := 0; i < 3; i++ { seedPeerPods[i] = getSeedPeerExec(i) } @@ -140,7 +140,7 @@ var _ = Describe("Preheat with manager", func() { }) It("preheat image for linux/amd64 platform should be ok", Label("preheat", "image"), func() { - if !e2eutil.FeatureGates.Enabled(e2eutil.FeatureGatePreheatMultiArchImage) { + if !util.FeatureGates.Enabled(util.FeatureGatePreheatMultiArchImage) { fmt.Println("feature gate preheat multi arch image is disable, skip") return } @@ -165,7 +165,7 @@ var _ = Describe("Preheat with manager", func() { } ) - var seedPeerPods [3]*e2eutil.PodExec + var seedPeerPods [3]*util.PodExec for i := 0; i < 3; i++ { seedPeerPods[i] = getSeedPeerExec(i) } @@ -202,7 +202,7 @@ var _ = Describe("Preheat with manager", func() { }) It("preheat image for linux/arm64 platform should be ok", Label("preheat", "image"), func() { - if !e2eutil.FeatureGates.Enabled(e2eutil.FeatureGatePreheatMultiArchImage) { + if !util.FeatureGates.Enabled(util.FeatureGatePreheatMultiArchImage) { fmt.Println("feature gate preheat multi arch image is disable, skip") return } @@ -227,7 +227,7 @@ var _ = Describe("Preheat with manager", func() { } ) - var seedPeerPods [3]*e2eutil.PodExec + var seedPeerPods [3]*util.PodExec for i := 0; i < 3; i++ { seedPeerPods[i] = getSeedPeerExec(i) } @@ -265,7 +265,7 @@ var _ = Describe("Preheat with manager", func() { }) }) -func waitForDone(preheat *models.Job, pod *e2eutil.PodExec) bool { +func waitForDone(preheat *models.Job, pod *util.PodExec) bool { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) defer cancel() @@ -294,7 +294,7 @@ func waitForDone(preheat *models.Job, pod *e2eutil.PodExec) bool { } } -func checkPreheatResult(seedPeerPods [3]*e2eutil.PodExec, seedPeerTaskID string) (string, error) { +func checkPreheatResult(seedPeerPods [3]*util.PodExec, seedPeerTaskID string) (string, error) { var sha256sum string for _, seedPeer := range seedPeerPods { taskDir := fmt.Sprintf("%s/%s", seedPeerDataPath, seedPeerTaskID) @@ -320,23 +320,23 @@ func checkPreheatResult(seedPeerPods [3]*e2eutil.PodExec, seedPeerTaskID string) } // getSeedPeerExec get seed peer pods -func getSeedPeerExec(n int) *e2eutil.PodExec { - out, err := e2eutil.KubeCtlCommand("-n", dragonflyNamespace, "get", "pod", "-l", "component=seed-peer", +func getSeedPeerExec(n int) *util.PodExec { + out, err := util.KubeCtlCommand("-n", dragonflyNamespace, "get", "pod", "-l", "component=seed-peer", "-o", fmt.Sprintf("jsonpath='{range .items[%d]}{.metadata.name}{end}'", n)).CombinedOutput() podName := strings.Trim(string(out), "'") Expect(err).NotTo(HaveOccurred()) fmt.Println(podName) Expect(strings.HasPrefix(podName, "dragonfly-seed-peer-")).Should(BeTrue()) - return e2eutil.NewPodExec(dragonflyNamespace, podName, "seed-peer") + return util.NewPodExec(dragonflyNamespace, podName, "seed-peer") } // getFileServerExec get the file-server pod for curl -func getFileServerExec() *e2eutil.PodExec { - out, err := e2eutil.KubeCtlCommand("-n", e2eNamespace, "get", "pod", "-l", "component=file-server", +func getFileServerExec() *util.PodExec { + out, err := util.KubeCtlCommand("-n", e2eNamespace, "get", "pod", "-l", "component=file-server", "-o", "jsonpath='{range .items[*]}{.metadata.name}{end}'").CombinedOutput() podName := strings.Trim(string(out), "'") Expect(err).NotTo(HaveOccurred()) fmt.Println(podName) Expect(strings.HasPrefix(podName, "file-server-")).Should(BeTrue()) - return e2eutil.NewPodExec(e2eNamespace, podName, "") + return util.NewPodExec(e2eNamespace, podName, "") } diff --git a/test/e2e/e2eutil/artifact.go b/test/e2e/util/artifact.go similarity index 99% rename from test/e2e/e2eutil/artifact.go rename to test/e2e/util/artifact.go index 70205f944..23ab661ad 100644 --- a/test/e2e/e2eutil/artifact.go +++ b/test/e2e/util/artifact.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package e2eutil +package util import ( "fmt" diff --git a/test/e2e/e2eutil/exec.go b/test/e2e/util/exec.go similarity index 99% rename from test/e2e/e2eutil/exec.go rename to test/e2e/util/exec.go index ae6060e7d..a595bdde1 100644 --- a/test/e2e/e2eutil/exec.go +++ b/test/e2e/util/exec.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package e2eutil +package util import ( "encoding/json" diff --git a/test/e2e/e2eutil/feature_gate.go b/test/e2e/util/feature_gate.go similarity index 99% rename from test/e2e/e2eutil/feature_gate.go rename to test/e2e/util/feature_gate.go index 73eb2b5c2..ab2ffe626 100644 --- a/test/e2e/e2eutil/feature_gate.go +++ b/test/e2e/util/feature_gate.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package e2eutil +package util import "k8s.io/component-base/featuregate" diff --git a/test/e2e/e2eutil/file_server.go b/test/e2e/util/file_server.go similarity index 98% rename from test/e2e/e2eutil/file_server.go rename to test/e2e/util/file_server.go index c3a35443c..bb0798228 100644 --- a/test/e2e/e2eutil/file_server.go +++ b/test/e2e/util/file_server.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package e2eutil +package util import "fmt"