Search in sources :

Example 6 with FlowPatch

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());
}
Also used : FlowPatch(org.openkilda.messaging.model.FlowPatch) TestFlowBuilder(org.openkilda.wfm.share.flow.TestFlowBuilder) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 7 with FlowPatch

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());
}
Also used : FlowPatch(org.openkilda.messaging.model.FlowPatch) UpdateFlowResult(org.openkilda.wfm.topology.nbworker.services.FlowOperationsService.UpdateFlowResult) SwitchId(org.openkilda.model.SwitchId) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 8 with FlowPatch

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());
}
Also used : FlowPatch(org.openkilda.messaging.model.FlowPatch) TestFlowBuilder(org.openkilda.wfm.share.flow.TestFlowBuilder) PathComputationStrategy(org.openkilda.model.PathComputationStrategy) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 9 with FlowPatch

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());
}
Also used : FlowPatch(org.openkilda.messaging.model.FlowPatch) UpdateFlowResult(org.openkilda.wfm.topology.nbworker.services.FlowOperationsService.UpdateFlowResult) SwitchId(org.openkilda.model.SwitchId) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 10 with FlowPatch

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);
}
Also used : FlowPatch(org.openkilda.messaging.model.FlowPatch) TestFlowBuilder(org.openkilda.wfm.share.flow.TestFlowBuilder) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Aggregations

FlowPatch (org.openkilda.messaging.model.FlowPatch)15 Test (org.junit.Test)12 Flow (org.openkilda.model.Flow)11 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)10 SwitchId (org.openkilda.model.SwitchId)7 UpdateFlowResult (org.openkilda.wfm.topology.nbworker.services.FlowOperationsService.UpdateFlowResult)6 TestFlowBuilder (org.openkilda.wfm.share.flow.TestFlowBuilder)4 MessageException (org.openkilda.messaging.error.MessageException)3 FlowResponse (org.openkilda.messaging.info.flow.FlowResponse)3 CommandMessage (org.openkilda.messaging.command.CommandMessage)2 SwapFlowResponse (org.openkilda.messaging.info.flow.SwapFlowResponse)2 PathComputationStrategy (org.openkilda.model.PathComputationStrategy)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 String.format (java.lang.String.format)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1