use of org.openkilda.messaging.model.SpeakerSwitchPortView 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.SpeakerSwitchPortView 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.SpeakerSwitchPortView 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);
}
use of org.openkilda.messaging.model.SpeakerSwitchPortView in project open-kilda by telstra.
the class NetworkSwitchServiceTest method switchFromOnlineToOffline.
@Test
public void switchFromOnlineToOffline() {
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);
resetMocks();
when(switchRepository.findById(alphaDatapath)).thenReturn(Optional.of(Switch.builder().switchId(alphaDatapath).build()));
SwitchInfoData deactivatedSwitch = switchAddEvent.toBuilder().state(SwitchChangeType.DEACTIVATED).build();
service.switchEvent(deactivatedSwitch);
// System.out.println(mockingDetails(carrier).printInvocations());
// System.out.println(mockingDetails(switchRepository).printInvocations());
verify(carrier).sendSwitchStateChanged(eq(alphaDatapath), eq(SwitchStatus.INACTIVE));
verify(carrier).setOnlineMode(Endpoint.of(alphaDatapath, ports.get(0).getNumber()), OnlineStatus.OFFLINE);
verify(carrier).setOnlineMode(Endpoint.of(alphaDatapath, ports.get(2).getNumber()), OnlineStatus.OFFLINE);
verifyNoMoreInteractions(carrier);
}
use of org.openkilda.messaging.model.SpeakerSwitchPortView in project open-kilda by telstra.
the class NetworkSwitchServiceTest method newSwitchWithSynchronizationSuccessAfterError.
@Test
public void newSwitchWithSynchronizationSuccessAfterError() {
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());
RulesSyncEntry rulesSyncEntry = new RulesSyncEntry(emptyList(), 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());
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