use of org.openkilda.messaging.error.ErrorMessage in project open-kilda by telstra.
the class FlowTopologyTest method deleteUnknownFlowCommandBoltTest.
@Test
public void deleteUnknownFlowCommandBoltTest() throws Exception {
String flowId = UUID.randomUUID().toString();
ConsumerRecord<String, String> record;
deleteFlow(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());
}
use of org.openkilda.messaging.error.ErrorMessage 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());
}
use of org.openkilda.messaging.error.ErrorMessage in project open-kilda by telstra.
the class FlowTopologyTest method createAlreadyExistsFlowCommandBoltTest.
@Test
public void createAlreadyExistsFlowCommandBoltTest() 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());
createFlow(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.ALREADY_EXISTS, errorData.getErrorType());
}
use of org.openkilda.messaging.error.ErrorMessage 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.error.ErrorMessage in project open-kilda by telstra.
the class RecordHandler method doControllerMsg.
protected void doControllerMsg(CommandMessage message) {
// Define the destination topic where the reply will be sent to.
final String replyToTopic;
if (message instanceof CommandWithReplyToMessage) {
replyToTopic = ((CommandWithReplyToMessage) message).getReplyTo();
} else {
replyToTopic = OUTPUT_FLOW_TOPIC;
}
final Destination replyDestination = getDestinationForTopic(replyToTopic);
try {
CommandData data = message.getData();
handleCommand(message, data, replyToTopic, replyDestination);
} catch (FlowCommandException e) {
ErrorMessage error = new ErrorMessage(e.makeErrorResponse(), System.currentTimeMillis(), message.getCorrelationId(), replyDestination);
context.getKafkaProducer().postMessage(replyToTopic, error);
} catch (Exception e) {
logger.error("Unhandled exception: {}", e);
}
}
Aggregations