Committed by
Jonathan Hart
Fix for [ONOS-3590]
Compare two devices instead of one with itself Add unit test for root node Change-Id: If109dd8b05cd77825e182399b321c321865b9786
Showing
2 changed files
with
12 additions
and
3 deletions
| ... | @@ -519,7 +519,7 @@ public class DefaultTopology extends AbstractModel implements Topology { | ... | @@ -519,7 +519,7 @@ public class DefaultTopology extends AbstractModel implements Topology { |
| 519 | private TopologyVertex findRoot(Set<TopologyVertex> vertexSet) { | 519 | private TopologyVertex findRoot(Set<TopologyVertex> vertexSet) { |
| 520 | TopologyVertex minVertex = null; | 520 | TopologyVertex minVertex = null; |
| 521 | for (TopologyVertex vertex : vertexSet) { | 521 | for (TopologyVertex vertex : vertexSet) { |
| 522 | - if ((minVertex == null) || (minVertex.deviceId() | 522 | + if ((minVertex == null) || (vertex.deviceId() |
| 523 | .toString().compareTo(minVertex.deviceId().toString()) < 0)) { | 523 | .toString().compareTo(minVertex.deviceId().toString()) < 0)) { |
| 524 | minVertex = vertex; | 524 | minVertex = vertex; |
| 525 | } | 525 | } | ... | ... |
| ... | @@ -29,9 +29,11 @@ import org.onosproject.net.PortNumber; | ... | @@ -29,9 +29,11 @@ import org.onosproject.net.PortNumber; |
| 29 | import org.onosproject.net.provider.ProviderId; | 29 | import org.onosproject.net.provider.ProviderId; |
| 30 | import org.onosproject.net.topology.ClusterId; | 30 | import org.onosproject.net.topology.ClusterId; |
| 31 | import org.onosproject.net.topology.DefaultGraphDescription; | 31 | import org.onosproject.net.topology.DefaultGraphDescription; |
| 32 | +import org.onosproject.net.topology.DefaultTopologyVertex; | ||
| 32 | import org.onosproject.net.topology.GraphDescription; | 33 | import org.onosproject.net.topology.GraphDescription; |
| 33 | import org.onosproject.net.topology.LinkWeight; | 34 | import org.onosproject.net.topology.LinkWeight; |
| 34 | import org.onosproject.net.topology.TopologyCluster; | 35 | import org.onosproject.net.topology.TopologyCluster; |
| 36 | +import org.onosproject.net.topology.TopologyVertex; | ||
| 35 | 37 | ||
| 36 | import java.util.Set; | 38 | import java.util.Set; |
| 37 | 39 | ||
| ... | @@ -53,6 +55,9 @@ public class DefaultTopologyTest { | ... | @@ -53,6 +55,9 @@ public class DefaultTopologyTest { |
| 53 | public static final DeviceId D4 = deviceId("of:4"); | 55 | public static final DeviceId D4 = deviceId("of:4"); |
| 54 | public static final DeviceId D5 = deviceId("of:5"); | 56 | public static final DeviceId D5 = deviceId("of:5"); |
| 55 | 57 | ||
| 58 | + public static final TopologyVertex V1 = new DefaultTopologyVertex(D1); | ||
| 59 | + public static final TopologyVertex V5 = new DefaultTopologyVertex(D5); | ||
| 60 | + | ||
| 56 | public static final PortNumber P1 = portNumber(1); | 61 | public static final PortNumber P1 = portNumber(1); |
| 57 | public static final PortNumber P2 = portNumber(2); | 62 | public static final PortNumber P2 = portNumber(2); |
| 58 | 63 | ||
| ... | @@ -62,6 +67,9 @@ public class DefaultTopologyTest { | ... | @@ -62,6 +67,9 @@ public class DefaultTopologyTest { |
| 62 | 67 | ||
| 63 | private DefaultTopology dt; | 68 | private DefaultTopology dt; |
| 64 | 69 | ||
| 70 | + public static final ClusterId C0 = ClusterId.clusterId(0); | ||
| 71 | + public static final ClusterId C1 = ClusterId.clusterId(1); | ||
| 72 | + | ||
| 65 | @Before | 73 | @Before |
| 66 | public void setUp() { | 74 | public void setUp() { |
| 67 | long now = System.currentTimeMillis(); | 75 | long now = System.currentTimeMillis(); |
| ... | @@ -81,8 +89,9 @@ public class DefaultTopologyTest { | ... | @@ -81,8 +89,9 @@ public class DefaultTopologyTest { |
| 81 | assertEquals("incorrect device count", 5, dt.deviceCount()); | 89 | assertEquals("incorrect device count", 5, dt.deviceCount()); |
| 82 | assertEquals("incorrect link count", 8, dt.linkCount()); | 90 | assertEquals("incorrect link count", 8, dt.linkCount()); |
| 83 | assertEquals("incorrect cluster count", 2, dt.clusterCount()); | 91 | assertEquals("incorrect cluster count", 2, dt.clusterCount()); |
| 84 | - assertEquals("incorrect broadcast set size", 6, | 92 | + assertEquals("incorrect broadcast set size", 6, dt.broadcastSetSize(C0)); |
| 85 | - dt.broadcastSetSize(ClusterId.clusterId(0))); | 93 | + assertEquals("incorrect root node", V1, dt.getCluster(C0).root()); |
| 94 | + assertEquals("incorrect root node", V5, dt.getCluster(C1).root()); | ||
| 86 | } | 95 | } |
| 87 | 96 | ||
| 88 | @Test | 97 | @Test | ... | ... |
-
Please register or login to post a comment