From e358e75681288c360ac1360f0acf0311d16821f1 Mon Sep 17 00:00:00 2001 From: tanjunchen Date: Wed, 8 Apr 2020 18:03:15 +0800 Subject: [PATCH] test/e2e/scheduling:improve code --- test/e2e/scheduling/nvidia-gpus.go | 2 +- test/e2e/scheduling/predicates.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/scheduling/nvidia-gpus.go b/test/e2e/scheduling/nvidia-gpus.go index 9c751de1cd2..09c43ad224c 100644 --- a/test/e2e/scheduling/nvidia-gpus.go +++ b/test/e2e/scheduling/nvidia-gpus.go @@ -288,11 +288,11 @@ func VerifyJobNCompletions(f *framework.Framework, completions int32) { framework.Logf("Got the following pods for job cuda-add: %v", createdPodNames) successes := int32(0) + regex := regexp.MustCompile("PASSED") for _, podName := range createdPodNames { f.PodClient().WaitForFinish(podName, 5*time.Minute) logs, err := e2epod.GetPodLogs(f.ClientSet, ns, podName, "vector-addition") framework.ExpectNoError(err, "Should be able to get logs for pod %v", podName) - regex := regexp.MustCompile("PASSED") if regex.MatchString(logs) { successes++ } diff --git a/test/e2e/scheduling/predicates.go b/test/e2e/scheduling/predicates.go index 462646e177d..03526b96211 100644 --- a/test/e2e/scheduling/predicates.go +++ b/test/e2e/scheduling/predicates.go @@ -1039,7 +1039,7 @@ func createHostPortPodOnNode(f *framework.Framework, podName, ns, hostIP string, // adding the well known prefix "0::ffff:" https://tools.ietf.org/html/rfc2765 // if the ip is IPv4 and the cluster IPFamily is IPv6, otherwise returns the same ip func translateIPv4ToIPv6(ip string) string { - if framework.TestContext.IPFamily == "ipv6" && !k8utilnet.IsIPv6String(ip) && ip != "" { + if framework.TestContext.IPFamily == "ipv6" && ip != "" && !k8utilnet.IsIPv6String(ip) { ip = "0::ffff:" + ip } return ip