Skip to content

Commit

Permalink
tetragon: Fix delayed sensor unblock code
Browse files Browse the repository at this point in the history
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: #2576
Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri authored and kkourt committed Sep 13, 2024
1 parent 3c95745 commit d54fb6c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/sensors/delayed_sensor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down

0 comments on commit d54fb6c

Please sign in to comment.