Search in sources :

Example 81 with Isl

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

the class FermaIslRepositoryTest method shouldUpdateAvailableBandwidthByPath.

@Test
public void shouldUpdateAvailableBandwidthByPath() {
    Isl isl = createIsl(switchA, 1, switchB, 2, IslStatus.ACTIVE, 100L);
    isl.setMaxBandwidth(100L);
    createPathWithSegment(TEST_FLOW_ID, switchA, 1, switchB, 2, 33L);
    islRepository.updateAvailableBandwidthOnIslsOccupiedByPath(new PathId(TEST_FLOW_ID));
    Isl islAfter = islRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2).get();
    assertEquals(67, 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 82 with Isl

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

the class FermaIslRepositoryTest method shouldFindIslBySrcSwitch.

@Test
public void shouldFindIslBySrcSwitch() {
    Isl isl1 = createIsl(switchA, 111, switchB, 112);
    Isl isl2 = createIsl(switchA, 112, switchB, 113);
    List<Isl> foundIsls = Lists.newArrayList(islRepository.findBySrcSwitch(TEST_SWITCH_A_ID));
    assertThat(foundIsls, Matchers.hasSize(2));
    assertThat(foundIsls, Matchers.containsInAnyOrder(isl1, isl2));
}
Also used : Isl(org.openkilda.model.Isl) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 83 with Isl

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

the class FermaIslRepositoryTest method shouldFindIslByPartialEndpoints.

@Test
public void shouldFindIslByPartialEndpoints() {
    Isl isl1 = createIsl(switchA, 111, switchB, 121);
    Isl isl2 = createIsl(switchA, 112, switchC, 121);
    List<Isl> foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(TEST_SWITCH_A_ID, 111, TEST_SWITCH_B_ID, 121));
    assertThat(foundIsls, Matchers.hasSize(1));
    assertThat(foundIsls, Matchers.contains(isl1));
    foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(TEST_SWITCH_A_ID, 111, TEST_SWITCH_B_ID, null));
    assertThat(foundIsls, Matchers.hasSize(1));
    assertThat(foundIsls, Matchers.contains(isl1));
    foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(TEST_SWITCH_A_ID, null, TEST_SWITCH_B_ID, 121));
    assertThat(foundIsls, Matchers.hasSize(1));
    assertThat(foundIsls, Matchers.contains(isl1));
    foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(TEST_SWITCH_A_ID, null, TEST_SWITCH_B_ID, null));
    assertThat(foundIsls, Matchers.hasSize(1));
    assertThat(foundIsls, Matchers.contains(isl1));
    foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(TEST_SWITCH_A_ID, 111, null, null));
    assertThat(foundIsls, Matchers.hasSize(1));
    assertThat(foundIsls, Matchers.contains(isl1));
    foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(TEST_SWITCH_A_ID, null, null, 121));
    assertThat(foundIsls, Matchers.hasSize(2));
    assertThat(foundIsls, Matchers.containsInAnyOrder(isl1, isl2));
    foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(TEST_SWITCH_A_ID, null, null, null));
    assertThat(foundIsls, Matchers.hasSize(2));
    assertThat(foundIsls, Matchers.containsInAnyOrder(isl1, isl2));
    foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(new SwitchId(123456), null, null, null));
    assertThat(foundIsls, Matchers.empty());
    foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(TEST_SWITCH_A_ID, null, new SwitchId(123456), null));
    assertThat(foundIsls, Matchers.empty());
    foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(null, 111, TEST_SWITCH_B_ID, 121));
    assertThat(foundIsls, Matchers.hasSize(1));
    assertThat(foundIsls, Matchers.contains(isl1));
    foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(null, 111, TEST_SWITCH_B_ID, null));
    assertThat(foundIsls, Matchers.hasSize(1));
    assertThat(foundIsls, Matchers.contains(isl1));
    foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(null, null, TEST_SWITCH_B_ID, 121));
    assertThat(foundIsls, Matchers.hasSize(1));
    assertThat(foundIsls, Matchers.contains(isl1));
    foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(null, 111, null, null));
    assertThat(foundIsls, Matchers.hasSize(1));
    assertThat(foundIsls, Matchers.contains(isl1));
    foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(null, null, null, 121));
    assertThat(foundIsls, Matchers.hasSize(2));
    assertThat(foundIsls, Matchers.containsInAnyOrder(isl1, isl2));
}
Also used : Isl(org.openkilda.model.Isl) SwitchId(org.openkilda.model.SwitchId) 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