Skip to content

Commit a6b47f3

Browse files
committed
fix: r
Signed-off-by: Ashing Zheng <[email protected]>
1 parent 75df484 commit a6b47f3

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

internal/adc/translator/apisixroute.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ func (t *Translator) translateHTTPRule(tctx *provider.TranslateContext, ar *apiv
7272

7373
var enableWebsocket *bool
7474
service := t.buildService(ar, rule, ruleIndex)
75-
t.buildRoute(ar, service, rule, plugins, timeout, vars, &enableWebsocket)
75+
// should build upstream before route because route needs to know the enableWebsocket flag
7676
t.buildUpstream(tctx, service, ar, rule, ruleIndex, &enableWebsocket)
77+
t.buildRoute(ar, service, rule, plugins, timeout, vars, &enableWebsocket)
7778

7879
return service, nil
7980
}

test/e2e/crds/v2/route.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,9 +2319,8 @@ spec:
23192319

23202320
applier.MustApplyAPIv2(types.NamespacedName{Namespace: s.Namespace(), Name: "default"},
23212321
new(apiv2.ApisixRoute), fmt.Sprintf(apisixRouteWithBackendWSS, s.Namespace()))
2322-
time.Sleep(6 * time.Second)
23232322

2324-
By("verify wss connection")
2323+
By("verify wss connection with retry")
23252324
u := url.URL{
23262325
Scheme: "wss",
23272326
Host: s.GetAPISIXHTTPSEndpoint(),
@@ -2335,8 +2334,13 @@ spec:
23352334
},
23362335
}
23372336

2338-
conn, resp, err := dialer.Dial(u.String(), headers)
2339-
Expect(err).ShouldNot(HaveOccurred(), "WebSocket handshake")
2337+
var conn *websocket.Conn
2338+
var resp *http.Response
2339+
Eventually(func() error {
2340+
var dialErr error
2341+
conn, resp, dialErr = dialer.Dial(u.String(), headers)
2342+
return dialErr
2343+
}).WithTimeout(30*time.Second).WithPolling(2*time.Second).Should(Succeed(), "WebSocket handshake should succeed")
23402344
Expect(resp.StatusCode).Should(Equal(http.StatusSwitchingProtocols))
23412345

23422346
defer func() {

0 commit comments

Comments
 (0)