use of org.openkilda.messaging.info.event.PathInfoData in project open-kilda by telstra.
the class CacheTopologyTest method flowShouldBeReroutedWhenSwitchGoesDown.
@Test
public void flowShouldBeReroutedWhenSwitchGoesDown() throws Exception {
sendData(sw);
SwitchInfoData dstSwitch = new SwitchInfoData();
dstSwitch.setState(SwitchState.ACTIVATED);
dstSwitch.setSwitchId("dstSwitch");
List<PathNode> path = ImmutableList.of(new PathNode(sw.getSwitchId(), 0, 0), new PathNode(dstSwitch.getSwitchId(), 0, 1));
// create inactive flow
firstFlow.getLeft().setFlowPath(new PathInfoData(0L, path));
firstFlow.getRight().setFlowPath(new PathInfoData(0L, Collections.emptyList()));
firstFlow.getLeft().setState(FlowState.DOWN);
sendFlowUpdate(firstFlow);
// create active flow
secondFlow.getLeft().setFlowPath(new PathInfoData(0L, path));
secondFlow.getRight().setFlowPath(new PathInfoData(0L, Collections.emptyList()));
secondFlow.getLeft().setState(FlowState.UP);
sendFlowUpdate(secondFlow);
flowConsumer.clear();
sw.setState(SwitchState.REMOVED);
sendData(sw);
// active flow should be rerouted
ConsumerRecord<String, String> record = flowConsumer.pollMessage();
assertNotNull(record);
CommandMessage message = objectMapper.readValue(record.value(), CommandMessage.class);
assertNotNull(message);
FlowRerouteRequest command = (FlowRerouteRequest) message.getData();
assertTrue(command.getPayload().getFlowId().equals(secondFlowId));
}
use of org.openkilda.messaging.info.event.PathInfoData in project open-kilda by telstra.
the class FlowTopologyTest method pathFlowTest.
@Test
public void pathFlowTest() throws Exception {
String flowId = UUID.randomUUID().toString();
ConsumerRecord<String, String> record;
createFlow(flowId);
record = cacheConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
PathInfoData payload = pathFlow(flowId);
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
InfoMessage infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
FlowPathResponse infoData = (FlowPathResponse) infoMessage.getData();
assertNotNull(infoData);
PathInfoData flowTePayload = infoData.getPayload();
assertEquals(payload, flowTePayload);
}
use of org.openkilda.messaging.info.event.PathInfoData in project open-kilda by telstra.
the class FlowTopologyTest method pathFlow.
private PathInfoData pathFlow(final String flowId) throws IOException {
System.out.println("NORTHBOUND: Path flow");
FlowIdStatusPayload payload = new FlowIdStatusPayload(flowId);
FlowPathRequest commandData = new FlowPathRequest(payload);
CommandMessage message = new CommandMessage(commandData, 0, "path-flow", Destination.WFM);
// sendNorthboundMessage(message);
sendFlowMessage(message);
return new PathInfoData(0L, Collections.emptyList());
}
use of org.openkilda.messaging.info.event.PathInfoData in project open-kilda by telstra.
the class FlowTopologyTest method getFlowTest.
@Test
public void getFlowTest() throws Exception {
String flowId = UUID.randomUUID().toString();
ConsumerRecord<String, String> record;
Flow flow = createFlow(flowId);
flow.setCookie(1);
flow.setFlowPath(new PathInfoData(0L, Collections.emptyList()));
flow.setMeterId(1);
flow.setTransitVlan(2);
flow.setState(FlowState.ALLOCATED);
record = cacheConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
getFlow(flowId);
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
InfoMessage infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
FlowResponse infoData = (FlowResponse) infoMessage.getData();
assertNotNull(infoData);
Flow flowTePayload = infoData.getPayload();
assertEquals(flow, flowTePayload);
}
use of org.openkilda.messaging.info.event.PathInfoData in project open-kilda by telstra.
the class PathComputerTest method testGetPathByCostActive.
@Test
public void testGetPathByCostActive() throws UnroutablePathException {
/*
* simple happy path test .. everything has cost
*/
createDiamond("active", 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());
// chooses path B
Assert.assertEquals("00:02", path.left.getPath().get(1).getSwitchId());
}
Aggregations