Search in sources :

Example 11 with Flow

use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.

the class FlowTopologyTest method deleteFlow.

private Flow deleteFlow(final String flowId) throws IOException {
    System.out.println("NORTHBOUND: Delete flow");
    Flow payload = new Flow();
    payload.setFlowId(flowId);
    FlowDeleteRequest commandData = new FlowDeleteRequest(payload);
    CommandMessage message = new CommandMessage(commandData, 0, "delete-flow", Destination.WFM);
    // sendNorthboundMessage(message);
    // sendTopologyEngineMessage(message);
    sendFlowMessage(message);
    return payload;
}
Also used : FlowDeleteRequest(org.openkilda.messaging.command.flow.FlowDeleteRequest) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) Flow(org.openkilda.messaging.model.Flow) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 12 with Flow

use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.

the class FlowTopologyTest method getFlowCommand.

private Flow getFlowCommand(final String flowId) throws IOException {
    System.out.println("TOPOLOGY: Get flow");
    Flow flowPayload = new Flow(flowId, 10000, false, "", "test-switch", 1, 2, "test-switch", 1, 2);
    FlowResponse infoData = new FlowResponse(flowPayload);
    InfoMessage infoMessage = new InfoMessage(infoData, 0, "get-flow", Destination.WFM);
    sendTopologyEngineMessage(infoMessage);
    return flowPayload;
}
Also used : 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)

Example 13 with Flow

use of org.openkilda.messaging.model.Flow 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 14 with Flow

use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.

the class FlowTopologyTest method errorFlowDeleteMessageStatusBoltTopologyEngineBoltTest.

@Test
public void errorFlowDeleteMessageStatusBoltTopologyEngineBoltTest() 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());
    deleteFlow(flowId);
    record = cacheConsumer.pollMessage();
    assertNotNull(record);
    InfoMessage message = objectMapper.readValue(record.value(), InfoMessage.class);
    assertNotNull(message);
    ImmutablePair<Flow, Flow> flow = getFlowPayload(message);
    assertNotNull(flow);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    statusFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    ErrorMessage errorMessage = objectMapper.readValue(record.value(), ErrorMessage.class);
    assertNotNull(errorMessage);
    ErrorData errorData = errorMessage.getData();
    assertEquals(ErrorType.NOT_FOUND, errorData.getErrorType());
    errorFlowTopologyEngineCommand(flowId, ErrorType.DELETION_FAILURE);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    errorMessage = objectMapper.readValue(record.value(), ErrorMessage.class);
    assertNotNull(errorMessage);
    errorData = errorMessage.getData();
    assertEquals(ErrorType.DELETION_FAILURE, errorData.getErrorType());
    statusFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    errorMessage = objectMapper.readValue(record.value(), ErrorMessage.class);
    assertNotNull(errorMessage);
    errorData = errorMessage.getData();
    assertEquals(ErrorType.NOT_FOUND, errorData.getErrorType());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) ErrorData(org.openkilda.messaging.error.ErrorData) 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 15 with Flow

use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.

the class FlowTopologyTest method errorFlowUpdateMessageStatusBoltTopologyEngineBoltTest.

@Test
public void errorFlowUpdateMessageStatusBoltTopologyEngineBoltTest() 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());
    updateFlow(flowId);
    record = cacheConsumer.pollMessage();
    assertNotNull(record);
    InfoMessage message = objectMapper.readValue(record.value(), InfoMessage.class);
    assertNotNull(message);
    ImmutablePair<Flow, Flow> flow = getFlowPayload(message);
    assertNotNull(flow);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    statusFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    InfoMessage infoMessageUp = objectMapper.readValue(record.value(), InfoMessage.class);
    assertNotNull(infoMessageUp);
    FlowStatusResponse infoDataUp = (FlowStatusResponse) infoMessageUp.getData();
    assertNotNull(infoDataUp);
    FlowIdStatusPayload flowNbPayloadUp = infoDataUp.getPayload();
    assertNotNull(flowNbPayloadUp);
    assertEquals(flowId, flowNbPayloadUp.getId());
    assertEquals(FlowState.ALLOCATED, flowNbPayloadUp.getStatus());
    errorFlowTopologyEngineCommand(flowId, ErrorType.UPDATE_FAILURE);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    ErrorMessage errorMessage = objectMapper.readValue(record.value(), ErrorMessage.class);
    assertNotNull(errorMessage);
    ErrorData errorData = errorMessage.getData();
    assertEquals(ErrorType.UPDATE_FAILURE, errorData.getErrorType());
    statusFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    InfoMessage infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
    assertNotNull(infoMessage);
    FlowStatusResponse response = (FlowStatusResponse) infoMessage.getData();
    assertNotNull(response);
    FlowIdStatusPayload flowNbPayload = response.getPayload();
    assertNotNull(flowNbPayload);
    assertEquals(flowId, flowNbPayload.getId());
    assertEquals(FlowState.DOWN, flowNbPayload.getStatus());
}
Also used : FlowStatusResponse(org.openkilda.messaging.info.flow.FlowStatusResponse) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) InfoMessage(org.openkilda.messaging.info.InfoMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) ErrorData(org.openkilda.messaging.error.ErrorData) 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)

Aggregations

Flow (org.openkilda.messaging.model.Flow)54 InfoMessage (org.openkilda.messaging.info.InfoMessage)23 Values (org.apache.storm.tuple.Values)14 PathInfoData (org.openkilda.messaging.info.event.PathInfoData)14 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)13 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)13 Test (org.junit.Test)12 CommandMessage (org.openkilda.messaging.command.CommandMessage)8 ImmutablePair (org.openkilda.messaging.model.ImmutablePair)8 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)8 FlowResponse (org.openkilda.messaging.info.flow.FlowResponse)6 Then (cucumber.api.java.en.Then)5 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)5 UnroutablePathException (org.openkilda.pce.provider.UnroutablePathException)5 Driver (org.neo4j.driver.v1.Driver)4 MessageException (org.openkilda.messaging.error.MessageException)4 FlowPayload (org.openkilda.messaging.payload.flow.FlowPayload)4 And (cucumber.api.java.en.And)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3