Search in sources :

Example 6 with IslImmutableView

use of org.openkilda.persistence.repositories.IslRepository.IslImmutableView in project open-kilda by telstra.

the class FermaIslRepositoryTest method shouldSkipIslOccupiedByFlowWithNoEnoughBandwidth.

@Test
public void shouldSkipIslOccupiedByFlowWithNoEnoughBandwidth() {
    createIsl(switchA, 1, switchB, 2, IslStatus.ACTIVE, 99L);
    Flow flow = createFlowWithPath(0, 0);
    List<IslImmutableView> foundIsls = Lists.newArrayList(islRepository.findActiveByPathAndBandwidthAndEncapsulationType(flow.getPathIds().iterator().next(), 100, FlowEncapsulationType.TRANSIT_VLAN));
    assertThat(foundIsls, Matchers.hasSize(0));
}
Also used : IslImmutableView(org.openkilda.persistence.repositories.IslRepository.IslImmutableView) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 7 with IslImmutableView

use of org.openkilda.persistence.repositories.IslRepository.IslImmutableView in project open-kilda by telstra.

the class AvailableNetworkFactoryTest method shouldBuildAvailableNetworkUsingSymmetricCostStrategy.

@Test
public void shouldBuildAvailableNetworkUsingSymmetricCostStrategy() throws RecoverableException {
    Flow flow = getFlow(false);
    IslImmutableView isl = getIslView(flow);
    when(config.getNetworkStrategy()).thenReturn("SYMMETRIC_COST");
    when(islRepository.findSymmetricActiveByBandwidthAndEncapsulationType(flow.getBandwidth(), flow.getEncapsulationType())).thenReturn(Collections.singletonList(isl));
    AvailableNetwork availableNetwork = availableNetworkFactory.getAvailableNetwork(flow, Collections.emptyList());
    assertAvailableNetworkIsCorrect(isl, availableNetwork);
}
Also used : IslImmutableView(org.openkilda.persistence.repositories.IslRepository.IslImmutableView) AvailableNetwork(org.openkilda.pce.impl.AvailableNetwork) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 8 with IslImmutableView

use of org.openkilda.persistence.repositories.IslRepository.IslImmutableView in project open-kilda by telstra.

the class AvailableNetworkFactoryTest method shouldBuildAvailableNetworkUsingCostStrategy.

@Test
public void shouldBuildAvailableNetworkUsingCostStrategy() throws RecoverableException {
    Flow flow = getFlow(false);
    IslImmutableView isl = getIslView(flow);
    when(config.getNetworkStrategy()).thenReturn("COST");
    when(islRepository.findActiveByBandwidthAndEncapsulationType(flow.getBandwidth(), flow.getEncapsulationType())).thenReturn(Collections.singletonList(isl));
    AvailableNetwork availableNetwork = availableNetworkFactory.getAvailableNetwork(flow, Collections.emptyList());
    assertAvailableNetworkIsCorrect(isl, availableNetwork);
}
Also used : IslImmutableView(org.openkilda.persistence.repositories.IslRepository.IslImmutableView) AvailableNetwork(org.openkilda.pce.impl.AvailableNetwork) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 9 with IslImmutableView

use of org.openkilda.persistence.repositories.IslRepository.IslImmutableView in project open-kilda by telstra.

the class FermaIslRepositoryTest method shouldFindIslOccupiedByFlowWithAvailableBandwidth.

