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"
|
"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