Search in sources :

Example 1 with FlowIdStatusPayload

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

the class FlowTopologyTest method removeFlowTopologyEngineSpeakerBoltTest.

@Test
public void removeFlowTopologyEngineSpeakerBoltTest() throws Exception {
    String flowId = UUID.randomUUID().toString();
    ConsumerRecord<String, String> ofsRecord;
    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());
    RemoveFlow data = removeFlowCommand(flowId);
    ofsRecord = ofsConsumer.pollMessage();
    assertNotNull(ofsRecord);
    assertNotNull(ofsRecord.value());
    CommandMessage response = objectMapper.readValue(ofsRecord.value(), CommandMessage.class);
    assertNotNull(response);
    RemoveFlow responseData = (RemoveFlow) 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);
    removeRuleCommand(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) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) InfoMessage(org.openkilda.messaging.info.InfoMessage) CommandMessage(org.openkilda.messaging.command.CommandMessage) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 2 with FlowIdStatusPayload

use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload 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 3 with FlowIdStatusPayload

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

the class FlowTopologyTest method dumpFlows.

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

Example 4 with FlowIdStatusPayload

use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload 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)

Example 5 with FlowIdStatusPayload

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

the class FlowUtils method waitFlowStatus.

/**
 * Poll flow status via getFlowStatus calls until it become equal to expected. Or until timeout.
 *
 * TODO: Why do we loop for 10 and sleep for 2? (ie why what for 20 seconds for flow state?)
 *
 * @return last result received from getFlowStatus (can be null)
 */
public static FlowIdStatusPayload waitFlowStatus(String flowName, FlowState expected) throws InterruptedException {
    FlowIdStatusPayload current = null;
    for (int i = 0; i < WAIT_ATTEMPTS; i++) {
        current = getFlowStatus(flowName);
        if (current != null && expected.equals(current.getStatus())) {
            break;
        }
        TimeUnit.SECONDS.sleep(WAIT_DELAY);
    }
    return current;
}
Also used : FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) DefaultParameters.topologyEndpoint(org.openkilda.DefaultParameters.topologyEndpoint) DefaultParameters.northboundEndpoint(org.openkilda.DefaultParameters.northboundEndpoint)

Aggregations

FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)31 InfoMessage (org.openkilda.messaging.info.InfoMessage)15 CommandMessage (org.openkilda.messaging.command.CommandMessage)11 Test (org.junit.Test)10 FlowStatusResponse (org.openkilda.messaging.info.flow.FlowStatusResponse)8 FlowPayload (org.openkilda.messaging.payload.flow.FlowPayload)7 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)6 Message (org.openkilda.messaging.Message)5 Then (cucumber.api.java.en.Then)3 Values (org.apache.storm.tuple.Values)3 FlowGetRequest (org.openkilda.messaging.command.flow.FlowGetRequest)3 FlowsGetRequest (org.openkilda.messaging.command.flow.FlowsGetRequest)3 Flow (org.openkilda.messaging.model.Flow)3 FlowState (org.openkilda.messaging.payload.flow.FlowState)3 FlowPathRequest (org.openkilda.messaging.command.flow.FlowPathRequest)2 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