Search in sources :

Example 21 with CommandContext

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);
}
Also used : YFlowDeleteRequest(org.openkilda.messaging.command.yflow.YFlowDeleteRequest) CommandContext(org.openkilda.wfm.CommandContext) FlowDeleteService(org.openkilda.wfm.topology.flowhs.service.FlowDeleteService) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Example 22 with CommandContext

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);
}
Also used : YFlow(org.openkilda.model.YFlow) CommandContext(org.openkilda.wfm.CommandContext) Collection(java.util.Collection) YFlowSwitchFlowEntriesBuilder(org.openkilda.wfm.topology.flowhs.fsm.yflow.validation.YFlowSwitchFlowEntriesBuilder) SwitchId(org.openkilda.model.SwitchId) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Example 23 with CommandContext

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);
    });
}
Also used : CommandContext(org.openkilda.wfm.CommandContext) FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) SpeakerResponse(org.openkilda.floodlight.api.response.SpeakerResponse) BaseSpeakerCommandsRequest(org.openkilda.floodlight.api.request.rulemanager.BaseSpeakerCommandsRequest)

Example 24 with CommandContext

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);
}
Also used : YFlow(org.openkilda.model.YFlow) CommandContext(org.openkilda.wfm.CommandContext) SwitchId(org.openkilda.model.SwitchId) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Example 25 with CommandContext

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());
}
Also used : Fields(org.apache.storm.tuple.Fields) CommandContext(org.openkilda.wfm.CommandContext) Tuple(org.apache.storm.tuple.Tuple) Test(org.junit.Test)

Aggregations

CommandContext (org.openkilda.wfm.CommandContext)95 Test (org.junit.Test)28 Values (org.apache.storm.tuple.Values)27 FlowSegmentRequest (org.openkilda.floodlight.api.request.FlowSegmentRequest)15 Flow (org.openkilda.model.Flow)15 AbstractYFlowTest (org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)14 Tuple (org.apache.storm.tuple.Tuple)12 SwitchId (org.openkilda.model.SwitchId)11 YFlow (org.openkilda.model.YFlow)11 BaseSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.BaseSpeakerCommandsRequest)9 SpeakerResponse (org.openkilda.floodlight.api.response.SpeakerResponse)9 YFlowRequest (org.openkilda.messaging.command.yflow.YFlowRequest)9 InfoMessage (org.openkilda.messaging.info.InfoMessage)9 TupleImpl (org.apache.storm.tuple.TupleImpl)8 FlowPath (org.openkilda.model.FlowPath)8 ArrayList (java.util.ArrayList)7 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)7 FlowProcessingException (org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException)7 UnknownKeyException (org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException)7 List (java.util.List)6