diff --git a/pkg/network/usm/kafka_monitor_test.go b/pkg/network/usm/kafka_monitor_test.go index 49e2154949438..ac5ea9285662f 100644 --- a/pkg/network/usm/kafka_monitor_test.go +++ b/pkg/network/usm/kafka_monitor_test.go @@ -782,6 +782,9 @@ func (can *CannedClientServer) runClient(msgs []Message) { require.NoError(can.t, err) can.t.Cleanup(func() { _ = conn.Close() }) + // Safety measure to avoid blocking forever in the case of bugs. + conn.SetDeadline(time.Now().Add(30 * time.Second)) + reader := bufio.NewReader(conn) for _, msg := range msgs { buf := make([]byte, 0)