Search in sources :

Example 91 with FlowPath

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

the class SpeakerFlowSegmentRequestBuilderTest method verifyReverseEgressRequest.

private void verifyReverseEgressRequest(Flow flow, FlowSegmentRequest rawRequest) {
    FlowPath path = Objects.requireNonNull(flow.getReversePath());
    EgressFlowSegmentRequest request = verifyCommonEgressRequest(flow, path, rawRequest);
    FlowEndpoint expectedEndpoint = new FlowEndpoint(flow.getSrcSwitchId(), flow.getSrcPort(), flow.getSrcVlan());
    assertEquals(expectedEndpoint, request.getEndpoint());
    FlowEndpoint expectedIngressEndpoint = new FlowEndpoint(flow.getDestSwitchId(), flow.getDestPort(), flow.getDestVlan());
    assertEquals(expectedIngressEndpoint, request.getIngressEndpoint());
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) FlowPath(org.openkilda.model.FlowPath) EgressFlowSegmentRequest(org.openkilda.floodlight.api.request.EgressFlowSegmentRequest)

Example 92 with FlowPath

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

the class SpeakerFlowSegmentRequestBuilderTest method verifyReverseOneSwitchRequest.

private void verifyReverseOneSwitchRequest(Flow flow, FlowSegmentRequest rawRequest) {
    FlowPath path = Objects.requireNonNull(flow.getReversePath());
    OneSwitchFlowRequest request = verifyCommonOneSwitchRequest(flow, path, rawRequest);
    assertEquals(new FlowEndpoint(flow.getDestSwitchId(), flow.getDestPort(), flow.getDestVlan()), request.getEndpoint());
    assertEquals(new FlowEndpoint(flow.getSrcSwitchId(), flow.getSrcPort(), flow.getSrcVlan()), request.getEgressEndpoint());
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) OneSwitchFlowRequest(org.openkilda.floodlight.api.request.OneSwitchFlowRequest) FlowPath(org.openkilda.model.FlowPath)

Example 93 with FlowPath

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

the class SpeakerFlowSegmentRequestBuilderTest method useActualFlowEndpoint.

@Test
public void useActualFlowEndpoint() {
    Switch srcSwitch = Switch.builder().switchId(SWITCH_1).build();
    Switch destSwitch = Switch.builder().switchId(SWITCH_2).build();
    // having flow stored in DB
    Flow origin = buildFlow(srcSwitch, 1, 5, destSwitch, 2, 0, 0);
    setSegmentsWithoutTransitSwitches(Objects.requireNonNull(origin.getForwardPath()), Objects.requireNonNull(origin.getReversePath()));
    // then new set of paths are created
    FlowPath goalForwardPath = buildFlowPath(origin, origin.getSrcSwitch(), origin.getDestSwitch(), new FlowSegmentCookie(FlowPathDirection.FORWARD, cookieFactory.next()));
    FlowPath goalReversePath = buildFlowPath(origin, origin.getDestSwitch(), origin.getSrcSwitch(), new FlowSegmentCookie(FlowPathDirection.REVERSE, cookieFactory.next()));
    setSegmentsWithTransitSwitches(goalForwardPath, goalReversePath);
    // than new version of flow is created to fulfill update request
    Flow goal = Flow.builder().flowId(origin.getFlowId()).srcSwitch(origin.getSrcSwitch()).srcPort(origin.getSrcPort()).srcVlan(// update
    origin.getSrcVlan() + 10).destSwitch(origin.getDestSwitch()).destPort(origin.getDestPort()).destVlan(origin.getDestVlan()).bandwidth(origin.getBandwidth()).encapsulationType(origin.getEncapsulationType()).build();
    // emulate db behaviour - flow will have "existing" paths after fetching it from DB
    goal.setForwardPath(origin.getForwardPath());
    goal.setReversePath(origin.getReversePath());
    goal.addPaths(goalForwardPath, goalReversePath);
    // then produce path segment request factories
    List<FlowSegmentRequestFactory> commands = target.buildIngressOnly(COMMAND_CONTEXT, goal, goalForwardPath, goalReversePath, SpeakerRequestBuildContext.getEmpty());
    boolean haveMatch = false;
    for (FlowSegmentRequestFactory entry : commands) {
        // search command for flow source side
        if (SWITCH_1.equals(entry.getSwitchId())) {
            haveMatch = true;
            Assert.assertTrue(entry instanceof IngressFlowSegmentRequestFactory);
            IngressFlowSegmentRequestFactory segment = (IngressFlowSegmentRequestFactory) entry;
            IngressFlowSegmentRequest request = segment.makeInstallRequest(commandIdGenerator.generate());
            Assert.assertEquals(goal.getSrcVlan(), request.getEndpoint().getOuterVlanId());
        }
    }
    Assert.assertTrue(haveMatch);
}
Also used : IngressFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.IngressFlowSegmentRequestFactory) FlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) IngressFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.IngressFlowSegmentRequestFactory) Switch(org.openkilda.model.Switch) IngressFlowSegmentRequest(org.openkilda.floodlight.api.request.IngressFlowSegmentRequest) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 94 with FlowPath

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

the class SpeakerFlowSegmentRequestBuilderTest method verifyForwardOneSwitchRequest.

private void verifyForwardOneSwitchRequest(Flow flow, FlowSegmentRequest rawRequest) {
    FlowPath path = Objects.requireNonNull(flow.getForwardPath());
    OneSwitchFlowRequest request = verifyCommonOneSwitchRequest(flow, path, rawRequest);
    assertEquals(new FlowEndpoint(flow.getSrcSwitchId(), flow.getSrcPort(), flow.getSrcVlan()), request.getEndpoint());
    assertEquals(new FlowEndpoint(flow.getDestSwitchId(), flow.getDestPort(), flow.getDestVlan()), request.getEgressEndpoint());
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) OneSwitchFlowRequest(org.openkilda.floodlight.api.request.OneSwitchFlowRequest) FlowPath(org.openkilda.model.FlowPath)

Example 95 with FlowPath

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

the class SpeakerFlowSegmentRequestBuilderTest method verifyForwardIngressRequest.

private IngressFlowSegmentRequest verifyForwardIngressRequest(Flow flow, FlowSegmentRequest rawRequest) {
    FlowPath path = Objects.requireNonNull(flow.getForwardPath());
    IngressFlowSegmentRequest request = verifyCommonIngressRequest(flow, path, rawRequest);
    assertEquals(flow.getSrcSwitchId(), request.getSwitchId());
    FlowEndpoint endpoint = new FlowEndpoint(flow.getSrcSwitchId(), flow.getSrcPort(), flow.getSrcVlan());
    assertEquals(endpoint, request.getEndpoint());
    return request;
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) IngressFlowSegmentRequest(org.openkilda.floodlight.api.request.IngressFlowSegmentRequest) 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