use of org.openkilda.messaging.model.SpeakerSwitchPortView in project open-kilda by telstra.
the class NetworkSwitchServiceTest method switchFromOnlineToOfflineToOnline.
@Test
public void switchFromOnlineToOfflineToOnline() {
List<SpeakerSwitchPortView> ports = getSpeakerSwitchPortViews();
SpeakerSwitchView speakerSwitchView = getSpeakerSwitchView().toBuilder().ports(ports).build();
SwitchInfoData switchAddEvent = new SwitchInfoData(alphaDatapath, SwitchChangeType.ACTIVATED, alphaInetAddress.toString(), alphaDescription, speakerInetAddress.toString(), false, speakerSwitchView);
NetworkSwitchService service = new NetworkSwitchService(carrier, persistenceManager, options);
service.switchEvent(switchAddEvent);
verifySwitchSync(service);
SwitchInfoData deactivatedSwitch = switchAddEvent.toBuilder().state(SwitchChangeType.DEACTIVATED).build();
service.switchEvent(deactivatedSwitch);
List<SpeakerSwitchPortView> ports2 = getSpeakerSwitchPortViewsRevert();
SpeakerSwitchView speakerSwitchView2 = getSpeakerSwitchView().toBuilder().ports(ports2).build();
SwitchInfoData switchAddEvent2 = new SwitchInfoData(alphaDatapath, SwitchChangeType.ACTIVATED, alphaInetAddress.toString(), alphaDescription, speakerInetAddress.toString(), false, speakerSwitchView2);
resetMocks();
service.switchEvent(switchAddEvent2);
verifySwitchSync(service);
// System.out.println(mockingDetails(carrier).printInvocations());
// System.out.println(mockingDetails(switchRepository).printInvocations());
verify(carrier).sendSwitchStateChanged(eq(alphaDatapath), eq(SwitchStatus.ACTIVE));
verify(carrier).setOnlineMode(Endpoint.of(alphaDatapath, ports.get(0).getNumber()), OnlineStatus.ONLINE);
verify(carrier).setOnlineMode(Endpoint.of(alphaDatapath, ports.get(2).getNumber()), OnlineStatus.ONLINE);
verify(carrier).setPortLinkMode(Endpoint.of(alphaDatapath, ports2.get(2).getNumber()), LinkStatus.of(ports2.get(2).getState()));
verify(carrier).sendBfdLinkStatusUpdate(Endpoint.of(alphaDatapath, ports2.get(3).getNumber()), LinkStatus.of(ports2.get(3).getState()));
verify(carrier).setPortLinkMode(Endpoint.of(alphaDatapath, ports2.get(0).getNumber()), LinkStatus.of(ports2.get(0).getState()));
verify(carrier).sendBfdLinkStatusUpdate(Endpoint.of(alphaDatapath, ports2.get(1).getNumber()), LinkStatus.of(ports2.get(0).getState()));
verify(carrier).sendAffectedFlowRerouteRequest(alphaDatapath);
}
use of org.openkilda.messaging.model.SpeakerSwitchPortView in project open-kilda by telstra.
the class NetworkSwitchServiceTest method portDelEventOnOnlineSwitch.
@Test
public void portDelEventOnOnlineSwitch() {
List<SpeakerSwitchPortView> portsDown = ImmutableList.of(new SpeakerSwitchPortView(1, State.DOWN), new SpeakerSwitchPortView(1 + BFD_LOGICAL_PORT_OFFSET, State.DOWN));
SpeakerSwitchView speakerSwitchView = getSpeakerSwitchView().toBuilder().ports(portsDown).build();
SwitchInfoData switchAddEvent = new SwitchInfoData(alphaDatapath, SwitchChangeType.ACTIVATED, alphaInetAddress.toString(), alphaDescription, speakerInetAddress.toString(), false, speakerSwitchView);
NetworkSwitchService service = new NetworkSwitchService(carrier, persistenceManager, options);
service.switchEvent(switchAddEvent);
verifySwitchSync(service);
resetMocks();
service.switchPortEvent(new PortInfoData(alphaDatapath, 1, PortChangeType.DELETE));
service.switchPortEvent(new PortInfoData(alphaDatapath, 1 + BFD_LOGICAL_PORT_OFFSET, PortChangeType.DELETE));
verify(carrier).removePortHandler(Endpoint.of(alphaDatapath, 1));
verify(carrier).sendBfdPortDelete(Endpoint.of(alphaDatapath, 1 + BFD_LOGICAL_PORT_OFFSET));
// System.out.println(mockingDetails(carrier).printInvocations());
}
use of org.openkilda.messaging.model.SpeakerSwitchPortView in project open-kilda by telstra.
the class NetworkSwitchServiceTest method switchFromHistoryToOfflineToOnlineRemovedPort.
@Test
public void switchFromHistoryToOfflineToOnlineRemovedPort() {
// History
HistoryFacts history = new HistoryFacts(alphaDatapath, SwitchStatus.ACTIVE);
Switch alphaSwitch = Switch.builder().switchId(alphaDatapath).build();
Switch betaSwitch = Switch.builder().switchId(betaDatapath).build();
Isl islAtoB = Isl.builder().srcSwitch(alphaSwitch).srcPort(1).destSwitch(betaSwitch).destPort(1).build();
Isl islAtoB2 = Isl.builder().srcSwitch(alphaSwitch).srcPort(2).destSwitch(betaSwitch).destPort(2).build();
Isl islAtoB3 = Isl.builder().srcSwitch(alphaSwitch).srcPort(3).destSwitch(betaSwitch).destPort(3).build();
history.addLink(islAtoB);
history.addLink(islAtoB2);
history.addLink(islAtoB3);
NetworkSwitchService service = new NetworkSwitchService(carrier, persistenceManager, options);
service.switchAddWithHistory(history);
// Online
List<SpeakerSwitchPortView> ports = getSpeakerSwitchPortViews();
SpeakerSwitchView speakerSwitchView = getSpeakerSwitchView().toBuilder().ports(ports).build();
SwitchInfoData switchAddEvent = new SwitchInfoData(alphaDatapath, SwitchChangeType.ACTIVATED, alphaInetAddress.toString(), alphaDescription, speakerInetAddress.toString(), false, speakerSwitchView);
resetMocks();
service.switchEvent(switchAddEvent);
verifySwitchSync(service);
verify(carrier).removePortHandler(Endpoint.of(alphaDatapath, 3));
// System.out.println(mockingDetails(carrier).printInvocations());
// System.out.println(mockingDetails(switchRepository).printInvocations());
}
use of org.openkilda.messaging.model.SpeakerSwitchPortView in project open-kilda by telstra.
the class NetworkSwitchServiceTest method switchFromOnlineToOnline.
@Test
public void switchFromOnlineToOnline() {
List<SpeakerSwitchPortView> ports = Lists.newArrayList(new SpeakerSwitchPortView(1, SpeakerSwitchPortView.State.UP), new SpeakerSwitchPortView(1 + BFD_LOGICAL_PORT_OFFSET, SpeakerSwitchPortView.State.UP), new SpeakerSwitchPortView(2, SpeakerSwitchPortView.State.DOWN), new SpeakerSwitchPortView(2 + BFD_LOGICAL_PORT_OFFSET, SpeakerSwitchPortView.State.DOWN), new SpeakerSwitchPortView(3, SpeakerSwitchPortView.State.UP), new SpeakerSwitchPortView(3 + BFD_LOGICAL_PORT_OFFSET, SpeakerSwitchPortView.State.UP), new SpeakerSwitchPortView(4, SpeakerSwitchPortView.State.DOWN), new SpeakerSwitchPortView(4 + BFD_LOGICAL_PORT_OFFSET, SpeakerSwitchPortView.State.DOWN));
SpeakerSwitchView speakerSwitchView = getSpeakerSwitchView().toBuilder().ports(ImmutableList.copyOf(ports)).build();
SwitchInfoData switchAddEvent = new SwitchInfoData(alphaDatapath, SwitchChangeType.ACTIVATED, alphaInetAddress.toString(), alphaDescription, speakerInetAddress.toString(), false, speakerSwitchView);
NetworkSwitchService service = new NetworkSwitchService(carrier, persistenceManager, options);
// initial switch ADD
service.switchEvent(switchAddEvent);
verifySwitchSync(service);
resetMocks();
// periodic network sync (swap UP/DOWN state for half of the ports)
for (int idx = 0; idx < 4 && idx < ports.size(); idx++) {
ports.set(idx, makePortEntryWithOppositeState(ports.get(idx)));
}
SpeakerSwitchView periodicSyncEvent = speakerSwitchView.toBuilder().ports(ImmutableList.copyOf(ports)).build();
service.switchBecomeManaged(periodicSyncEvent, DUMMY_CORRELATION_ID);
// only changed ports
verify(carrier).setPortLinkMode(Endpoint.of(alphaDatapath, 1), LinkStatus.DOWN);
verify(carrier).sendBfdLinkStatusUpdate(Endpoint.of(alphaDatapath, 1 + BFD_LOGICAL_PORT_OFFSET), LinkStatus.DOWN);
verify(carrier).setPortLinkMode(Endpoint.of(alphaDatapath, 2), LinkStatus.UP);
verify(carrier).sendBfdLinkStatusUpdate(Endpoint.of(alphaDatapath, 2 + BFD_LOGICAL_PORT_OFFSET), LinkStatus.UP);
verifyNoMoreInteractions(carrier);
}
use of org.openkilda.messaging.model.SpeakerSwitchPortView in project open-kilda by telstra.
the class NetworkSwitchServiceTest method newSwitchWithSynchronizationErrorResponse.
@Test
public void newSwitchWithSynchronizationErrorResponse() {
List<SpeakerSwitchPortView> ports = getSpeakerSwitchPortViews();
SpeakerSwitchView speakerSwitchView = getSpeakerSwitchView().toBuilder().ports(ports).build();
SwitchInfoData switchAddEvent = new SwitchInfoData(alphaDatapath, SwitchChangeType.ACTIVATED, alphaInetAddress.toString(), alphaDescription, speakerInetAddress.toString(), false, speakerSwitchView);
NetworkSwitchService service = new NetworkSwitchService(carrier, persistenceManager, options);
service.switchEvent(switchAddEvent);
// for a randomly generated key in SwitchFsm
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(carrier).sendSwitchSynchronizeRequest(captor.capture(), eq(alphaDatapath));
SwitchSyncErrorData errorData = new SwitchSyncErrorData(alphaDatapath, null, null, null);
service.switchManagerErrorResponse(errorData, captor.getValue());
verify(carrier, times(SYNC_ATTEMPTS)).sendSwitchSynchronizeRequest(captor.capture(), eq(alphaDatapath));
service.switchManagerErrorResponse(errorData, captor.getValue());
verifyNewSwitchAfterSwitchSync(ports);
verify(carrier).sendSwitchStateChanged(alphaDatapath, SwitchStatus.ACTIVE);
verifyNoMoreInteractions(carrier);
}
Aggregations