mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Merge pull request #15445 from mesosphere/sttts-timeout-port-forward-tests
Auto commit by PR queue bot
This commit is contained in:
commit
f58d5d486f
@ -24,8 +24,10 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
|
"k8s.io/kubernetes/pkg/util"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
)
|
)
|
||||||
@ -110,6 +112,20 @@ func runPortForward(ns, podName string, port int) (*exec.Cmd, int) {
|
|||||||
return cmd, listenPort
|
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() {
|
var _ = Describe("Port forwarding", func() {
|
||||||
framework := NewFramework("port-forwarding")
|
framework := NewFramework("port-forwarding")
|
||||||
|
|
||||||
@ -133,7 +149,7 @@ var _ = Describe("Port forwarding", func() {
|
|||||||
By("Closing the connection to the local port")
|
By("Closing the connection to the local port")
|
||||||
conn.Close()
|
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, "Accepted client connection")
|
||||||
verifyLogMessage(logOutput, "Expected to read 3 bytes from client, but got 0 instead")
|
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)
|
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, "^Accepted client connection$")
|
||||||
verifyLogMessage(logOutput, "^Received expected client data$")
|
verifyLogMessage(logOutput, "^Received expected client data$")
|
||||||
verifyLogMessage(logOutput, "^Done$")
|
verifyLogMessage(logOutput, "^Done$")
|
||||||
@ -215,7 +231,7 @@ var _ = Describe("Port forwarding", func() {
|
|||||||
Failf("Expected %q from server, got %q", e, a)
|
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, "Accepted client connection")
|
||||||
verifyLogMessage(logOutput, "Done")
|
verifyLogMessage(logOutput, "Done")
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user