@@ -23,7 +23,6 @@ import (
2323 "encoding/base64"
2424 "fmt"
2525 "net/http"
26- "net/url"
2726 "strings"
2827 "time"
2928
@@ -992,14 +991,13 @@ spec:
992991 By ("create Ingress" )
993992 err := s .CreateResourceFromStringWithNamespace (fmt .Sprintf (ingress , s .Namespace ()), s .Namespace ())
994993 Expect (err ).NotTo (HaveOccurred (), "creating Ingress" )
995- time .Sleep (5 * time .Second )
996994
997995 By ("verify Ingress works" )
998- s .NewAPISIXClient ().
999- GET ( "/get" ).
1000- WithHost ( "ingress.example.com" ).
1001- Expect ().
1002- Status ( 200 )
996+ s .RequestAssert ( & scaffold. RequestAssert {
997+ Method : " GET" ,
998+ Host : "ingress.example.com" ,
999+ Check : scaffold . WithExpectedStatus ( http . StatusOK ),
1000+ } )
10031001
10041002 By ("create additional gateway group to get new admin key" )
10051003 additionalGatewayGroupID , _ , err = s .Deployer .CreateAdditionalGateway ("gateway-proxy-update" )
@@ -1121,30 +1119,13 @@ spec:
11211119 createSecret (s , _secretName )
11221120 By ("create Ingress" )
11231121 Expect (s .CreateResourceFromString (fmt .Sprintf (ingressWithWSS , s .Namespace ()))).ShouldNot (HaveOccurred (), "creating Ingress" )
1124- time .Sleep (6 * time .Second )
11251122
11261123 By ("verify wss connection" )
1127- u := url.URL {
1128- Scheme : "wss" ,
1129- Host : s .GetAPISIXHTTPSEndpoint (),
1130- Path : "/ws" ,
1131- }
1132- headers := http.Header {"Host" : []string {"api6.com" }}
1133- dialer := websocket.Dialer {
1134- TLSClientConfig : & tls.Config {
1135- InsecureSkipVerify : true ,
1136- ServerName : "api6.com" ,
1137- },
1138- }
1139-
1140- var conn * websocket.Conn
1141- var resp * http.Response
1142- Eventually (func () error {
1143- var dialErr error
1144- conn , resp , dialErr = dialer .Dial (u .String (), headers )
1145- return dialErr
1146- }).WithTimeout (30 * time .Second ).WithPolling (2 * time .Second ).Should (Succeed (), "WebSocket handshake should succeed" )
1147- Expect (resp .StatusCode ).Should (Equal (http .StatusSwitchingProtocols ))
1124+ hostname := "api6.com"
1125+ conn := s .NewWebsocketClient (& tls.Config {
1126+ InsecureSkipVerify : true ,
1127+ ServerName : hostname ,
1128+ }, "/ws" , http.Header {"Host" : []string {hostname }})
11481129
11491130 defer func () {
11501131 _ = conn .Close ()
0 commit comments