Search in sources :

Example 11 with IslDataHolder

use of org.openkilda.wfm.topology.network.model.IslDataHolder in project open-kilda by telstra.

the class NetworkUniIslServiceTest method newIslFromUnknownToDownToUp.

@Test
public void newIslFromUnknownToDownToUp() {
    NetworkUniIslService service = new NetworkUniIslService(carrier);
    Endpoint endpoint1 = Endpoint.of(alphaDatapath, 1);
    Endpoint endpoint2 = Endpoint.of(alphaDatapath, 2);
    Switch alphaSwitch = Switch.builder().switchId(alphaDatapath).build();
    Switch betaSwitch = Switch.builder().switchId(betaDatapath).build();
    Isl islAtoB = Isl.builder().srcSwitch(alphaSwitch).srcPort(1).destSwitch(betaSwitch).destPort(1).build();
    Isl islAtoB2 = Isl.builder().srcSwitch(alphaSwitch).srcPort(2).destSwitch(betaSwitch).destPort(2).build();
    Isl islAtoB3 = Isl.builder().srcSwitch(alphaSwitch).srcPort(1).destSwitch(betaSwitch).destPort(3).build();
    service.uniIslSetup(endpoint1, islAtoB);
    service.uniIslSetup(endpoint2, null);
    service.uniIslFail(endpoint1);
    service.uniIslPhysicalDown(endpoint2);
    resetMocks();
    IslInfoData disco1 = IslMapper.INSTANCE.map(islAtoB3);
    IslInfoData disco2 = IslMapper.INSTANCE.map(islAtoB2);
    service.uniIslDiscovery(endpoint1, disco1);
    service.uniIslDiscovery(endpoint2, disco2);
    System.out.println(mockingDetails(carrier).printInvocations());
    verify(carrier).notifyIslMove(endpoint1, IslReference.of(islAtoB));
    verify(carrier).notifyIslUp(endpoint1, IslReference.of(islAtoB3), new IslDataHolder(islAtoB2));
    verify(carrier).notifyIslUp(endpoint2, IslReference.of(islAtoB2), new IslDataHolder(islAtoB2));
}
Also used : Isl(org.openkilda.model.Isl) Endpoint(org.openkilda.wfm.share.model.Endpoint) Switch(org.openkilda.model.Switch) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) IslDataHolder(org.openkilda.wfm.topology.network.model.IslDataHolder) Test(org.junit.Test)

Example 12 with IslDataHolder

use of org.openkilda.wfm.topology.network.model.IslDataHolder in project open-kilda by telstra.

the class NetworkUniIslServiceTest method verifyIslCanBeDiscovered.

private void verifyIslCanBeDiscovered(NetworkUniIslService service, Isl link) {
    Endpoint endpointA = Endpoint.of(link.getSrcSwitchId(), link.getSrcPort());
    Endpoint endpointZ = Endpoint.of(link.getDestSwitchId(), link.getDestPort());
    service.uniIslDiscovery(endpointA, IslMapper.INSTANCE.map(link));
    verify(carrier).notifyIslUp(endpointA, new IslReference(endpointA, endpointZ), new IslDataHolder(link));
    verify(carrier).exhaustedPollModeUpdateRequest(endpointA, false);
    verifyNoMoreInteractions(carrier);
    reset(carrier);
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint) IslReference(org.openkilda.wfm.share.model.IslReference) IslDataHolder(org.openkilda.wfm.topology.network.model.IslDataHolder)

Example 13 with IslDataHolder

use of org.openkilda.wfm.topology.network.model.IslDataHolder in project open-kilda by telstra.

the class DiscoveryPollMonitor method load.

@Override
public void load(Endpoint endpoint, Isl persistentView) {
    super.load(endpoint, persistentView);
    IslDataHolder islData = new IslDataHolder(persistentView);
    IslEndpointPollStatus status = new IslEndpointPollStatus(islData, persistentView.getStatus());
    discoveryData.put(endpoint, status);
    cache.put(endpoint, status);
}
Also used : IslEndpointPollStatus(org.openkilda.wfm.topology.network.model.IslEndpointPollStatus) IslDataHolder(org.openkilda.wfm.topology.network.model.IslDataHolder)

Example 14 with IslDataHolder

use of org.openkilda.wfm.topology.network.model.IslDataHolder in project open-kilda by telstra.

the class NetworkIslServiceTest method resurrectAfterRemoval.

@Test
public void resurrectAfterRemoval() {
    IslReference reference = prepareResurrection();
    service.islUp(reference.getSource(), reference, new IslDataHolder(1000, 1000, 1000));
    testResurrection(reference, true);
}
Also used : IslReference(org.openkilda.wfm.share.model.IslReference) IslDataHolder(org.openkilda.wfm.topology.network.model.IslDataHolder) Test(org.junit.Test)

Example 15 with IslDataHolder

use of org.openkilda.wfm.topology.network.model.IslDataHolder in project open-kilda by telstra.

