forked from quic-go/quic-go
proxy: fix test timeout failures during cleanup (#5010)
Several proxy tests timed out because it got stuck in the packet read
loop after all tests have run. Avoid this by running the `conn.Close()`
Cleanup call from `newUPDConnLocalhost` before the timeout handler.
Update CI to run these tests.
Fixes: 3e87ea3f50 ("proxy: add function to simulate NAT rebinding (#4922)")
Relates to: #5009
This commit is contained in:
2
.github/workflows/integration.yml
vendored
2
.github/workflows/integration.yml
vendored
@@ -47,7 +47,7 @@ jobs:
|
|||||||
run: echo "GOARCH=386" >> $GITHUB_ENV
|
run: echo "GOARCH=386" >> $GITHUB_ENV
|
||||||
- run: go version
|
- run: go version
|
||||||
- name: Run tools tests
|
- name: Run tools tests
|
||||||
run: go test ${{ env.RACEFLAG }} -v -timeout 30s -shuffle=on ./integrationtests/tools
|
run: go test ${{ env.RACEFLAG }} -v -timeout 30s -shuffle=on ./integrationtests/tools/...
|
||||||
- name: Run version negotiation tests
|
- name: Run version negotiation tests
|
||||||
run: go test ${{ env.RACEFLAG }} -v -timeout 30s -shuffle=on ./integrationtests/versionnegotiation ${{ env.QLOGFLAG }}
|
run: go test ${{ env.RACEFLAG }} -v -timeout 30s -shuffle=on ./integrationtests/versionnegotiation ${{ env.QLOGFLAG }}
|
||||||
- name: Run self tests, using QUIC v1
|
- name: Run self tests, using QUIC v1
|
||||||
|
|||||||
@@ -79,10 +79,17 @@ func readPacketNumber(t *testing.T, b []byte) protocol.PacketNumber {
|
|||||||
// Set up a dumb UDP server.
|
// Set up a dumb UDP server.
|
||||||
// In production this would be a QUIC server.
|
// In production this would be a QUIC server.
|
||||||
func runServer(t *testing.T) (*net.UDPAddr, chan []byte) {
|
func runServer(t *testing.T) (*net.UDPAddr, chan []byte) {
|
||||||
serverConn := newUPDConnLocalhost(t)
|
|
||||||
|
|
||||||
serverReceivedPackets := make(chan []byte, 100)
|
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
|
t.Cleanup(func() {
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
t.Fatal("timeout")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
serverConn := newUPDConnLocalhost(t)
|
||||||
|
serverReceivedPackets := make(chan []byte, 100)
|
||||||
go func() {
|
go func() {
|
||||||
defer close(done)
|
defer close(done)
|
||||||
for {
|
for {
|
||||||
@@ -100,14 +107,6 @@ func runServer(t *testing.T) (*net.UDPAddr, chan []byte) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
t.Cleanup(func() {
|
|
||||||
select {
|
|
||||||
case <-done:
|
|
||||||
case <-time.After(time.Second):
|
|
||||||
t.Fatalf("timeout")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return serverConn.LocalAddr().(*net.UDPAddr), serverReceivedPackets
|
return serverConn.LocalAddr().(*net.UDPAddr), serverReceivedPackets
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -433,11 +432,8 @@ func TestProxySwitchConn(t *testing.T) {
|
|||||||
Data []byte
|
Data []byte
|
||||||
Addr *net.UDPAddr
|
Addr *net.UDPAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
serverReceivedPackets := make(chan packet, 1)
|
serverReceivedPackets := make(chan packet, 1)
|
||||||
done := make(chan struct{})
|
|
||||||
go func() {
|
go func() {
|
||||||
defer close(done)
|
|
||||||
for {
|
for {
|
||||||
buf := make([]byte, 1000)
|
buf := make([]byte, 1000)
|
||||||
n, addr, err := serverConn.ReadFromUDP(buf)
|
n, addr, err := serverConn.ReadFromUDP(buf)
|
||||||
|
|||||||
Reference in New Issue
Block a user