change how the multiplex test is skipped on Linux (#3817)

This commit is contained in:
Marten Seemann 2023-05-12 08:14:46 +03:00 committed by GitHub
parent 5aa2beb706
commit 22ca1fb8a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -156,58 +156,58 @@ var _ = Describe("Multiplexing", func() {
Eventually(done, timeout).Should(BeClosed()) Eventually(done, timeout).Should(BeClosed())
}) })
It("runs a server and client on the same conn", func() { // This test would require setting of iptables rules, see https://stackoverflow.com/questions/23859164/linux-udp-socket-sendto-operation-not-permitted.
if runtime.GOOS == "linux" { if runtime.GOOS != "linux" {
Skip("This test would require setting of iptables rules, see https://stackoverflow.com/questions/23859164/linux-udp-socket-sendto-operation-not-permitted.") It("runs a server and client on the same conn", func() {
} addr1, err := net.ResolveUDPAddr("udp", "localhost:0")
addr1, err := net.ResolveUDPAddr("udp", "localhost:0") Expect(err).ToNot(HaveOccurred())
Expect(err).ToNot(HaveOccurred()) conn1, err := net.ListenUDP("udp", addr1)
conn1, err := net.ListenUDP("udp", addr1) Expect(err).ToNot(HaveOccurred())
Expect(err).ToNot(HaveOccurred()) defer conn1.Close()
defer conn1.Close() tr1 := &quic.Transport{Conn: conn1}
tr1 := &quic.Transport{Conn: conn1}
addr2, err := net.ResolveUDPAddr("udp", "localhost:0") addr2, err := net.ResolveUDPAddr("udp", "localhost:0")
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
conn2, err := net.ListenUDP("udp", addr2) conn2, err := net.ListenUDP("udp", addr2)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
defer conn2.Close() defer conn2.Close()
tr2 := &quic.Transport{Conn: conn2} tr2 := &quic.Transport{Conn: conn2}
server1, err := tr1.Listen( server1, err := tr1.Listen(
getTLSConfig(), getTLSConfig(),
getQuicConfig(nil), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
runServer(server1) runServer(server1)
defer server1.Close() defer server1.Close()
server2, err := tr2.Listen( server2, err := tr2.Listen(
getTLSConfig(), getTLSConfig(),
getQuicConfig(nil), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
runServer(server2) runServer(server2)
defer server2.Close() defer server2.Close()
done1 := make(chan struct{}) done1 := make(chan struct{})
done2 := make(chan struct{}) done2 := make(chan struct{})
go func() { go func() {
defer GinkgoRecover() defer GinkgoRecover()
dial(tr2, server1.Addr()) dial(tr2, server1.Addr())
close(done1) close(done1)
}() }()
go func() { go func() {
defer GinkgoRecover() defer GinkgoRecover()
dial(tr1, server2.Addr()) dial(tr1, server2.Addr())
close(done2) close(done2)
}() }()
timeout := 30 * time.Second timeout := 30 * time.Second
if debugLog() { if debugLog() {
timeout = time.Minute timeout = time.Minute
} }
Eventually(done1, timeout).Should(BeClosed()) Eventually(done1, timeout).Should(BeClosed())
Eventually(done2, timeout).Should(BeClosed()) Eventually(done2, timeout).Should(BeClosed())
}) })
}
}) })
}) })