Search in sources :

Example 86 with FlowPath

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

the class FlowLoopTransitRuleGeneratorTest method buildOneSwitchFlowTransitRuleTest.

@Test
public void buildOneSwitchFlowTransitRuleTest() {
    FlowPath path = FlowPath.builder().pathId(PATH_ID).cookie(PATH_COOKIE).srcSwitch(SWITCH_1).destSwitch(SWITCH_1).build();
    FlowLoopTransitRuleGenerator generator = FlowLoopTransitRuleGenerator.builder().flow(buildFlow(path)).flowPath(path).inPort(PORT_NUMBER_1).multiTable(true).encapsulation(VLAN_ENCAPSULATION).build();
    assertEquals(0, generator.generateCommands(SWITCH_1).size());
}
Also used : FlowPath(org.openkilda.model.FlowPath) Test(org.junit.Test)

Example 87 with FlowPath

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

the class IngressMirrorRuleGeneratorTest method pathWithWrongMirrorSwitchMirrorsEgressMirrorRuleTest.

@Test
public void pathWithWrongMirrorSwitchMirrorsEgressMirrorRuleTest() {
    FlowPath path = buildPath(true);
    path.addFlowMirrorPoints(buildMirrorPoints(SWITCH_2));
    Flow flow = buildFlow(path, 0, 0);
    IngressMirrorRuleGenerator generator = buildGenerator(path, flow, VXLAN_ENCAPSULATION);
    assertEquals(0, generator.generateCommands(SWITCH_1).size());
}
Also used : FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 88 with FlowPath

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

the class StatsTopologyTest method meterFlowRulesStatsTest.

@Test
public void meterFlowRulesStatsTest() {
    Flow flow = createOneSwitchFlow(SWITCH_ID_1);
    FlowPath flowPath = flow.getForwardPath();
    sendUpdateFlowPathInfo(flowPath);
    MeterStatsEntry meterStats = new MeterStatsEntry(flowPath.getMeterId().getValue(), 500L, 700L);
    sendStatsMessage(new MeterStatsData(SWITCH_ID_1, Collections.singletonList(meterStats)));
    List<Datapoint> datapoints = pollDatapoints(3);
    Map<String, Datapoint> datapointMap = createDatapointMap(datapoints);
    assertEquals(meterStats.getPacketsInCount(), datapointMap.get(METRIC_PREFIX + "flow.meter.packets").getValue().longValue());
    assertEquals(meterStats.getByteInCount(), datapointMap.get(METRIC_PREFIX + "flow.meter.bytes").getValue().longValue());
    assertEquals(meterStats.getByteInCount() * 8, datapointMap.get(METRIC_PREFIX + "flow.meter.bits").getValue().longValue());
    datapoints.forEach(datapoint -> {
        assertEquals(6, datapoint.getTags().size());
        assertEquals(SWITCH_ID_1.toOtsdFormat(), datapoint.getTags().get("switchid"));
        assertEquals(String.valueOf(flowPath.getMeterId().getValue()), datapoint.getTags().get("meterid"));
        assertEquals("forward", datapoint.getTags().get("direction"));
        assertEquals("false", datapoint.getTags().get("is_y_flow_subflow"));
        assertEquals(flowId, datapoint.getTags().get("flowid"));
        assertEquals(String.valueOf(flowPath.getCookie().getValue()), datapoint.getTags().get("cookie"));
        assertEquals(timestamp, datapoint.getTime().longValue());
    });
}
Also used : MeterStatsData(org.openkilda.messaging.info.stats.MeterStatsData) Datapoint(org.openkilda.messaging.info.Datapoint) FlowPath(org.openkilda.model.FlowPath) MeterStatsEntry(org.openkilda.messaging.info.stats.MeterStatsEntry) Flow(org.openkilda.model.Flow) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 89 with FlowPath

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

the class UtilsTest method multiSwitchPathWithoutSegmentsOutPortTest.

@Test(expected = IllegalStateException.class)
public void multiSwitchPathWithoutSegmentsOutPortTest() {
    FlowPath path = FlowPath.builder().pathId(PATH_ID).srcSwitch(SWITCH_1).destSwitch(SWITCH_2).segments(newArrayList()).build();
    Utils.getOutPort(path, null);
}
Also used : FlowPath(org.openkilda.model.FlowPath) Test(org.junit.Test)

Example 90 with FlowPath

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

the class FlowMapperTest method buildFlow.

private Flow buildFlow() {
    Flow flow = Flow.builder().flowId("test_flow").srcSwitch(Switch.builder().switchId(SRC_SWITCH_ID).build()).destSwitch(Switch.builder().switchId(DST_SWITCH_ID).build()).allocateProtectedPath(true).build();
    FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId("forward_flow_path")).srcSwitch(Switch.builder().switchId(SRC_SWITCH_ID).build()).destSwitch(Switch.builder().switchId(DST_SWITCH_ID).build()).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1)).status(FlowPathStatus.ACTIVE).build();
    flow.setForwardPath(forwardFlowPath);
    FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId("reverse_flow_path")).srcSwitch(Switch.builder().switchId(DST_SWITCH_ID).build()).destSwitch(Switch.builder().switchId(SRC_SWITCH_ID).build()).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1)).status(FlowPathStatus.ACTIVE).build();
    flow.setReversePath(reverseFlowPath);
    FlowPath forwardProtectedFlowPath = FlowPath.builder().pathId(new PathId("forward_protected_flow_path")).srcSwitch(Switch.builder().switchId(SRC_SWITCH_ID).build()).destSwitch(Switch.builder().switchId(DST_SWITCH_ID).build()).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 2)).status(FlowPathStatus.INACTIVE).build();
    flow.setProtectedForwardPath(forwardProtectedFlowPath);
    FlowPath reverseProtectedFlowPath = FlowPath.builder().pathId(new PathId("reverse_protected_flow_path")).srcSwitch(Switch.builder().switchId(DST_SWITCH_ID).build()).destSwitch(Switch.builder().switchId(SRC_SWITCH_ID).build()).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 2)).status(FlowPathStatus.INACTIVE).build();
    flow.setProtectedReversePath(reverseProtectedFlowPath);
    return flow;
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow)

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