Search in sources :

Example 16 with PersistenceException

use of org.openkilda.persistence.exceptions.PersistenceException in project open-kilda by telstra.

the class FermaIslRepositoryTest method shouldNotUpdateAvailableBandwidthIfEndpointDoesntMatch.

@Test
public void shouldNotUpdateAvailableBandwidthIfEndpointDoesntMatch() {
    Isl isl = createIsl(switchA, 1, switchB, 2, IslStatus.ACTIVE, 100L);
    isl.setMaxBandwidth(100L);
    try {
        createPathWithSegment(TEST_FLOW_ID + "_1", switchA, 1, switchB, 3, 33L);
        islRepository.updateAvailableBandwidth(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 3);
        fail();
    } catch (PersistenceException ex) {
    // expected
    }
    Isl islAfter = islRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2).get();
    assertEquals(100, islAfter.getAvailableBandwidth());
    try {
        createPathWithSegment(TEST_FLOW_ID + "_2", switchA, 2, switchB, 2, 33L);
        islRepository.updateAvailableBandwidth(TEST_SWITCH_A_ID, 2, TEST_SWITCH_B_ID, 2);
        fail();
    } catch (PersistenceException ex) {
    // expected
    }
    islAfter = islRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2).get();
    assertEquals(100, islAfter.getAvailableBandwidth());
    try {
        createPathWithSegment(TEST_FLOW_ID + "_3", switchC, 1, switchB, 2, 33L);
        islRepository.updateAvailableBandwidth(TEST_SWITCH_C_ID, 1, TEST_SWITCH_B_ID, 2);
        fail();
    } catch (PersistenceException ex) {
    // expected
    }
    islAfter = islRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2).get();
    assertEquals(100, islAfter.getAvailableBandwidth());
    try {
        createPathWithSegment(TEST_FLOW_ID + "_4", switchA, 1, switchC, 2, 33L);
        islRepository.updateAvailableBandwidth(TEST_SWITCH_A_ID, 1, TEST_SWITCH_C_ID, 2);
        fail();
    } catch (PersistenceException ex) {
    // expected
    }
    islAfter = islRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2).get();
    assertEquals(100, islAfter.getAvailableBandwidth());
}
Also used : Isl(org.openkilda.model.Isl) PersistenceException(org.openkilda.persistence.exceptions.PersistenceException) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Aggregations

PersistenceException (org.openkilda.persistence.exceptions.PersistenceException)16 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 PathId (org.openkilda.model.PathId)6 Collection (java.util.Collection)5 Optional (java.util.Optional)5 FermaPersistentImplementation (org.openkilda.persistence.ferma.FermaPersistentImplementation)5 PathIdConverter (org.openkilda.persistence.ferma.frames.converters.PathIdConverter)5 P (org.apache.tinkerpop.gremlin.process.traversal.P)4 GraphTraversal (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal)4 org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__ (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__)4 SwitchId (org.openkilda.model.SwitchId)4 FlowMeterFrame (org.openkilda.persistence.ferma.frames.FlowMeterFrame)4 KildaBaseVertexFrame (org.openkilda.persistence.ferma.frames.KildaBaseVertexFrame)4 SwitchIdConverter (org.openkilda.persistence.ferma.frames.converters.SwitchIdConverter)4 OrientGraph (org.apache.tinkerpop.gremlin.orientdb.OrientGraph)2 Flow (org.openkilda.model.Flow)2 FlowMeter (org.openkilda.model.FlowMeter)2 FlowMeterData (org.openkilda.model.FlowMeter.FlowMeterData)2 FlowPath (org.openkilda.model.FlowPath)2