Search in sources :

Example 61 with Endpoint

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

the class NetworkUniIslServiceTest method selfLoopWhenDownAndRemoteIsNotSet.

@Test
public void selfLoopWhenDownAndRemoteIsNotSet() {
    NetworkUniIslService service = new NetworkUniIslService(carrier);
    final Endpoint endpointAlpha1 = Endpoint.of(alphaDatapath, 1);
    final Endpoint endpointAlpha2 = Endpoint.of(alphaDatapath, 2);
    final Endpoint endpointBeta3 = Endpoint.of(betaDatapath, 3);
    // setup
    service.uniIslSetup(endpointAlpha1, null);
    verifyNoMoreInteractions(carrier);
    // fail
    service.uniIslPhysicalDown(endpointAlpha1);
    verify(carrier).exhaustedPollModeUpdateRequest(endpointAlpha1, true);
    verifyNoMoreInteractions(carrier);
    // discovery (self-loop)
    Isl selfLoopIsl = makeIslBuilder(endpointAlpha1, endpointAlpha2).build();
    service.uniIslDiscovery(endpointAlpha1, IslMapper.INSTANCE.map(selfLoopIsl));
    verify(carrier).exhaustedPollModeUpdateRequest(endpointAlpha1, true);
    verifyNoMoreInteractions(carrier);
    // ensure following discovery will be processed
    verifyIslCanBeDiscovered(service, makeIslBuilder(endpointAlpha1, endpointBeta3).build());
}
Also used : Isl(org.openkilda.model.Isl) Endpoint(org.openkilda.wfm.share.model.Endpoint) Test(org.junit.Test)

Example 62 with Endpoint

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

the class NetworkWatcherServiceTest method discovery.

@Test
public void discovery() {
    NetworkWatcherService w = makeService();
    w.addWatch(Endpoint.of(new SwitchId(1), 1), 1);
    w.addWatch(Endpoint.of(new SwitchId(1), 2), 1);
    w.addWatch(Endpoint.of(new SwitchId(2), 1), 2);
    w.addWatch(Endpoint.of(new SwitchId(2), 1), 2);
    w.addWatch(Endpoint.of(new SwitchId(2), 2), 3);
    assertThat(w.getConfirmedPackets().size(), is(0));
    assertThat(w.getTimeouts().size(), is(3));
    verify(carrier, times(5)).sendDiscovery(any(DiscoverIslCommandData.class));
    w.confirmation(Endpoint.of(new SwitchId(1), 1), 0);
    w.confirmation(Endpoint.of(new SwitchId(2), 1), 2);
    assertThat(w.getConfirmedPackets().size(), is(2));
    PathNode source = new PathNode(new SwitchId(1), 1, 0);
    PathNode destination = new PathNode(new SwitchId(2), 1, 0);
    IslInfoData islAlphaBeta = IslInfoData.builder().source(source).destination(destination).packetId(0L).build();
    IslInfoData islBetaAlpha = IslInfoData.builder().source(destination).destination(source).packetId(2L).build();
    w.discovery(islAlphaBeta);
    w.discovery(islBetaAlpha);
    w.tick(100);
    assertThat(w.getConfirmedPackets().size(), is(0));
    verify(carrier).oneWayDiscoveryReceived(eq(new Endpoint(islAlphaBeta.getSource())), eq(0L), eq(islAlphaBeta), anyLong());
    verify(carrier).oneWayDiscoveryReceived(eq(new Endpoint(islBetaAlpha.getSource())), eq(2L), eq(islBetaAlpha), anyLong());
    verify(carrier, times(2)).oneWayDiscoveryReceived(any(Endpoint.class), anyLong(), any(IslInfoData.class), anyLong());
    assertThat(w.getTimeouts().size(), is(0));
}
Also used : DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData) 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 63 with Endpoint

use of org.openkilda.wfm.share.model.Endpoint 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);
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint) SpeakerSwitchView(org.openkilda.messaging.model.SpeakerSwitchView) PortInfoData(org.openkilda.messaging.info.event.PortInfoData) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) Test(org.junit.Test)

Example 64 with Endpoint

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

the class LinkOperationsServiceTest method verifyBfdProperties.

private void verifyBfdProperties(BfdProperties expectedValue) {
    Endpoint source = Endpoint.of(TEST_SWITCH_A_ID, TEST_SWITCH_A_PORT);
    Endpoint destination = Endpoint.of(TEST_SWITCH_B_ID, TEST_SWITCH_B_PORT);
    verifyBfdProperties(source, destination, expectedValue);
    verifyBfdProperties(destination, source, expectedValue);
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint)

Example 65 with Endpoint

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

the class SwitchOperationsServiceTest method setUpOnce.

@BeforeClass
public static void setUpOnce() {
    RepositoryFactory repositoryFactory = persistenceManager.getRepositoryFactory();
    switchRepository = repositoryFactory.createSwitchRepository();
    switchPropertiesRepository = repositoryFactory.createSwitchPropertiesRepository();
    portPropertiesRepository = repositoryFactory.createPortPropertiesRepository();
    flowRepository = repositoryFactory.createFlowRepository();
    mirrorGroupRepository = repositoryFactory.createMirrorGroupRepository();
    flowMirrorPointsRepository = repositoryFactory.createFlowMirrorPointsRepository();
    flowMirrorPathRepository = repositoryFactory.createFlowMirrorPathRepository();
    lagLogicalPortRepository = repositoryFactory.createLagLogicalPortRepository();
    SwitchOperationsServiceCarrier carrier = new SwitchOperationsServiceCarrier() {

        @Override
        public void requestSwitchSync(SwitchId switchId) {
        }

        @Override
        public void enableServer42FlowRttOnSwitch(SwitchId switchId) {
        }

        @Override
        public void disableServer42FlowRttOnSwitch(SwitchId switchId) {
        }

        @Override
        public void enableServer42IslRttOnSwitch(SwitchId switchId) {
        }

        @Override
        public void disableServer42IslRttOnSwitch(SwitchId switchId) {
        }
    };
    ILinkOperationsServiceCarrier linkCarrier = new ILinkOperationsServiceCarrier() {

        @Override
        public void islBfdPropertiesChanged(Endpoint source, Endpoint destination) {
        }
    };
    switchOperationsService = new SwitchOperationsService(persistenceManager.getRepositoryFactory(), persistenceManager.getTransactionManager(), carrier, linkCarrier);
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint) SwitchId(org.openkilda.model.SwitchId) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) BeforeClass(org.junit.BeforeClass)

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