Search in sources :

Example 16 with IslReference

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

the class NetworkIslServiceTest method initialMoveEvent.

@Test
@Ignore("become invalid due to change initialisation logic")
public void initialMoveEvent() {
    emulateEmptyPersistentDb();
    IslReference ref = new IslReference(endpointAlpha1, endpointBeta2);
    service.islMove(ref.getSource(), ref);
    // System.out.println(mockingDetails(carrier).printInvocations());
    verify(carrier, times(2)).triggerReroute(any(RerouteAffectedFlows.class));
    // System.out.println(mockingDetails(islRepository).printInvocations());
    verify(islRepository).add(argThat(link -> link.getSrcSwitchId().equals(endpointAlpha1.getDatapath()) && link.getSrcPort() == endpointAlpha1.getPortNumber() && link.getDestSwitchId().equals(endpointBeta2.getDatapath()) && link.getDestPort() == endpointBeta2.getPortNumber() && link.getActualStatus() == IslStatus.INACTIVE && link.getStatus() == IslStatus.INACTIVE));
    verify(islRepository).add(argThat(link -> link.getSrcSwitchId().equals(endpointBeta2.getDatapath()) && link.getSrcPort() == endpointBeta2.getPortNumber() && link.getDestSwitchId().equals(endpointAlpha1.getDatapath()) && link.getDestPort() == endpointAlpha1.getPortNumber() && link.getActualStatus() == IslStatus.INACTIVE && link.getStatus() == IslStatus.INACTIVE));
    verifyNoMoreInteractions(carrier);
}
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) IslReference(org.openkilda.wfm.share.model.IslReference) RerouteAffectedFlows(org.openkilda.messaging.command.reroute.RerouteAffectedFlows) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 17 with IslReference

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

the class NetworkIslServiceTest method considerLinkPropsDataOnCreate.

@Test
public void considerLinkPropsDataOnCreate() {
    setupIslStorageStub();
    mockPersistenceLinkProps(endpointAlpha1, endpointBeta2, makeLinkProps(endpointAlpha1, endpointBeta2).maxBandwidth(50L).build());
    mockPersistenceLinkProps(endpointBeta2, endpointAlpha1, null);
    mockPersistenceBandwidthAllocation(endpointAlpha1, endpointBeta2, 0L);
    mockPersistenceBandwidthAllocation(endpointBeta2, endpointAlpha1, 0L);
    IslReference reference = new IslReference(endpointAlpha1, endpointBeta2);
    service.islUp(endpointAlpha1, reference, new IslDataHolder(200L, 200L, 200L));
    service.islUp(endpointBeta2, reference, new IslDataHolder(200L, 200L, 200L));
    verifyIslBandwidthUpdate(50L, 200L);
}
Also used : IslReference(org.openkilda.wfm.share.model.IslReference) IslDataHolder(org.openkilda.wfm.topology.network.model.IslDataHolder) Test(org.junit.Test)

Example 18 with IslReference

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

the class NetworkIslServiceTest method noIslCreationOnIslDown.

@Test
public void noIslCreationOnIslDown() {
    setupIslStorageStub();
    IslReference reference = new IslReference(endpointAlpha1, endpointBeta2);
    for (IslDownReason reason : IslDownReason.values()) {
        try {
            service.islDown(reference.getSource(), reference, reason);
            Assert.fail("No expected exception IslControllerNotFoundException");
        } catch (IslControllerNotFoundException e) {
        // expected
        }
    }
}
Also used : IslControllerNotFoundException(org.openkilda.wfm.topology.network.error.IslControllerNotFoundException) IslReference(org.openkilda.wfm.share.model.IslReference) IslDownReason(org.openkilda.model.IslDownReason) Test(org.junit.Test)

Example 19 with IslReference

use of org.openkilda.wfm.share.model.IslReference 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 20 with IslReference

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

the class NetworkIslServiceTest method noResurrectOnPollFail.

@Test
public void noResurrectOnPollFail() {
    IslReference reference = prepareResurrection();
    service.islDown(reference.getSource(), reference, IslDownReason.POLL_TIMEOUT);
    testResurrection(reference, false);
}
Also used : IslReference(org.openkilda.wfm.share.model.IslReference) Test(org.junit.Test)

Aggregations

IslReference (org.openkilda.wfm.share.model.IslReference)50 Test (org.junit.Test)30 IslDataHolder (org.openkilda.wfm.topology.network.model.IslDataHolder)16 Isl (org.openkilda.model.Isl)13 RoundTripStatus (org.openkilda.wfm.topology.network.model.RoundTripStatus)10 Endpoint (org.openkilda.wfm.share.model.Endpoint)8 Instant (java.time.Instant)4 Values (org.apache.storm.tuple.Values)4 RemoveIslDefaultRulesResult (org.openkilda.messaging.info.discovery.RemoveIslDefaultRulesResult)4 Ignore (org.junit.Ignore)3 Switch (org.openkilda.model.Switch)3 Duration (java.time.Duration)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 AllArgsConstructor (lombok.AllArgsConstructor)2 EqualsAndHashCode (lombok.EqualsAndHashCode)2