diff --git a/pkg/network/testutil/ping.go b/pkg/network/testutil/ping.go index 20d23c216e250b..830613b1dd616a 100644 --- a/pkg/network/testutil/ping.go +++ b/pkg/network/testutil/ping.go @@ -65,6 +65,11 @@ func PingUDP(tb require.TestingT, ip net.IP, port int) net.Conn { return nil } + bs := make([]byte, 10) + n, err := conn.Read(bs) + require.NoError(tb, err) + require.Equal(tb, []byte("pong"), bs[:n]) + return conn } diff --git a/pkg/network/testutil/server.go b/pkg/network/testutil/server.go index 8dc22615de6869..0fdc9a561113cc 100644 --- a/pkg/network/testutil/server.go +++ b/pkg/network/testutil/server.go @@ -110,14 +110,19 @@ func StartServerUDP(t *testing.T, ip net.IP, port int) io.Closer { Port: port, } - l, err := net.ListenUDP(network, addr) + udpConn, err := net.ListenUDP(network, addr) require.NoError(t, err) go func() { close(ch) for { bs := make([]byte, 10) - _, err := l.Read(bs) + _, addr, err := udpConn.ReadFrom(bs) + if err != nil { + return + } + + _, err = udpConn.WriteTo([]byte("pong"), addr) if err != nil { return } @@ -132,5 +137,5 @@ func StartServerUDP(t *testing.T, ip net.IP, port int) io.Closer { } }, 3*time.Second, 10*time.Millisecond, "timed out waiting for UDP server to come up") - return l + return udpConn }