use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class YFlowDeleteServiceTest method shouldFailIfNoFlowExists.
@Test
public void shouldFailIfNoFlowExists() throws DuplicateKeyException {
String yFlowId = "unknown_yflow";
// when
FlowDeleteService flowDeleteService = makeFlowDeleteService(0);
YFlowDeleteService service = makeYFlowDeleteService(flowDeleteService, 0);
YFlowDeleteRequest yFlowRequest = new YFlowDeleteRequest(yFlowId);
service.handleRequest(yFlowRequest.getYFlowId(), new CommandContext(), yFlowRequest);
// then
verifyNorthboundErrorResponse(yFlowDeleteHubCarrier, ErrorType.NOT_FOUND);
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class YFlowValidationHubServiceTest method shouldValidateYFlowSuccessfully.
@Test
public void shouldValidateYFlowSuccessfully() throws DuplicateKeyException {
// given
String yFlowId = "test_y_flow_1";
YFlow yFlow = createYFlowViaTransit(yFlowId);
YFlowSwitchFlowEntriesBuilder flowEntriesBuilder = new YFlowSwitchFlowEntriesBuilder(yFlow, persistenceManager.getRepositoryFactory().createTransitVlanRepository(), persistenceManager.getRepositoryFactory().createVxlanRepository());
Map<SwitchId, Collection<FlowEntry>> flowEntries = flowEntriesBuilder.getFlowEntries();
Map<SwitchId, Collection<MeterEntry>> meterEntries = flowEntriesBuilder.getMeterEntries();
Map<SwitchId, Collection<GroupEntry>> groupEntries = flowEntriesBuilder.getGroupEntries();
YFlowValidationHubService service = makeYFlowValidationHubService();
service.handleRequest(yFlow.getYFlowId(), new CommandContext(), yFlow.getYFlowId());
// when
handleSpeakerRequests(service, yFlowId, flowEntries, meterEntries, groupEntries);
// then
verifyNorthboundSuccessResponse(yFlowValidationHubCarrier);
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class YFlowUpdateServiceTest method processCreateRequestAndSpeakerCommands.
private void processCreateRequestAndSpeakerCommands(YFlowRequest yFlowRequest) throws DuplicateKeyException {
YFlowCreateService service = makeYFlowCreateService(0);
service.handleRequest(yFlowRequest.getYFlowId(), new CommandContext(), yFlowRequest);
verifyYFlowStatus(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 YFlowUpdateServiceTest method shouldFailOnTimeoutDuringMeterInstallation.
@Test
public void shouldFailOnTimeoutDuringMeterInstallation() throws UnroutableFlowException, RecoverableException, DuplicateKeyException, UnknownKeyException {
// given
YFlowRequest request = createYFlow();
request.setMaximumBandwidth(2000L);
request.getSubFlows().get(0).setEndpoint(newFirstEndpoint);
request.getSubFlows().get(1).setEndpoint(newSecondEndpoint);
preparePathComputationForUpdate("test_flow_1", buildNewFirstSubFlowPathPair(), buildFirstSubFlowPathPair());
preparePathComputationForUpdate("test_flow_2", buildNewSecondSubFlowPathPair(), buildSecondSubFlowPathPair());
prepareYPointComputation(SWITCH_SHARED, SWITCH_NEW_FIRST_EP, SWITCH_NEW_SECOND_EP, SWITCH_TRANSIT);
YFlowUpdateService service = makeYFlowUpdateService(0);
// when
service.handleRequest(request.getYFlowId(), new CommandContext(), request);
verifyYFlowStatus(request.getYFlowId(), FlowStatus.IN_PROGRESS);
// and
handleSpeakerCommandsAndTimeoutInstall(service, request.getYFlowId());
// then
verifyYFlowStatus(request.getYFlowId(), FlowStatus.UP);
YFlow flow = getYFlow(request.getYFlowId());
assertEquals(1000L, flow.getMaximumBandwidth());
Set<SwitchId> expectedEndpointSwitchIds = Stream.of(SWITCH_FIRST_EP, SWITCH_SECOND_EP).collect(Collectors.toSet());
Set<SwitchId> actualEndpointSwitchIds = flow.getSubFlows().stream().map(YSubFlow::getEndpointSwitchId).collect(Collectors.toSet());
assertEquals(expectedEndpointSwitchIds, actualEndpointSwitchIds);
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class LoggerContextInitializerTest method shouldNotFailParsingJsonWithoutCorrId.
@Test
public void shouldNotFailParsingJsonWithoutCorrId() {
// given
Tuple tuple = mock(Tuple.class);
when(tuple.getFields()).thenReturn(new Fields("message"));
when(tuple.getValueByField(eq("message"))).thenReturn("{fake:\"value\"}");
// when
Optional<CommandContext> result = LoggerContextInitializer.extract(tuple);
// then
assertFalse(result.isPresent());
}
Aggregations