Search in sources :

Example 1 with PingMeters

use of org.openkilda.messaging.model.PingMeters in project open-kilda by telstra.

the class UniFlowPingResponseTest method serializeLoop.

@Test
public void serializeLoop() throws Exception {
    NetworkEndpoint endpointAlpha = new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:01"), 8);
    NetworkEndpoint endpointBeta = new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:02"), 10);
    UniFlowPingResponse origin = new UniFlowPingResponse(new Ping(endpointBeta, endpointAlpha, new FlowTransitEncapsulation(4, FlowEncapsulationType.TRANSIT_VLAN), 5), new PingMeters(3L, 2L, 1L), null);
    InfoMessage wrapper = new InfoMessage(origin, System.currentTimeMillis(), getClass().getSimpleName());
    serializer.serialize(wrapper);
    InfoMessage decodedWrapper = (InfoMessage) serializer.deserialize();
    InfoData decoded = decodedWrapper.getData();
    Assert.assertEquals(String.format("%s object have been mangled in serialisation/deserialization loop", origin.getClass().getName()), origin, decoded);
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) InfoMessage(org.openkilda.messaging.info.InfoMessage) InfoData(org.openkilda.messaging.info.InfoData) Ping(org.openkilda.messaging.model.Ping) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) SwitchId(org.openkilda.model.SwitchId) PingMeters(org.openkilda.messaging.model.PingMeters) Test(org.junit.Test)

Example 2 with PingMeters

use of org.openkilda.messaging.model.PingMeters in project open-kilda by telstra.

the class FlowPingResponseTest method serializeLoop.

@Test
public void serializeLoop() throws Exception {
    NetworkEndpoint endpointAlpha = new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:01"), 8);
    NetworkEndpoint endpointBeta = new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:02"), 10);
    UniFlowPingResponse forward = new UniFlowPingResponse(new Ping(endpointAlpha, endpointBeta, new FlowTransitEncapsulation(4, FlowEncapsulationType.TRANSIT_VLAN), 5), new PingMeters(1L, 2L, 3L), null);
    UniFlowPingResponse reverse = new UniFlowPingResponse(new Ping(endpointBeta, endpointAlpha, new FlowTransitEncapsulation(4, FlowEncapsulationType.TRANSIT_VLAN), 5), new PingMeters(3L, 2L, 1L), null);
    FlowPingResponse origin = new FlowPingResponse("flowId-" + getClass().getSimpleName(), forward, reverse, null);
    InfoMessage wrapper = new InfoMessage(origin, System.currentTimeMillis(), getClass().getSimpleName());
    serializer.serialize(wrapper);
    InfoMessage decodedWrapper = (InfoMessage) serializer.deserialize();
    InfoData decoded = decodedWrapper.getData();
    Assert.assertEquals(String.format("%s object have been mangled in serialisation/deserialization loop", origin.getClass().getName()), origin, decoded);
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) InfoMessage(org.openkilda.messaging.info.InfoMessage) InfoData(org.openkilda.messaging.info.InfoData) Ping(org.openkilda.messaging.model.Ping) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) SwitchId(org.openkilda.model.SwitchId) PingMeters(org.openkilda.messaging.model.PingMeters) Test(org.junit.Test)

Example 3 with PingMeters

use of org.openkilda.messaging.model.PingMeters in project open-kilda by telstra.

the class PingResponseTest method serializeLoop.

@Test
public void serializeLoop() throws Exception {
    PingMeters meters = new PingMeters(1L, 2L, 3L);
    PingResponse origin = new PingResponse(System.currentTimeMillis(), UUID.randomUUID(), null, meters);
    InfoMessage wrapper = new InfoMessage(origin, System.currentTimeMillis(), getClass().getSimpleName());
    serializer.serialize(wrapper);
    InfoMessage decodedWrapper = (InfoMessage) serializer.deserialize();
    InfoData decoded = decodedWrapper.getData();
    Assert.assertEquals(String.format("%s object have been mangled in serialisation/deserialization loop", origin.getClass().getName()), origin, decoded);
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) InfoData(org.openkilda.messaging.info.InfoData) PingMeters(org.openkilda.messaging.model.PingMeters) Test(org.junit.Test)

Example 4 with PingMeters

use of org.openkilda.messaging.model.PingMeters in project open-kilda by telstra.

the class PingResponseCommand method process.

private void process(PingData data) {
    Long latency = input.getLatency();
    if (latency == null) {
        log.warn("There is no latency info for {} - ping latency is unreliable", data.getPingId());
        latency = 0L;
    }
    PingMeters meters = data.produceMeasurements(input.getReceiveTime(), latency);
    logCatch(data, meters);
    PingResponse response = new PingResponse(getContext().getCtime(), data.getPingId(), meters);
    sendResponse(response);
}
Also used : PingResponse(org.openkilda.messaging.floodlight.response.PingResponse) PingMeters(org.openkilda.messaging.model.PingMeters)

Example 5 with PingMeters

use of org.openkilda.messaging.model.PingMeters in project open-kilda by telstra.

the class FlowMapperTest method testPingOutput.

@Test
public void testPingOutput() {
    FlowPingResponse response = new FlowPingResponse(FLOW_ID, new UniFlowPingResponse(false, Errors.TIMEOUT, null, null), new UniFlowPingResponse(true, null, new PingMeters(1, 2, 3), null), ERROR_MESSAGE);
    PingOutput output = flowMapper.toPingOutput(response);
    assertEquals(response.getFlowId(), output.getFlowId());
    assertEquals(response.getError(), output.getError());
    assertEquals(response.getForward().isPingSuccess(), output.getForward().isPingSuccess());
    assertEquals(0, output.getForward().getLatency());
    assertEquals(TIMEOUT_ERROR_MESSAGE, output.getForward().getError());
    assertEquals(response.getReverse().isPingSuccess(), output.getReverse().isPingSuccess());
    assertEquals(1, output.getReverse().getLatency());
    assertNull(output.getReverse().getError());
}
Also used : UniFlowPingResponse(org.openkilda.messaging.info.flow.UniFlowPingResponse) PingOutput(org.openkilda.northbound.dto.v1.flows.PingOutput) UniFlowPingResponse(org.openkilda.messaging.info.flow.UniFlowPingResponse) FlowPingResponse(org.openkilda.messaging.info.flow.FlowPingResponse) PingMeters(org.openkilda.messaging.model.PingMeters) Test(org.junit.Test)

Aggregations

PingMeters (org.openkilda.messaging.model.PingMeters)5 Test (org.junit.Test)4 InfoData (org.openkilda.messaging.info.InfoData)3 InfoMessage (org.openkilda.messaging.info.InfoMessage)3 NetworkEndpoint (org.openkilda.messaging.model.NetworkEndpoint)2 Ping (org.openkilda.messaging.model.Ping)2 FlowTransitEncapsulation (org.openkilda.model.FlowTransitEncapsulation)2 SwitchId (org.openkilda.model.SwitchId)2 PingResponse (org.openkilda.messaging.floodlight.response.PingResponse)1 FlowPingResponse (org.openkilda.messaging.info.flow.FlowPingResponse)1 UniFlowPingResponse (org.openkilda.messaging.info.flow.UniFlowPingResponse)1 PingOutput (org.openkilda.northbound.dto.v1.flows.PingOutput)1