weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.topology; |
| 2 | |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 3 | import static org.junit.Assert.*; |
| 4 | import static org.hamcrest.Matchers.*; |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 5 | |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 6 | import java.util.Collection; |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 7 | import java.util.Iterator; |
| 8 | |
| 9 | import net.floodlightcontroller.util.MACAddress; |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 10 | import net.onrc.onos.core.util.Dpid; |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 11 | import net.onrc.onos.core.util.LinkTuple; |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 12 | import net.onrc.onos.core.util.PortNumber; |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 13 | import net.onrc.onos.core.util.SwitchPort; |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 14 | |
| 15 | import org.junit.After; |
| 16 | import org.junit.Before; |
| 17 | import org.junit.Test; |
| 18 | |
| 19 | /** |
| 20 | * Unit tests for the TopologyImpl Class in the Topology module. |
| 21 | * These test cases check the sanity of getSwitch/removeSwitch, |
| 22 | * getLink/removeLink, getDevice/removeDevice, and getPort functions and |
| 23 | * verify the data objects inside the global graphDB through a injected network. |
| 24 | * The injected network has a ring topology with a large number of switches (configurable), and |
| 25 | * each switch is associated with one device and connected to two other switches. |
| 26 | */ |
| 27 | public class TopologyImplTest { |
| 28 | private TopologyImpl testTopology; |
| 29 | private static final Long SWITCH_HOST_PORT = 1L; |
| 30 | private static final Long SWITCH_PORT_1 = 2L; |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 31 | private static final PortNumber PORT_NUMBER_1 = new PortNumber(SWITCH_PORT_1.shortValue()); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 32 | private static final Long SWITCH_PORT_2 = 3L; |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 33 | private static final PortNumber PORT_NUMBER_2 = new PortNumber(SWITCH_PORT_2.shortValue()); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 34 | |
| 35 | // Set the test network size, it should be larger than 3 |
| 36 | private static final long TEST_SWITCH_NUM = 100L; |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 37 | private static final long TEST_HOST_NUM = TEST_SWITCH_NUM; |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 38 | |
| 39 | @Before |
| 40 | public void setUp() throws Exception { |
| 41 | // Create the injected network first |
| 42 | testTopology = new TopologyImpl(); |
| 43 | |
| 44 | // Create a number of switches and install two ports for each switch |
| 45 | for (long switchID = 1; switchID <= TEST_SWITCH_NUM; switchID++) { |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 46 | final Dpid dpid = new Dpid(switchID); |
| 47 | SwitchEvent testSwitch = new SwitchEvent(dpid); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 48 | testTopology.putSwitch(testSwitch); |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 49 | testTopology.putPort(new PortEvent(dpid, PORT_NUMBER_1)); |
| 50 | testTopology.putPort(new PortEvent(dpid, PORT_NUMBER_2)); |
| 51 | PortEvent hostPort = new PortEvent(dpid, |
| 52 | new PortNumber(SWITCH_HOST_PORT.shortValue())); |
Yuta HIGUCHI | e2a4e17 | 2014-07-03 10:50:39 -0700 | [diff] [blame] | 53 | testTopology.putPort(hostPort); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 54 | |
| 55 | // Create a host for each switch |
| 56 | MACAddress devMac = MACAddress.valueOf(switchID); |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 57 | HostEvent testHost = new HostEvent(devMac); |
| 58 | testHost.addAttachmentPoint(hostPort.getSwitchPort()); |
Yuta HIGUCHI | bfc77f0 | 2014-07-14 22:50:25 -0700 | [diff] [blame] | 59 | testTopology.putHost(testHost); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | // Create one bidirectional link b/w two switches to construct a ring topology |
| 63 | for (long switchID = 1; switchID <= TEST_SWITCH_NUM; switchID++) { |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 64 | final Dpid dpidA = new Dpid(switchID); |
| 65 | final Dpid dpidB = new Dpid(switchID % TEST_SWITCH_NUM + 1); |
| 66 | LinkEvent testLinkEast = new LinkEvent( |
Yuta HIGUCHI | cd14dda | 2014-07-24 09:57:22 -0700 | [diff] [blame^] | 67 | testTopology.getPort(dpidA, PORT_NUMBER_2).getSwitchPort(), |
| 68 | testTopology.getPort(dpidB, PORT_NUMBER_1).getSwitchPort() |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 69 | ); |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 70 | LinkEvent testLinkWest = new LinkEvent( |
Yuta HIGUCHI | cd14dda | 2014-07-24 09:57:22 -0700 | [diff] [blame^] | 71 | testTopology.getPort(dpidB, PORT_NUMBER_1).getSwitchPort(), |
| 72 | testTopology.getPort(dpidA, PORT_NUMBER_2).getSwitchPort() |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 73 | ); |
| 74 | testTopology.putLink(testLinkEast); |
| 75 | testTopology.putLink(testLinkWest); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | @After |
| 80 | public void tearDown() throws Exception { |
| 81 | |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Test the result of getSwitch function. |
| 86 | */ |
| 87 | @Test |
| 88 | public void testGetSwitch() { |
| 89 | // Verify the switch is in the graphDB |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 90 | assertNotNull(testTopology.getSwitch(new Dpid(TEST_SWITCH_NUM - 1))); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 91 | |
| 92 | // Verify there is no such switch in the graphDB |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 93 | assertNull(testTopology.getSwitch(new Dpid(TEST_SWITCH_NUM + 1))); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 94 | long index = 0; |
| 95 | Iterator<Switch> itr = testTopology.getSwitches().iterator(); |
| 96 | while (itr.hasNext()) { |
| 97 | index++; |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 98 | Dpid swID = itr.next().getDpid(); |
| 99 | assertThat(swID.value(), |
| 100 | is(both(greaterThanOrEqualTo(1L)) |
| 101 | .and(lessThanOrEqualTo(TEST_SWITCH_NUM)))); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | // Verify the total number of switches |
| 105 | assertEquals(TEST_SWITCH_NUM, index); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Test the result of getPort function. |
| 110 | */ |
| 111 | @Test |
| 112 | public void testGetPort() { |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 113 | PortNumber bogusPortNum = new PortNumber((short) (SWITCH_PORT_2 + 1)); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 114 | for (long switchID = 1; switchID <= TEST_SWITCH_NUM; switchID++) { |
| 115 | // Verify ports are in the graphDB |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 116 | final Dpid dpid = new Dpid(switchID); |
| 117 | assertNotNull(testTopology.getSwitch(dpid).getPort(PORT_NUMBER_1)); |
| 118 | assertNotNull(testTopology.getSwitch(dpid).getPort(PORT_NUMBER_2)); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 119 | |
| 120 | // Verify there is no such port in the graphDB |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 121 | assertNull(testTopology.getSwitch(dpid).getPort(bogusPortNum)); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 122 | } |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Test the result of getLink function. |
| 127 | */ |
| 128 | @Test |
| 129 | public void testGetLink() { |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 130 | Dpid sw1ID = new Dpid(1L); |
| 131 | Dpid sw3ID = new Dpid(3L); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 132 | |
| 133 | // Verify there is no such link b/w these two switches |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 134 | assertNull((testTopology.getSwitch(sw1ID)).getLinkToNeighbor(sw3ID)); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 135 | long index = 0; |
| 136 | Iterator<Link> itr = testTopology.getLinks().iterator(); |
| 137 | while (itr.hasNext()) { |
| 138 | index++; |
| 139 | Link objectLink = itr.next(); |
| 140 | Switch srcSw = (objectLink.getSrcSwitch()); |
| 141 | Switch dstSw = (objectLink.getDstSwitch()); |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 142 | |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 143 | LinkTuple linkId = objectLink.getLinkTuple(); |
| 144 | // Verify the link through #getLink |
| 145 | Link linkA = testTopology.getLink(linkId.getSrc().getDpid(), |
| 146 | linkId.getSrc().getPortNumber(), |
| 147 | linkId.getDst().getDpid(), |
| 148 | linkId.getDst().getPortNumber()); |
| 149 | assertEquals(linkId, linkA.getLinkTuple()); |
| 150 | |
| 151 | Link linkB = testTopology.getLink(linkId.getSrc().getDpid(), |
| 152 | linkId.getSrc().getPortNumber(), |
| 153 | linkId.getDst().getDpid(), |
| 154 | linkId.getDst().getPortNumber(), |
| 155 | TopologyElement.TYPE_PACKET_LAYER); |
| 156 | assertEquals(linkId, linkB.getLinkTuple()); |
| 157 | |
| 158 | |
| 159 | |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 160 | // confirm link is forming a link |
| 161 | final long smallerDpid = Math.min(srcSw.getDpid().value(), dstSw.getDpid().value()); |
| 162 | final long largerDpid = Math.max(srcSw.getDpid().value(), dstSw.getDpid().value()); |
| 163 | assertThat(largerDpid - smallerDpid, |
| 164 | is(either(equalTo(1L)).or(equalTo(TEST_SWITCH_NUM - 1)))); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | // Verify the total number of links |
| 168 | assertEquals(TEST_SWITCH_NUM * 2, index); |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * Test the result of getOutgoingLink function. |
| 173 | */ |
| 174 | @Test |
| 175 | public void testGetOutgoingLink() { |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 176 | PortNumber bogusPortNum = new PortNumber((short) (SWITCH_PORT_2 + 1)); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 177 | for (long switchID = 1; switchID <= TEST_SWITCH_NUM; switchID++) { |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 178 | final Dpid dpid = new Dpid(switchID); |
| 179 | assertNotNull(testTopology.getOutgoingLink(dpid, PORT_NUMBER_1)); |
| 180 | assertNotNull(testTopology.getOutgoingLink(dpid, PORT_NUMBER_2)); |
| 181 | |
| 182 | Link la = testTopology.getOutgoingLink(dpid, PORT_NUMBER_2, |
| 183 | TopologyElement.TYPE_PACKET_LAYER); |
| 184 | Link lb = testTopology.getOutgoingLink(dpid, PORT_NUMBER_2); |
| 185 | |
| 186 | assertTrue(la.getLinkTuple().equals(lb.getLinkTuple())); |
| 187 | |
| 188 | Collection<Link> links = testTopology.getOutgoingLinks( |
| 189 | new SwitchPort(dpid, PORT_NUMBER_1)); |
| 190 | assertEquals(1, links.size()); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 191 | |
| 192 | // Verify there is no such link in the graphDB |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 193 | assertNull(testTopology.getOutgoingLink(dpid, bogusPortNum)); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 194 | } |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * Test the result of getIncomingLink function. |
| 199 | */ |
| 200 | @Test |
| 201 | public void testGetIncomingLink() { |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 202 | PortNumber bogusPortNum = new PortNumber((short) (SWITCH_PORT_2 + 1)); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 203 | for (long switchID = 1; switchID <= TEST_SWITCH_NUM; switchID++) { |
| 204 | // Verify the links are in the graphDB |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 205 | final Dpid dpid = new Dpid(switchID); |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 206 | assertNotNull(testTopology.getIncomingLink( |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 207 | dpid, PORT_NUMBER_1)); |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 208 | assertNotNull(testTopology.getIncomingLink( |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 209 | dpid, PORT_NUMBER_2)); |
| 210 | |
| 211 | Link la = testTopology.getIncomingLink(dpid, PORT_NUMBER_2, |
| 212 | TopologyElement.TYPE_PACKET_LAYER); |
| 213 | Link lb = testTopology.getIncomingLink(dpid, PORT_NUMBER_2); |
| 214 | |
| 215 | assertTrue(la.getLinkTuple().equals(lb.getLinkTuple())); |
| 216 | |
| 217 | Collection<Link> links = testTopology.getIncomingLinks( |
| 218 | new SwitchPort(dpid, PORT_NUMBER_1)); |
| 219 | assertEquals(1, links.size()); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 220 | |
| 221 | // Verify there is no such link in the graphDB |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 222 | assertNull(testTopology.getIncomingLink( |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 223 | dpid, bogusPortNum)); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 224 | } |
| 225 | } |
| 226 | |
| 227 | /** |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 228 | * Test the result of getHostByMac function. |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 229 | */ |
| 230 | @Test |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 231 | public void testGetHostByMac() { |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 232 | for (long switchID = 1; switchID <= TEST_SWITCH_NUM; switchID++) { |
| 233 | MACAddress devMac = MACAddress.valueOf(switchID); |
| 234 | |
| 235 | // Verify the device is in the graphDB |
Yuta HIGUCHI | bfc77f0 | 2014-07-14 22:50:25 -0700 | [diff] [blame] | 236 | assertNotNull(testTopology.getHostByMac(devMac)); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 237 | } |
| 238 | } |
| 239 | |
| 240 | /** |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 241 | * Test the result of removeHost function. |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 242 | */ |
| 243 | @Test |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 244 | public void testRemoveHost() { |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 245 | int devCount = 0; |
Yuta HIGUCHI | bfc77f0 | 2014-07-14 22:50:25 -0700 | [diff] [blame] | 246 | Iterator<Host> itr = testTopology.getHosts().iterator(); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 247 | while (itr.hasNext()) { |
Yuta HIGUCHI | bfc77f0 | 2014-07-14 22:50:25 -0700 | [diff] [blame] | 248 | Host currDev = itr.next(); |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 249 | final MACAddress mac = currDev.getMacAddress(); |
| 250 | testTopology.removeHost(mac); |
| 251 | assertNull(testTopology.getHostByMac(mac)); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 252 | devCount++; |
| 253 | } |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 254 | for (Switch sw : testTopology.getSwitches()) { |
| 255 | for (Port port : sw.getPorts()) { |
| 256 | assertTrue(port.getHosts().isEmpty()); |
| 257 | } |
| 258 | } |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 259 | |
| 260 | // Verify all hosts have been removed successfully |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 261 | assertEquals(TEST_HOST_NUM, devCount); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | /** |
| 265 | * Test the result of removeLink function. |
| 266 | */ |
| 267 | @Test |
| 268 | public void testRemoveLink() { |
| 269 | long index = 0; |
| 270 | Iterator<Link> itr = testTopology.getLinks().iterator(); |
| 271 | while (itr.hasNext()) { |
| 272 | index++; |
| 273 | Link objectLink = itr.next(); |
| 274 | Switch srcSw = (objectLink.getSrcSwitch()); |
| 275 | Port srcPort = objectLink.getSrcPort(); |
| 276 | Switch dstSw = (objectLink.getDstSwitch()); |
| 277 | Port dstPort = objectLink.getDstPort(); |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 278 | |
| 279 | testTopology.removeLink(objectLink.getLinkTuple()); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 280 | |
| 281 | // Verify the link was removed successfully |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 282 | assertNull(testTopology.getLink( |
| 283 | srcSw.getDpid(), srcPort.getNumber(), |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 284 | dstSw.getDpid(), dstPort.getNumber())); |
| 285 | } |
| 286 | |
| 287 | // Verify all links have been removed successfully |
| 288 | assertEquals(TEST_SWITCH_NUM * 2, index); |
| 289 | } |
| 290 | |
| 291 | /** |
| 292 | * Test the result of removeSwitch function. |
| 293 | */ |
| 294 | @Test |
| 295 | public void testRemoveSwitch() { |
| 296 | for (long switchID = 1; switchID <= TEST_SWITCH_NUM; switchID++) { |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 297 | final Dpid dpid = new Dpid(switchID); |
| 298 | Iterator<Host> itr = testTopology.getSwitch(dpid).getHosts().iterator(); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 299 | while (itr.hasNext()) { |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 300 | testTopology.removeHost(itr.next().getMacAddress()); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 301 | } |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 302 | for (Port port : testTopology.getSwitch(dpid).getPorts()) { |
Yuta HIGUCHI | cd14dda | 2014-07-24 09:57:22 -0700 | [diff] [blame^] | 303 | testTopology.removePort(port.getSwitchPort()); |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 304 | } |
| 305 | testTopology.removeSwitch(dpid); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 306 | |
| 307 | // Verify the switch has been removed from the graphDB successfully |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 308 | assertNull(testTopology.getSwitch(dpid)); |
weibit | d503707 | 2014-06-13 10:07:01 -0700 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | // Verify all switches have been removed successfully |
| 312 | Iterator<Switch> itr = testTopology.getSwitches().iterator(); |
| 313 | assertFalse(itr.hasNext()); |
| 314 | } |
| 315 | } |