Search in sources :

Example 16 with NetworkEndpoint

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

the class SpeakerToNetworkProxyBoltTest method verifySpeakerToConsumerTupleConsistency.

@Test
public void verifySpeakerToConsumerTupleConsistency() throws Exception {
    injectLifecycleEventUpdate(START_SIGNAL);
    ArgumentCaptor<Values> outputCaptor = ArgumentCaptor.forClass(Values.class);
    verify(outputCollector).emit(anyString(), any(Tuple.class), outputCaptor.capture());
    Values output = outputCaptor.getValue();
    assertEquals(START_SIGNAL, ((LifecycleEvent) output.get(0)).getSignal());
    InfoMessage discoveryConfirmation = new InfoMessage(new DiscoPacketSendingConfirmation(new NetworkEndpoint(switchAlpha, 1), 1L), 3L, "discovery-confirmation", REGION_ONE);
    Tuple tuple = new TupleImpl(generalTopologyContext, new Values(switchAlpha.toString(), discoveryConfirmation, new CommandContext(discoveryConfirmation)), TASK_ID_SPOUT, STREAM_SPOUT_DEFAULT);
    subject.execute(tuple);
    ArgumentCaptor<Values> discoReplyValuesCaptor = ArgumentCaptor.forClass(Values.class);
    verify(outputCollector).emit(eq(SpeakerToNetworkProxyBolt.STREAM_ALIVE_EVIDENCE_ID), eq(tuple), discoReplyValuesCaptor.capture());
    assertEquals(REGION_ONE, discoReplyValuesCaptor.getValue().get(0));
    assertEquals(discoveryConfirmation.getTimestamp(), discoReplyValuesCaptor.getValue().get(1));
    ArgumentCaptor<Values> topoDiscoCaptor = ArgumentCaptor.forClass(Values.class);
    verify(outputCollector).emit(eq(tuple), topoDiscoCaptor.capture());
    assertEquals(switchAlpha.toString(), topoDiscoCaptor.getValue().get(0));
    assertEquals(discoveryConfirmation, topoDiscoCaptor.getValue().get(1));
}
Also used : DiscoPacketSendingConfirmation(org.openkilda.messaging.info.discovery.DiscoPacketSendingConfirmation) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) CommandContext(org.openkilda.wfm.CommandContext) InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values) TupleImpl(org.apache.storm.tuple.TupleImpl) Tuple(org.apache.storm.tuple.Tuple) Test(org.junit.Test)

Example 17 with NetworkEndpoint

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

the class PingRequestTest method serializeLoop.

@Test
public void serializeLoop() throws Exception {
    Ping ping = new Ping((short) 100, new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:01"), 8), new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:02"), 10));
    PingRequest origin = new PingRequest(ping);
    CommandMessage wrapper = new CommandMessage(origin, System.currentTimeMillis(), getClass().getSimpleName());
    serializer.serialize(wrapper);
    CommandMessage decodedWrapper = (CommandMessage) serializer.deserialize();
    CommandData 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) Ping(org.openkilda.messaging.model.Ping) SwitchId(org.openkilda.model.SwitchId) CommandData(org.openkilda.messaging.command.CommandData) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Example 18 with NetworkEndpoint

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

the class PingData method of.

/**
 * Build {@link PingData} from {@link Ping} instance.
 */
public static PingData of(Ping ping) {
    NetworkEndpoint ingress = ping.getSource();
    DatapathId source = DatapathId.of(ingress.getDatapath().toLong());
    DatapathId dest = DatapathId.of(ping.getDest().getDatapath().toLong());
    return new PingData(ingress.getPortNumber(), source, dest, ping.getPingId());
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) DatapathId(org.projectfloodlight.openflow.types.DatapathId)

Example 19 with NetworkEndpoint

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

the class NetworkDiscoveryEmitter method emit.

