Fix TestConnections pipedRequestBody flakiness

This commit is contained in:
MoofMonkey 2022-10-04 06:19:37 +03:00
parent 36554d8648
commit 17387dadc6
1 changed files with 5 additions and 0 deletions

View File

@ -683,9 +683,12 @@ func TestConnections(t *testing.T) {
req.Header = test.args.requestHeaders req.Header = test.args.requestHeaders
respWriter := test.args.eyeballResponseWriter respWriter := test.args.eyeballResponseWriter
var wg sync.WaitGroup
if pipedReqBody, ok := test.args.eyeballRequestBody.(*pipedRequestBody); ok { if pipedReqBody, ok := test.args.eyeballRequestBody.(*pipedRequestBody); ok {
respWriter = newTCPRespWriter(pipedReqBody.pipedConn) respWriter = newTCPRespWriter(pipedReqBody.pipedConn)
wg.Add(1)
go func() { go func() {
defer wg.Done()
resp := pipedReqBody.roundtrip(test.args.ingressServiceScheme + ln.Addr().String()) resp := pipedReqBody.roundtrip(test.args.ingressServiceScheme + ln.Addr().String())
replayer.Write(resp) replayer.Write(resp)
}() }()
@ -698,6 +701,8 @@ func TestConnections(t *testing.T) {
err = proxy.ProxyHTTP(respWriter, tracing.NewTracedHTTPRequest(req, &log), test.args.connectionType == connection.TypeWebsocket) err = proxy.ProxyHTTP(respWriter, tracing.NewTracedHTTPRequest(req, &log), test.args.connectionType == connection.TypeWebsocket)
} }
wg.Wait()
cancel() cancel()
assert.Equal(t, test.want.err, err != nil) assert.Equal(t, test.want.err, err != nil)
assert.Equal(t, test.want.message, replayer.Bytes()) assert.Equal(t, test.want.message, replayer.Bytes())