use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class LoggerContextInitializerTest method shouldParseJsonAndExtractCorrelationId.
@Test
public void shouldParseJsonAndExtractCorrelationId() throws JsonProcessingException {
// given
Tuple tuple = mock(Tuple.class);
when(tuple.getFields()).thenReturn(new Fields("message"));
String correlationId = String.format("test-%s", UUID.randomUUID());
InfoMessage message = new InfoMessage(new FlowsResponse(Collections.emptyList()), System.currentTimeMillis(), correlationId);
ObjectMapper mapper = new ObjectMapper();
when(tuple.getValueByField(eq("message"))).thenReturn(mapper.writeValueAsString(message));
// when
Optional<CommandContext> result = LoggerContextInitializer.extract(tuple);
// then
assertEquals(correlationId, result.get().getCorrelationId());
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class YFlowCreateServiceTest method processRequestAndSpeakerCommands.
private void processRequestAndSpeakerCommands(YFlowRequest yFlowRequest) throws DuplicateKeyException {
YFlowCreateService service = makeYFlowCreateService(0);
service.handleRequest(yFlowRequest.getYFlowId(), new CommandContext(), yFlowRequest);
verifyYFlowAndSubFlowStatus(yFlowRequest.getYFlowId(), FlowStatus.IN_PROGRESS);
handleSpeakerRequests(speakerRequest -> {
SpeakerResponse commandResponse;
if (speakerRequest instanceof FlowSegmentRequest) {
FlowSegmentRequest flowSegmentRequest = (FlowSegmentRequest) speakerRequest;
commandResponse = buildSuccessfulSpeakerResponse(flowSegmentRequest);
} else {
BaseSpeakerCommandsRequest speakerCommandsRequest = (BaseSpeakerCommandsRequest) speakerRequest;
commandResponse = buildSuccessfulYFlowSpeakerResponse(speakerCommandsRequest);
}
handleAsyncResponse(service, yFlowRequest.getYFlowId(), commandResponse);
});
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class YFlowCreateServiceTest method shouldFailOnUnsuccessfulValidation.
@Ignore("TODO: implement meter validation")
@Test
public void shouldFailOnUnsuccessfulValidation() throws RecoverableException, UnroutableFlowException, DuplicateKeyException {
// given
YFlowRequest request = buildYFlowRequest("test_failed_yflow", "test_flow_1", "test_flow_2").build();
preparePathComputation("test_flow_1", buildFirstSubFlowPathPair());
preparePathComputation("test_flow_2", buildSecondSubFlowPathPair());
prepareYPointComputation(SWITCH_SHARED, SWITCH_FIRST_EP, SWITCH_SECOND_EP, SWITCH_TRANSIT);
YFlowCreateService service = makeYFlowCreateService(0);
// when
service.handleRequest(request.getYFlowId(), new CommandContext(), request);
verifyYFlowAndSubFlowStatus(request.getYFlowId(), FlowStatus.IN_PROGRESS);
// and
handleSpeakerCommandsAndFailVerify(service, request.getYFlowId(), request.getYFlowId());
// then
verifyNoSpeakerInteraction(yFlowCreateHubCarrier);
verifyYFlowIsAbsent(request.getYFlowId());
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class YFlowCreateServiceTest method shouldFailOnTimeoutDuringMeterInstallation.
@Test
public void shouldFailOnTimeoutDuringMeterInstallation() throws RecoverableException, UnroutableFlowException, DuplicateKeyException {
// given
YFlowRequest request = buildYFlowRequest("test_failed_yflow", "test_flow_1", "test_flow_2").build();
preparePathComputation("test_flow_1", buildFirstSubFlowPathPair());
preparePathComputation("test_flow_2", buildSecondSubFlowPathPair());
prepareYPointComputation(SWITCH_SHARED, SWITCH_FIRST_EP, SWITCH_SECOND_EP, SWITCH_TRANSIT);
YFlowCreateService service = makeYFlowCreateService(0);
// when
service.handleRequest(request.getYFlowId(), new CommandContext(), request);
verifyYFlowAndSubFlowStatus(request.getYFlowId(), FlowStatus.IN_PROGRESS);
// and
handleSpeakerCommandsAndTimeoutInstall(service, request.getYFlowId());
// then
verifyYFlowIsAbsent(request.getYFlowId());
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class YFlowUpdateServiceTest method processUpdateRequestAndSpeakerCommands.
private void processUpdateRequestAndSpeakerCommands(YFlowPartialUpdateRequest request) throws DuplicateKeyException {
YFlowUpdateService service = makeYFlowUpdateService(0);
service.handlePartialUpdateRequest(request.getYFlowId(), new CommandContext(), request);
verifyYFlowStatus(request.getYFlowId(), FlowStatus.IN_PROGRESS);
handleSpeakerRequests(speakerRequest -> {
SpeakerResponse commandResponse;
if (speakerRequest instanceof FlowSegmentRequest) {
FlowSegmentRequest flowSegmentRequest = (FlowSegmentRequest) speakerRequest;
commandResponse = buildSuccessfulSpeakerResponse(flowSegmentRequest);
} else {
BaseSpeakerCommandsRequest speakerCommandsRequest = (BaseSpeakerCommandsRequest) speakerRequest;
commandResponse = buildSuccessfulYFlowSpeakerResponse(speakerCommandsRequest);
}
handleAsyncResponse(service, request.getYFlowId(), commandResponse);
});
}
Aggregations