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