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));
}
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);
}
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());
}
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));
}
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));
}
Aggregations