From d54fb6cfec54c1c6d331d7679f166aa8c5ff0277 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Tue, 10 Sep 2024 17:15:37 +0000 Subject: [PATCH] tetragon: Fix delayed sensor unblock code The delayed sensor is used in TestPolicyListingWhileLoadUnload to check on loaded sensors states with following code path. - one go routine is periodically listing sensors and when found it calls unblock on delayed sensor that sends data on sensor's channel - another go routine is adding sensor and calls Load on delayed sensor to receive data from the sensors channel Currently the test can fail in delayed sensor's unblock if the receiving side is not ready yet, which is completely ok, because sensor is first added in the collections and only after the Load method is called. Instead of failing immediately adding 10 seconds timer on delayed sensor's unblock select. Fixes: https://github.com/cilium/tetragon/issues/2576 Signed-off-by: Jiri Olsa --- pkg/sensors/delayed_sensor_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/sensors/delayed_sensor_test.go b/pkg/sensors/delayed_sensor_test.go index ff66fadd7d0..eddb8821505 100644 --- a/pkg/sensors/delayed_sensor_test.go +++ b/pkg/sensors/delayed_sensor_test.go @@ -66,7 +66,7 @@ func (tds *TestDelayedSensor) Destroy() { func (tds *TestDelayedSensor) unblock(t *testing.T) { select { case tds.ch <- struct{}{}: - default: + case <-time.After(10 * time.Second): t.Fatalf("unblocked failed: channel does not seem to be empty") }