Search in sources :

Example 11 with PathInfoData

use of org.openkilda.messaging.info.event.PathInfoData in project open-kilda by telstra.

the class PathComputerTest method testGetPathByCostNoCost.

@Test
public void testGetPathByCostNoCost() throws UnroutablePathException {
    /*
         * simple happy path test .. but pathB has no cost .. but still cheaper than pathC (test the default)
         */
    createDiamond("active", -1, 2000);
    Driver driver = GraphDatabase.driver("bolt://localhost:7878", AuthTokens.basic("neo4j", "password"));
    NeoDriver nd = new NeoDriver(driver);
    Flow f = new Flow();
    f.setSourceSwitch("00:01");
    f.setDestinationSwitch("00:04");
    f.setBandwidth(100);
    ImmutablePair<PathInfoData, PathInfoData> path = nd.getPath(f, PathComputer.Strategy.COST);
    // System.out.println("path = " + path);
    Assert.assertNotNull(path);
    Assert.assertEquals(4, path.left.getPath().size());
    // ====> Should choose B .. because default cost (700) cheaper than 2000
    // chooses path B
    Assert.assertEquals("00:02", path.left.getPath().get(1).getSwitchId());
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) Driver(org.neo4j.driver.v1.Driver) Flow(org.openkilda.messaging.model.Flow)

Example 12 with PathInfoData

use of org.openkilda.messaging.info.event.PathInfoData in project open-kilda by telstra.

the class PathComputerTest method testGetPathByCostInactive.

@Test
public void testGetPathByCostInactive() throws UnroutablePathException {
    /*
         * simple happy path test .. but lowest path is inactive
         */
    createDiamond("inactive", 10, 20);
    Driver driver = GraphDatabase.driver("bolt://localhost:7878", AuthTokens.basic("neo4j", "password"));
    NeoDriver nd = new NeoDriver(driver);
    Flow f = new Flow();
    f.setSourceSwitch("00:01");
    f.setDestinationSwitch("00:04");
    f.setBandwidth(100);
    ImmutablePair<PathInfoData, PathInfoData> path = nd.getPath(f, PathComputer.Strategy.COST);
    // System.out.println("path = " + path);
    Assert.assertNotNull(path);
    Assert.assertEquals(4, path.left.getPath().size());
    // ====> only difference is it should now have C as first hop .. since B is inactive
    // chooses path B
    Assert.assertEquals("00:03", path.left.getPath().get(1).getSwitchId());
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) Driver(org.neo4j.driver.v1.Driver) Flow(org.openkilda.messaging.model.Flow)

Example 13 with PathInfoData

use of org.openkilda.messaging.info.event.PathInfoData in project open-kilda by telstra.

the class PathComputerTest method testGetPathByCostInactiveOnTriangleTopo.

@Test
public void testGetPathByCostInactiveOnTriangleTopo() throws UnroutablePathException {
    /*
         * simple happy path test .. but lowest path is inactive
         */
    createTriangleTopo("inactive", 10, 20);
    Driver driver = GraphDatabase.driver("bolt://localhost:7878", AuthTokens.basic("neo4j", "password"));
    NeoDriver nd = new NeoDriver(driver);
    Flow f = new Flow();
    f.setSourceSwitch("00:01");
    f.setDestinationSwitch("00:02");
    f.setBandwidth(100);
    ImmutablePair<PathInfoData, PathInfoData> path = nd.getPath(f, PathComputer.Strategy.COST);
    // System.out.println("path = " + path);
    Assert.assertNotNull(path);
    Assert.assertEquals(4, path.left.getPath().size());
    // ====> only difference is it should now have C as first hop .. since B is inactive
    // chooses path B
    Assert.assertEquals("00:03", path.left.getPath().get(1).getSwitchId());
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) Driver(org.neo4j.driver.v1.Driver) Flow(org.openkilda.messaging.model.Flow)

Example 14 with PathInfoData

