use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.
the class NetworkPortServiceTest method newPort.
@Test
public void newPort() {
NetworkPortService service = makeService();
Endpoint port1 = Endpoint.of(alphaDatapath, 1);
Endpoint port2 = Endpoint.of(alphaDatapath, 2);
service.setup(port1, null);
service.updateOnlineMode(port1, OnlineStatus.OFFLINE);
service.setup(port2, null);
service.updateOnlineMode(port2, OnlineStatus.OFFLINE);
service.remove(port1);
service.remove(port2);
verify(carrier).setupUniIslHandler(Endpoint.of(alphaDatapath, 1), null);
verify(carrier).removeUniIslHandler(Endpoint.of(alphaDatapath, 1));
verify(carrier).setupUniIslHandler(Endpoint.of(alphaDatapath, 2), null);
verify(carrier).removeUniIslHandler(Endpoint.of(alphaDatapath, 2));
// System.out.println(mockingDetails(carrier).printInvocations());
}
use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.
the class NetworkPortServiceTest method inUnOperationalUpDownPort.
@Test
public void inUnOperationalUpDownPort() {
NetworkPortService service = makeService();
Endpoint endpoint = Endpoint.of(alphaDatapath, 1);
service.setup(endpoint, null);
service.updateOnlineMode(endpoint, OnlineStatus.ONLINE);
resetMocks();
service.updateOnlineMode(endpoint, OnlineStatus.OFFLINE);
// Port 1 from Unknown to UP then DOWN
service.updateLinkStatus(endpoint, LinkStatus.UP);
service.updateLinkStatus(endpoint, LinkStatus.DOWN);
verifyZeroInteractions(dashboardLogger);
verify(carrier, never()).enableDiscoveryPoll(endpoint);
verify(carrier, never()).disableDiscoveryPoll(endpoint);
verify(carrier, never()).notifyPortPhysicalDown(endpoint);
resetMocks();
service.updateOnlineMode(endpoint, OnlineStatus.ONLINE);
service.updateLinkStatus(endpoint, LinkStatus.UP);
service.updateLinkStatus(endpoint, LinkStatus.DOWN);
verify(dashboardLogger).onPortUp(endpoint);
verify(dashboardLogger).onPortDown(endpoint);
verifyNoMoreInteractions(dashboardLogger);
verify(carrier).enableDiscoveryPoll(endpoint);
verify(carrier).disableDiscoveryPoll(endpoint);
verify(carrier).notifyPortPhysicalDown(endpoint);
verify(carrier).sendPortStateChangedHistory(eq(endpoint), eq(PortHistoryEvent.PORT_UP), any(Instant.class));
verify(carrier).sendPortStateChangedHistory(eq(endpoint), eq(PortHistoryEvent.PORT_DOWN), any(Instant.class));
// System.out.println(mockingDetails(carrier).printInvocations());
}
use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.
the class NetworkPortServiceTest method disableDiscoveryWhenPortDown.
@Test
public void disableDiscoveryWhenPortDown() {
NetworkPortService service = makeService();
int port = 7;
Endpoint endpoint = Endpoint.of(alphaDatapath, port);
expectSwitchLookup(endpoint, getDefaultSwitch());
service.setup(endpoint, null);
service.updateOnlineMode(endpoint, OnlineStatus.ONLINE);
service.updateLinkStatus(endpoint, LinkStatus.DOWN);
service.updatePortProperties(endpoint, false);
service.updateLinkStatus(endpoint, LinkStatus.UP);
service.remove(endpoint);
verify(carrier).setupUniIslHandler(endpoint, null);
verify(carrier).sendPortStateChangedHistory(eq(endpoint), eq(PortHistoryEvent.PORT_DOWN), any(Instant.class));
verify(carrier, new Times(2)).disableDiscoveryPoll(endpoint);
verify(carrier).notifyPortPhysicalDown(endpoint);
verify(carrier).notifyPortPropertiesChanged(any(PortProperties.class));
verify(carrier).sendPortStateChangedHistory(eq(endpoint), eq(PortHistoryEvent.PORT_UP), any(Instant.class));
verify(carrier, new Times(0)).enableDiscoveryPoll(endpoint);
verify(carrier).removeUniIslHandler(endpoint);
verify(portPropertiesRepository).add(PortProperties.builder().switchObj(getDefaultSwitch()).port(port).discoveryEnabled(false).build());
}
use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.
the class NetworkPortServiceTest method ignorePollFailWhenRegionOffline.
@Test
public void ignorePollFailWhenRegionOffline() {
Endpoint endpoint = Endpoint.of(alphaDatapath, 8);
expectSwitchLookup(endpoint, getDefaultSwitch());
NetworkPortService service = makeService();
service.setup(endpoint, null);
service.updateOnlineMode(endpoint, OnlineStatus.ONLINE);
service.updateLinkStatus(endpoint, LinkStatus.UP);
verify(carrier).setupUniIslHandler(endpoint, null);
verify(carrier).sendPortStateChangedHistory(eq(endpoint), eq(PortHistoryEvent.PORT_UP), any(Instant.class));
verify(carrier).enableDiscoveryPoll(eq(endpoint));
verifyNoMoreInteractions(carrier);
service.updateOnlineMode(endpoint, OnlineStatus.REGION_OFFLINE);
verify(carrier).disableDiscoveryPoll(endpoint);
verifyNoMoreInteractions(carrier);
service.fail(endpoint);
verifyNoMoreInteractions(carrier);
service.updateOnlineMode(endpoint, OnlineStatus.ONLINE);
service.updateLinkStatus(endpoint, LinkStatus.UP);
verify(carrier).enableDiscoveryPoll(endpoint);
verifyNoMoreInteractions(carrier);
service.fail(endpoint);
verify(carrier).notifyPortDiscoveryFailed(endpoint);
}
use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.
the class NetworkPortServiceTest method createPortProperties.
@Test
public void createPortProperties() {
NetworkPortService service = makeService();
int port = 7;
Endpoint endpoint = Endpoint.of(alphaDatapath, port);
when(portPropertiesRepository.getBySwitchIdAndPort(alphaDatapath, port)).thenReturn(Optional.empty());
when(switchRepository.findById(alphaDatapath)).thenReturn(Optional.of(getDefaultSwitch()));
service.setup(endpoint, null);
service.updateOnlineMode(endpoint, OnlineStatus.ONLINE);
service.updateLinkStatus(endpoint, LinkStatus.UP);
service.updatePortProperties(endpoint, false);
service.remove(endpoint);
verify(carrier).setupUniIslHandler(endpoint, null);
verify(carrier).sendPortStateChangedHistory(eq(endpoint), eq(PortHistoryEvent.PORT_UP), any(Instant.class));
verify(carrier).enableDiscoveryPoll(endpoint);
verify(carrier, new Times(2)).disableDiscoveryPoll(endpoint);
verify(carrier).notifyPortDiscoveryFailed(endpoint);
verify(carrier).notifyPortPropertiesChanged(any(PortProperties.class));
verify(carrier).removeUniIslHandler(endpoint);
verify(portPropertiesRepository).add(PortProperties.builder().switchObj(getDefaultSwitch()).port(port).discoveryEnabled(false).build());
}
Aggregations