Search in sources :

Example 21 with FlowIdStatusPayload

use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.

the class FlowTopologyTest method errorFlowCreateMessageStatusBoltTopologyEngineBoltTest.

@Test
public void errorFlowCreateMessageStatusBoltTopologyEngineBoltTest() 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());
    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.CREATION_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.CREATION_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 : 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) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 22 with FlowIdStatusPayload

use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.

the class FlowTopologyTest method getFlow.

private FlowIdStatusPayload getFlow(final String flowId) throws IOException {
    System.out.println("NORTHBOUND: Get flow");
    FlowIdStatusPayload payload = new FlowIdStatusPayload(flowId);
    FlowGetRequest commandData = new FlowGetRequest(payload);
    CommandMessage message = new CommandMessage(commandData, 0, "get-flow", Destination.WFM);
    // sendNorthboundMessage(message);
    sendFlowMessage(message);
    return payload;
}
Also used : FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) FlowGetRequest(org.openkilda.messaging.command.flow.FlowGetRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 23 with FlowIdStatusPayload

use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.

the class FlowTopologyTest method statusFlow.

private FlowIdStatusPayload statusFlow(final String flowId) throws IOException {
    System.out.println("NORTHBOUND: Status flow");
    FlowIdStatusPayload payload = new FlowIdStatusPayload(flowId);
    FlowStatusRequest commandData = new FlowStatusRequest(payload);
    CommandMessage message = new CommandMessage(commandData, 0, "status-flow", Destination.WFM);
    // sendNorthboundMessage(message);
    sendFlowMessage(message);
    return payload;
}
Also used : FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) FlowStatusRequest(org.openkilda.messaging.command.flow.FlowStatusRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 24 with FlowIdStatusPayload

use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.

the class FlowTopologyTest method errorMessageStatusBoltSpeakerBoltTest.

@Test
public void errorMessageStatusBoltSpeakerBoltTest() 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());
    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());
    errorFlowSpeakerCommand(flowId);
    statusFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    InfoMessage infoMessageDown = objectMapper.readValue(record.value(), InfoMessage.class);
    assertNotNull(infoMessageDown);
    FlowStatusResponse infoDataDown = (FlowStatusResponse) infoMessageDown.getData();
    assertNotNull(infoDataDown);
    FlowIdStatusPayload flowNbPayloadDown = infoDataDown.getPayload();
    assertNotNull(flowNbPayloadDown);
    assertEquals(flowId, flowNbPayloadDown.getId());
    assertEquals(FlowState.DOWN, flowNbPayloadDown.getStatus());
}
Also used : FlowStatusResponse(org.openkilda.messaging.info.flow.FlowStatusResponse) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) InfoMessage(org.openkilda.messaging.info.InfoMessage) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 25 with FlowIdStatusPayload

use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.

the class FlowTopologyTest method installFlowTopologyEngineSpeakerBoltTest.

@Test
public void installFlowTopologyEngineSpeakerBoltTest() throws Exception {
    /*
         * This test will verify the state transitions of a flow, through the status mechanism.
         * It achieves this by doing the following:
         *      - CreateFlow .. clear both cache and northbound consumers
         *      - GetStatus .. confirm STATE = FlowState.ALLOCATED
         *      - baseInstallFlowCommand .. read speaker .. validate data/responsedata
         *      - GetStatus .. confirm STATE = FlowState.IN_PROGRESS
         *      - baseInstallRuleCommand ..
         *      - GetStatus .. confirm STATE = FlowState.UP
         */
    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());
    statusFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    InfoMessage infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
    assertNotNull(infoMessage);
    FlowStatusResponse infoData = (FlowStatusResponse) infoMessage.getData();
    assertNotNull(infoData);
    FlowIdStatusPayload flowNbPayload = infoData.getPayload();
    assertNotNull(flowNbPayload);
    assertEquals(flowId, flowNbPayload.getId());
    assertEquals(FlowState.ALLOCATED, flowNbPayload.getStatus());
    InstallOneSwitchFlow data = baseInstallFlowCommand(flowId);
    record = ofsConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    CommandMessage response = objectMapper.readValue(record.value(), CommandMessage.class);
    assertNotNull(response);
    InstallOneSwitchFlow responseData = (InstallOneSwitchFlow) response.getData();
    Long transactionId = responseData.getTransactionId();
    responseData.setTransactionId(0L);
    assertEquals(data, responseData);
    responseData.setTransactionId(transactionId);
    statusFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
    assertNotNull(infoMessage);
    infoData = (FlowStatusResponse) infoMessage.getData();
    assertNotNull(infoData);
    flowNbPayload = infoData.getPayload();
    assertNotNull(flowNbPayload);
    assertEquals(flowId, flowNbPayload.getId());
    assertEquals(FlowState.IN_PROGRESS, flowNbPayload.getStatus());
    response.setDestination(Destination.WFM_TRANSACTION);
    baseInstallRuleCommand(response);
    statusFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
    assertNotNull(infoMessage);
    infoData = (FlowStatusResponse) infoMessage.getData();
    assertNotNull(infoData);
    flowNbPayload = infoData.getPayload();
    assertNotNull(flowNbPayload);
    assertEquals(flowId, flowNbPayload.getId());
    assertEquals(FlowState.UP, flowNbPayload.getStatus());
}
Also used : FlowStatusResponse(org.openkilda.messaging.info.flow.FlowStatusResponse) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) InfoMessage(org.openkilda.messaging.info.InfoMessage) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) CommandMessage(org.openkilda.messaging.command.CommandMessage) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Aggregations

FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)29 InfoMessage (org.openkilda.messaging.info.InfoMessage)16 CommandMessage (org.openkilda.messaging.command.CommandMessage)12 Test (org.junit.Test)9 FlowStatusResponse (org.openkilda.messaging.info.flow.FlowStatusResponse)8 Message (org.openkilda.messaging.Message)6 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)6 FlowPayload (org.openkilda.messaging.payload.flow.FlowPayload)5 Then (cucumber.api.java.en.Then)3 Values (org.apache.storm.tuple.Values)3 FlowGetRequest (org.openkilda.messaging.command.flow.FlowGetRequest)3 FlowPathRequest (org.openkilda.messaging.command.flow.FlowPathRequest)3 FlowsGetRequest (org.openkilda.messaging.command.flow.FlowsGetRequest)3 Flow (org.openkilda.messaging.model.Flow)3 FlowState (org.openkilda.messaging.payload.flow.FlowState)3 FlowStatusRequest (org.openkilda.messaging.command.flow.FlowStatusRequest)2 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)2 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)2 ErrorData (org.openkilda.messaging.error.ErrorData)2 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)2