use of org.openkilda.messaging.model.SpeakerSwitchView in project open-kilda by telstra.
the class NetworkSwitchServiceTest method portAddOnOnlineSwitch.
@Test
public void portAddOnOnlineSwitch() {
NetworkSwitchService service = new NetworkSwitchService(carrier, persistenceManager, options);
// prepare
SpeakerSwitchView speakerSwitchView = getSpeakerSwitchView().toBuilder().ports(emptyList()).build();
SwitchInfoData switchAddEvent = new SwitchInfoData(alphaDatapath, SwitchChangeType.ACTIVATED, alphaInetAddress.toString(), alphaDescription, speakerInetAddress.toString(), false, speakerSwitchView);
service.switchEvent(switchAddEvent);
verifySwitchSync(service);
// process
Endpoint endpoint = Endpoint.of(alphaDatapath, 1);
PortInfoData speakerPortEvent = new PortInfoData(endpoint.getDatapath(), endpoint.getPortNumber(), PortChangeType.ADD, true);
service.switchPortEvent(speakerPortEvent);
verify(carrier).sendSwitchStateChanged(alphaDatapath, SwitchStatus.ACTIVE);
verify(carrier).setupPortHandler(endpoint, null);
verify(carrier).setOnlineMode(endpoint, OnlineStatus.ONLINE);
verify(carrier).setPortLinkMode(endpoint, LinkStatus.UP);
verify(carrier).sendAffectedFlowRerouteRequest(alphaDatapath);
verifyNoMoreInteractions(carrier);
}
use of org.openkilda.messaging.model.SpeakerSwitchView in project open-kilda by telstra.
the class NetworkSwitchServiceTest method portUpDownEventsOnOnlineSwitch.
@Test
public void portUpDownEventsOnOnlineSwitch() {
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();
// System.out.println(mockingDetails(carrier).printInvocations());
service.switchPortEvent(new PortInfoData(alphaDatapath, 1, PortChangeType.UP));
service.switchPortEvent(new PortInfoData(alphaDatapath, 1 + BFD_LOGICAL_PORT_OFFSET, PortChangeType.UP));
List<SpeakerSwitchPortView> portsUp = ImmutableList.of(new SpeakerSwitchPortView(1, State.UP), new SpeakerSwitchPortView(1 + BFD_LOGICAL_PORT_OFFSET, State.UP));
verify(carrier).setPortLinkMode(Endpoint.of(alphaDatapath, portsUp.get(0).getNumber()), LinkStatus.of(portsUp.get(0).getState()));
verify(carrier).sendBfdLinkStatusUpdate(Endpoint.of(alphaDatapath, portsUp.get(1).getNumber()), LinkStatus.of(portsUp.get(1).getState()));
resetMocks();
service.switchPortEvent(new PortInfoData(alphaDatapath, 1, PortChangeType.DOWN));
service.switchPortEvent(new PortInfoData(alphaDatapath, 1 + BFD_LOGICAL_PORT_OFFSET, PortChangeType.DOWN));
verify(carrier).setPortLinkMode(Endpoint.of(alphaDatapath, portsDown.get(0).getNumber()), LinkStatus.of(portsDown.get(0).getState()));
verify(carrier).sendBfdLinkStatusUpdate(Endpoint.of(alphaDatapath, portsDown.get(1).getNumber()), LinkStatus.of(portsDown.get(1).getState()));
// System.out.println(mockingDetails(carrier).printInvocations());
}
use of org.openkilda.messaging.model.SpeakerSwitchView in project open-kilda by telstra.
the class NetworkSwitchServiceTest method switchMustStayOnlineIfItReceivePeriodicDumps.
@Test
public void switchMustStayOnlineIfItReceivePeriodicDumps() {
NetworkSwitchService service = new NetworkSwitchService(carrier, persistenceManager, options);
SpeakerSwitchView dump = getSpeakerSwitchView();
service.switchBecomeManaged(dump, "A-0");
ArgumentCaptor<String> syncKeyCaptor = ArgumentCaptor.forClass(String.class);
verify(carrier).sendSwitchSynchronizeRequest(syncKeyCaptor.capture(), eq(dump.getDatapath()));
verifyNoMoreInteractions(carrier);
String syncKey = syncKeyCaptor.getValue();
SwitchSyncResponse response = makeSuccessSwitchSyncResponse(dump.getDatapath());
service.switchManagerResponse(response, syncKey);
verify(carrier).sendSwitchStateChanged(dump.getDatapath(), SwitchStatus.ACTIVE);
verify(carrier).sendAffectedFlowRerouteRequest(dump.getDatapath());
verifyNoMoreInteractions(carrier);
// +10 to be sure to cover +-1 mismatches
for (int i = 0; i < options.getSwitchOfflineGenerationLag() + 10; i++) {
service.switchBecomeManaged(dump, String.format("dump#%d", i));
verifyNoMoreInteractions(carrier);
}
}
use of org.openkilda.messaging.model.SpeakerSwitchView in project open-kilda by telstra.
the class NetworkSwitchServiceTest method newSwitchWithSynchronizationTimeout.
@Test
public void newSwitchWithSynchronizationTimeout() {
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));
service.switchManagerTimeout(alphaDatapath, captor.getValue());
verify(carrier, times(SYNC_ATTEMPTS)).sendSwitchSynchronizeRequest(captor.capture(), eq(alphaDatapath));
service.switchManagerTimeout(alphaDatapath, captor.getValue());
verifyNewSwitchAfterSwitchSync(ports);
verify(carrier).sendSwitchStateChanged(alphaDatapath, SwitchStatus.ACTIVE);
verifyNoMoreInteractions(carrier);
}
use of org.openkilda.messaging.model.SpeakerSwitchView in project open-kilda by telstra.
the class NetworkSwitchServiceTest method newSwitchWithWrongSynchronizationResponse.
@Test
public void newSwitchWithWrongSynchronizationResponse() {
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);
RulesSyncEntry rulesSyncEntry = new RulesSyncEntry(singletonList(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1).getValue()), emptyList(), emptyList(), emptyList(), emptyList(), emptyList());
MetersSyncEntry metersSyncEntry = new MetersSyncEntry(emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList());
GroupSyncEntry groupSyncEntry = new GroupSyncEntry(emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList());
SwitchSyncResponse response = new SwitchSyncResponse(alphaDatapath, rulesSyncEntry, metersSyncEntry, groupSyncEntry, LogicalPortsSyncEntry.builder().build());
// for a randomly generated key in SwitchFsm
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(carrier).sendSwitchSynchronizeRequest(captor.capture(), eq(alphaDatapath));
service.switchManagerResponse(response, captor.getValue());
verify(carrier, times(SYNC_ATTEMPTS)).sendSwitchSynchronizeRequest(captor.capture(), eq(alphaDatapath));
service.switchManagerResponse(response, captor.getValue());
verifyNewSwitchAfterSwitchSync(ports);
verify(carrier).sendSwitchStateChanged(alphaDatapath, SwitchStatus.ACTIVE);
verifyNoMoreInteractions(carrier);
}
Aggregations