@@ -587,7 +587,7 @@ var _ = SIGDescribe("Kubectl Port forwarding", func() {
587
587
for sentBodySize := 0 ; sentBodySize < 1024 * 1024 * 1024 ; {
588
588
size := rand .Intn (4 * 1024 * 1024 )
589
589
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 )
591
591
if err != nil {
592
592
errorChan <- err
593
593
}
@@ -611,7 +611,10 @@ var _ = SIGDescribe("Kubectl Port forwarding", func() {
611
611
612
612
ginkgo .By ("Check the client error" )
613
613
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" )))
615
618
616
619
ginkgo .By ("Check kubectl port-forward exit code" )
617
620
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 {
695
698
return err
696
699
}
697
700
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 ,
701
705
}
702
- client := & http.Client {Transport : transport }
703
706
req , err := http .NewRequest (http .MethodPost , url , reader )
704
707
if err != nil {
705
708
return "" , err
0 commit comments