use of org.openkilda.messaging.model.FlowPatch in project open-kilda by telstra.
the class FlowOperationsServiceTest method testStrictBandwidthUpdate.
@Test
public void testStrictBandwidthUpdate() throws FlowNotFoundException {
String testFlowId = "flow_id";
Flow flow = new TestFlowBuilder().flowId(testFlowId).srcSwitch(createSwitch(SWITCH_ID_1)).destSwitch(createSwitch(SWITCH_ID_2)).build();
flowRepository.add(flow);
FlowPatch receivedFlow = FlowPatch.builder().flowId(testFlowId).strictBandwidth(true).build();
Flow updatedFlow = flowOperationsService.updateFlow(new FlowCarrierImpl(), receivedFlow);
assertTrue(updatedFlow.isStrictBandwidth());
}
use of org.openkilda.messaging.model.FlowPatch in project open-kilda by telstra.
the class FlowOperationsServiceTest method shouldPrepareFlowUpdateResultShouldNotUpdateSecondCase.
@Test
public void shouldPrepareFlowUpdateResultShouldNotUpdateSecondCase() {
// given: FlowPatch with no max latency and no strategy
// and Flow with MAX_LATENCY strategy and max latency
String flowId = "test_flow_id";
FlowPatch flowDto = FlowPatch.builder().flowId(flowId).build();
Flow flow = Flow.builder().flowId(flowId).srcSwitch(Switch.builder().switchId(new SwitchId(1)).build()).destSwitch(Switch.builder().switchId(new SwitchId(2)).build()).maxLatency(100L).pathComputationStrategy(PathComputationStrategy.MAX_LATENCY).build();
UpdateFlowResult result = flowOperationsService.prepareFlowUpdateResult(flowDto, flow).build();
assertFalse(result.isNeedUpdateFlow());
}
use of org.openkilda.messaging.model.FlowPatch in project open-kilda by telstra.
the class FlowOperationsServiceTest method shouldUpdateMaxLatencyPriorityAndPinnedFlowFields.
@Test
public void shouldUpdateMaxLatencyPriorityAndPinnedFlowFields() throws FlowNotFoundException {
String testFlowId = "flow_id";
Long maxLatency = 555L;
Integer priority = 777;
PathComputationStrategy pathComputationStrategy = PathComputationStrategy.LATENCY;
String description = "new_description";
Flow flow = new TestFlowBuilder().flowId(testFlowId).srcSwitch(createSwitch(SWITCH_ID_1)).srcPort(1).srcVlan(10).destSwitch(createSwitch(SWITCH_ID_2)).destPort(2).destVlan(11).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.COST).description("description").status(FlowStatus.UP).build();
flowRepository.add(flow);
FlowPatch receivedFlow = FlowPatch.builder().flowId(testFlowId).maxLatency(maxLatency).priority(priority).pinned(true).targetPathComputationStrategy(pathComputationStrategy).description("new_description").build();
Flow updatedFlow = flowOperationsService.updateFlow(new FlowCarrierImpl(), receivedFlow);
assertEquals(maxLatency, updatedFlow.getMaxLatency());
assertEquals(priority, updatedFlow.getPriority());
assertEquals(pathComputationStrategy, updatedFlow.getTargetPathComputationStrategy());
assertEquals(description, updatedFlow.getDescription());
assertTrue(updatedFlow.isPinned());
receivedFlow = FlowPatch.builder().flowId(testFlowId).build();
updatedFlow = flowOperationsService.updateFlow(new FlowCarrierImpl(), receivedFlow);
assertEquals(maxLatency, updatedFlow.getMaxLatency());
assertEquals(priority, updatedFlow.getPriority());
assertEquals(pathComputationStrategy, updatedFlow.getTargetPathComputationStrategy());
assertEquals(description, updatedFlow.getDescription());
assertTrue(updatedFlow.isPinned());
}
use of org.openkilda.messaging.model.FlowPatch in project open-kilda by telstra.
the class FlowOperationsServiceTest method shouldPrepareFlowUpdateResultWithChangedMaxLatencyFirstCase.
@Test
public void shouldPrepareFlowUpdateResultWithChangedMaxLatencyFirstCase() {
// given: FlowPatch with max latency and no strategy and Flow with MAX_LATENCY strategy and no max latency
String flowId = "test_flow_id";
FlowPatch flowDto = FlowPatch.builder().flowId(flowId).maxLatency(100L).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 FlowOperationsServiceTest method testStrictBandwidthAndIgnoreBandwidthFlowConflict.
@Test(expected = IllegalArgumentException.class)
public void testStrictBandwidthAndIgnoreBandwidthFlowConflict() throws FlowNotFoundException {
String testFlowId = "flow_id";
Flow flow = new TestFlowBuilder().flowId(testFlowId).srcSwitch(createSwitch(SWITCH_ID_1)).destSwitch(createSwitch(SWITCH_ID_2)).ignoreBandwidth(true).build();
flowRepository.add(flow);
FlowPatch receivedFlow = FlowPatch.builder().flowId(testFlowId).strictBandwidth(true).ignoreBandwidth(false).build();
flowOperationsService.updateFlow(new FlowCarrierImpl(), receivedFlow);
}
Aggregations