Search in sources :

Example 1 with IslStatusUpdateNotification

use of org.openkilda.messaging.info.event.IslStatusUpdateNotification in project open-kilda by telstra.

the class CacheServiceTest method handleUpdateCacheInactiveTest.

@Test()
public void handleUpdateCacheInactiveTest() {
    IslStatusUpdateNotification notification = new IslStatusUpdateNotification(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, INACTIVE);
    updateIslStatus(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, INACTIVE);
    updateIslStatus(SWITCH_ID_2, PORT_2, SWITCH_ID_1, PORT_1, INACTIVE);
    cacheService.handleUpdateCache(notification);
    IslRoundTripLatency forward = new IslRoundTripLatency(SWITCH_ID_1, PORT_1, 1, 0L);
    checkHandleGetDataFromCache(forward, SWITCH_ID_2, PORT_2);
    IslRoundTripLatency reverse = new IslRoundTripLatency(SWITCH_ID_2, PORT_2, 1, 0L);
    checkHandleGetDataFromCache(reverse, SWITCH_ID_1, PORT_1);
}
Also used : IslStatusUpdateNotification(org.openkilda.messaging.info.event.IslStatusUpdateNotification) IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 2 with IslStatusUpdateNotification

use of org.openkilda.messaging.info.event.IslStatusUpdateNotification in project open-kilda by telstra.

the class CacheServiceTest method testHandleUpdateCache.

private void testHandleUpdateCache(IslStatus islStatus) {
    IslStatusUpdateNotification notification = new IslStatusUpdateNotification(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, islStatus);
    updateIslStatus(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, islStatus);
    updateIslStatus(SWITCH_ID_2, PORT_2, SWITCH_ID_1, PORT_1, islStatus);
    cacheService.handleUpdateCache(notification);
    IslRoundTripLatency forward = new IslRoundTripLatency(SWITCH_ID_1, PORT_1, 1, 0L);
    checkHandleGetDataFromCacheDidNotCallEmitCacheData(forward);
    IslRoundTripLatency reverse = new IslRoundTripLatency(SWITCH_ID_2, PORT_2, 1, 0L);
    checkHandleGetDataFromCacheDidNotCallEmitCacheData(reverse);
}
Also used : IslStatusUpdateNotification(org.openkilda.messaging.info.event.IslStatusUpdateNotification) IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency)

Example 3 with IslStatusUpdateNotification

use of org.openkilda.messaging.info.event.IslStatusUpdateNotification in project open-kilda by telstra.

the class IslStatsServiceTest method handleOneWayLatencyEmitOnEachIslDownTest.

@Test
public void handleOneWayLatencyEmitOnEachIslDownTest() throws InterruptedException {
    // RTL:      ............................
    // OneWay:   ..X.X.X.X........X.X.X.X....
    // Timeout:  ...|_________|...|_________|
    // ISL down: .........^..............^...
    List<LatencyRecord> buffer = new ArrayList<>();
    Instant time = Instant.now().minusSeconds(LATENCY_TIMEOUT).minusMillis(500);
    for (int i = 0; i < 4; i++) {
        sendForwardOneWayLatency(i, time);
        // waiting for timeout and collecting one way records
        verifyNoMoreInteractions(carrier);
        buffer.add(new LatencyRecord(i, time.toEpochMilli()));
        time = time.plusSeconds(1);
    }
    buffer.remove(0);
    islStatsService.handleIstStatusUpdateNotification(new IslStatusUpdateNotification(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, INACTIVE));
    time = Instant.now();
    int secondPartOfPacketsSize = 4;
    for (int i = 0; i < secondPartOfPacketsSize; i++) {
        sendForwardOneWayLatency(i + secondPartOfPacketsSize, time);
        buffer.add(new LatencyRecord(i + secondPartOfPacketsSize, time.toEpochMilli()));
        time = time.plusMillis(500);
        // need to real shift of system clock
        sleep(50);
    }
    islStatsService.handleIstStatusUpdateNotification(new IslStatusUpdateNotification(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, INACTIVE));
    assertEmitLatency(buffer);
}
Also used : IslStatusUpdateNotification(org.openkilda.messaging.info.event.IslStatusUpdateNotification) LatencyRecord(org.openkilda.wfm.topology.isllatency.model.LatencyRecord) Instant(java.time.Instant) ArrayList(java.util.ArrayList) Endpoint(org.openkilda.wfm.share.model.Endpoint) Test(org.junit.Test)

