T3 Handling lldp and Bddp
Change-Id: Iecbe22bbbaa6d4719092be97385f70828d628b8c
(cherry picked from commit e30f33e3eb8b0250894c856bb0a0e260fcd349cd)
diff --git a/src/test/java/org/onosproject/t3/impl/T3TestObjects.java b/src/test/java/org/onosproject/t3/impl/T3TestObjects.java
index abbe77e..4e1eb68 100644
--- a/src/test/java/org/onosproject/t3/impl/T3TestObjects.java
+++ b/src/test/java/org/onosproject/t3/impl/T3TestObjects.java
@@ -539,6 +539,29 @@
.build();
static final FlowEntry DEFERRED_CLEAR_FLOW_ENTRY = new DefaultFlowEntry(DEFERRED_CLEAR_FLOW);
+ //LLDP
+
+ static final DeviceId LLDP_FLOW_DEVICE = DeviceId.deviceId("LldpDevice");
+
+ private static final TrafficSelector LLDP_FLOW_SELECTOR = DefaultTrafficSelector.builder()
+ .matchInPort(PortNumber.portNumber(1))
+ .matchEthType(EthType.EtherType.LLDP.ethType().toShort())
+ .build();
+
+ private static final TrafficTreatment LLDP_FLOW_TREATMENT = DefaultTrafficTreatment.builder()
+ .setOutput(PortNumber.CONTROLLER).build();
+ private static final FlowRule LLDP_FLOW = DefaultFlowEntry.builder().forDevice(LLDP_FLOW_DEVICE)
+ .forTable(0)
+ .withPriority(100)
+ .withSelector(LLDP_FLOW_SELECTOR)
+ .withTreatment(LLDP_FLOW_TREATMENT)
+ .fromApp(new DefaultApplicationId(0, "TestApp"))
+ .makePermanent()
+ .build();
+ static final FlowEntry LLDP_FLOW_ENTRY = new DefaultFlowEntry(LLDP_FLOW);
+
+ static final ConnectPoint LLDP_FLOW_CP = ConnectPoint.deviceConnectPoint(LLDP_FLOW_DEVICE + "/" + 1);
+
//helper elements
static final String MASTER_1 = "Master1";
@@ -571,6 +594,11 @@
.matchEthType(EthType.EtherType.ARP.ethType().toShort())
.build();
+ static final TrafficSelector PACKET_LLDP = DefaultTrafficSelector.builder()
+ .matchInPort(PortNumber.portNumber(1))
+ .matchEthType(EthType.EtherType.LLDP.ethType().toShort())
+ .build();
+
static final TrafficSelector PACKET_FAIL = DefaultTrafficSelector.builder()
.matchInPort(PortNumber.portNumber(1))
.matchIPSrc(IpPrefix.valueOf("127.0.0.1/32"))
diff --git a/src/test/java/org/onosproject/t3/impl/TroubleshootManagerTest.java b/src/test/java/org/onosproject/t3/impl/TroubleshootManagerTest.java
index 9767730..7b6c570 100644
--- a/src/test/java/org/onosproject/t3/impl/TroubleshootManagerTest.java
+++ b/src/test/java/org/onosproject/t3/impl/TroubleshootManagerTest.java
@@ -62,6 +62,7 @@
import static org.junit.Assert.assertTrue;
import static org.onosproject.net.Device.Type.SWITCH;
import static org.onosproject.t3.impl.T3TestObjects.*;
+import static org.onosproject.t3.impl.TroubleshootManager.PACKET_TO_CONTROLLER;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -132,7 +133,7 @@
StaticPacketTrace traceSuccess = mngr.trace(PACKET_ARP, ARP_FLOW_CP);
assertNotNull("Trace should not be null", traceSuccess);
assertTrue("Trace should be successful",
- traceSuccess.resultMessage().contains("Packet goes to the controller"));
+ traceSuccess.resultMessage().contains(PACKET_TO_CONTROLLER));
assertTrue("Master should be Master1",
traceSuccess.resultMessage().contains(MASTER_1));
ConnectPoint connectPoint = traceSuccess.getGroupOuputs(ARP_FLOW_DEVICE).get(0).getOutput();
@@ -303,6 +304,22 @@
}
+ /**
+ * Test LLDP output to controller.
+ */
+ @Test
+ public void lldpToController() {
+ StaticPacketTrace traceSuccess = mngr.trace(PACKET_LLDP, LLDP_FLOW_CP);
+ assertNotNull("Trace should not be null", traceSuccess);
+ assertTrue("Trace should be successful",
+ traceSuccess.resultMessage().contains("Packet goes to the controller"));
+ assertTrue("Master should be Master1",
+ traceSuccess.resultMessage().contains(MASTER_1));
+ ConnectPoint connectPoint = traceSuccess.getGroupOuputs(LLDP_FLOW_DEVICE).get(0).getOutput();
+ assertEquals("Packet Should go to CONTROLLER", PortNumber.CONTROLLER, connectPoint.port());
+ log.info("trace {}", traceSuccess.resultMessage());
+ }
+
private StaticPacketTrace testSuccess(TrafficSelector packet, ConnectPoint in, DeviceId deviceId, ConnectPoint out,
int paths, int outputs) {
StaticPacketTrace traceSuccess = mngr.trace(packet, in);
@@ -365,6 +382,8 @@
} else if (deviceId.equals(HARDWARE_DEVICE_10)) {
return ImmutableList.of(HARDWARE_10_FLOW_ENTRY, HARDWARE_10_SECOND_FLOW_ENTRY,
HARDWARE_10_OUTPUT_FLOW_ENTRY);
+ } else if (deviceId.equals(LLDP_FLOW_DEVICE)) {
+ return ImmutableList.of(LLDP_FLOW_ENTRY);
}
return ImmutableList.of();
}