@@ -23,7 +23,6 @@ import (
2323 "encoding/base64"
2424 "fmt"
2525 "net/http"
26- "net/url"
2726 "strings"
2827 "time"
2928
@@ -944,14 +943,13 @@ spec:
944943 By ("create Ingress" )
945944 err := s .CreateResourceFromStringWithNamespace (fmt .Sprintf (ingress , s .Namespace ()), s .Namespace ())
946945 Expect (err ).NotTo (HaveOccurred (), "creating Ingress" )
947- time .Sleep (5 * time .Second )
948946
949947 By ("verify Ingress works" )
950- s .NewAPISIXClient ().
951- GET ( "/get" ).
952- WithHost ( "ingress.example.com" ).
953- Expect ().
954- Status ( 200 )
948+ s .RequestAssert ( & scaffold. RequestAssert {
949+ Method : " GET" ,
950+ Host : "ingress.example.com" ,
951+ Check : scaffold . WithExpectedStatus ( http . StatusOK ),
952+ } )
955953
956954 By ("create additional gateway group to get new admin key" )
957955 additionalGatewayGroupID , _ , err = s .Deployer .CreateAdditionalGateway ("gateway-proxy-update" )
@@ -1070,33 +1068,21 @@ spec:
10701068 createSecret (s , _secretName )
10711069 By ("create Ingress" )
10721070 Expect (s .CreateResourceFromString (fmt .Sprintf (ingressWithWSS , s .Namespace ()))).ShouldNot (HaveOccurred (), "creating Ingress" )
1073- time .Sleep (6 * time .Second )
10741071
10751072 By ("verify wss connection" )
1076- u := url.URL {
1077- Scheme : "wss" ,
1078- Host : s .GetAPISIXHTTPSEndpoint (),
1079- Path : "/ws" ,
1080- }
1081- headers := http.Header {"Host" : []string {"api6.com" }}
1082- dialer := websocket.Dialer {
1083- TLSClientConfig : & tls.Config {
1084- InsecureSkipVerify : true ,
1085- ServerName : "api6.com" ,
1086- },
1087- }
1088-
1089- conn , resp , err := dialer .Dial (u .String (), headers )
1090- Expect (err ).ShouldNot (HaveOccurred (), "WebSocket handshake" )
1091- Expect (resp .StatusCode ).Should (Equal (http .StatusSwitchingProtocols ))
1073+ hostname := "api6.com"
1074+ conn := s .NewWebsocketClient (& tls.Config {
1075+ InsecureSkipVerify : true ,
1076+ ServerName : hostname ,
1077+ }, "/ws" , http.Header {"Host" : []string {hostname }})
10921078
10931079 defer func () {
10941080 _ = conn .Close ()
10951081 }()
10961082
10971083 By ("send and receive message through WebSocket" )
10981084 testMessage := "hello, this is APISIX"
1099- err = conn .WriteMessage (websocket .TextMessage , []byte (testMessage ))
1085+ err : = conn .WriteMessage (websocket .TextMessage , []byte (testMessage ))
11001086 Expect (err ).ShouldNot (HaveOccurred (), "writing WebSocket message" )
11011087
11021088 // Then our echo
0 commit comments