void emit(DiscoveryHolder discovery) {
    DiscoverIslCommandData request = discovery.getDiscoveryRequest();
    DatapathId dpId = DatapathId.of(request.getSwitchId().getId());
    pathVerificationService.sendDiscoveryMessage(dpId, OFPort.of(request.getPortNumber()), request.getPacketId());
    DiscoPacketSendingConfirmation confirmation = new DiscoPacketSendingConfirmation(new NetworkEndpoint(request.getSwitchId(), request.getPortNumber()), request.getPacketId());
    kafkaProducerService.sendMessageAndTrackWithZk(confirmationTopic, request.getSwitchId().toString(), new InfoMessage(confirmation, System.currentTimeMillis(), discovery.getCorrelationId(), region));
}
Also used : DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData) DiscoPacketSendingConfirmation(org.openkilda.messaging.info.discovery.DiscoPacketSendingConfirmation) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) InfoMessage(org.openkilda.messaging.info.InfoMessage) DatapathId(org.projectfloodlight.openflow.types.DatapathId)

Example 20 with NetworkEndpoint

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

the class PingServiceTest method testWrapUnwrapCycleVlan.

@Test
public void testWrapUnwrapCycleVlan() throws Exception {
    Ping ping = new Ping(new NetworkEndpoint(new SwitchId(dpIdAlpha.getLong()), 8), new NetworkEndpoint(new SwitchId(dpIdBeta.getLong()), 9), new FlowTransitEncapsulation(2, FlowEncapsulationType.TRANSIT_VLAN), 3);
    moduleContext.getServiceImpl(InputService.class).addTranslator(eq(OFType.PACKET_IN), anyObject(PingInputTranslator.class));
    replayAll();
    pingService.setup(moduleContext);
    byte[] payload = new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35 };
    byte[] wrapped = pingService.wrapData(ping, payload).serialize();
    IPacket decoded = new Ethernet().deserialize(wrapped, 0, wrapped.length);
    Assert.assertTrue(decoded instanceof Ethernet);
    PingWiredView parsed = pingService.unwrapData(dpIdBeta, (Ethernet) decoded);
    Assert.assertNotNull(parsed);
    Assert.assertArrayEquals(payload, parsed.getPayload());
    Assert.assertEquals(ping.getTransitEncapsulation().getId(), parsed.getVlanStack().get(0));
}
Also used : IPacket(net.floodlightcontroller.packet.IPacket) InputService(org.openkilda.floodlight.service.of.InputService) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) PingWiredView(org.openkilda.floodlight.model.PingWiredView) Ping(org.openkilda.messaging.model.Ping) Ethernet(net.floodlightcontroller.packet.Ethernet) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) SwitchId(org.openkilda.model.SwitchId) Test(org.junit.Test)

Aggregations

NetworkEndpoint (org.openkilda.messaging.model.NetworkEndpoint)32 SwitchId (org.openkilda.model.SwitchId)16 Test (org.junit.Test)14 Ping (org.openkilda.messaging.model.Ping)7 CommandMessage (org.openkilda.messaging.command.CommandMessage)5 InfoMessage (org.openkilda.messaging.info.InfoMessage)5 LinkPropsDto (org.openkilda.messaging.model.LinkPropsDto)5 LinkPropsResponse (org.openkilda.messaging.nbtopology.response.LinkPropsResponse)5 FlowTransitEncapsulation (org.openkilda.model.FlowTransitEncapsulation)5 ApiOperation (io.swagger.annotations.ApiOperation)4 HashMap (java.util.HashMap)4 MessageException (org.openkilda.messaging.error.MessageException)4 LinkPropsPut (org.openkilda.messaging.nbtopology.request.LinkPropsPut)4 LinkPropsDto (org.openkilda.northbound.dto.v1.links.LinkPropsDto)4 Ethernet (net.floodlightcontroller.packet.Ethernet)3 IPacket (net.floodlightcontroller.packet.IPacket)3 InputService (org.openkilda.floodlight.service.of.InputService)3 DatapathId (org.projectfloodlight.openflow.types.DatapathId)3 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)3 Date (java.util.Date)2