Example 4 with IslStatusUpdateNotification

use of org.openkilda.messaging.info.event.IslStatusUpdateNotification in project open-kilda by telstra.

the class IslStatsServiceTest method handleOneWayLatencyNoEmitOnEachIslMoveTest.

@Test
public void handleOneWayLatencyNoEmitOnEachIslMoveTest() throws InterruptedException {
    // RTL:      ............................
    // OneWay:   ..X.X.X.X........X.X.X.X....
    // Timeout:  ...|_________|...|_________|
    // ISL move: .........^..............^...
    Instant time = Instant.now().minusSeconds(LATENCY_TIMEOUT - 1);
    for (int i = 0; i < 4; i++) {
        sendForwardOneWayLatency(i, time);
        // waiting for timeout and collecting one way records
        time = time.plusSeconds(1);
    }
    islStatsService.handleIstStatusUpdateNotification(new IslStatusUpdateNotification(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, MOVED));
    time = time.plusSeconds(LATENCY_TIMEOUT + 1);
    int secondPartOfPacketsSize = 4;
    for (int i = 0; i < secondPartOfPacketsSize; i++) {
        sendForwardOneWayLatency(i + secondPartOfPacketsSize, time);
        time = time.plusMillis(50);
        // need to real shift of system clock
        sleep(50);
    }
    islStatsService.handleIstStatusUpdateNotification(new IslStatusUpdateNotification(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, MOVED));
    verifyNoMoreInteractions(carrier);
}
Also used : IslStatusUpdateNotification(org.openkilda.messaging.info.event.IslStatusUpdateNotification) Instant(java.time.Instant) Endpoint(org.openkilda.wfm.share.model.Endpoint) Test(org.junit.Test)

Example 5 with IslStatusUpdateNotification

use of org.openkilda.messaging.info.event.IslStatusUpdateNotification in project open-kilda by telstra.

the class CacheBolt method handleStatusUpdate.

private void handleStatusUpdate(Tuple tuple) throws PipelineException {
    IslStatusUpdateNotification notification = pullValue(tuple, ISL_STATUS_FIELD, IslStatusUpdateNotification.class);
    cacheService.handleUpdateCache(notification);
}
Also used : IslStatusUpdateNotification(org.openkilda.messaging.info.event.IslStatusUpdateNotification)

Aggregations

IslStatusUpdateNotification (org.openkilda.messaging.info.event.IslStatusUpdateNotification)12 Test (org.junit.Test)8 Instant (java.time.Instant)6 Endpoint (org.openkilda.wfm.share.model.Endpoint)6 ArrayList (java.util.ArrayList)3 LatencyRecord (org.openkilda.wfm.topology.isllatency.model.LatencyRecord)3 RerouteAffectedFlows (org.openkilda.messaging.command.reroute.RerouteAffectedFlows)2 IslRoundTripLatency (org.openkilda.messaging.info.event.IslRoundTripLatency)2 Isl (org.openkilda.model.Isl)2 IslReference (org.openkilda.wfm.share.model.IslReference)2 RoundTripStatus (org.openkilda.wfm.topology.network.model.RoundTripStatus)2 Duration (java.time.Duration)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 AllArgsConstructor (lombok.AllArgsConstructor)1 EqualsAndHashCode (lombok.EqualsAndHashCode)1