Exclude alien Port from Edge ports
- Remote end of inter-domain link can contain Port
not managed by local cluster. Exclude them.
Change-Id: I74cd705d98d16ffefd14242ac273272bb1e6677d
diff --git a/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java b/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java
index bc9411d..7d31d0f 100644
--- a/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java
+++ b/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java
@@ -103,7 +103,10 @@
@Override
public Port getPort(DeviceId deviceId, PortNumber portNumber) {
- return null;
+ return getPorts(deviceId).stream()
+ .filter(port -> deviceId.equals(port.element().id()))
+ .filter(port -> portNumber.equals(port.number()))
+ .findFirst().orElse(null);
}
@Override
diff --git a/core/net/src/main/java/org/onosproject/net/edgeservice/impl/EdgeManager.java b/core/net/src/main/java/org/onosproject/net/edgeservice/impl/EdgeManager.java
index 68a58c2..4bb22ae 100644
--- a/core/net/src/main/java/org/onosproject/net/edgeservice/impl/EdgeManager.java
+++ b/core/net/src/main/java/org/onosproject/net/edgeservice/impl/EdgeManager.java
@@ -227,6 +227,7 @@
// Logical ports are not counted as edge ports nor are infrastructure
// ports. Ports that have only edge links are considered edge ports.
return !point.port().isLogical() &&
+ deviceService.getPort(point) != null &&
linkService.getLinks(point).stream()
.allMatch(link -> link.type() == Type.EDGE);
}
diff --git a/core/net/src/test/java/org/onosproject/net/edgeservice/impl/EdgeManagerTest.java b/core/net/src/test/java/org/onosproject/net/edgeservice/impl/EdgeManagerTest.java
index 971ce4b..93234d3 100644
--- a/core/net/src/test/java/org/onosproject/net/edgeservice/impl/EdgeManagerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/edgeservice/impl/EdgeManagerTest.java
@@ -131,9 +131,12 @@
ConnectPoint testPoint, referencePoint;
//Testing link removal
+ devices.put(NetTestTools.did("a"), NetTestTools.device("a"));
+ devices.put(NetTestTools.did("b"), NetTestTools.device("b"));
postTopologyEvent(new LinkEvent(LINK_REMOVED, NetTestTools.link("a", 1, "b", 2)));
- assertTrue("The list contained an unexpected number of events", events.size() == 2);
+ assertEquals("The list contained an unexpected number of events",
+ 2, events.size());
assertTrue("The first element is of the wrong type.",
events.get(0).type() == EDGE_PORT_ADDED);