mirror of
https://github.com/siderolabs/talos.git
synced 2025-11-28 14:11:15 +01:00
test: update events test with more flow control
Some of the event tests rely on publishing more events than buffer capacity, so consumers should be able to keep up with the producer to avoid hitting buffer overrun. Producer was rate-limited already, now adding rate limiting for consumer with higher burst, it should allow consumers to reach blocked state, but syncronizes them a bit with each other. Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
This commit is contained in:
parent
9590030a84
commit
bdd011be30
@ -79,6 +79,8 @@ func TestEvents_Publish(t *testing.T) {
|
||||
if err := e.Watch(func(events <-chan runtime.Event) {
|
||||
defer wg.Done()
|
||||
|
||||
l := rate.NewLimiter(500, tt.cap*8/10)
|
||||
|
||||
for j := 0; j < tt.messages; j++ {
|
||||
event, ok := <-events
|
||||
|
||||
@ -97,6 +99,8 @@ func TestEvents_Publish(t *testing.T) {
|
||||
}
|
||||
|
||||
atomic.AddUint32(&got, 1)
|
||||
|
||||
_ = l.Wait(context.Background()) //nolint: errcheck
|
||||
}
|
||||
}); err != nil {
|
||||
t.Errorf("Watch error %s", err)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user