Search in sources :

Example 71 with Isl

use of org.openkilda.model.Isl in project open-kilda by telstra.

the class FermaIslRepositoryTest method shouldUpdateAvailableBandwidthForAllKindsOfSharedBandwidthGroups.

@Test
public void shouldUpdateAvailableBandwidthForAllKindsOfSharedBandwidthGroups() {
    Isl isl = createIsl(switchA, 1, switchB, 2, IslStatus.ACTIVE, 100L);
    isl.setMaxBandwidth(100L);
    createPathWithSegment("path1", switchA, 1, switchB, 2, 10L, "path12group");
    createPathWithSegment("path2", switchA, 1, switchB, 2, 30L, "path12group");
    createPathWithSegment("path3", switchA, 1, switchB, 2, 50L, "path3group");
    createPathWithSegment("path4", switchA, 1, switchB, 2, 5L);
    islRepository.updateAvailableBandwidth(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2);
    Isl islAfter = islRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2).get();
    assertEquals(15, islAfter.getAvailableBandwidth());
}
Also used : Isl(org.openkilda.model.Isl) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 72 with Isl

use of org.openkilda.model.Isl 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 73 with Isl

use of org.openkilda.model.Isl in project open-kilda by telstra.

the class FermaIslRepositoryTest method shouldNotUpdateAvailableBandwidthByPathIfDoesntMatch.

@Test
public void shouldNotUpdateAvailableBandwidthByPathIfDoesntMatch() {
    Isl isl = createIsl(switchA, 1, switchB, 2, IslStatus.ACTIVE, 100L);
    isl.setMaxBandwidth(100L);
    createPathWithSegment(TEST_FLOW_ID + "_1", switchA, 1, switchB, 2, 33L);
    Collection<?> updatedIsls = islRepository.updateAvailableBandwidthOnIslsOccupiedByPath(new PathId(TEST_FLOW_ID + "_faked")).values();
    assertThat(updatedIsls, Matchers.empty());
    Isl islAfter = islRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2).get();
    assertEquals(100, islAfter.getAvailableBandwidth());
}
Also used : PathId(org.openkilda.model.PathId) Isl(org.openkilda.model.Isl) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 74 with Isl

use of org.openkilda.model.Isl in project open-kilda by telstra.

the class FermaIslRepositoryTest method shouldUpdateAvailableBandwidth.

@Test
public void shouldUpdateAvailableBandwidth() {
    Isl isl = createIsl(switchA, 1, switchB, 2, IslStatus.ACTIVE, 100L);
    isl.setMaxBandwidth(100L);
    createPathWithSegment(TEST_FLOW_ID, switchA, 1, switchB, 2, 33L);
    islRepository.updateAvailableBandwidth(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2);
    Isl islAfter = islRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2).get();
    assertEquals(67, islAfter.getAvailableBandwidth());
}
Also used : Isl(org.openkilda.model.Isl) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 75 with Isl

use of org.openkilda.model.Isl 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

Isl (org.openkilda.model.Isl)83 Test (org.junit.Test)49 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)25 Endpoint (org.openkilda.wfm.share.model.Endpoint)18 Switch (org.openkilda.model.Switch)17 IslReference (org.openkilda.wfm.share.model.IslReference)11 SwitchId (org.openkilda.model.SwitchId)10 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)9 IslDataHolder (org.openkilda.wfm.topology.network.model.IslDataHolder)8 ArrayList (java.util.ArrayList)6 PathId (org.openkilda.model.PathId)6 Flow (org.openkilda.model.Flow)5 IslRepository (org.openkilda.persistence.repositories.IslRepository)5 Collection (java.util.Collection)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)4 FlowPath (org.openkilda.model.FlowPath)4 PersistenceException (org.openkilda.persistence.exceptions.PersistenceException)4 IslFrame (org.openkilda.persistence.ferma.frames.IslFrame)4