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());
}
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());
}
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());
}
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());
}
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")));
}
Aggregations