use of io.kubernetes.client.extended.event.legacy.EventSpamFilter in project java by kubernetes-client.
the class EventSpamFilterTest method testSpammingEventFiltering.
@Test
public void testSpammingEventFiltering() {
int burst = 10;
EventSpamFilter filter = new EventSpamFilter(100, EventUtils::getSpamKey, burst, Duration.ofDays(1), // never refill
1);
CoreV1Event spammingEvent1 = new CoreV1EventBuilder().withMessage("1").withSource(new V1EventSourceBuilder().withComponent("c1").build()).withInvolvedObject(new V1ObjectReference()).build();
CoreV1Event spammingEvent2 = new CoreV1EventBuilder().withMessage("2").withSource(new V1EventSourceBuilder().withComponent("c1").build()).withInvolvedObject(new V1ObjectReference()).build();
CoreV1Event spammingEvent3 = new CoreV1EventBuilder().withMessage("3").withSource(new V1EventSourceBuilder().withComponent("c2").build()).withInvolvedObject(new V1ObjectReference()).build();
for (int i = 0; i < burst; i++) {
assertEquals(true, filter.filter(spammingEvent1));
}
assertEquals(false, filter.filter(spammingEvent1));
assertEquals(false, filter.filter(spammingEvent2));
assertEquals(true, filter.filter(spammingEvent3));
}
Aggregations