use of org.openkilda.model.SwitchId in project open-kilda by telstra.
the class EgressFlowSegmentCommandJsonTest method makeRequest.
@Override
protected EgressFlowSegmentRequest makeRequest() {
SwitchId swId = new SwitchId(1);
EgressFlowSegmentRequestFactory factory = new EgressFlowSegmentRequestFactory(new MessageContext(), new FlowSegmentMetadata("egress-flow-segment-install-request", new Cookie(2), false), new FlowEndpoint(swId, 3, 4), new FlowEndpoint(new SwitchId(swId.toLong() + 1), 6, 7), 9, new FlowTransitEncapsulation(10, FlowEncapsulationType.TRANSIT_VLAN), MirrorConfig.builder().build());
return makeRequest(factory);
}
use of org.openkilda.model.SwitchId in project open-kilda by telstra.
the class OneSwitchFlowCommandJsonTest method makeRequest.
@Override
protected OneSwitchFlowRequest makeRequest() {
SwitchId swId = new SwitchId(1);
OneSwitchFlowRequestFactory factory = new OneSwitchFlowRequestFactory(new MessageContext(), new FlowSegmentMetadata("single-switch-flow-install-request", new Cookie(2), false), new FlowEndpoint(swId, 3, 4), new MeterConfig(new MeterId(6), 7000), new FlowEndpoint(swId, 8, 9), RulesContext.builder().build(), MirrorConfig.builder().build());
return makeRequest(factory);
}
use of org.openkilda.model.SwitchId in project open-kilda by telstra.
the class SwitchTrackingServiceTest method verifySwitchEvent.
private void verifySwitchEvent(SwitchChangeType expectedState, SpeakerSwitchView expectedSwitchView, Capture<Message> producedMessage) {
assertTrue(producedMessage.hasCaptured());
Message message = producedMessage.getValues().get(0);
assertTrue(message instanceof InfoMessage);
InfoData data = ((InfoMessage) message).getData();
assertTrue(data instanceof SwitchInfoData);
SwitchInfoData switchInfo = (SwitchInfoData) data;
assertEquals(new SwitchId(dpId.getLong()), switchInfo.getSwitchId());
assertEquals(expectedState, switchInfo.getState());
assertEquals(expectedSwitchView, switchInfo.getSwitchView());
}
use of org.openkilda.model.SwitchId in project open-kilda by telstra.
the class PingServiceTest method testWrapUnwrapCycleVxlan.
@Test
public void testWrapUnwrapCycleVxlan() throws Exception {
Ping ping = new Ping(new NetworkEndpoint(new SwitchId(dpIdAlpha.getLong()), 8), new NetworkEndpoint(new SwitchId(dpIdBeta.getLong()), 9), new FlowTransitEncapsulation(2, FlowEncapsulationType.VXLAN), 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 ethernet = new Ethernet().deserialize(wrapped, 0, wrapped.length);
Assert.assertTrue(ethernet instanceof Ethernet);
IPacket ipv4 = ethernet.getPayload();
Assert.assertTrue(ipv4 instanceof IPv4);
IPacket udp = ipv4.getPayload();
Assert.assertTrue(udp instanceof UDP);
Assert.assertEquals(((UDP) udp).getSourcePort(), TransportPort.of(SwitchManager.STUB_VXLAN_UDP_SRC));
Assert.assertEquals(((UDP) udp).getDestinationPort(), TransportPort.of(SwitchManager.VXLAN_UDP_DST));
byte[] udpPayload = udp.getPayload().serialize();
Vxlan vxlan = (Vxlan) new Vxlan().deserialize(udpPayload, 0, udpPayload.length);
Assert.assertEquals((int) ping.getTransitEncapsulation().getId(), vxlan.getVni());
byte[] vxlanPayload = vxlan.getPayload().serialize();
IPacket decoded = new Ethernet().deserialize(vxlanPayload, 0, vxlanPayload.length);
Assert.assertTrue(decoded instanceof Ethernet);
PingWiredView parsed = pingService.unwrapData(dpIdBeta, (Ethernet) decoded);
Assert.assertNotNull(parsed);
Assert.assertArrayEquals(payload, parsed.getPayload());
Assert.assertTrue(parsed.getVlanStack().isEmpty());
}
use of org.openkilda.model.SwitchId in project open-kilda by telstra.
the class SwitchMonitorServiceTest method testLoseActiveRegion.
@Test
public void testLoseActiveRegion() {
SwitchMonitorService subject = makeSubject();
Instant t0 = clock.instant();
SwitchId targetSw = SWITCH_ALPHA;
makeConnectInRegions(subject, targetSw, REGION_ALPHA, REGION_BETA);
clock.adjust(Duration.ofSeconds(1));
subject.handleRegionOfflineNotification(REGION_ALPHA);
verify(carrier).regionUpdateNotification(eq(new RegionMappingSet(targetSw, REGION_BETA, true)));
SpeakerSwitchView suggestedBetaSpeakerData = makeSwitchActivateNotification(targetSw, 2).getSwitchView();
verify(carrier).sendSwitchAvailabilityUpdateNotification(eq(targetSw), argThat(arg -> matchAvailabilityData(SwitchAvailabilityData.builder().connection(SwitchAvailabilityEntry.builder().regionName(REGION_BETA).connectMode(SwitchConnectMode.READ_WRITE).master(true).connectedAt(t0).switchAddress(suggestedBetaSpeakerData.getSwitchSocketAddress()).speakerAddress(suggestedBetaSpeakerData.getSpeakerSocketAddress()).build()).build(), arg)));
verifyNoMoreInteractions(carrier);
reset(carrier);
clock.adjust(Duration.ofSeconds(1));
Instant t1 = clock.instant();
SpeakerSwitchView suggestedAlphaSpeakerData = makeSwitchActivateNotification(targetSw, 1).getSwitchView();
NetworkDumpSwitchData dumpBeta = new NetworkDumpSwitchData(suggestedAlphaSpeakerData, NETWORK_DUMP_CORRELATION_ID, true);
subject.handleNetworkDumpResponse(dumpBeta, REGION_ALPHA);
verify(carrier).sendSwitchAvailabilityUpdateNotification(eq(targetSw), argThat(arg -> matchAvailabilityData(SwitchAvailabilityData.builder().connection(SwitchAvailabilityEntry.builder().regionName(REGION_ALPHA).connectMode(SwitchConnectMode.READ_WRITE).master(false).connectedAt(t1).switchAddress(suggestedAlphaSpeakerData.getSwitchSocketAddress()).speakerAddress(suggestedAlphaSpeakerData.getSpeakerSocketAddress()).build()).connection(SwitchAvailabilityEntry.builder().regionName(REGION_BETA).connectMode(SwitchConnectMode.READ_WRITE).master(true).connectedAt(t0).switchAddress(suggestedBetaSpeakerData.getSwitchSocketAddress()).speakerAddress(suggestedBetaSpeakerData.getSpeakerSocketAddress()).build()).build(), arg)));
verifyNoMoreInteractions(carrier);
}
Aggregations