Search in sources :

Example 46 with Endpoint

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());
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint) Test(org.junit.Test)

Example 47 with Endpoint

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());
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint) Instant(java.time.Instant) Test(org.junit.Test)

Example 48 with Endpoint

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());
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint) Instant(java.time.Instant) Times(org.mockito.internal.verification.Times) Endpoint(org.openkilda.wfm.share.model.Endpoint) PortProperties(org.openkilda.model.PortProperties) Test(org.junit.Test)

Example 49 with Endpoint

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);
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint) Instant(java.time.Instant) Test(org.junit.Test)

Example 50 with 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());
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint) Instant(java.time.Instant) Times(org.mockito.internal.verification.Times) Endpoint(org.openkilda.wfm.share.model.Endpoint) PortProperties(org.openkilda.model.PortProperties) Test(org.junit.Test)

Aggregations

Endpoint (org.openkilda.wfm.share.model.Endpoint)72 Test (org.junit.Test)33 Isl (org.openkilda.model.Isl)17 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)13 SwitchId (org.openkilda.model.SwitchId)10 Switch (org.openkilda.model.Switch)8 IslReference (org.openkilda.wfm.share.model.IslReference)8 PathNode (org.openkilda.messaging.info.event.PathNode)7 Instant (java.time.Instant)6 IslDataHolder (org.openkilda.wfm.topology.network.model.IslDataHolder)6 HashSet (java.util.HashSet)4 Set (java.util.Set)4 DiscoverIslCommandData (org.openkilda.messaging.command.discovery.DiscoverIslCommandData)4 IslNotFoundException (org.openkilda.wfm.error.IslNotFoundException)4 Values (org.apache.storm.tuple.Values)3 IslRoundTripLatency (org.openkilda.messaging.info.event.IslRoundTripLatency)3 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)3 CommandContext (org.openkilda.wfm.CommandContext)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 HashMap (java.util.HashMap)2