Search in sources :

Example 11 with IslRoundTripLatency

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

the class IslLatencyTopologyTest method checkTopologyMetricAndDatabaseUpdateTest.

@Test
public void checkTopologyMetricAndDatabaseUpdateTest() throws IslNotFoundException, JsonProcessingException {
    // It's hard to split this test on several tests because IslStatsBolts and IslLatencyBolt has internal states
    long latency1 = 1;
    long latency2 = 2;
    long latency3 = 3;
    long latency4 = 4;
    long latency5 = 5;
    IslOneWayLatency firstOneWayLatency = createForwardIslOneWayLatency(latency1);
    IslOneWayLatency secondOneWayLatency = createForwardIslOneWayLatency(latency3);
    IslOneWayLatency reverseOneWayLatency = createReverseIslOneWayLatency(latency5);
    IslRoundTripLatency firstRoundTripLatency = new IslRoundTripLatency(SWITCH_ID_1, PORT_1, latency2, PACKET_ID);
    IslRoundTripLatency secondRoundTripLatency = new IslRoundTripLatency(SWITCH_ID_1, PORT_1, latency4, PACKET_ID);
    // we have no round trip latency so we have to use one way latency for the database, but not for OpenTSDB
    pushMessage(firstOneWayLatency);
    assertTrue(otsdbConsumer.isEmpty());
    assertEquals(latency1 * ONE_WAY_LATENCY_MULTIPLIER, getIslLatency(FORWARD_ISL));
    // we got round trip latency so we will use it for metric and database
    long timestamp2 = pushMessage(firstRoundTripLatency);
    assertMetric(FORWARD_ISL, latency2, timestamp2);
    assertEquals(latency2, getIslLatency(FORWARD_ISL));
    // we got one way latency but bolts already has data with RTL latency. one way latency will be ignored
    pushMessage(secondOneWayLatency);
    assertTrue(otsdbConsumer.isEmpty());
    assertEquals(latency2, getIslLatency(FORWARD_ISL));
    // we got new round trip latency and it will be used for metric
    long timestamp4 = pushMessage(secondRoundTripLatency);
    assertMetric(FORWARD_ISL, latency4, timestamp4);
    // but not for database, because of big update time interval
    assertEquals(latency2, getIslLatency(FORWARD_ISL));
    // we got one way latency for reverse isl, but we already has RTL for forward ISL and we can use it
    long timestamp5 = pushMessage(reverseOneWayLatency);
    assertMetric(REVERSE_ISL, latency4, timestamp5);
    assertEquals((latency2 + latency4) / 2, getIslLatency(REVERSE_ISL));
}
Also used : IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency) IslOneWayLatency(org.openkilda.messaging.info.event.IslOneWayLatency) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 12 with IslRoundTripLatency

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

the class CacheServiceTest method handleGetDataFromCacheNonExistentIslTest.

@Test()
public void handleGetDataFromCacheNonExistentIslTest() {
    IslRoundTripLatency nonExistent = new IslRoundTripLatency(SWITCH_ID_1, 999, 1, 0L);
    checkHandleGetDataFromCacheDidNotCallEmitCacheData(nonExistent);
}
Also used : IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 13 with IslRoundTripLatency

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

the class CacheServiceTest method handleGetDataFromCacheNonExistentSwitchTest.

@Test()
public void handleGetDataFromCacheNonExistentSwitchTest() {
    IslRoundTripLatency nonExistent = new IslRoundTripLatency(new SwitchId(999), PORT_1, 1, 0L);
    checkHandleGetDataFromCacheDidNotCallEmitCacheData(nonExistent);
}
Also used : IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency) SwitchId(org.openkilda.model.SwitchId) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 14 with IslRoundTripLatency

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

the class CacheServiceTest method handleGetDataFromCacheTest.

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

Example 15 with IslRoundTripLatency

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

the class CacheServiceTest method testGetDataFromCacheNotFromInitCache.

private void testGetDataFromCacheNotFromInitCache(IslStatus islStatus) {
    int srcPort = 5;
    int dstPort = 6;
    // isl is not in init cache yet
    createIsl(switchRepository.findById(SWITCH_ID_1).get(), srcPort, switchRepository.findById(SWITCH_ID_2).get(), dstPort, 10, islStatus);
    IslRoundTripLatency forward = new IslRoundTripLatency(SWITCH_ID_1, srcPort, 1, 0L);
    IslRoundTripLatency reverse = new IslRoundTripLatency(SWITCH_ID_2, dstPort, 1, 0L);
    checkHandleGetDataFromCache(forward, SWITCH_ID_2, dstPort);
    checkHandleGetDataFromCache(reverse, SWITCH_ID_1, srcPort);
}
Also used : IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency) Endpoint(org.openkilda.wfm.share.model.Endpoint)

Aggregations

IslRoundTripLatency (org.openkilda.messaging.info.event.IslRoundTripLatency)23 Test (org.junit.Test)11 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)10 IslOneWayLatency (org.openkilda.messaging.info.event.IslOneWayLatency)7 Endpoint (org.openkilda.wfm.share.model.Endpoint)6 InfoData (org.openkilda.messaging.info.InfoData)4 IslChangedInfoData (org.openkilda.messaging.info.event.IslChangedInfoData)4 SwitchId (org.openkilda.model.SwitchId)4 Duration (java.time.Duration)2 Instant (java.time.Instant)2 Values (org.apache.storm.tuple.Values)2 IslStatusUpdateNotification (org.openkilda.messaging.info.event.IslStatusUpdateNotification)2 Link (org.openkilda.wfm.topology.flowmonitoring.model.Link)2 Clock (java.time.Clock)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Message (org.openkilda.messaging.Message)1