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());
}
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;
}
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;
}
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());
}
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());
}
Aggregations