use of org.openkilda.messaging.info.event.PathInfoData in project open-kilda by telstra.

the class FlowCrudStepsTest method shouldDefineFlowsOver3Switches.

@Test
public void shouldDefineFlowsOver3Switches() {
    // given
    when(topologyEngineService.getPaths(eq("00:00:00:00:00:01"), eq("00:00:00:00:00:02"))).thenReturn(singletonList(new PathInfoData()));
    when(topologyEngineService.getPaths(eq("00:00:00:00:00:02"), eq("00:00:00:00:00:03"))).thenReturn(singletonList(new PathInfoData()));
    // when
    flowCrudSteps.defineFlowsOverAllSwitches();
    // then
    assertEquals(2, flowCrudSteps.flows.size());
    final FlowPayload sw1sw2Flow = flowCrudSteps.flows.get(0);
    assertEquals(20, (int) sw1sw2Flow.getSource().getPortId());
    assertEquals(1, (int) sw1sw2Flow.getSource().getVlanId());
    assertEquals(20, (int) sw1sw2Flow.getDestination().getPortId());
    assertEquals(1, (int) sw1sw2Flow.getDestination().getVlanId());
    final FlowPayload sw2sw3Flow = flowCrudSteps.flows.get(1);
    assertEquals(20, (int) sw2sw3Flow.getSource().getPortId());
    assertEquals(2, (int) sw2sw3Flow.getSource().getVlanId());
    assertEquals(20, (int) sw2sw3Flow.getDestination().getPortId());
    assertEquals(2, (int) sw2sw3Flow.getDestination().getVlanId());
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) Test(org.junit.Test)

Example 15 with PathInfoData

use of org.openkilda.messaging.info.event.PathInfoData in project open-kilda by telstra.

the class FlowCrudStepsTest method shouldSkipSwitchesIfNoVlanAvailable.

@Test
public void shouldSkipSwitchesIfNoVlanAvailable() {
    // given
    when(topologyEngineService.getPaths(eq("00:00:00:00:00:04"), eq("00:00:00:00:00:02"))).thenReturn(singletonList(new PathInfoData()));
    when(topologyEngineService.getPaths(eq("00:00:00:00:00:04"), eq("00:00:00:00:00:01"))).thenReturn(singletonList(new PathInfoData()));
    // when
    flowCrudSteps.defineFlowsOverAllSwitches();
    // then
    assertEquals(1, flowCrudSteps.flows.size());
    final FlowPayload flowPayload = flowCrudSteps.flows.get(0);
    assertThat(flowPayload.getSource(), hasProperty("switchId", equalTo("00:00:00:00:00:04")));
    assertThat(flowPayload.getDestination(), hasProperty("switchId", equalTo("00:00:00:00:00:01")));
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) Test(org.junit.Test)

Aggregations

PathInfoData (org.openkilda.messaging.info.event.PathInfoData)27 Flow (org.openkilda.messaging.model.Flow)13 Test (org.junit.Test)12 InfoMessage (org.openkilda.messaging.info.InfoMessage)8 PathNode (org.openkilda.messaging.info.event.PathNode)6 FlowPayload (org.openkilda.messaging.payload.flow.FlowPayload)5 Values (org.apache.storm.tuple.Values)4 Driver (org.neo4j.driver.v1.Driver)4 MessageException (org.openkilda.messaging.error.MessageException)4 ImmutablePair (org.openkilda.messaging.model.ImmutablePair)4 UnroutablePathException (org.openkilda.pce.provider.UnroutablePathException)4 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)4 ArrayList (java.util.ArrayList)3 CommandMessage (org.openkilda.messaging.command.CommandMessage)3 FlowPathResponse (org.openkilda.messaging.info.flow.FlowPathResponse)3 HashSet (java.util.HashSet)2 Set (java.util.Set)2 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)2 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)2 FlowValidationException (org.openkilda.wfm.topology.flow.validation.FlowValidationException)2