Search in sources :

Example 46 with FlowPath

use of org.openkilda.model.FlowPath in project open-kilda by telstra.

the class FermaFlowPathRepositoryTest method shouldFindPathBySegmentSwitch.

@Test
public void shouldFindPathBySegmentSwitch() {
    FlowPath flowPath = createTestFlowPathWithIntermediate(switchC, 100);
    flow.setForwardPath(flowPath);
    Collection<FlowPath> foundPaths = flowPathRepository.findBySegmentSwitch(switchC.getSwitchId());
    assertThat(foundPaths, hasSize(1));
}
Also used : FlowPath(org.openkilda.model.FlowPath) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 47 with FlowPath

use of org.openkilda.model.FlowPath in project open-kilda by telstra.

the class FermaFlowPathRepositoryTest method shouldFlowPathUpdateKeepFlowRelations.

@Test
public void shouldFlowPathUpdateKeepFlowRelations() {
    createTestFlowPathPair();
    Flow foundFlow = flowRepository.findById(TEST_FLOW_ID).get();
    assertThat(foundFlow.getPaths(), hasSize(2));
    FlowPath flowPath = foundFlow.getPaths().stream().filter(path -> path.getPathId().equals(flow.getReversePathId())).findAny().get();
    flowPath.setStatus(FlowPathStatus.INACTIVE);
    foundFlow = flowRepository.findById(TEST_FLOW_ID).get();
    assertThat(foundFlow.getPaths(), hasSize(2));
}
Also used : FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 48 with FlowPath

use of org.openkilda.model.FlowPath in project open-kilda by telstra.

the class FermaFlowPathRepositoryTest method shouldCreateFlowPaths.

@Test
public void shouldCreateFlowPaths() {
    createTestFlowPathPair();
    Collection<FlowPath> allPaths = flowPathRepository.findAll();
    assertThat(allPaths, hasSize(2));
    FlowPath foundForwardPath = flowPathRepository.findById(flow.getForwardPathId()).get();
    assertEquals(switchA.getSwitchId(), foundForwardPath.getSrcSwitchId());
    assertEquals(switchB.getSwitchId(), foundForwardPath.getDestSwitchId());
    Flow foundFlow = flowRepository.findById(TEST_FLOW_ID).get();
    assertThat(foundFlow.getPaths(), hasSize(2));
    assertEquals(foundFlow.getFlowId(), foundForwardPath.getFlow().getFlowId());
}
Also used : FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 49 with FlowPath

use of org.openkilda.model.FlowPath in project open-kilda by telstra.

the class FermaFlowPathRepositoryTest method buildTestProtectedFlow.

private Flow buildTestProtectedFlow(String flowId, Switch srcSwitch, int srcPort, int srcVlan, Switch destSwitch, int destPort, int destVlan) {
    Flow flow = buildTestFlow(flowId, srcSwitch, srcPort, srcVlan, destSwitch, destPort, destVlan);
    FlowPath forwardProtectedFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_forward_protected_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 2L)).srcSwitch(srcSwitch).destSwitch(destSwitch).status(FlowPathStatus.ACTIVE).build();
    flow.setProtectedForwardPath(forwardProtectedFlowPath);
    PathSegment forwardSegment = PathSegment.builder().pathId(forwardProtectedFlowPath.getPathId()).srcSwitch(srcSwitch).srcPort(srcPort).destSwitch(destSwitch).destPort(destPort).build();
    forwardProtectedFlowPath.setSegments(Collections.singletonList(forwardSegment));
    FlowPath reverseProtectedFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_reverse_protected_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 2L)).srcSwitch(destSwitch).destSwitch(srcSwitch).status(FlowPathStatus.ACTIVE).build();
    flow.setProtectedReversePath(reverseProtectedFlowPath);
    PathSegment reverseSegment = PathSegment.builder().pathId(reverseProtectedFlowPath.getPathId()).srcSwitch(destSwitch).srcPort(destPort).destSwitch(srcSwitch).destPort(srcPort).build();
    reverseProtectedFlowPath.setSegments(Collections.singletonList(reverseSegment));
    return flow;
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow)

Example 50 with FlowPath

use of org.openkilda.model.FlowPath in project open-kilda by telstra.

the class FermaFlowPathRepositoryTest method createTestFlowPath.

private FlowPath createTestFlowPath() {
    FlowPath flowPath = createFlowPath(flow, "_path", 1, 1, switchA, switchB);
    flow.setForwardPath(flowPath);
    return flowPath;
}
Also used : FlowPath(org.openkilda.model.FlowPath)

Aggregations

FlowPath (org.openkilda.model.FlowPath)229 Flow (org.openkilda.model.Flow)128 Test (org.junit.Test)108 PathId (org.openkilda.model.PathId)65 PathSegment (org.openkilda.model.PathSegment)42 SwitchId (org.openkilda.model.SwitchId)40 ArrayList (java.util.ArrayList)39 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)33 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)29 Switch (org.openkilda.model.Switch)28 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)27 SpeakerData (org.openkilda.rulemanager.SpeakerData)27 Action (org.openkilda.rulemanager.action.Action)26 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)26 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)26 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)26 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)26 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)26 MeterId (org.openkilda.model.MeterId)20 YFlow (org.openkilda.model.YFlow)19