mirror of https://github.com/k3s-io/k3s
Let port forwarding e2e tests timeout on kubectl calls
parent
8e25b7c7bf
commit
f1b6158a6d
|
@ -24,8 +24,10 @@ import (
|
|||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
)
|
||||
|
@ -110,6 +112,20 @@ func runPortForward(ns, podName string, port int) (*exec.Cmd, int) {
|
|||
return cmd, listenPort
|
||||
}
|
||||
|
||||
func runKubectlWithTimeout(timeout time.Duration, args ...string) string {
|
||||
logOutput := make(chan string)
|
||||
go func() {
|
||||
logOutput <- runKubectl(args...)
|
||||
}()
|
||||
select {
|
||||
case <-time.After(timeout):
|
||||
Failf("kubectl timed out")
|
||||
return ""
|
||||
case o := <-logOutput:
|
||||
return o
|
||||
}
|
||||
}
|
||||
|
||||
var _ = Describe("Port forwarding", func() {
|
||||
framework := NewFramework("port-forwarding")
|
||||
|
||||
|
@ -133,7 +149,7 @@ var _ = Describe("Port forwarding", func() {
|
|||
By("Closing the connection to the local port")
|
||||
conn.Close()
|
||||
|
||||
logOutput := runKubectl("logs", fmt.Sprintf("--namespace=%v", framework.Namespace.Name), "-f", podName)
|
||||
logOutput := runKubectlWithTimeout(util.ForeverTestTimeout, "logs", fmt.Sprintf("--namespace=%v", framework.Namespace.Name), "-f", podName)
|
||||
verifyLogMessage(logOutput, "Accepted client connection")
|
||||
verifyLogMessage(logOutput, "Expected to read 3 bytes from client, but got 0 instead")
|
||||
})
|
||||
|
@ -178,7 +194,7 @@ var _ = Describe("Port forwarding", func() {
|
|||
Failf("Expected %q from server, got %q", e, a)
|
||||
}
|
||||
|
||||
logOutput := runKubectl("logs", fmt.Sprintf("--namespace=%v", framework.Namespace.Name), "-f", podName)
|
||||
logOutput := runKubectlWithTimeout(util.ForeverTestTimeout, "logs", fmt.Sprintf("--namespace=%v", framework.Namespace.Name), "-f", podName)
|
||||
verifyLogMessage(logOutput, "^Accepted client connection$")
|
||||
verifyLogMessage(logOutput, "^Received expected client data$")
|
||||
verifyLogMessage(logOutput, "^Done$")
|
||||
|
@ -215,7 +231,7 @@ var _ = Describe("Port forwarding", func() {
|
|||
Failf("Expected %q from server, got %q", e, a)
|
||||
}
|
||||
|
||||
logOutput := runKubectl("logs", fmt.Sprintf("--namespace=%v", framework.Namespace.Name), "-f", podName)
|
||||
logOutput := runKubectlWithTimeout(util.ForeverTestTimeout, "logs", fmt.Sprintf("--namespace=%v", framework.Namespace.Name), "-f", podName)
|
||||
verifyLogMessage(logOutput, "Accepted client connection")
|
||||
verifyLogMessage(logOutput, "Done")
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue