Renamed *NetworkGraph* references to *Topology*.
Change-Id: Iec01c47086e1518592c0753e75395d3fe5abcde3
diff --git a/src/test/java/net/onrc/onos/core/intent/ConstrainedBFSTreeTest.java b/src/test/java/net/onrc/onos/core/intent/ConstrainedBFSTreeTest.java
index a99fc10..8d5a6d6 100644
--- a/src/test/java/net/onrc/onos/core/intent/ConstrainedBFSTreeTest.java
+++ b/src/test/java/net/onrc/onos/core/intent/ConstrainedBFSTreeTest.java
@@ -26,81 +26,81 @@
@Test
public void testCreate() {
- MockNetworkGraph graph = new MockNetworkGraph();
- graph.createSampleTopology1();
- ConstrainedBFSTree tree = new ConstrainedBFSTree(graph.getSwitch(1L));
+ MockTopology topology = new MockTopology();
+ topology.createSampleTopology1();
+ ConstrainedBFSTree tree = new ConstrainedBFSTree(topology.getSwitch(1L));
assertNotNull(tree);
}
@Test
public void testCreateConstrained() {
- MockNetworkGraph graph = new MockNetworkGraph();
- graph.createSampleTopology1();
+ MockTopology topology = new MockTopology();
+ topology.createSampleTopology1();
PathIntentMap intents = new PathIntentMap();
- ConstrainedBFSTree tree = new ConstrainedBFSTree(graph.getSwitch(1L), intents, 1000.0);
+ ConstrainedBFSTree tree = new ConstrainedBFSTree(topology.getSwitch(1L), intents, 1000.0);
assertNotNull(tree);
}
@Test
public void testGetPath() {
- MockNetworkGraph graph = new MockNetworkGraph();
- graph.createSampleTopology1();
- ConstrainedBFSTree tree = new ConstrainedBFSTree(graph.getSwitch(1L));
- Path path11 = tree.getPath(graph.getSwitch(1L));
- Path path12 = tree.getPath(graph.getSwitch(2L));
- Path path13 = tree.getPath(graph.getSwitch(3L));
- Path path14 = tree.getPath(graph.getSwitch(4L));
+ MockTopology topology = new MockTopology();
+ topology.createSampleTopology1();
+ ConstrainedBFSTree tree = new ConstrainedBFSTree(topology.getSwitch(1L));
+ Path path11 = tree.getPath(topology.getSwitch(1L));
+ Path path12 = tree.getPath(topology.getSwitch(2L));
+ Path path13 = tree.getPath(topology.getSwitch(3L));
+ Path path14 = tree.getPath(topology.getSwitch(4L));
assertNotNull(path11);
assertEquals(0, path11.size());
assertNotNull(path12);
assertEquals(1, path12.size());
- assertEquals(new LinkEvent(graph.getOutgoingLink(1L, 12L)), path12.get(0));
+ assertEquals(new LinkEvent(topology.getOutgoingLink(1L, 12L)), path12.get(0));
assertNotNull(path13);
assertEquals(2, path13.size());
if (path13.get(0).getDst().getDpid() == 2L) {
- assertEquals(new LinkEvent(graph.getOutgoingLink(1L, 12L)), path13.get(0));
- assertEquals(new LinkEvent(graph.getOutgoingLink(2L, 23L)), path13.get(1));
+ assertEquals(new LinkEvent(topology.getOutgoingLink(1L, 12L)), path13.get(0));
+ assertEquals(new LinkEvent(topology.getOutgoingLink(2L, 23L)), path13.get(1));
} else {
- assertEquals(new LinkEvent(graph.getOutgoingLink(1L, 14L)), path13.get(0));
- assertEquals(new LinkEvent(graph.getOutgoingLink(4L, 43L)), path13.get(1));
+ assertEquals(new LinkEvent(topology.getOutgoingLink(1L, 14L)), path13.get(0));
+ assertEquals(new LinkEvent(topology.getOutgoingLink(4L, 43L)), path13.get(1));
}
assertNotNull(path14);
assertEquals(1, path14.size());
- assertEquals(new LinkEvent(graph.getOutgoingLink(1L, 14L)), path14.get(0));
+ assertEquals(new LinkEvent(topology.getOutgoingLink(1L, 14L)), path14.get(0));
}
@Test
public void testGetPathNull() {
- MockNetworkGraph graph = new MockNetworkGraph();
- graph.createSampleTopology1();
- graph.removeLink(1L, 12L, 2L, 21L);
- graph.removeLink(1L, 14L, 4L, 41L);
+ MockTopology topology = new MockTopology();
+ topology.createSampleTopology1();
+ topology.removeLink(1L, 12L, 2L, 21L);
+ topology.removeLink(1L, 14L, 4L, 41L);
// now, there is no path from switch 1, but to switch1
- ConstrainedBFSTree tree1 = new ConstrainedBFSTree(graph.getSwitch(1L));
- Path path12 = tree1.getPath(graph.getSwitch(2L));
- Path path13 = tree1.getPath(graph.getSwitch(3L));
- Path path14 = tree1.getPath(graph.getSwitch(4L));
+ ConstrainedBFSTree tree1 = new ConstrainedBFSTree(topology.getSwitch(1L));
+ Path path12 = tree1.getPath(topology.getSwitch(2L));
+ Path path13 = tree1.getPath(topology.getSwitch(3L));
+ Path path14 = tree1.getPath(topology.getSwitch(4L));
- ConstrainedBFSTree tree2 = new ConstrainedBFSTree(graph.getSwitch(2L));
- Path path21 = tree2.getPath(graph.getSwitch(1L));
+ ConstrainedBFSTree tree2 = new ConstrainedBFSTree(topology.getSwitch(2L));
+ Path path21 = tree2.getPath(topology.getSwitch(1L));
assertNull(path12);
assertNull(path13);
assertNull(path14);
assertNotNull(path21);
assertEquals(1, path21.size());
- assertEquals(new LinkEvent(graph.getOutgoingLink(2L, 21L)), path21.get(0));
+ assertEquals(new LinkEvent(topology.getOutgoingLink(2L, 21L)), path21.get(0));
}
@Test
public void testGetConstrainedPath() {
- MockNetworkGraph graph = new MockNetworkGraph();
- graph.createSampleTopology1();
+ MockTopology topology = new MockTopology();
+ topology.createSampleTopology1();
PathIntentMap intents = new PathIntentMap();
IntentOperationList intentOps = new IntentOperationList();
@@ -111,33 +111,33 @@
"2", 1L, LOCAL_PORT, 0x333L, 2L, LOCAL_PORT, 0x444L, 600.0);
// calculate path of the intent1
- ConstrainedBFSTree tree = new ConstrainedBFSTree(graph.getSwitch(1L), intents, 600.0);
- Path path1 = tree.getPath(graph.getSwitch(2L));
+ ConstrainedBFSTree tree = new ConstrainedBFSTree(topology.getSwitch(1L), intents, 600.0);
+ Path path1 = tree.getPath(topology.getSwitch(2L));
assertNotNull(path1);
assertEquals(1, path1.size());
- assertEquals(new LinkEvent(graph.getOutgoingLink(1L, 12L)), path1.get(0));
+ assertEquals(new LinkEvent(topology.getOutgoingLink(1L, 12L)), path1.get(0));
PathIntent pathIntent1 = new PathIntent("pi1", path1, 600.0, intent1);
intentOps.add(Operator.ADD, pathIntent1);
intents.executeOperations(intentOps);
// calculate path of the intent2
- tree = new ConstrainedBFSTree(graph.getSwitch(1L), intents, 600.0);
- Path path2 = tree.getPath(graph.getSwitch(2L));
+ tree = new ConstrainedBFSTree(topology.getSwitch(1L), intents, 600.0);
+ Path path2 = tree.getPath(topology.getSwitch(2L));
assertNotNull(path2);
assertEquals(2, path2.size());
- assertEquals(new LinkEvent(graph.getOutgoingLink(1L, 14L)), path2.get(0));
- assertEquals(new LinkEvent(graph.getOutgoingLink(4L, 42L)), path2.get(1));
+ assertEquals(new LinkEvent(topology.getOutgoingLink(1L, 14L)), path2.get(0));
+ assertEquals(new LinkEvent(topology.getOutgoingLink(4L, 42L)), path2.get(1));
PathIntent pathIntent2 = new PathIntent("pi2", path2, 600.0, intent2);
intentOps.add(Operator.ADD, pathIntent2);
intents.executeOperations(intentOps);
// calculate path of the intent3
- tree = new ConstrainedBFSTree(graph.getSwitch(1L), intents, 600.0);
- Path path3 = tree.getPath(graph.getSwitch(2L));
+ tree = new ConstrainedBFSTree(topology.getSwitch(1L), intents, 600.0);
+ Path path3 = tree.getPath(topology.getSwitch(2L));
assertNull(path3);
}
diff --git a/src/test/java/net/onrc/onos/core/intent/MockNetworkGraph.java b/src/test/java/net/onrc/onos/core/intent/MockTopology.java
similarity index 84%
rename from src/test/java/net/onrc/onos/core/intent/MockNetworkGraph.java
rename to src/test/java/net/onrc/onos/core/intent/MockTopology.java
index d481182..680acc2 100644
--- a/src/test/java/net/onrc/onos/core/intent/MockNetworkGraph.java
+++ b/src/test/java/net/onrc/onos/core/intent/MockTopology.java
@@ -2,22 +2,22 @@
import net.onrc.onos.core.topology.Link;
import net.onrc.onos.core.topology.LinkImpl;
-import net.onrc.onos.core.topology.NetworkGraphImpl;
import net.onrc.onos.core.topology.Switch;
import net.onrc.onos.core.topology.SwitchImpl;
+import net.onrc.onos.core.topology.TopologyImpl;
/**
- * A mock class of NetworkGraph.
+ * A mock class of Topology.
* This class should be used only by test codes.
*
* @author Toshio Koide (t-koide@onlab.us)
*/
-public class MockNetworkGraph extends NetworkGraphImpl {
- // TODO this class doesn't seem like it should extend NetworkGraphImpl. It
- // isn't a NetworkGraph, it's more of a NetworkGraphBuilder - methods to
- // create an populate a fake network graph that's not based on discovery
+public class MockTopology extends TopologyImpl {
+ // TODO this class doesn't seem like it should extend TopologyImpl. It
+ // isn't a Topology, it's more of a TopologyBuilder - methods to
+ // create an populate a fake topology that's not based on discovery
// data from the driver modules.
- // We may well need a MockNetworkGraph, but that's not what this class is
+ // We may well need a MockTopology, but that's not what this class is
// doing.
public static Long LOCAL_PORT = 0xFFFEL;
diff --git a/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java b/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java
index 5e1a11d..2d57cfe 100644
--- a/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java
+++ b/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java
@@ -20,7 +20,6 @@
import net.floodlightcontroller.core.module.FloodlightModuleContext;
import net.floodlightcontroller.core.module.FloodlightModuleException;
import net.floodlightcontroller.restserver.IRestApiService;
-
import net.onrc.onos.core.datagrid.IDatagridService;
import net.onrc.onos.core.datagrid.IEventChannel;
import net.onrc.onos.core.datagrid.IEventChannelListener;
@@ -29,13 +28,13 @@
import net.onrc.onos.core.intent.IntentMap;
import net.onrc.onos.core.intent.IntentOperation.Operator;
import net.onrc.onos.core.intent.IntentOperationList;
-import net.onrc.onos.core.intent.MockNetworkGraph;
+import net.onrc.onos.core.intent.MockTopology;
import net.onrc.onos.core.intent.ShortestPathIntent;
import net.onrc.onos.core.intent.runtime.web.IntentWebRoutable;
import net.onrc.onos.core.registry.IControllerRegistryService;
import net.onrc.onos.core.topology.DeviceEvent;
-import net.onrc.onos.core.topology.INetworkGraphListener;
-import net.onrc.onos.core.topology.INetworkGraphService;
+import net.onrc.onos.core.topology.ITopologyListener;
+import net.onrc.onos.core.topology.ITopologyService;
import net.onrc.onos.core.topology.LinkEvent;
import net.onrc.onos.core.topology.PortEvent;
import net.onrc.onos.core.topology.SwitchEvent;
@@ -58,7 +57,7 @@
* <p/>
* Unit tests for the Path Calculation Runtime module (PathCalcRuntimeModule).
* These test cases check the results of creating paths, deleting paths, and
- * rerouting paths. The network graph, controller registry, and data grid are
+ * rerouting paths. The topology, controller registry, and data grid are
* mocked out. The individual tests check the high level intents and the
* resulting operation lists to be sure they match the intended APIs.
*/
@@ -69,22 +68,22 @@
private FloodlightModuleContext modContext;
private IDatagridService datagridService;
- private INetworkGraphService networkGraphService;
+ private ITopologyService topologyService;
private IControllerRegistryService controllerRegistryService;
private PersistIntent persistIntent;
private IRestApiService restApi;
- private MockNetworkGraph graph;
+ private MockTopology topology;
private IEventChannel<Long, IntentOperationList> intentOperationChannel;
private IEventChannel<Long, IntentStateList> intentStateChannel;
@SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
- graph = new MockNetworkGraph();
- graph.createSampleTopology1();
+ topology = new MockTopology();
+ topology.createSampleTopology1();
datagridService = createMock(IDatagridService.class);
- networkGraphService = createMock(INetworkGraphService.class);
+ topologyService = createMock(ITopologyService.class);
controllerRegistryService = createMock(IControllerRegistryService.class);
modContext = createMock(FloodlightModuleContext.class);
intentOperationChannel = createMock(IEventChannel.class);
@@ -97,8 +96,8 @@
expect(modContext.getServiceImpl(IDatagridService.class))
.andReturn(datagridService).once();
- expect(modContext.getServiceImpl(INetworkGraphService.class))
- .andReturn(networkGraphService).once();
+ expect(modContext.getServiceImpl(ITopologyService.class))
+ .andReturn(topologyService).once();
expect(modContext.getServiceImpl(IControllerRegistryService.class))
.andReturn(controllerRegistryService).once();
expect(persistIntent.getKey()).andReturn(1L).anyTimes();
@@ -108,10 +107,10 @@
expect(modContext.getServiceImpl(IRestApiService.class))
.andReturn(restApi).once();
- expect(networkGraphService.getNetworkGraph()).andReturn(graph)
+ expect(topologyService.getTopology()).andReturn(topology)
.anyTimes();
- networkGraphService.registerNetworkGraphListener(
- anyObject(INetworkGraphListener.class));
+ topologyService.registerTopologyListener(
+ anyObject(ITopologyListener.class));
expectLastCall();
expect(datagridService.createChannel("onos.pathintent",
@@ -127,7 +126,7 @@
restApi.addRestletRoutable(anyObject(IntentWebRoutable.class));
replay(datagridService);
- replay(networkGraphService);
+ replay(topologyService);
replay(modContext);
replay(controllerRegistryService);
PowerMock.replay(persistIntent, PersistIntent.class);
@@ -240,7 +239,7 @@
@After
public void tearDown() {
verify(datagridService);
- verify(networkGraphService);
+ verify(topologyService);
verify(modContext);
verify(controllerRegistryService);
PowerMock.verify(persistIntent, PersistIntent.class);
@@ -494,13 +493,13 @@
final List<LinkEvent> addedLinkEvents = new LinkedList<>();
final List<LinkEvent> removedLinkEvents = new LinkedList<>();
- graph.removeLink(1L, 12L, 2L, 21L); // This link is used by the intent "1"
- graph.removeLink(2L, 21L, 1L, 12L);
+ topology.removeLink(1L, 12L, 2L, 21L); // This link is used by the intent "1"
+ topology.removeLink(2L, 21L, 1L, 12L);
LinkEvent linkEvent1 = new LinkEvent(1L, 12L, 2L, 21L);
LinkEvent linkEvent2 = new LinkEvent(2L, 21L, 1L, 12L);
removedLinkEvents.add(linkEvent1);
removedLinkEvents.add(linkEvent2);
- runtime.networkGraphEvents(
+ runtime.topologyEvents(
emptySwitchEvents,
emptySwitchEvents,
emptyPortEvents,
diff --git a/src/test/java/net/onrc/onos/core/intent/runtime/UseCaseTest.java b/src/test/java/net/onrc/onos/core/intent/runtime/UseCaseTest.java
index f3c9aaa..8cacabc 100644
--- a/src/test/java/net/onrc/onos/core/intent/runtime/UseCaseTest.java
+++ b/src/test/java/net/onrc/onos/core/intent/runtime/UseCaseTest.java
@@ -25,19 +25,19 @@
import net.onrc.onos.core.intent.Intent.IntentState;
import net.onrc.onos.core.intent.IntentOperation.Operator;
import net.onrc.onos.core.intent.IntentOperationList;
-import net.onrc.onos.core.intent.MockNetworkGraph;
+import net.onrc.onos.core.intent.MockTopology;
import net.onrc.onos.core.intent.PathIntent;
import net.onrc.onos.core.intent.PathIntentMap;
import net.onrc.onos.core.intent.ShortestPathIntent;
import net.onrc.onos.core.intent.runtime.web.IntentWebRoutable;
import net.onrc.onos.core.registry.IControllerRegistryService;
import net.onrc.onos.core.topology.DeviceEvent;
-import net.onrc.onos.core.topology.INetworkGraphListener;
-import net.onrc.onos.core.topology.INetworkGraphService;
+import net.onrc.onos.core.topology.ITopologyListener;
+import net.onrc.onos.core.topology.ITopologyService;
import net.onrc.onos.core.topology.LinkEvent;
-import net.onrc.onos.core.topology.NetworkGraph;
import net.onrc.onos.core.topology.PortEvent;
import net.onrc.onos.core.topology.SwitchEvent;
+import net.onrc.onos.core.topology.Topology;
import org.junit.After;
import org.junit.Before;
@@ -57,10 +57,10 @@
@RunWith(PowerMockRunner.class)
@PrepareForTest(PathCalcRuntimeModule.class)
public class UseCaseTest {
- private NetworkGraph g;
+ private Topology topology;
private FloodlightModuleContext modContext;
private IDatagridService datagridService;
- private INetworkGraphService networkGraphService;
+ private ITopologyService topologyService;
private IControllerRegistryService controllerRegistryService;
private PersistIntent persistIntent;
private IRestApiService restApi;
@@ -72,12 +72,12 @@
@SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
- MockNetworkGraph graph = new MockNetworkGraph();
- graph.createSampleTopology1();
- g = graph;
+ MockTopology topology = new MockTopology();
+ topology.createSampleTopology1();
+ this.topology = topology;
datagridService = createMock(IDatagridService.class);
- networkGraphService = createMock(INetworkGraphService.class);
+ topologyService = createMock(ITopologyService.class);
controllerRegistryService = createMock(IControllerRegistryService.class);
modContext = createMock(FloodlightModuleContext.class);
intentOperationChannel = createMock(IEventChannel.class);
@@ -90,8 +90,8 @@
expect(modContext.getServiceImpl(IDatagridService.class))
.andReturn(datagridService).once();
- expect(modContext.getServiceImpl(INetworkGraphService.class))
- .andReturn(networkGraphService).once();
+ expect(modContext.getServiceImpl(ITopologyService.class))
+ .andReturn(topologyService).once();
expect(modContext.getServiceImpl(IControllerRegistryService.class))
.andReturn(controllerRegistryService).once();
expect(persistIntent.getKey()).andReturn(1L).anyTimes();
@@ -100,8 +100,8 @@
expect(modContext.getServiceImpl(IRestApiService.class))
.andReturn(restApi).once();
- expect(networkGraphService.getNetworkGraph()).andReturn(g).anyTimes();
- networkGraphService.registerNetworkGraphListener(anyObject(INetworkGraphListener.class));
+ expect(topologyService.getTopology()).andReturn(topology).anyTimes();
+ topologyService.registerTopologyListener(anyObject(ITopologyListener.class));
expectLastCall();
expect(datagridService.createChannel("onos.pathintent", Long.class, IntentOperationList.class))
@@ -116,7 +116,7 @@
restApi.addRestletRoutable(anyObject(IntentWebRoutable.class));
replay(datagridService);
- replay(networkGraphService);
+ replay(topologyService);
replay(modContext);
replay(controllerRegistryService);
PowerMock.replay(persistIntent, PersistIntent.class);
@@ -126,7 +126,7 @@
@After
public void tearDown() {
verify(datagridService);
- verify(networkGraphService);
+ verify(topologyService);
verify(modContext);
verify(controllerRegistryService);
PowerMock.verify(persistIntent, PersistIntent.class);
@@ -258,14 +258,14 @@
runtime1.getPathIntents().changeStates(states);
// link down
- ((MockNetworkGraph) g).removeLink(1L, 12L, 2L, 21L); // This link is used by the intent "1"
- ((MockNetworkGraph) g).removeLink(2L, 21L, 1L, 12L);
+ ((MockTopology) topology).removeLink(1L, 12L, 2L, 21L); // This link is used by the intent "1"
+ ((MockTopology) topology).removeLink(2L, 21L, 1L, 12L);
LinkEvent linkEvent1 = new LinkEvent(1L, 12L, 2L, 21L);
LinkEvent linkEvent2 = new LinkEvent(2L, 21L, 1L, 12L);
removedLinkEvents.clear();
removedLinkEvents.add(linkEvent1);
removedLinkEvents.add(linkEvent2);
- runtime1.networkGraphEvents(
+ runtime1.topologyEvents(
addedSwitchEvents,
removedSwitchEvents,
addedPortEvents,