From 58c3121c6b3afe54ddb31edc5efca613142bbe4e Mon Sep 17 00:00:00 2001 From: David Fifield Date: Thu, 29 Jun 2023 21:10:58 +0000 Subject: [PATCH] Close temporary UDPSession in TestQueuePacketConnWriteToKCP. With these not being closed, they were continuing to consume resources after the return of the test function, which was affecting the later BenchmarkSendQueue. Before: ``` snowflake/common/turbotunnel$ go test -bench BenchmarkSendQueue -v === RUN TestQueueIncomingOversize --- PASS: TestQueueIncomingOversize (0.00s) === RUN TestWriteToOversize --- PASS: TestWriteToOversize (0.00s) === RUN TestRestoreMTU --- PASS: TestRestoreMTU (0.00s) === RUN TestRestoreCap --- PASS: TestRestoreCap (0.00s) === RUN TestQueuePacketConnWriteToKCP --- PASS: TestQueuePacketConnWriteToKCP (1.01s) goos: linux goarch: amd64 pkg: gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/turbotunnel cpu: Intel(R) Core(TM) i5 CPU 680 @ 3.60GHz BenchmarkSendQueue BenchmarkSendQueue-4 8519708 136.0 ns/op PASS ok gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/turbotunnel 3.481s ``` After: ``` snowflake/common/turbotunnel$ go test -bench BenchmarkSendQueue -v === RUN TestQueueIncomingOversize --- PASS: TestQueueIncomingOversize (0.00s) === RUN TestWriteToOversize --- PASS: TestWriteToOversize (0.00s) === RUN TestRestoreMTU --- PASS: TestRestoreMTU (0.00s) === RUN TestRestoreCap --- PASS: TestRestoreCap (0.00s) === RUN TestQueuePacketConnWriteToKCP --- PASS: TestQueuePacketConnWriteToKCP (1.02s) goos: linux goarch: amd64 pkg: gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/turbotunnel cpu: Intel(R) Core(TM) i5 CPU 680 @ 3.60GHz BenchmarkSendQueue BenchmarkSendQueue-4 11620237 105.7 ns/op PASS ok gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/turbotunnel 3.244s ``` --- common/turbotunnel/queuepacketconn_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/common/turbotunnel/queuepacketconn_test.go b/common/turbotunnel/queuepacketconn_test.go index b9f62c9..30e69e3 100644 --- a/common/turbotunnel/queuepacketconn_test.go +++ b/common/turbotunnel/queuepacketconn_test.go @@ -182,6 +182,7 @@ func TestQueuePacketConnWriteToKCP(t *testing.T) { if err != nil { panic(err) } + conn.Close() // Signal the main test to start once we have done one // iterator of this noisy loop. readyClose.Do(func() { close(ready) })