the class NetworkIslServiceTest method continuousReplugVsRoundTripAlive.

@Test
public void continuousReplugVsRoundTripAlive() {
    setupIslStorageStub();
    IslReference referenceAlpha = prepareActiveIsl();
    IslReference referenceBeta = new IslReference(Endpoint.of(referenceAlpha.getSource().getDatapath(), referenceAlpha.getSource().getPortNumber() + 1), referenceAlpha.getDest());
    Instant lastSeen = clock.instant();
    service.roundTripStatusNotification(referenceAlpha, new RoundTripStatus(referenceAlpha.getSource(), IslStatus.ACTIVE));
    IslDataHolder alphaSource = new IslDataHolder(lookupIsl(referenceAlpha.getSource(), referenceAlpha.getDest()));
    IslDataHolder alphaDest = new IslDataHolder(lookupIsl(referenceAlpha.getDest(), referenceAlpha.getSource()));
    IslDataHolder betaSource = new IslDataHolder(makeIsl(referenceBeta.getSource(), referenceBeta.getDest(), false).build());
    IslDataHolder betaDest = new IslDataHolder(makeIsl(referenceBeta.getDest(), referenceBeta.getSource(), false).build());
    IslStatusUpdateNotification alphaNotification = new IslStatusUpdateNotification(referenceAlpha.getSource().getDatapath(), referenceAlpha.getSource().getPortNumber(), referenceAlpha.getDest().getDatapath(), referenceAlpha.getDest().getPortNumber(), IslStatus.MOVED);
    IslStatusUpdateNotification betaNotification = new IslStatusUpdateNotification(referenceBeta.getSource().getDatapath(), referenceBeta.getSource().getPortNumber(), referenceBeta.getDest().getDatapath(), referenceBeta.getDest().getPortNumber(), IslStatus.MOVED);
    for (int i = 0; i < 100; i++) {
        // alpha -> beta
        service.islMove(referenceAlpha.getSource(), referenceAlpha);
        service.islUp(referenceBeta.getSource(), referenceBeta, betaSource);
        service.islUp(referenceBeta.getDest(), referenceBeta, betaDest);
        service.roundTripStatusNotification(referenceBeta, new RoundTripStatus(referenceBeta.getSource(), IslStatus.ACTIVE));
        verifyStatus(referenceAlpha, IslStatus.MOVED);
        verifyStatus(referenceBeta, IslStatus.ACTIVE);
        verify(carrier, times(i + 1)).islStatusUpdateNotification(eq(alphaNotification));
        verify(carrier, times(i + 1)).triggerReroute(argThat(entry -> entry instanceof RerouteAffectedFlows && Objects.equals(new PathNode(referenceAlpha.getSource().getDatapath(), referenceAlpha.getSource().getPortNumber(), 0), entry.getPathNode())));
        verify(carrier, times(i + 1)).triggerReroute(argThat(entry -> entry instanceof RerouteInactiveFlows && Objects.equals(new PathNode(referenceBeta.getSource().getDatapath(), referenceBeta.getSource().getPortNumber(), 0), entry.getPathNode())));
        // beta -> alpha
        service.islMove(referenceBeta.getSource(), referenceBeta);
        service.islUp(referenceAlpha.getSource(), referenceAlpha, alphaSource);
        service.islUp(referenceAlpha.getDest(), referenceAlpha, alphaDest);
        service.roundTripStatusNotification(referenceAlpha, new RoundTripStatus(referenceAlpha.getSource(), IslStatus.ACTIVE));
        verifyStatus(referenceAlpha, IslStatus.ACTIVE);
        verifyStatus(referenceBeta, IslStatus.MOVED);
        verify(carrier, times(i + 1)).islStatusUpdateNotification(eq(betaNotification));
        verify(carrier, times(i + 1)).triggerReroute(argThat(entry -> entry instanceof RerouteAffectedFlows && Objects.equals(new PathNode(referenceBeta.getSource().getDatapath(), referenceBeta.getSource().getPortNumber(), 0), entry.getPathNode())));
        verify(carrier, times(i + 1)).triggerReroute(argThat(entry -> entry instanceof RerouteInactiveFlows && Objects.equals(new PathNode(referenceAlpha.getSource().getDatapath(), referenceAlpha.getSource().getPortNumber(), 0), entry.getPathNode())));
    }
}
Also used : Mockito.mockingDetails(org.mockito.Mockito.mockingDetails) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) KildaFeatureTogglesRepository(org.openkilda.persistence.repositories.KildaFeatureTogglesRepository) IslReference(org.openkilda.wfm.share.model.IslReference) NetworkOptions(org.openkilda.wfm.topology.network.model.NetworkOptions) IslDataHolder(org.openkilda.wfm.topology.network.model.IslDataHolder) KildaFeatureToggles(org.openkilda.model.KildaFeatureToggles) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) RerouteAffectedFlows(org.openkilda.messaging.command.reroute.RerouteAffectedFlows) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Duration(java.time.Duration) Map(java.util.Map) LinkProps(org.openkilda.model.LinkProps) ClassRule(org.junit.ClassRule) SwitchProperties(org.openkilda.model.SwitchProperties) IslStatusUpdateNotification(org.openkilda.messaging.info.event.IslStatusUpdateNotification) IslDownReason(org.openkilda.model.IslDownReason) ManualClock(org.openkilda.stubs.ManualClock) FlowPathRepository(org.openkilda.persistence.repositories.FlowPathRepository) BfdStatusUpdate(org.openkilda.wfm.topology.network.model.BfdStatusUpdate) RetryPolicy(net.jodah.failsafe.RetryPolicy) EqualsAndHashCode(lombok.EqualsAndHashCode) Instant(java.time.Instant) BfdSessionStatus(org.openkilda.model.BfdSessionStatus) Objects(java.util.Objects) SwitchPropertiesRepository(org.openkilda.persistence.repositories.SwitchPropertiesRepository) List(java.util.List) Optional(java.util.Optional) RerouteInactiveFlows(org.openkilda.messaging.command.reroute.RerouteInactiveFlows) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) SwitchRepository(org.openkilda.persistence.repositories.SwitchRepository) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) RoundTripStatus(org.openkilda.wfm.topology.network.model.RoundTripStatus) BfdProperties(org.openkilda.model.BfdProperties) TransactionManager(org.openkilda.persistence.tx.TransactionManager) Getter(lombok.Getter) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) Mockito.verifyZeroInteractions(org.mockito.Mockito.verifyZeroInteractions) RemoveIslDefaultRulesResult(org.openkilda.messaging.info.discovery.RemoveIslDefaultRulesResult) LinkPropsRepository(org.openkilda.persistence.repositories.LinkPropsRepository) IslControllerNotFoundException(org.openkilda.wfm.topology.network.error.IslControllerNotFoundException) IslRepository(org.openkilda.persistence.repositories.IslRepository) PersistenceManager(org.openkilda.persistence.PersistenceManager) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) Before(org.junit.Before) InMemoryGraphPersistenceManager(org.openkilda.persistence.inmemory.InMemoryGraphPersistenceManager) Switch(org.openkilda.model.Switch) Endpoint(org.openkilda.wfm.share.model.Endpoint) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) IslStatus(org.openkilda.model.IslStatus) PathNode(org.openkilda.messaging.info.event.PathNode) Mockito.verify(org.mockito.Mockito.verify) Failsafe(net.jodah.failsafe.Failsafe) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) Mockito(org.mockito.Mockito) Mockito.never(org.mockito.Mockito.never) SwitchId(org.openkilda.model.SwitchId) Ignore(org.junit.Ignore) InstallIslDefaultRulesResult(org.openkilda.messaging.info.discovery.InstallIslDefaultRulesResult) TransactionCallbackWithoutResult(org.openkilda.persistence.tx.TransactionCallbackWithoutResult) AllArgsConstructor(lombok.AllArgsConstructor) Assert(org.junit.Assert) Mockito.reset(org.mockito.Mockito.reset) Isl(org.openkilda.model.Isl) SwitchStatus(org.openkilda.model.SwitchStatus) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) TemporaryFolder(org.junit.rules.TemporaryFolder) NetworkTopologyDashboardLogger(org.openkilda.wfm.topology.network.NetworkTopologyDashboardLogger) IslStatusUpdateNotification(org.openkilda.messaging.info.event.IslStatusUpdateNotification) IslReference(org.openkilda.wfm.share.model.IslReference) Instant(java.time.Instant) RerouteAffectedFlows(org.openkilda.messaging.command.reroute.RerouteAffectedFlows) RoundTripStatus(org.openkilda.wfm.topology.network.model.RoundTripStatus) PathNode(org.openkilda.messaging.info.event.PathNode) RerouteInactiveFlows(org.openkilda.messaging.command.reroute.RerouteInactiveFlows) IslDataHolder(org.openkilda.wfm.topology.network.model.IslDataHolder) Endpoint(org.openkilda.wfm.share.model.Endpoint) Test(org.junit.Test)

Aggregations

IslDataHolder (org.openkilda.wfm.topology.network.model.IslDataHolder)20 Test (org.junit.Test)15 IslReference (org.openkilda.wfm.share.model.IslReference)15 Isl (org.openkilda.model.Isl)9 Endpoint (org.openkilda.wfm.share.model.Endpoint)7 Switch (org.openkilda.model.Switch)3 Ignore (org.junit.Ignore)2 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)2 Duration (java.time.Duration)1 Instant (java.time.Instant)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 AllArgsConstructor (lombok.AllArgsConstructor)1 EqualsAndHashCode (lombok.EqualsAndHashCode)1 Getter (lombok.Getter)1 Failsafe (net.jodah.failsafe.Failsafe)1