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());
}
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());
}
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());
});
}
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);
}
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;
}
Aggregations