blob: ce647a4ab7fccefb465991b35f13022e60f4f9f0 [file] [log] [blame]
Jonathan Hart6df90172014-04-03 10:13:11 -07001package net.onrc.onos.core.datastore.topology;
Yuta HIGUCHI6a643132014-03-18 22:39:27 -07002
Jonathan Harta88fd242014-04-03 11:24:54 -07003import static org.hamcrest.Matchers.anyOf;
4import static org.hamcrest.Matchers.equalTo;
5import static org.hamcrest.Matchers.hasItem;
6import static org.hamcrest.Matchers.hasKey;
7import static org.hamcrest.Matchers.is;
8import static org.junit.Assert.assertArrayEquals;
9import static org.junit.Assert.assertEquals;
10import static org.junit.Assert.assertNotEquals;
11import static org.junit.Assert.assertThat;
12import static org.junit.Assert.fail;
Yuta HIGUCHI6a643132014-03-18 22:39:27 -070013
14import java.util.ArrayList;
15import java.util.Arrays;
16import java.util.HashMap;
17import java.util.List;
18import java.util.Map;
19import java.util.TreeMap;
20
Jonathan Hart6df90172014-04-03 10:13:11 -070021import net.onrc.onos.core.datastore.DataStoreClient;
22import net.onrc.onos.core.datastore.IKVClient;
23import net.onrc.onos.core.datastore.IKVTable;
24import net.onrc.onos.core.datastore.ObjectDoesntExistException;
25import net.onrc.onos.core.datastore.ObjectExistsException;
26import net.onrc.onos.core.datastore.WrongVersionException;
Jonathan Hart6df90172014-04-03 10:13:11 -070027import net.onrc.onos.core.datastore.utils.ByteArrayComparator;
28import net.onrc.onos.core.datastore.utils.KVObject;
29import net.onrc.onos.core.datastore.utils.KVObject.WriteOp;
Yuta HIGUCHI6a643132014-03-18 22:39:27 -070030
31import org.junit.After;
32import org.junit.Before;
33import org.junit.Test;
34
35public class KVTopologyTest {
36
Ray Milkey7531a342014-04-11 15:08:12 -070037 static final long VERSION_NONEXISTENT = DataStoreClient.getClient().getVersionNonexistant();
Yuta HIGUCHI6a643132014-03-18 22:39:27 -070038
Ray Milkey269ffb92014-04-03 14:43:30 -070039 private static final byte[] DEVICE2_MAC_SW2P2 = new byte[]{6, 5, 4, 3, 2, 1, 0};
Yuta HIGUCHI6a643132014-03-18 22:39:27 -070040
41 private static final Long SW2_PORTNO2 = 2L;
42
43 private static final Long SW2_PORTNO1 = 1L;
44
45 private static final Long DPID2 = 0x2L;
46
Ray Milkey269ffb92014-04-03 14:43:30 -070047 private static final byte[] DEVICE1_MAC_SW1P1 = new byte[]{0, 1, 2, 3, 4, 5, 6};
Yuta HIGUCHI6a643132014-03-18 22:39:27 -070048
49 private static final Long SW1_PORTNO2 = 2L;
50
51 private static final Long SW1_PORTNO1 = 1L;
52
53 private static final Long DPID1 = 0x1L;
54
55 @Before
56 @After
57 public void wipeTopology() throws Exception {
Ray Milkey269ffb92014-04-03 14:43:30 -070058 IKVTable switchTable = DataStoreClient.getClient().getTable(KVSwitch.GLOBAL_SWITCH_TABLE_NAME);
59 DataStoreClient.getClient().dropTable(switchTable);
Yuta HIGUCHI6a643132014-03-18 22:39:27 -070060
Ray Milkey269ffb92014-04-03 14:43:30 -070061 IKVTable portTable = DataStoreClient.getClient().getTable(KVPort.GLOBAL_PORT_TABLE_NAME);
62 DataStoreClient.getClient().dropTable(portTable);
Yuta HIGUCHI6a643132014-03-18 22:39:27 -070063
Ray Milkey269ffb92014-04-03 14:43:30 -070064 IKVTable linkTable = DataStoreClient.getClient().getTable(KVLink.GLOBAL_LINK_TABLE_NAME);
65 DataStoreClient.getClient().dropTable(linkTable);
Yuta HIGUCHI6a643132014-03-18 22:39:27 -070066
Ray Milkey269ffb92014-04-03 14:43:30 -070067 IKVTable deviceTable = DataStoreClient.getClient().getTable(KVDevice.GLOBAL_DEVICE_TABLE_NAME);
68 DataStoreClient.getClient().dropTable(deviceTable);
Yuta HIGUCHI6a643132014-03-18 22:39:27 -070069 }
70
71 @Test
72 public void basic_switch_test() {
Ray Milkey269ffb92014-04-03 14:43:30 -070073 // create switch 0x1
74 try {
75 KVSwitch sw = new KVSwitch(DPID1);
76 sw.setStatus(KVSwitch.STATUS.ACTIVE);
77 sw.create();
78 assertNotEquals(VERSION_NONEXISTENT, sw.getVersion());
79 assertEquals(DPID1, sw.getDpid());
80 assertEquals(KVSwitch.STATUS.ACTIVE, sw.getStatus());
81 } catch (ObjectExistsException e) {
82 e.printStackTrace();
83 fail("Create Switch Failed " + e);
84 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -070085
Ray Milkey269ffb92014-04-03 14:43:30 -070086 // read switch 0x1
87 KVSwitch swRead = new KVSwitch(DPID1);
88 try {
89 swRead.read();
90 assertNotEquals(VERSION_NONEXISTENT, swRead.getVersion());
91 assertEquals(DPID1, swRead.getDpid());
92 assertEquals(KVSwitch.STATUS.ACTIVE, swRead.getStatus());
93 } catch (ObjectDoesntExistException e) {
94 e.printStackTrace();
95 fail("Reading Switch Failed " + e);
96 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -070097
Ray Milkey269ffb92014-04-03 14:43:30 -070098 // and update 0x1
99 swRead.setStatus(KVSwitch.STATUS.INACTIVE);
100 try {
101 swRead.update();
102 assertNotEquals(VERSION_NONEXISTENT, swRead.getVersion());
103 assertEquals(DPID1, swRead.getDpid());
104 assertEquals(KVSwitch.STATUS.INACTIVE, swRead.getStatus());
105 } catch (ObjectDoesntExistException | WrongVersionException e) {
106 e.printStackTrace();
107 fail("Updating Switch Failed " + e);
108 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700109
Ray Milkey269ffb92014-04-03 14:43:30 -0700110 // read 0x1 again and delete
111 KVSwitch swRead2 = new KVSwitch(DPID1);
112 try {
113 swRead2.read();
114 assertNotEquals(VERSION_NONEXISTENT, swRead2.getVersion());
115 assertEquals(DPID1, swRead2.getDpid());
116 assertEquals(KVSwitch.STATUS.INACTIVE, swRead2.getStatus());
117 } catch (ObjectDoesntExistException e) {
118 e.printStackTrace();
119 fail("Reading Switch Again Failed " + e);
120 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700121
Ray Milkey269ffb92014-04-03 14:43:30 -0700122 try {
123 swRead2.delete();
124 assertNotEquals(VERSION_NONEXISTENT, swRead2.getVersion());
125 } catch (ObjectDoesntExistException | WrongVersionException e) {
126 e.printStackTrace();
127 fail("Deleting Switch Failed " + e);
128 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700129
Ray Milkey269ffb92014-04-03 14:43:30 -0700130 // make sure 0x1 is deleted
131 KVObject swRead3 = new KVSwitch(DPID1);
132 try {
133 swRead3.read();
134 fail(swRead3 + " was supposed to be deleted, but read succeed");
135 } catch (ObjectDoesntExistException e) {
136 System.out.println("-- " + swRead3 + " not found as expected--");
137 e.printStackTrace(System.out);
138 System.out.println("---------------------------------------");
139 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700140 }
141
142 @Test
143 public void topology_setup_and_tear_down() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700144 topology_setup();
145 topology_walk();
146 topology_delete();
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700147 }
148
149 private static void topology_setup() {
150
Ray Milkey269ffb92014-04-03 14:43:30 -0700151 // d1 - s1p1 - s1 - s1p2 - s2p1 - s2 - s2p2
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700152
Ray Milkey269ffb92014-04-03 14:43:30 -0700153 KVSwitch sw1 = new KVSwitch(DPID1);
154 sw1.setStatus(KVSwitch.STATUS.ACTIVE);
155 try {
156 sw1.create();
157 assertNotEquals(VERSION_NONEXISTENT, sw1.getVersion());
158 assertEquals(DPID1, sw1.getDpid());
159 assertEquals(KVSwitch.STATUS.ACTIVE, sw1.getStatus());
160 } catch (ObjectExistsException e) {
161 e.printStackTrace();
162 fail("Switch creation failed " + e);
163 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700164
Ray Milkey269ffb92014-04-03 14:43:30 -0700165 KVPort sw1p1 = new KVPort(DPID1, SW1_PORTNO1);
166 sw1p1.setStatus(KVPort.STATUS.ACTIVE);
167 KVPort sw1p2 = new KVPort(DPID1, SW1_PORTNO2);
168 sw1p2.setStatus(KVPort.STATUS.ACTIVE);
169 try {
170 sw1p1.create();
171 assertNotEquals(VERSION_NONEXISTENT, sw1p1.getVersion());
172 assertEquals(DPID1, sw1p1.getDpid());
173 assertEquals(SW1_PORTNO1, sw1p1.getNumber());
174 assertEquals(KVPort.STATUS.ACTIVE, sw1p1.getStatus());
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700175
Ray Milkey269ffb92014-04-03 14:43:30 -0700176 sw1p2.create();
177 assertNotEquals(VERSION_NONEXISTENT, sw1p2.getVersion());
178 assertEquals(DPID1, sw1p2.getDpid());
179 assertEquals(SW1_PORTNO2, sw1p2.getNumber());
180 assertEquals(KVPort.STATUS.ACTIVE, sw1p2.getStatus());
181 } catch (ObjectExistsException e) {
182 e.printStackTrace();
183 fail("Port creation failed " + e);
184 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700185
Ray Milkey269ffb92014-04-03 14:43:30 -0700186 try {
187 sw1.update();
188 assertNotEquals(VERSION_NONEXISTENT, sw1.getVersion());
189 assertEquals(DPID1, sw1.getDpid());
190 assertEquals(KVSwitch.STATUS.ACTIVE, sw1.getStatus());
191 } catch (ObjectDoesntExistException | WrongVersionException e) {
192 e.printStackTrace();
193 fail("Switch update failed " + e);
194 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700195
Ray Milkey269ffb92014-04-03 14:43:30 -0700196 KVDevice d1 = new KVDevice(DEVICE1_MAC_SW1P1);
197 d1.addPortId(sw1p1.getId());
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700198
Ray Milkey269ffb92014-04-03 14:43:30 -0700199 try {
200 d1.create();
201 assertNotEquals(VERSION_NONEXISTENT, d1.getVersion());
202 assertEquals(1, d1.getAllPortIds().size());
203 assertArrayEquals(sw1p1.getId(), d1.getAllPortIds().iterator().next());
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700204
Ray Milkey269ffb92014-04-03 14:43:30 -0700205 try {
206 sw1p1.update();
207 assertNotEquals(VERSION_NONEXISTENT, sw1p1.getVersion());
208 assertEquals(DPID1, sw1p1.getDpid());
209 assertEquals(SW1_PORTNO1, sw1p1.getNumber());
210 assertEquals(KVPort.STATUS.ACTIVE, sw1p1.getStatus());
211 } catch (ObjectDoesntExistException | WrongVersionException e) {
212 e.printStackTrace();
213 fail("Link update failed " + e);
214 }
215 } catch (ObjectExistsException e) {
216 e.printStackTrace();
217 fail("Device creation failed " + e);
218 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700219
Ray Milkey269ffb92014-04-03 14:43:30 -0700220 KVSwitch sw2 = new KVSwitch(DPID2);
221 sw2.setStatus(KVSwitch.STATUS.ACTIVE);
222 KVPort sw2p1 = new KVPort(DPID2, SW2_PORTNO1);
223 sw2p1.setStatus(KVPort.STATUS.ACTIVE);
224 KVPort sw2p2 = new KVPort(DPID2, SW2_PORTNO2);
225 sw2p2.setStatus(KVPort.STATUS.ACTIVE);
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700226
Ray Milkey269ffb92014-04-03 14:43:30 -0700227 KVDevice d2 = new KVDevice(DEVICE2_MAC_SW2P2);
228 d2.addPortId(sw2p2.getId());
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700229
Ray Milkey269ffb92014-04-03 14:43:30 -0700230 IKVClient client = DataStoreClient.getClient();
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700231
Ray Milkey269ffb92014-04-03 14:43:30 -0700232 List<WriteOp> groupOp = Arrays.asList(
233 sw2.createOp(client), sw2p1.createOp(client),
234 sw2p2.createOp(client), d2.createOp(client));
235 boolean failed = KVObject.multiWrite(groupOp);
236 if (failed) {
237 for (WriteOp op : groupOp) {
238 System.err.println(op);
239 }
240 fail("Some of Switch/Port/Device creation failed");
241 } else {
242 assertNotEquals(VERSION_NONEXISTENT, sw2.getVersion());
243 assertEquals(DPID2, sw2.getDpid());
244 assertEquals(KVSwitch.STATUS.ACTIVE, sw2.getStatus());
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700245
Ray Milkey269ffb92014-04-03 14:43:30 -0700246 assertNotEquals(VERSION_NONEXISTENT, sw2p1.getVersion());
247 assertEquals(DPID2, sw2p1.getDpid());
248 assertEquals(SW2_PORTNO1, sw2p1.getNumber());
249 assertEquals(KVPort.STATUS.ACTIVE, sw2p1.getStatus());
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700250
Ray Milkey269ffb92014-04-03 14:43:30 -0700251 assertNotEquals(VERSION_NONEXISTENT, sw2p2.getVersion());
252 assertEquals(DPID2, sw2p2.getDpid());
253 assertEquals(SW2_PORTNO2, sw2p2.getNumber());
254 assertEquals(KVPort.STATUS.ACTIVE, sw2p2.getStatus());
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700255
Ray Milkey269ffb92014-04-03 14:43:30 -0700256 assertNotEquals(VERSION_NONEXISTENT, d2.getVersion());
257 assertEquals(1, d2.getAllPortIds().size());
258 assertArrayEquals(sw2p2.getId(), d2.getAllPortIds().iterator().next());
259 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700260
Ray Milkey269ffb92014-04-03 14:43:30 -0700261 KVLink l1 = new KVLink(DPID1, SW1_PORTNO2, DPID2, SW2_PORTNO1);
262 l1.setStatus(KVLink.STATUS.ACTIVE);
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700263
Ray Milkey269ffb92014-04-03 14:43:30 -0700264 try {
265 l1.create();
266 assertNotEquals(VERSION_NONEXISTENT, l1.getVersion());
267 assertEquals(KVLink.STATUS.ACTIVE, l1.getStatus());
268 assertArrayEquals(sw1.getId(), l1.getSrc().getSwitchID());
269 assertArrayEquals(sw1p2.getId(), l1.getSrc().getPortID());
270 assertArrayEquals(sw2.getId(), l1.getDst().getSwitchID());
271 assertArrayEquals(sw2p1.getId(), l1.getDst().getPortID());
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700272
Ray Milkey269ffb92014-04-03 14:43:30 -0700273 try {
274 sw1p2.update();
275 assertNotEquals(VERSION_NONEXISTENT, sw1p2.getVersion());
276 assertEquals(DPID1, sw1p2.getDpid());
277 assertEquals(SW1_PORTNO2, sw1p2.getNumber());
278 assertEquals(KVPort.STATUS.ACTIVE, sw1p2.getStatus());
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700279
Ray Milkey269ffb92014-04-03 14:43:30 -0700280 sw2p1.update();
281 assertNotEquals(VERSION_NONEXISTENT, sw2p1.getVersion());
282 assertEquals(DPID2, sw2p1.getDpid());
283 assertEquals(SW2_PORTNO1, sw2p1.getNumber());
284 assertEquals(KVPort.STATUS.ACTIVE, sw2p1.getStatus());
285 } catch (ObjectDoesntExistException | WrongVersionException e) {
286 e.printStackTrace();
287 fail("Port update failed " + e);
288 }
289 } catch (ObjectExistsException e) {
290 e.printStackTrace();
291 fail("Link creation failed " + e);
292 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700293 }
294
295
296 private static void topology_walk() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700297 Iterable<KVSwitch> swIt = KVSwitch.getAllSwitches();
298 List<Long> switchesExpected = new ArrayList<>(Arrays.asList(DPID1, DPID2));
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700299
Ray Milkey269ffb92014-04-03 14:43:30 -0700300 System.out.println("Enumerating Switches start");
301 for (KVSwitch sw : swIt) {
302 System.out.println(sw + " @ " + sw.getVersion());
303 assertNotEquals(VERSION_NONEXISTENT, sw.getVersion());
304 assertEquals(KVSwitch.STATUS.ACTIVE, sw.getStatus());
305 assertThat(sw.getDpid(), is(anyOf(equalTo(DPID1), equalTo(DPID2))));
306 assertThat(switchesExpected, hasItem(sw.getDpid()));
307 switchesExpected.remove(sw.getDpid());
308 }
309 System.out.println("Enumerating Switches end");
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700310
Ray Milkey269ffb92014-04-03 14:43:30 -0700311 KVSwitch sw1 = new KVSwitch(DPID1);
312 try {
313 sw1.read();
314 assertNotEquals(VERSION_NONEXISTENT, sw1.getVersion());
315 assertEquals(DPID1, sw1.getDpid());
316 assertEquals(KVSwitch.STATUS.ACTIVE, sw1.getStatus());
317 } catch (ObjectDoesntExistException e) {
318 e.printStackTrace();
319 fail("Reading switch failed " + e);
320 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700321
Ray Milkey269ffb92014-04-03 14:43:30 -0700322 KVSwitch sw2 = new KVSwitch(DPID2);
323 if (KVObject.multiRead(Arrays.asList(sw2))) {
324 fail("Failed to read switch " + sw2);
325 } else {
326 assertNotEquals(VERSION_NONEXISTENT, sw2.getVersion());
327 assertEquals(DPID2, sw2.getDpid());
328 assertEquals(KVSwitch.STATUS.ACTIVE, sw2.getStatus());
329 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700330
331
Ray Milkey269ffb92014-04-03 14:43:30 -0700332 // DPID -> [port_no]
333 @SuppressWarnings("serial")
334 Map<Long, List<Long>> expectedPorts = new HashMap<Long, List<Long>>() {{
335 put(DPID1, new ArrayList<>(Arrays.asList(SW1_PORTNO1, SW1_PORTNO2)));
336 put(DPID2, new ArrayList<>(Arrays.asList(SW2_PORTNO1, SW2_PORTNO2)));
337 }};
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700338
Ray Milkey269ffb92014-04-03 14:43:30 -0700339 for (KVPort port : KVPort.getAllPorts()) {
340 System.out.println(port + " @ " + port.getVersion());
341 assertNotEquals(VERSION_NONEXISTENT, port.getVersion());
342 assertEquals(KVPort.STATUS.ACTIVE, port.getStatus());
343 assertThat(port.getDpid(), is(anyOf(equalTo(DPID1), equalTo(DPID2))));
344 assertThat(port.getNumber(), is(anyOf(equalTo(SW1_PORTNO1), equalTo(SW1_PORTNO2))));
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700345
Ray Milkey269ffb92014-04-03 14:43:30 -0700346 assertThat(expectedPorts, hasKey(port.getDpid()));
347 assertThat(expectedPorts.get(port.getDpid()), hasItem(port.getNumber()));
348 expectedPorts.get(port.getDpid()).remove(port.getNumber());
349 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700350
Ray Milkey269ffb92014-04-03 14:43:30 -0700351 // DeviceID -> PortID
352 @SuppressWarnings("serial")
353 Map<byte[], byte[]> expectedDevice = new TreeMap<byte[], byte[]>(ByteArrayComparator.BYTEARRAY_COMPARATOR) {{
354 put(DEVICE1_MAC_SW1P1, KVPort.getPortID(DPID1, SW1_PORTNO1));
355 put(DEVICE2_MAC_SW2P2, KVPort.getPortID(DPID2, SW2_PORTNO2));
356 }};
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700357
Ray Milkey269ffb92014-04-03 14:43:30 -0700358 for (KVDevice device : KVDevice.getAllDevices()) {
359 System.out.println(device + " @ " + device.getVersion());
360 assertNotEquals(VERSION_NONEXISTENT, device.getVersion());
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700361
Ray Milkey269ffb92014-04-03 14:43:30 -0700362 assertThat(expectedDevice, hasKey(device.getMac()));
363 assertThat(device.getAllPortIds(), hasItem(expectedDevice.get(device.getMac())));
364 expectedDevice.remove(device.getMac());
365 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700366
Ray Milkey269ffb92014-04-03 14:43:30 -0700367 for (KVLink link : KVLink.getAllLinks()) {
368 System.out.println(link + " @ " + link.getVersion());
369 assertNotEquals(VERSION_NONEXISTENT, link.getVersion());
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700370
Ray Milkey269ffb92014-04-03 14:43:30 -0700371 // there is currently only 1 link SW1P2->SW2P1
372 assertEquals(DPID1, link.getSrc().dpid);
373 assertEquals(SW1_PORTNO2, link.getSrc().number);
374 assertEquals(DPID2, link.getDst().dpid);
375 assertEquals(SW2_PORTNO1, link.getDst().number);
376 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700377
378 }
379
380
381 private static void topology_delete() {
382
Ray Milkey269ffb92014-04-03 14:43:30 -0700383 for (KVSwitch sw : KVSwitch.getAllSwitches()) {
384 try {
385 sw.read();
386 sw.delete();
387 assertNotEquals(VERSION_NONEXISTENT, sw.getVersion());
388 } catch (ObjectDoesntExistException | WrongVersionException e) {
389 e.printStackTrace();
390 fail("Delete Switch Failed " + e);
391 }
392 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700393
Ray Milkey269ffb92014-04-03 14:43:30 -0700394 for (KVPort p : KVPort.getAllPorts()) {
395 try {
396 p.read();
397 p.delete();
398 assertNotEquals(VERSION_NONEXISTENT, p.getVersion());
399 } catch (ObjectDoesntExistException | WrongVersionException e) {
400 e.printStackTrace();
401 fail("Delete Port Failed " + e);
402 }
403 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700404
Ray Milkey269ffb92014-04-03 14:43:30 -0700405 for (KVDevice d : KVDevice.getAllDevices()) {
406 d.forceDelete();
407 assertNotEquals(VERSION_NONEXISTENT, d.getVersion());
408 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700409
Ray Milkey269ffb92014-04-03 14:43:30 -0700410 for (KVLink l : KVLink.getAllLinks()) {
411 try {
412 l.read();
413 l.delete();
414 assertNotEquals(VERSION_NONEXISTENT, l.getVersion());
415 } catch (ObjectDoesntExistException | WrongVersionException e) {
416 e.printStackTrace();
417 fail("Delete Link Failed " + e);
418 }
419 }
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700420 }
421
422 public static void main(final String[] argv) {
423
Ray Milkey269ffb92014-04-03 14:43:30 -0700424 topology_setup();
425 topology_walk();
426 topology_delete();
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700427
Ray Milkey269ffb92014-04-03 14:43:30 -0700428 System.exit(0);
Yuta HIGUCHI6a643132014-03-18 22:39:27 -0700429 }
430
431}