forked from quic-go/quic-go
fix race condition in tests when setting the key update interval (#5121)
* fix race conditions in tests when setting the key update interval * remove test for running transports and handshakes
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/quic-go/quic-go"
|
||||
"github.com/quic-go/quic-go/internal/handshake"
|
||||
"github.com/quic-go/quic-go/internal/protocol"
|
||||
"github.com/quic-go/quic-go/logging"
|
||||
|
||||
@@ -15,9 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestKeyUpdates(t *testing.T) {
|
||||
origKeyUpdateInterval := handshake.KeyUpdateInterval
|
||||
t.Cleanup(func() { handshake.KeyUpdateInterval = origKeyUpdateInterval })
|
||||
handshake.KeyUpdateInterval = 1 // update keys as frequently as possible
|
||||
t.Setenv("QUIC_GO_TEST_KEY_UPDATE_INTERVAL", "1") // update keys as frequently as possible
|
||||
|
||||
var sentHeaders []*logging.ShortHeader
|
||||
var receivedHeaders []*logging.ShortHeader
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package self_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
@@ -11,9 +10,7 @@ import (
|
||||
"math/rand/v2"
|
||||
"net"
|
||||
"os"
|
||||
"runtime/pprof"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -161,12 +158,6 @@ func newUDPConnLocalhost(t testing.TB) *net.UDPConn {
|
||||
return conn
|
||||
}
|
||||
|
||||
func areTransportsRunning() bool {
|
||||
var b bytes.Buffer
|
||||
pprof.Lookup("goroutine").WriteTo(&b, 1)
|
||||
return strings.Contains(b.String(), "quic-go.(*Transport).listen")
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
var versionParam string
|
||||
flag.StringVar(&versionParam, "version", "1", "QUIC version")
|
||||
@@ -184,15 +175,7 @@ func TestMain(m *testing.M) {
|
||||
}
|
||||
fmt.Printf("using QUIC version: %s\n", version)
|
||||
|
||||
status := m.Run()
|
||||
if status != 0 {
|
||||
os.Exit(status)
|
||||
}
|
||||
if areTransportsRunning() {
|
||||
fmt.Println("stray transport goroutines found")
|
||||
os.Exit(1)
|
||||
}
|
||||
os.Exit(status)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
func scaleDuration(d time.Duration) time.Duration {
|
||||
|
||||
Reference in New Issue
Block a user