Search in sources :

Example 1 with EventCorrelator

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

the class EventCorrelatorTest method testEventCorrelate.

@Test
public void testEventCorrelate() throws InterruptedException {
    EventCorrelator correlator = new EventCorrelator();
    for (CoreV1Event event : previousEvents) {
        OffsetDateTime now = OffsetDateTime.now();
        event.setFirstTimestamp(now);
        event.setLastTimestamp(now);
        Optional<MutablePair<CoreV1Event, V1Patch>> result = correlator.correlate(event);
        if (!result.isPresent()) {
            correlator.updateState(event);
        }
    }
    Thread.sleep(100);
    OffsetDateTime now = OffsetDateTime.now();
    newEvent.setFirstTimestamp(now);
    newEvent.setLastTimestamp(now);
    Optional<MutablePair<CoreV1Event, V1Patch>> result = correlator.correlate(newEvent);
    assertEquals(expectedSkip, !result.isPresent());
    if (!expectedSkip) {
        CoreV1Event correlatedEvent = result.get().getLeft();
        correlatedEvent.setMetadata(new V1ObjectMetaBuilder().withName("").withNamespace("").build());
        validateEvent(expectedEvent, correlatedEvent);
    }
}
Also used : MutablePair(org.apache.commons.lang3.tuple.MutablePair) EventCorrelator(io.kubernetes.client.extended.event.legacy.EventCorrelator) OffsetDateTime(java.time.OffsetDateTime) V1ObjectMetaBuilder(io.kubernetes.client.openapi.models.V1ObjectMetaBuilder) CoreV1Event(io.kubernetes.client.openapi.models.CoreV1Event) Test(org.junit.Test)

Aggregations

EventCorrelator (io.kubernetes.client.extended.event.legacy.EventCorrelator)1 CoreV1Event (io.kubernetes.client.openapi.models.CoreV1Event)1 V1ObjectMetaBuilder (io.kubernetes.client.openapi.models.V1ObjectMetaBuilder)1 OffsetDateTime (java.time.OffsetDateTime)1 MutablePair (org.apache.commons.lang3.tuple.MutablePair)1 Test (org.junit.Test)1