Search in sources :

Example 1 with EventAggregator

use of io.kubernetes.client.extended.event.legacy.EventAggregator in project java by kubernetes-client.

the class EventAggregatorTest method testSpammingEventsShouldBeAggregated.

@Test
public void testSpammingEventsShouldBeAggregated() {
    String aggregatedMessage = "noxu";
    EventAggregator aggregator = new EventAggregator(100, EventUtils::getAggregatedAndLocalKeyByReason, event -> aggregatedMessage);
    for (int i = 0; i < aggregator.getMaxEvents() - 1; i++) {
        String message = aggregator.aggregate(new CoreV1EventBuilder().withSource(new V1EventSource()).withInvolvedObject(new V1ObjectReference()).withMessage("foo: " + i).build()).getLeft().getMessage();
        assertNotEquals(aggregatedMessage, message);
    }
    CoreV1Event aggregatedEvent = aggregator.aggregate(new CoreV1EventBuilder().withSource(new V1EventSource()).withInvolvedObject(new V1ObjectReference()).withMessage("not_noxu").build()).getLeft();
    assertEquals(aggregatedMessage, aggregatedEvent.getMessage());
}
Also used : V1ObjectReference(io.kubernetes.client.openapi.models.V1ObjectReference) EventAggregator(io.kubernetes.client.extended.event.legacy.EventAggregator) EventUtils(io.kubernetes.client.extended.event.legacy.EventUtils) V1EventSource(io.kubernetes.client.openapi.models.V1EventSource) CoreV1EventBuilder(io.kubernetes.client.openapi.models.CoreV1EventBuilder) CoreV1Event(io.kubernetes.client.openapi.models.CoreV1Event) Test(org.junit.Test)

Aggregations

EventAggregator (io.kubernetes.client.extended.event.legacy.EventAggregator)1 EventUtils (io.kubernetes.client.extended.event.legacy.EventUtils)1 CoreV1Event (io.kubernetes.client.openapi.models.CoreV1Event)1 CoreV1EventBuilder (io.kubernetes.client.openapi.models.CoreV1EventBuilder)1 V1EventSource (io.kubernetes.client.openapi.models.V1EventSource)1 V1ObjectReference (io.kubernetes.client.openapi.models.V1ObjectReference)1 Test (org.junit.Test)1