@Test
public void shouldFindIslOccupiedByFlowWithAvailableBandwidth() {
    Isl isl = createIsl(switchA, 1, switchB, 2, IslStatus.ACTIVE, 101L);
    Flow flow = createFlowWithPath(0, 0);
    PathId pathId = flow.getPaths().stream().filter(path -> path.getSegments().get(0).getSrcPort() == isl.getSrcPort()).findAny().map(FlowPath::getPathId).orElseThrow(AssertionFailedError::new);
    List<IslImmutableView> foundIsls = Lists.newArrayList(islRepository.findActiveByPathAndBandwidthAndEncapsulationType(pathId, 100, FlowEncapsulationType.TRANSIT_VLAN));
    assertThat(foundIsls, Matchers.hasSize(1));
}
Also used : PathId(org.openkilda.model.PathId) IslImmutableView(org.openkilda.persistence.repositories.IslRepository.IslImmutableView) PathSegment(org.openkilda.model.PathSegment) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) FlowPath(org.openkilda.model.FlowPath) FlowStatus(org.openkilda.model.FlowStatus) FlowPathStatus(org.openkilda.model.FlowPathStatus) Lists(com.google.common.collect.Lists) Flow(org.openkilda.model.Flow) IslRepository(org.openkilda.persistence.repositories.IslRepository) Map(java.util.Map) Assert.fail(org.junit.Assert.fail) FlowRepository(org.openkilda.persistence.repositories.FlowRepository) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathId(org.openkilda.model.PathId) SwitchProperties(org.openkilda.model.SwitchProperties) Before(org.junit.Before) FlowEncapsulationType(org.openkilda.model.FlowEncapsulationType) Switch(org.openkilda.model.Switch) FlowPathRepository(org.openkilda.persistence.repositories.FlowPathRepository) Collection(java.util.Collection) Assert.assertTrue(org.junit.Assert.assertTrue) Matchers(org.hamcrest.Matchers) Set(java.util.Set) AssertionFailedError(junit.framework.AssertionFailedError) Test(org.junit.Test) IslStatus(org.openkilda.model.IslStatus) PersistenceException(org.openkilda.persistence.exceptions.PersistenceException) MeterId(org.openkilda.model.MeterId) SwitchPropertiesRepository(org.openkilda.persistence.repositories.SwitchPropertiesRepository) List(java.util.List) SwitchId(org.openkilda.model.SwitchId) Ignore(org.junit.Ignore) Isl(org.openkilda.model.Isl) SwitchStatus(org.openkilda.model.SwitchStatus) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) SwitchRepository(org.openkilda.persistence.repositories.SwitchRepository) IslImmutableView(org.openkilda.persistence.repositories.IslRepository.IslImmutableView) Isl(org.openkilda.model.Isl) AssertionFailedError(junit.framework.AssertionFailedError) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 10 with IslImmutableView

use of org.openkilda.persistence.repositories.IslRepository.IslImmutableView in project open-kilda by telstra.

the class FermaIslRepositoryTest method shouldFindActiveIslWithAvailableBandwidth.

@Test
public void shouldFindActiveIslWithAvailableBandwidth() {
    Isl isl = createIsl(switchA, 111, switchB, 112, IslStatus.ACTIVE, 101L);
    List<IslImmutableView> foundIsls = Lists.newArrayList(islRepository.findActiveByBandwidthAndEncapsulationType(100, FlowEncapsulationType.TRANSIT_VLAN));
    assertThat(foundIsls, Matchers.hasSize(1));
    assertEquals(isl.getAvailableBandwidth(), foundIsls.get(0).getAvailableBandwidth());
}
Also used : IslImmutableView(org.openkilda.persistence.repositories.IslRepository.IslImmutableView) Isl(org.openkilda.model.Isl) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Aggregations

IslImmutableView (org.openkilda.persistence.repositories.IslRepository.IslImmutableView)10 Test (org.junit.Test)9 Flow (org.openkilda.model.Flow)8 AvailableNetwork (org.openkilda.pce.impl.AvailableNetwork)6 FlowPath (org.openkilda.model.FlowPath)3 PathId (org.openkilda.model.PathId)3 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)3 Isl (org.openkilda.model.Isl)2 Lists (com.google.common.collect.Lists)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 AssertionFailedError (junit.framework.AssertionFailedError)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Matchers (org.hamcrest.Matchers)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertTrue (org.junit.Assert.assertTrue)1