use of org.openkilda.messaging.model.FlowPatch in project open-kilda by telstra.
the class FlowOperationsServiceTest method shouldPrepareFlowUpdateResultWithChangedStrategy.
@Test
public void shouldPrepareFlowUpdateResultWithChangedStrategy() {
// given: FlowPatch with COST strategy and Flow with MAX_LATENCY strategy
String flowId = "test_flow_id";
FlowPatch flowDto = FlowPatch.builder().flowId(flowId).maxLatency(100L).pathComputationStrategy(PathComputationStrategy.COST).build();
Flow flow = Flow.builder().flowId(flowId).srcSwitch(Switch.builder().switchId(new SwitchId(1)).build()).destSwitch(Switch.builder().switchId(new SwitchId(2)).build()).pathComputationStrategy(PathComputationStrategy.MAX_LATENCY).build();
// when: compare this flows
UpdateFlowResult result = flowOperationsService.prepareFlowUpdateResult(flowDto, flow).build();
// then: needUpdateFlow flag set to true
assertTrue(result.isNeedUpdateFlow());
}
use of org.openkilda.messaging.model.FlowPatch in project open-kilda by telstra.
the class FlowOperationsServiceTest method shouldPrepareFlowUpdateResultWithChangedMaxLatencySecondCase.
@Test
public void shouldPrepareFlowUpdateResultWithChangedMaxLatencySecondCase() {
// given: FlowPatch with max latency and MAX_LATENCY strategy
// and Flow with MAX_LATENCY strategy and no max latency
String flowId = "test_flow_id";
FlowPatch flowDto = FlowPatch.builder().flowId(flowId).maxLatency(100L).pathComputationStrategy(PathComputationStrategy.MAX_LATENCY).build();
Flow flow = Flow.builder().flowId(flowId).srcSwitch(Switch.builder().switchId(new SwitchId(1)).build()).destSwitch(Switch.builder().switchId(new SwitchId(2)).build()).pathComputationStrategy(PathComputationStrategy.MAX_LATENCY).build();
// when: compare this flows
UpdateFlowResult result = flowOperationsService.prepareFlowUpdateResult(flowDto, flow).build();
// then: needRerouteFlow flag set to true
assertTrue(result.isNeedUpdateFlow());
}
use of org.openkilda.messaging.model.FlowPatch in project open-kilda by telstra.
the class FlowMapperTest method testFlowPatchV2ToFlowDto.
@Test
public void testFlowPatchV2ToFlowDto() {
FlowPatchV2 flowPatchDto = new FlowPatchV2(new FlowPatchEndpoint(SRC_SWITCH_ID, SRC_PORT, SRC_VLAN, SRC_INNER_VLAN, SRC_DETECT_CONNECTED_DEVICES), new FlowPatchEndpoint(DST_SWITCH_ID, DST_PORT, DST_VLAN, DST_INNER_VLAN, DST_DETECT_CONNECTED_DEVICES), (long) BANDWIDTH, IGNORE_BANDWIDTH, STRICT_BANDWIDTH, PERIODIC_PINGS, DESCRIPTION, LATENCY, LATENCY_TIER2, PRIORITY, DIVERSE_FLOW_ID, AFFINITY_FLOW_ID, PINNED, ALLOCATE_PROTECTED_PATH, ENCAPSULATION_TYPE, PATH_COMPUTATION_STRATEGY, TARGET_PATH_COMPUTATION_STRATEGY);
FlowPatch flowPatch = flowMapper.toFlowPatch(flowPatchDto);
assertEquals(flowPatchDto.getSource().getSwitchId(), flowPatch.getSource().getSwitchId());
assertEquals(flowPatchDto.getSource().getPortNumber(), flowPatch.getSource().getPortNumber());
assertEquals(flowPatchDto.getSource().getVlanId(), flowPatch.getSource().getVlanId());
assertEquals(flowPatchDto.getSource().getInnerVlanId(), flowPatch.getSource().getInnerVlanId());
assertEquals(flowPatchDto.getSource().getDetectConnectedDevices().isLldp(), flowPatch.getSource().getTrackLldpConnectedDevices());
assertEquals(flowPatchDto.getSource().getDetectConnectedDevices().isArp(), flowPatch.getSource().getTrackArpConnectedDevices());
assertEquals(flowPatchDto.getDestination().getSwitchId(), flowPatch.getDestination().getSwitchId());
assertEquals(flowPatchDto.getDestination().getPortNumber(), flowPatch.getDestination().getPortNumber());
assertEquals(flowPatchDto.getDestination().getVlanId(), flowPatch.getDestination().getVlanId());
assertEquals(flowPatchDto.getDestination().getInnerVlanId(), flowPatch.getDestination().getInnerVlanId());
assertEquals(flowPatchDto.getDestination().getDetectConnectedDevices().isLldp(), flowPatch.getDestination().getTrackLldpConnectedDevices());
assertEquals(flowPatchDto.getDestination().getDetectConnectedDevices().isArp(), flowPatch.getDestination().getTrackArpConnectedDevices());
assertEquals(flowPatchDto.getMaxLatency() * MS_TO_NS_MULTIPLIER, (long) flowPatch.getMaxLatency());
assertEquals(flowPatchDto.getMaxLatencyTier2() * MS_TO_NS_MULTIPLIER, (long) flowPatch.getMaxLatencyTier2());
assertEquals(flowPatchDto.getPriority(), flowPatch.getPriority());
assertEquals(flowPatchDto.getPeriodicPings(), flowPatch.getPeriodicPings());
assertEquals(flowPatchDto.getTargetPathComputationStrategy(), flowPatch.getTargetPathComputationStrategy().name().toLowerCase());
assertEquals(flowPatchDto.getDiverseFlowId(), flowPatch.getDiverseFlowId());
assertEquals(flowPatchDto.getAffinityFlowId(), flowPatch.getAffinityFlowId());
assertEquals(flowPatchDto.getMaximumBandwidth(), flowPatch.getBandwidth());
assertEquals(flowPatchDto.getAllocateProtectedPath(), flowPatch.getAllocateProtectedPath());
assertEquals(flowPatchDto.getPinned(), flowPatch.getPinned());
assertEquals(flowPatchDto.getIgnoreBandwidth(), flowPatch.getIgnoreBandwidth());
assertEquals(flowPatchDto.getStrictBandwidth(), flowPatch.getStrictBandwidth());
assertEquals(flowPatchDto.getDescription(), flowPatch.getDescription());
assertEquals(flowPatchDto.getEncapsulationType(), flowPatch.getEncapsulationType().name().toLowerCase());
assertEquals(flowPatchDto.getPathComputationStrategy(), flowPatch.getPathComputationStrategy().name().toLowerCase());
}
use of org.openkilda.messaging.model.FlowPatch in project open-kilda by telstra.
the class FlowMapperTest method testFlowPatchDtoToFlowDto.
@Test
public void testFlowPatchDtoToFlowDto() {
FlowPatchDto flowPatchDto = new FlowPatchDto(LATENCY, PRIORITY, PERIODIC_PINGS, TARGET_PATH_COMPUTATION_STRATEGY);
FlowPatch flowPatch = flowMapper.toFlowPatch(flowPatchDto);
assertEquals(flowPatchDto.getMaxLatency() * MS_TO_NS_MULTIPLIER, (long) flowPatch.getMaxLatency());
assertEquals(flowPatchDto.getPriority(), flowPatch.getPriority());
assertEquals(flowPatchDto.getPeriodicPings(), flowPatch.getPeriodicPings());
assertEquals(flowPatchDto.getTargetPathComputationStrategy(), flowPatch.getTargetPathComputationStrategy().name().toLowerCase());
}
use of org.openkilda.messaging.model.FlowPatch in project open-kilda by telstra.
the class FlowServiceImpl method patchFlow.
@Override
public CompletableFuture<FlowResponsePayload> patchFlow(String flowId, FlowPatchDto flowPatchDto) {
logger.info("Patch flow request for flow {}", flowId);
String correlationId = RequestCorrelationId.getId();
FlowPatch flowPatch;
try {
flowPatch = flowMapper.toFlowPatch(flowPatchDto);
} catch (IllegalArgumentException e) {
logger.error("Can not parse arguments: {}", e.getMessage(), e);
throw new MessageException(correlationId, System.currentTimeMillis(), ErrorType.DATA_INVALID, e.getMessage(), "Can not parse arguments of the flow patch request");
}
flowPatch.setFlowId(flowId);
CommandMessage request = new CommandMessage(new FlowPatchRequest(flowPatch), System.currentTimeMillis(), correlationId);
return messagingChannel.sendAndGet(nbworkerTopic, request).thenApply(FlowResponse.class::cast).thenApply(FlowResponse::getPayload).thenApply(flowMapper::toFlowResponseOutput);
}
Aggregations