Search in sources :

Example 21 with Endpoint

use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.

the class NetworkIslServiceTest method prepareResurrection.

private IslReference prepareResurrection() {
    setupIslStorageStub();
    IslReference reference = prepareActiveIsl(true);
    final Endpoint alphaEnd = reference.getSource();
    final Endpoint zetaEnd = reference.getDest();
    service.islDown(alphaEnd, reference, IslDownReason.POLL_TIMEOUT);
    service.islDown(zetaEnd, reference, IslDownReason.POLL_TIMEOUT);
    reset(carrier);
    service.remove(reference);
    verify(carrier).islDefaultRulesDelete(eq(alphaEnd), eq(zetaEnd));
    verify(carrier).islDefaultRulesDelete(eq(zetaEnd), eq(alphaEnd));
    verify(carrier).bfdDisableRequest(eq(alphaEnd));
    verify(carrier).bfdDisableRequest(eq(zetaEnd));
    verify(carrier).auxiliaryPollModeUpdateRequest(alphaEnd, false);
    verify(carrier).auxiliaryPollModeUpdateRequest(zetaEnd, false);
    verifyNoMoreInteractions(carrier);
    Assert.assertTrue(islStorage.lookup(alphaEnd, zetaEnd).isPresent());
    return reference;
}
Also used : IslReference(org.openkilda.wfm.share.model.IslReference) Endpoint(org.openkilda.wfm.share.model.Endpoint)

Example 22 with Endpoint

use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.

the class NetworkBfdSessionServiceTest method setupCarrier.

private void setupCarrier() {
    doAnswer(invocation -> {
        Endpoint logical = invocation.getArgument(0);
        boolean error = invocation.getArgument(1);
        service.rotate(logical, error);
        return null;
    }).when(carrier).sessionRotateRequest(any(Endpoint.class), any(Boolean.class));
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint)

Example 23 with Endpoint

use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.

the class NetworkPortServiceTest method testEnableDiscoveryAfterOfflineOnlineCycle.

@Test
public void testEnableDiscoveryAfterOfflineOnlineCycle() {
    Endpoint endpoint = Endpoint.of(alphaDatapath, 1);
    when(portPropertiesRepository.getBySwitchIdAndPort(alphaDatapath, endpoint.getPortNumber())).thenReturn(Optional.empty()).thenReturn(Optional.of(PortProperties.builder().switchObj(getDefaultSwitch()).port(endpoint.getPortNumber()).discoveryEnabled(false).build()));
    when(switchRepository.findById(alphaDatapath)).thenReturn(Optional.of(getDefaultSwitch()));
    NetworkPortService service = makeService();
    service.setup(endpoint, null);
    service.updateOnlineMode(endpoint, OnlineStatus.ONLINE);
    service.updateLinkStatus(endpoint, LinkStatus.UP);
    verify(carrier).enableDiscoveryPoll(eq(endpoint));
    service.updatePortProperties(endpoint, false);
    verify(carrier).disableDiscoveryPoll(eq(endpoint));
    service.updateOnlineMode(endpoint, OnlineStatus.OFFLINE);
    service.updateOnlineMode(endpoint, OnlineStatus.ONLINE);
    service.updateLinkStatus(endpoint, LinkStatus.UP);
    // discovery still disabled
    verify(carrier, times(1)).enableDiscoveryPoll(eq(endpoint));
    service.updatePortProperties(endpoint, true);
    verify(carrier, times(2)).enableDiscoveryPoll(eq(endpoint));
    Endpoint remote = Endpoint.of(new SwitchId(endpoint.getDatapath().getId() + 1), 1);
    IslInfoData discovery = new IslInfoData(new PathNode(endpoint.getDatapath(), endpoint.getPortNumber(), 0), new PathNode(remote.getDatapath(), remote.getPortNumber(), 0), IslChangeType.DISCOVERED, false);
    service.discovery(endpoint, discovery);
    verify(carrier).notifyPortDiscovered(eq(endpoint), eq(discovery));
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint) SwitchId(org.openkilda.model.SwitchId) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) PathNode(org.openkilda.messaging.info.event.PathNode) Test(org.junit.Test)

Example 24 with Endpoint

use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.

the class NetworkPortServiceTest method testDiscoveryEventWhenDiscoveryDisabled.

@Test
public void testDiscoveryEventWhenDiscoveryDisabled() {
    Endpoint endpoint = Endpoint.of(alphaDatapath, 1);
    when(portPropertiesRepository.getBySwitchIdAndPort(alphaDatapath, endpoint.getPortNumber())).thenReturn(Optional.empty());
    when(switchRepository.findById(alphaDatapath)).thenReturn(Optional.of(getDefaultSwitch()));
    NetworkPortService service = makeService();
    service.setup(endpoint, null);
    service.updateOnlineMode(endpoint, OnlineStatus.ONLINE);
    service.updateLinkStatus(endpoint, LinkStatus.UP);
    verify(carrier).enableDiscoveryPoll(eq(endpoint));
    verify(carrier, never()).notifyPortDiscovered(eq(endpoint), any(IslInfoData.class));
    service.updatePortProperties(endpoint, false);
    verify(carrier).disableDiscoveryPoll(eq(endpoint));
    Endpoint remote = Endpoint.of(new SwitchId(endpoint.getDatapath().getId() + 1), 1);
    IslInfoData discovery = new IslInfoData(new PathNode(endpoint.getDatapath(), endpoint.getPortNumber(), 0), new PathNode(remote.getDatapath(), remote.getPortNumber(), 0), IslChangeType.DISCOVERED, false);
    service.discovery(endpoint, discovery);
    verify(carrier, never()).notifyPortDiscovered(eq(endpoint), any(IslInfoData.class));
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint) SwitchId(org.openkilda.model.SwitchId) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) PathNode(org.openkilda.messaging.info.event.PathNode) Test(org.junit.Test)

Example 25 with Endpoint

use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.

the class NetworkUniIslServiceTest method fromUptoBfdToUp.

@Test
public void fromUptoBfdToUp() {
    NetworkUniIslService service = new NetworkUniIslService(carrier);
    Endpoint endpoint1 = Endpoint.of(alphaDatapath, 1);
    Switch alphaSwitch = Switch.builder().switchId(alphaDatapath).build();
    Switch betaSwitch = Switch.builder().switchId(betaDatapath).build();
    Isl islA1toB1 = Isl.builder().srcSwitch(alphaSwitch).srcPort(1).destSwitch(betaSwitch).destPort(1).build();
    service.uniIslSetup(endpoint1, islA1toB1);
    IslInfoData disco1 = IslMapper.INSTANCE.map(islA1toB1);
    service.uniIslDiscovery(endpoint1, disco1);
    resetMocks();
    service.uniIslBfdStatusUpdate(endpoint1, BfdStatusUpdate.UP);
    service.uniIslBfdStatusUpdate(endpoint1, BfdStatusUpdate.KILL);
    // System.out.println(mockingDetails(carrier).printInvocations());
    InOrder order = inOrder(carrier);
    order.verify(carrier).notifyBfdStatus(endpoint1, IslReference.of(islA1toB1), BfdStatusUpdate.UP);
    order.verify(carrier).notifyBfdStatus(endpoint1, IslReference.of(islA1toB1), BfdStatusUpdate.KILL);
}
Also used : Isl(org.openkilda.model.Isl) InOrder(org.mockito.InOrder) Endpoint(org.openkilda.wfm.share.model.Endpoint) Switch(org.openkilda.model.Switch) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) 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