use of org.openkilda.wfm.topology.nbworker.services.FlowOperationsService.UpdateFlowResult in project open-kilda by telstra.
the class FlowOperationsServiceTest method shouldPrepareFlowUpdateResultShouldNotUpdateFirstCase.
@Test
public void shouldPrepareFlowUpdateResultShouldNotUpdateFirstCase() {
// given: FlowPatch with max latency and MAX_LATENCY strategy
// and Flow with MAX_LATENCY strategy and same 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()).maxLatency(100L).pathComputationStrategy(PathComputationStrategy.MAX_LATENCY).build();
// when: compare this flows
UpdateFlowResult result = flowOperationsService.prepareFlowUpdateResult(flowDto, flow).build();
// then: needRerouteFlow flag set to false
assertFalse(result.isNeedUpdateFlow());
}
use of org.openkilda.wfm.topology.nbworker.services.FlowOperationsService.UpdateFlowResult in project open-kilda by telstra.
the class FlowOperationsServiceTest method shouldPrepareFlowUpdateResultWithNeedUpdateFlag.
@Test
public void shouldPrepareFlowUpdateResultWithNeedUpdateFlag() {
String flowId = "test_flow_id";
Flow flow = Flow.builder().flowId(flowId).srcSwitch(Switch.builder().switchId(new SwitchId(1)).build()).srcPort(2).srcVlan(3).destSwitch(Switch.builder().switchId(new SwitchId(2)).build()).destPort(4).destVlan(5).bandwidth(1000).allocateProtectedPath(true).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.COST).build();
// new src switch
FlowPatch flowPatch = FlowPatch.builder().source(PatchEndpoint.builder().switchId(new SwitchId(3)).build()).build();
UpdateFlowResult result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new src port
flowPatch = FlowPatch.builder().source(PatchEndpoint.builder().portNumber(9).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new src vlan
flowPatch = FlowPatch.builder().source(PatchEndpoint.builder().vlanId(9).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new src inner vlan
flowPatch = FlowPatch.builder().source(PatchEndpoint.builder().innerVlanId(9).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new src LLDP flag
flowPatch = FlowPatch.builder().source(PatchEndpoint.builder().trackLldpConnectedDevices(true).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new src ARP flag
flowPatch = FlowPatch.builder().source(PatchEndpoint.builder().trackArpConnectedDevices(true).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new dst switch
flowPatch = FlowPatch.builder().destination(PatchEndpoint.builder().switchId(new SwitchId(3)).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new dst port
flowPatch = FlowPatch.builder().destination(PatchEndpoint.builder().portNumber(9).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new dst vlan
flowPatch = FlowPatch.builder().destination(PatchEndpoint.builder().vlanId(9).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new dst inner vlan
flowPatch = FlowPatch.builder().destination(PatchEndpoint.builder().innerVlanId(9).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new dst LLDP flag
flowPatch = FlowPatch.builder().destination(PatchEndpoint.builder().trackLldpConnectedDevices(true).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new dst ARP flag
flowPatch = FlowPatch.builder().destination(PatchEndpoint.builder().trackArpConnectedDevices(true).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new maximum bandwidth
flowPatch = FlowPatch.builder().bandwidth(9000L).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new flag allocate protected path
flowPatch = FlowPatch.builder().allocateProtectedPath(false).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// add diverse flow id
flowPatch = FlowPatch.builder().diverseFlowId("diverse_flow_id").build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new ignore bandwidth flag
flowPatch = FlowPatch.builder().ignoreBandwidth(true).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new encapsulation type
flowPatch = FlowPatch.builder().encapsulationType(FlowEncapsulationType.VXLAN).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new path computation strategy
flowPatch = FlowPatch.builder().pathComputationStrategy(PathComputationStrategy.LATENCY).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
}
use of org.openkilda.wfm.topology.nbworker.services.FlowOperationsService.UpdateFlowResult 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.wfm.topology.nbworker.services.FlowOperationsService.UpdateFlowResult 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.wfm.topology.nbworker.services.FlowOperationsService.UpdateFlowResult 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());
}
Aggregations