refactor: replace framework.Failf with e2elog.Failf

This commit is contained in:
SataQiu
2019-06-19 17:52:35 +08:00
parent 9162d932cf
commit 332be4b1e3
144 changed files with 767 additions and 723 deletions

View File

@@ -175,7 +175,7 @@ func runPortForward(ns, podName string, port int) *portForwardCommand {
e2elog.Logf("starting port-forward command and streaming output")
portOutput, _, err := framework.StartCmdAndStreamOutput(cmd)
if err != nil {
framework.Failf("Failed to start port-forward command: %v", err)
e2elog.Failf("Failed to start port-forward command: %v", err)
}
buf := make([]byte, 128)
@@ -183,17 +183,17 @@ func runPortForward(ns, podName string, port int) *portForwardCommand {
var n int
e2elog.Logf("reading from `kubectl port-forward` command's stdout")
if n, err = portOutput.Read(buf); err != nil {
framework.Failf("Failed to read from kubectl port-forward stdout: %v", err)
e2elog.Failf("Failed to read from kubectl port-forward stdout: %v", err)
}
portForwardOutput := string(buf[:n])
match := portForwardRegexp.FindStringSubmatch(portForwardOutput)
if len(match) != 3 {
framework.Failf("Failed to parse kubectl port-forward output: %s", portForwardOutput)
e2elog.Failf("Failed to parse kubectl port-forward output: %s", portForwardOutput)
}
listenPort, err := strconv.Atoi(match[2])
if err != nil {
framework.Failf("Error converting %s to an int: %v", match[2], err)
e2elog.Failf("Error converting %s to an int: %v", match[2], err)
}
return &portForwardCommand{
@@ -206,10 +206,10 @@ func doTestConnectSendDisconnect(bindAddress string, f *framework.Framework) {
ginkgo.By("Creating the target pod")
pod := pfPod("", "10", "10", "100", fmt.Sprintf("%s", bindAddress))
if _, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod); err != nil {
framework.Failf("Couldn't create pod: %v", err)
e2elog.Failf("Couldn't create pod: %v", err)
}
if err := f.WaitForPodReady(pod.Name); err != nil {
framework.Failf("Pod did not start running: %v", err)
e2elog.Failf("Pod did not start running: %v", err)
}
ginkgo.By("Running 'kubectl port-forward'")
@@ -219,7 +219,7 @@ func doTestConnectSendDisconnect(bindAddress string, f *framework.Framework) {
ginkgo.By("Dialing the local port")
conn, err := net.Dial("tcp", fmt.Sprintf("127.0.0.1:%d", cmd.port))
if err != nil {
framework.Failf("Couldn't connect to port %d: %v", cmd.port, err)
e2elog.Failf("Couldn't connect to port %d: %v", cmd.port, err)
}
defer func() {
ginkgo.By("Closing the connection to the local port")
@@ -229,16 +229,16 @@ func doTestConnectSendDisconnect(bindAddress string, f *framework.Framework) {
ginkgo.By("Reading data from the local port")
fromServer, err := ioutil.ReadAll(conn)
if err != nil {
framework.Failf("Unexpected error reading data from the server: %v", err)
e2elog.Failf("Unexpected error reading data from the server: %v", err)
}
if e, a := strings.Repeat("x", 100), string(fromServer); e != a {
framework.Failf("Expected %q from server, got %q", e, a)
e2elog.Failf("Expected %q from server, got %q", e, a)
}
ginkgo.By("Waiting for the target pod to stop running")
if err := WaitForTerminatedContainer(f, pod, "portforwardtester"); err != nil {
framework.Failf("Container did not terminate: %v", err)
e2elog.Failf("Container did not terminate: %v", err)
}
ginkgo.By("Verifying logs")
@@ -254,10 +254,10 @@ func doTestMustConnectSendNothing(bindAddress string, f *framework.Framework) {
ginkgo.By("Creating the target pod")
pod := pfPod("abc", "1", "1", "1", fmt.Sprintf("%s", bindAddress))
if _, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod); err != nil {
framework.Failf("Couldn't create pod: %v", err)
e2elog.Failf("Couldn't create pod: %v", err)
}
if err := f.WaitForPodReady(pod.Name); err != nil {
framework.Failf("Pod did not start running: %v", err)
e2elog.Failf("Pod did not start running: %v", err)
}
ginkgo.By("Running 'kubectl port-forward'")
@@ -267,7 +267,7 @@ func doTestMustConnectSendNothing(bindAddress string, f *framework.Framework) {
ginkgo.By("Dialing the local port")
conn, err := net.Dial("tcp", fmt.Sprintf("127.0.0.1:%d", cmd.port))
if err != nil {
framework.Failf("Couldn't connect to port %d: %v", cmd.port, err)
e2elog.Failf("Couldn't connect to port %d: %v", cmd.port, err)
}
ginkgo.By("Closing the connection to the local port")
@@ -275,7 +275,7 @@ func doTestMustConnectSendNothing(bindAddress string, f *framework.Framework) {
ginkgo.By("Waiting for the target pod to stop running")
if err := WaitForTerminatedContainer(f, pod, "portforwardtester"); err != nil {
framework.Failf("Container did not terminate: %v", err)
e2elog.Failf("Container did not terminate: %v", err)
}
ginkgo.By("Verifying logs")
@@ -291,10 +291,10 @@ func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework)
ginkgo.By("Creating the target pod")
pod := pfPod("abc", "10", "10", "100", fmt.Sprintf("%s", bindAddress))
if _, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod); err != nil {
framework.Failf("Couldn't create pod: %v", err)
e2elog.Failf("Couldn't create pod: %v", err)
}
if err := f.WaitForPodReady(pod.Name); err != nil {
framework.Failf("Pod did not start running: %v", err)
e2elog.Failf("Pod did not start running: %v", err)
}
ginkgo.By("Running 'kubectl port-forward'")
@@ -304,11 +304,11 @@ func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework)
ginkgo.By("Dialing the local port")
addr, err := net.ResolveTCPAddr("tcp", fmt.Sprintf("127.0.0.1:%d", cmd.port))
if err != nil {
framework.Failf("Error resolving tcp addr: %v", err)
e2elog.Failf("Error resolving tcp addr: %v", err)
}
conn, err := net.DialTCP("tcp", nil, addr)
if err != nil {
framework.Failf("Couldn't connect to port %d: %v", cmd.port, err)
e2elog.Failf("Couldn't connect to port %d: %v", cmd.port, err)
}
defer func() {
ginkgo.By("Closing the connection to the local port")
@@ -324,16 +324,16 @@ func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework)
ginkgo.By("Reading data from the local port")
fromServer, err := ioutil.ReadAll(conn)
if err != nil {
framework.Failf("Unexpected error reading data from the server: %v", err)
e2elog.Failf("Unexpected error reading data from the server: %v", err)
}
if e, a := strings.Repeat("x", 100), string(fromServer); e != a {
framework.Failf("Expected %q from server, got %q", e, a)
e2elog.Failf("Expected %q from server, got %q", e, a)
}
ginkgo.By("Waiting for the target pod to stop running")
if err := WaitForTerminatedContainer(f, pod, "portforwardtester"); err != nil {
framework.Failf("Container did not terminate: %v", err)
e2elog.Failf("Container did not terminate: %v", err)
}
ginkgo.By("Verifying logs")
@@ -353,10 +353,10 @@ func doTestOverWebSockets(bindAddress string, f *framework.Framework) {
ginkgo.By("Creating the pod")
pod := pfPod("def", "10", "10", "100", fmt.Sprintf("%s", bindAddress))
if _, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod); err != nil {
framework.Failf("Couldn't create pod: %v", err)
e2elog.Failf("Couldn't create pod: %v", err)
}
if err := f.WaitForPodReady(pod.Name); err != nil {
framework.Failf("Pod did not start running: %v", err)
e2elog.Failf("Pod did not start running: %v", err)
}
req := f.ClientSet.CoreV1().RESTClient().Get().
@@ -369,7 +369,7 @@ func doTestOverWebSockets(bindAddress string, f *framework.Framework) {
url := req.URL()
ws, err := framework.OpenWebSocketForURL(url, config, []string{"v4.channel.k8s.io"})
if err != nil {
framework.Failf("Failed to open websocket to %s: %v", url.String(), err)
e2elog.Failf("Failed to open websocket to %s: %v", url.String(), err)
}
defer ws.Close()
@@ -404,7 +404,7 @@ func doTestOverWebSockets(bindAddress string, f *framework.Framework) {
ginkgo.By("Sending the expected data to the local port")
err = wsWrite(ws, 0, []byte("def"))
if err != nil {
framework.Failf("Failed to write to websocket %s: %v", url.String(), err)
e2elog.Failf("Failed to write to websocket %s: %v", url.String(), err)
}
ginkgo.By("Reading data from the local port")