Skip to content

Commit

Permalink
Allow TestWebSocket to pass with resolvable domains. (#6189)
Browse files Browse the repository at this point in the history
Previously this test never relied on DNS, and it relied on `--ingressendpoint` to pass with non-istio ingress implementations.  With this change, the test will pass with `--resolvabledomain=true` as well.
  • Loading branch information
mattmoor authored and pull[bot] committed Nov 18, 2020
1 parent 50b5af5 commit d93618c
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions test/e2e/websocket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,21 @@ const (

// connect attempts to establish WebSocket connection with the Service.
// It will retry until reaching `connectTimeout` duration.
func connect(t *testing.T, ingressIP string, domain string) (*websocket.Conn, error) {
u := url.URL{Scheme: "ws", Host: ingressIP, Path: "/"}
func connect(t *testing.T, clients *test.Clients, domain string) (*websocket.Conn, error) {
var (
err error
address string
)

if test.ServingFlags.ResolvableDomain {
address = domain
} else if pkgTest.Flags.IngressEndpoint != "" {
address = pkgTest.Flags.IngressEndpoint
} else if address, err = ingress.GetIngressEndpoint(clients.KubeClient.Kube); err != nil {
return nil, err
}

u := url.URL{Scheme: "ws", Host: address, Path: "/"}
var conn *websocket.Conn
waitErr := wait.PollImmediate(connectRetryInterval, connectTimeout, func() (bool, error) {
t.Logf("Connecting using websocket: url=%s, host=%s", u.String(), domain)
Expand Down Expand Up @@ -72,15 +85,9 @@ func connect(t *testing.T, ingressIP string, domain string) (*websocket.Conn, er

func validateWebSocketConnection(t *testing.T, clients *test.Clients, names test.ResourceNames) error {
var err error
gatewayIP := pkgTest.Flags.IngressEndpoint
if pkgTest.Flags.IngressEndpoint == "" {
if gatewayIP, err = ingress.GetIngressEndpoint(clients.KubeClient.Kube); err != nil {
return err
}
}

// Establish the websocket connection.
conn, err := connect(t, gatewayIP, names.URL.Hostname())
conn, err := connect(t, clients, names.URL.Hostname())
if err != nil {
return err
}
Expand Down

0 comments on commit d93618c

Please sign in to comment.