Search in sources :

Example 6 with PathInfoData

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));
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) PathNode(org.openkilda.messaging.info.event.PathNode) CommandMessage(org.openkilda.messaging.command.CommandMessage) AbstractStormTest(org.openkilda.wfm.AbstractStormTest)

Example 7 with PathInfoData

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);
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) FlowPathResponse(org.openkilda.messaging.info.flow.FlowPathResponse) InfoMessage(org.openkilda.messaging.info.InfoMessage) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 8 with PathInfoData

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());
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) FlowPathRequest(org.openkilda.messaging.command.flow.FlowPathRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 9 with PathInfoData

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);
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) Flow(org.openkilda.messaging.model.Flow) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 10 with PathInfoData

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());
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) Driver(org.neo4j.driver.v1.Driver) Flow(org.openkilda.messaging.model.Flow)

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