use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class StatsTopologyTest method flowAttendantRulesStatsTest.
@Test
public void flowAttendantRulesStatsTest() {
Flow flow = createFlow();
FlowSegmentCookie server42IngressCookie = MAIN_FORWARD_COOKIE.toBuilder().type(CookieType.SERVER_42_FLOW_RTT_INGRESS).build();
FlowEndpoint ingress = new FlowEndpoint(SWITCH_ID_1, PORT_1);
FlowStatsEntry measure0 = new FlowStatsEntry(0, server42IngressCookie.getValue(), 0, 0, ingress.getPortNumber(), ingress.getPortNumber() + 1);
FlowStatsEntry measure1 = new FlowStatsEntry(0, server42IngressCookie.getValue(), 1, 200, ingress.getPortNumber(), ingress.getPortNumber() + 1);
FlowStatsEntry measure2 = new FlowStatsEntry(0, server42IngressCookie.getValue(), 2, 300, ingress.getPortNumber(), ingress.getPortNumber() + 1);
sendStatsMessage(new FlowStatsData(ingress.getSwitchId(), Collections.singletonList(measure0)));
sendUpdateFlowPathInfo(flow.getForwardPath());
sendStatsMessage(new FlowStatsData(ingress.getSwitchId(), Collections.singletonList(measure1)));
sendRemoveFlowPathInfo(flow.getForwardPath());
sendStatsMessage(new FlowStatsData(ingress.getSwitchId(), Collections.singletonList(measure2)));
List<Datapoint> datapoints = pollDatapoints(9);
List<Datapoint> rawPacketsMetric = datapoints.stream().filter(entry -> (METRIC_PREFIX + "flow.raw.packets").equals(entry.getMetric())).collect(Collectors.toList());
Assert.assertEquals(3, rawPacketsMetric.size());
for (Datapoint entry : rawPacketsMetric) {
Map<String, String> tags = entry.getTags();
Assert.assertEquals(CookieType.SERVER_42_FLOW_RTT_INGRESS.name().toLowerCase(), tags.get("type"));
if (Objects.equals(0, entry.getValue())) {
Assert.assertEquals("unknown", tags.get("flowid"));
} else if (Objects.equals(1, entry.getValue())) {
Assert.assertEquals(flowId, tags.get("flowid"));
} else if (Objects.equals(2, entry.getValue())) {
Assert.assertEquals("unknown", tags.get("flowid"));
} else {
Assert.fail(format("Unexpected metric value: %s", entry));
}
}
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class IngressMirrorRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
List<SpeakerData> result = new ArrayList<>();
FlowMirrorPoints mirrorPoints = flowPath.getFlowMirrorPointsSet().stream().filter(points -> sw.getSwitchId().equals(points.getMirrorSwitchId())).findFirst().orElse(null);
if (mirrorPoints == null) {
return result;
}
FlowEndpoint ingressEndpoint = checkAndBuildIngressEndpoint(flow, flowPath, sw.getSwitchId());
FlowSpeakerData ingressCommand = buildFlowIngressCommand(sw, ingressEndpoint, mirrorPoints.getMirrorGroupId());
result.add(ingressCommand);
SpeakerData groupCommand = buildGroup(sw, mirrorPoints);
result.add(groupCommand);
ingressCommand.getDependsOn().add(groupCommand.getUuid());
if (sharedMeterCommandUuid != null) {
ingressCommand.getDependsOn().add(sharedMeterCommandUuid);
}
return result;
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class InputArpRuleGeneratorTest method buildCorrectRuleForOf13Test.
@Test
public void buildCorrectRuleForOf13Test() {
FlowEndpoint endpoint = new FlowEndpoint(SW.getSwitchId(), PORT_NUMBER_1, 0, 0, false, true);
FlowSideAdapter overlapAdapter = new FlowSourceAdapter(Flow.builder().flowId("some").srcSwitch(SW).destSwitch(buildSwitch("OF_13", Collections.emptySet())).detectConnectedDevices(DetectConnectedDevices.builder().srcArp(false).srcSwitchArp(false).build()).build());
InputArpRuleGenerator generator = InputArpRuleGenerator.builder().ingressEndpoint(endpoint).multiTable(true).overlappingIngressAdapters(Sets.newHashSet(overlapAdapter)).build();
List<SpeakerData> commands = generator.generateCommands(SW);
assertEquals(1, commands.size());
FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
assertEquals(SW.getSwitchId(), flowCommandData.getSwitchId());
assertEquals(SW.getOfVersion(), flowCommandData.getOfVersion().toString());
assertTrue(flowCommandData.getDependsOn().isEmpty());
assertEquals(new PortColourCookie(CookieType.ARP_INPUT_CUSTOMER_TYPE, PORT_NUMBER_1), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(Priority.ARP_INPUT_CUSTOMER_PRIORITY, flowCommandData.getPriority());
Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.ARP).build());
assertEqualsMatch(expectedMatch, flowCommandData.getMatch());
RoutingMetadata metadata = RoutingMetadata.builder().arpFlag(true).build(SW.getFeatures());
Instructions expectedInstructions = Instructions.builder().writeMetadata(new OfMetadata(metadata.getValue(), metadata.getMask())).goToTable(OfTable.PRE_INGRESS).build();
assertEquals(expectedInstructions, flowCommandData.getInstructions());
assertTrue(flowCommandData.getFlags().isEmpty());
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class InputArpRuleGeneratorTest method buildArpRuleForSingleTableTest.
@Test
public void buildArpRuleForSingleTableTest() {
FlowEndpoint endpoint = new FlowEndpoint(SW.getSwitchId(), PORT_NUMBER_1, 0, 0, true, false);
InputArpRuleGenerator generator = InputArpRuleGenerator.builder().ingressEndpoint(endpoint).multiTable(false).overlappingIngressAdapters(new HashSet<>()).build();
assertEquals(0, generator.generateCommands(SW).size());
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class InputArpRuleGeneratorTest method buildArpRuleWithoutArpTest.
@Test
public void buildArpRuleWithoutArpTest() {
FlowEndpoint endpoint = new FlowEndpoint(SW.getSwitchId(), PORT_NUMBER_1, 0, 0, false, false);
InputArpRuleGenerator generator = InputArpRuleGenerator.builder().ingressEndpoint(endpoint).multiTable(true).overlappingIngressAdapters(new HashSet<>()).build();
assertEquals(0, generator.generateCommands(SW).size());
}
Aggregations