Skip to content

Commit cf480a3

Browse files
authored
Merge pull request kubernetes#128800 from soltysh/flake_128742
Add timeout for port-forward test
2 parents 23e7643 + 9e87e99 commit cf480a3

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

test/e2e/kubectl/portforward.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ var _ = SIGDescribe("Kubectl Port forwarding", func() {
587587
for sentBodySize := 0; sentBodySize < 1024*1024*1024; {
588588
size := rand.Intn(4 * 1024 * 1024)
589589
url := fmt.Sprintf("http://localhost:%d/header", cmd.port)
590-
_, err := post(url, strings.NewReader(strings.Repeat("x", size)), nil)
590+
_, err := post(url, strings.NewReader(strings.Repeat("x", size)), 10*time.Second)
591591
if err != nil {
592592
errorChan <- err
593593
}
@@ -611,7 +611,10 @@ var _ = SIGDescribe("Kubectl Port forwarding", func() {
611611

612612
ginkgo.By("Check the client error")
613613
gomega.Expect(err).To(gomega.HaveOccurred())
614-
gomega.Expect(err.Error()).To(gomega.Or(gomega.ContainSubstring("connection reset by peer"), gomega.ContainSubstring("EOF")))
614+
gomega.Expect(err.Error()).To(gomega.Or(
615+
gomega.ContainSubstring("connection reset by peer"),
616+
gomega.ContainSubstring("EOF"),
617+
gomega.ContainSubstring("context deadline exceeded")))
615618

616619
ginkgo.By("Check kubectl port-forward exit code")
617620
gomega.Expect(cmd.cmd.ProcessState.ExitCode()).To(gomega.BeNumerically("<", 0), "kubectl port-forward should finish with non-zero exit code")
@@ -695,11 +698,11 @@ func wsWrite(conn *websocket.Conn, channel byte, data []byte) error {
695698
return err
696699
}
697700

698-
func post(url string, reader io.Reader, transport *http.Transport) (string, error) {
699-
if transport == nil {
700-
transport = utilnet.SetTransportDefaults(&http.Transport{})
701+
func post(url string, reader io.Reader, timeout time.Duration) (string, error) {
702+
client := &http.Client{
703+
Transport: utilnet.SetTransportDefaults(&http.Transport{}),
704+
Timeout: timeout,
701705
}
702-
client := &http.Client{Transport: transport}
703706
req, err := http.NewRequest(http.MethodPost, url, reader)
704707
if err != nil {
705708
return "", err

0 commit comments

Comments
 (0)