Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.linkdiscovery.internal; |
| 2 | |
Jonathan Hart | d1c5a1c | 2013-01-23 00:56:14 -0800 | [diff] [blame] | 3 | import static org.junit.Assert.assertEquals; |
| 4 | import static org.junit.Assert.assertFalse; |
| 5 | import static org.junit.Assert.assertTrue; |
| 6 | |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 7 | import java.util.ArrayList; |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 8 | import java.util.Iterator; |
Jonathan Hart | c86a2ea | 2013-01-15 22:39:42 -0800 | [diff] [blame] | 9 | import java.util.List; |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 10 | |
Jonathan Hart | 627f10c | 2013-01-16 14:20:03 -0800 | [diff] [blame] | 11 | import net.floodlightcontroller.core.internal.TestDatabaseManager; |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 12 | import net.floodlightcontroller.linkdiscovery.LinkInfo; |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 13 | import net.floodlightcontroller.routing.Link; |
HIGUCHI Yuta | 2051490 | 2013-06-12 11:24:16 -0700 | [diff] [blame] | 14 | import net.onrc.onos.ofcontroller.core.INetMapStorage.DM_OPERATION; |
HIGUCHI Yuta | 80c3ab8 | 2013-06-12 13:17:05 -0700 | [diff] [blame] | 15 | import net.onrc.onos.ofcontroller.linkdiscovery.ILinkStorage; |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 16 | |
mininet | 37dc589 | 2013-06-04 10:58:44 -0700 | [diff] [blame] | 17 | import org.easymock.EasyMock; |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 18 | import org.junit.After; |
| 19 | import org.junit.Before; |
Jonathan Hart | d1c5a1c | 2013-01-23 00:56:14 -0800 | [diff] [blame] | 20 | import org.junit.Ignore; |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 21 | import org.junit.Test; |
mininet | 37dc589 | 2013-06-04 10:58:44 -0700 | [diff] [blame] | 22 | import org.junit.runner.RunWith; |
Naoki Shiota | cae568a | 2013-06-05 17:53:41 -0700 | [diff] [blame] | 23 | import org.openflow.protocol.OFPhysicalPort; |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 24 | import org.openflow.util.HexString; |
mininet | 37dc589 | 2013-06-04 10:58:44 -0700 | [diff] [blame] | 25 | import org.powermock.api.easymock.PowerMock; |
| 26 | import org.powermock.core.classloader.annotations.PrepareForTest; |
| 27 | import org.powermock.modules.junit4.PowerMockRunner; |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 28 | |
mininet | 37dc589 | 2013-06-04 10:58:44 -0700 | [diff] [blame] | 29 | import com.thinkaurelius.titan.core.TitanFactory; |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 30 | import com.thinkaurelius.titan.core.TitanGraph; |
Naoki Shiota | cae568a | 2013-06-05 17:53:41 -0700 | [diff] [blame] | 31 | import com.tinkerpop.blueprints.Direction; |
| 32 | import com.tinkerpop.blueprints.Edge; |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 33 | import com.tinkerpop.blueprints.Vertex; |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 34 | import com.tinkerpop.gremlin.java.GremlinPipeline; |
Naoki Shiota | cae568a | 2013-06-05 17:53:41 -0700 | [diff] [blame] | 35 | import com.tinkerpop.pipes.PipeFunction; |
| 36 | import com.tinkerpop.pipes.transform.PathPipe; |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 37 | |
mininet | 37dc589 | 2013-06-04 10:58:44 -0700 | [diff] [blame] | 38 | @RunWith(PowerMockRunner.class) |
| 39 | @PrepareForTest({TitanFactory.class}) |
Jonathan Hart | d1c5a1c | 2013-01-23 00:56:14 -0800 | [diff] [blame] | 40 | public class LinkStorageImplTest { |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 41 | private static ILinkStorage linkStorage; |
| 42 | private static TitanGraph titanGraph; |
| 43 | |
mininet | 37dc589 | 2013-06-04 10:58:44 -0700 | [diff] [blame] | 44 | //private static IController |
| 45 | |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 46 | /** |
| 47 | * Setup code called before each tests. |
| 48 | * Read test graph data and replace DB access by test graph data. |
| 49 | * @throws Exception |
| 50 | */ |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 51 | @Before |
Jonathan Hart | 627f10c | 2013-01-16 14:20:03 -0800 | [diff] [blame] | 52 | public void setUp() throws Exception{ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 53 | TestDatabaseManager.deleteTestDatabase(); |
| 54 | |
Jonathan Hart | 627f10c | 2013-01-16 14:20:03 -0800 | [diff] [blame] | 55 | titanGraph = TestDatabaseManager.getTestDatabase(); |
| 56 | TestDatabaseManager.populateTestData(titanGraph); |
mininet | 37dc589 | 2013-06-04 10:58:44 -0700 | [diff] [blame] | 57 | |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 58 | // replace return value of TitanFactory.open() to dummy DB created above |
mininet | 37dc589 | 2013-06-04 10:58:44 -0700 | [diff] [blame] | 59 | PowerMock.mockStatic(TitanFactory.class); |
| 60 | EasyMock.expect(TitanFactory.open((String)EasyMock.anyObject())).andReturn(titanGraph); |
| 61 | PowerMock.replay(TitanFactory.class); |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 62 | |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 63 | linkStorage = new LinkStorageImpl(); |
| 64 | |
| 65 | // initialize with dummy string |
mininet | 37dc589 | 2013-06-04 10:58:44 -0700 | [diff] [blame] | 66 | linkStorage.init("/dummy/path/to/db"); |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 67 | } |
| 68 | |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 69 | /** |
| 70 | * Closing code called after each tests. |
| 71 | * Discard test graph data. |
| 72 | * @throws Exception |
| 73 | */ |
Jonathan Hart | d1c5a1c | 2013-01-23 00:56:14 -0800 | [diff] [blame] | 74 | @After |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 75 | public void tearDown() throws Exception { |
| 76 | // finish code |
| 77 | linkStorage.close(); |
| 78 | |
Jonathan Hart | d1c5a1c | 2013-01-23 00:56:14 -0800 | [diff] [blame] | 79 | titanGraph.shutdown(); |
mininet | 37dc589 | 2013-06-04 10:58:44 -0700 | [diff] [blame] | 80 | TestDatabaseManager.deleteTestDatabase(); |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 81 | } |
| 82 | |
Naoki Shiota | cae568a | 2013-06-05 17:53:41 -0700 | [diff] [blame] | 83 | // TODO: remove @Ignore after UPDATE method is implemented |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 84 | /** |
| 85 | * Test if update() can correctly updates LinkInfo for a Link. |
| 86 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 87 | @Ignore @Test |
| 88 | public void testUpdate_UpdateSingleLink() { |
| 89 | Link linkToUpdate= createExistingLink(); |
Naoki Shiota | cae568a | 2013-06-05 17:53:41 -0700 | [diff] [blame] | 90 | long currentTime = System.currentTimeMillis(); |
| 91 | LinkInfo infoToUpdate = createFeasibleLinkInfo(currentTime); |
| 92 | LinkInfo infoToVerify = createFeasibleLinkInfo(currentTime); |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 93 | |
| 94 | linkStorage.update(linkToUpdate, infoToUpdate, ILinkStorage.DM_OPERATION.UPDATE); |
| 95 | |
Naoki Shiota | cae568a | 2013-06-05 17:53:41 -0700 | [diff] [blame] | 96 | doTestLinkHasStateOf(linkToUpdate, infoToVerify); |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 97 | } |
| 98 | |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 99 | /** |
| 100 | * Test if update() can correctly creates a Link. |
| 101 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 102 | @Test |
| 103 | public void testUpdate_CreateSingleLink() { |
| 104 | Link linkToCreate = createFeasibleLink(); |
| 105 | Link linkToVerify = createFeasibleLink(); |
| 106 | |
| 107 | //Use the link storage API to add the link |
| 108 | linkStorage.update(linkToCreate, ILinkStorage.DM_OPERATION.CREATE); |
| 109 | doTestLinkIsInGraph(linkToVerify); |
| 110 | |
| 111 | // Add same link |
| 112 | Link linkToCreateTwice = createFeasibleLink(); |
| 113 | linkStorage.update(linkToCreateTwice, ILinkStorage.DM_OPERATION.CREATE); |
| 114 | |
| 115 | // this occurs assertion failure if there are two links in titanGraph |
| 116 | doTestLinkIsInGraph(linkToVerify); |
| 117 | } |
| 118 | |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 119 | /** |
| 120 | * Test if update() can correctly inserts a Link. |
| 121 | */ |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 122 | @Test |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 123 | public void testUpdate_InsertSingleLink(){ |
| 124 | Link linkToInsert = createFeasibleLink(); |
| 125 | Link linkToVerify = createFeasibleLink(); |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 126 | |
| 127 | //Use the link storage API to add the link |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 128 | linkStorage.update(linkToInsert, ILinkStorage.DM_OPERATION.INSERT); |
| 129 | |
| 130 | doTestLinkIsInGraph(linkToVerify); |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 131 | |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 132 | // Add same link |
| 133 | Link linkToInsertTwice = createFeasibleLink(); |
| 134 | linkStorage.update(linkToInsertTwice, ILinkStorage.DM_OPERATION.INSERT); |
| 135 | |
| 136 | // this occurs assertion failure if there are two links in titanGraph |
| 137 | doTestLinkIsInGraph(linkToVerify); |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 138 | } |
| 139 | |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 140 | /** |
| 141 | * Test if update() can correctly deletes a Link. |
| 142 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 143 | @Test |
| 144 | public void testUpdate_DeleteSingleLink(){ |
| 145 | Link linkToDelete = createExistingLink(); |
| 146 | Link linkToVerify = createExistingLink(); |
| 147 | |
| 148 | // Test deletion of existing link |
| 149 | linkStorage.update(linkToDelete, DM_OPERATION.DELETE); |
| 150 | doTestLinkIsNotInGraph(linkToVerify); |
| 151 | |
| 152 | linkToDelete = createFeasibleLink(); |
| 153 | linkToVerify = createFeasibleLink(); |
| 154 | |
| 155 | // Test deletion of not-existing link |
| 156 | linkStorage.update(linkToDelete, DM_OPERATION.DELETE); |
| 157 | doTestLinkIsNotInGraph(linkToVerify); |
| 158 | } |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 159 | |
| 160 | /** |
| 161 | * Test if update() can correctly creates multiple Links. |
| 162 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 163 | @Test |
| 164 | public void testUpdate_CreateLinks(){ |
| 165 | List<Link> linksToCreate = createFeasibleLinks(); |
| 166 | List<Link> linksToVerify = createFeasibleLinks(); |
| 167 | |
| 168 | // Test creation of new links |
| 169 | linkStorage.update(linksToCreate, ILinkStorage.DM_OPERATION.CREATE); |
| 170 | for(Link l : linksToVerify) { |
| 171 | doTestLinkIsInGraph(l); |
| 172 | } |
| 173 | |
| 174 | // Test creation of existing links |
| 175 | linksToCreate = createFeasibleLinks(); |
| 176 | linkStorage.update(linksToCreate, ILinkStorage.DM_OPERATION.CREATE); |
| 177 | for(Link l : linksToVerify) { |
| 178 | doTestLinkIsInGraph(l); |
| 179 | } |
| 180 | } |
| 181 | |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 182 | /** |
| 183 | * Test if update() can handle mixture of normal/abnormal input for creation of Links. |
| 184 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 185 | @Test |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 186 | public void testUpdate_CreateLinks_Mixuture(){ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 187 | List<Link> linksToCreate = new ArrayList<Link>(); |
| 188 | linksToCreate.add(createFeasibleLink()); |
| 189 | linksToCreate.add(createExistingLink()); |
| 190 | |
| 191 | // Test creation of mixture of new/existing links |
| 192 | linkStorage.update(linksToCreate, ILinkStorage.DM_OPERATION.CREATE); |
| 193 | doTestLinkIsInGraph(createFeasibleLink()); |
| 194 | doTestLinkIsInGraph(createExistingLink()); |
| 195 | } |
| 196 | |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 197 | /** |
| 198 | * Test if update() can correctly inserts multiple Links. |
| 199 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 200 | @Test |
| 201 | public void testUpdate_InsertLinks(){ |
| 202 | List<Link> linksToInsert = createFeasibleLinks(); |
| 203 | List<Link> linksToVerify = createFeasibleLinks(); |
| 204 | |
| 205 | // Test insertion of new links |
| 206 | linkStorage.update(linksToInsert, ILinkStorage.DM_OPERATION.INSERT); |
| 207 | for(Link l : linksToVerify) { |
| 208 | doTestLinkIsInGraph(l); |
| 209 | } |
| 210 | |
| 211 | // Test insertion of existing links |
| 212 | linksToInsert = createFeasibleLinks(); |
| 213 | linkStorage.update(linksToInsert, ILinkStorage.DM_OPERATION.INSERT); |
| 214 | for(Link l : linksToVerify) { |
| 215 | doTestLinkIsInGraph(l); |
| 216 | } |
| 217 | } |
| 218 | |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 219 | /** |
| 220 | * Test if update() can handle mixture of normal/abnormal input for creation of Links. |
| 221 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 222 | @Test |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 223 | public void testUpdate_InsertLinks_Mixuture(){ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 224 | List<Link> linksToInsert = new ArrayList<Link>(); |
| 225 | linksToInsert.add(createFeasibleLink()); |
| 226 | linksToInsert.add(createExistingLink()); |
| 227 | |
| 228 | // Test insertion of mixture of new/existing links |
| 229 | linkStorage.update(linksToInsert, ILinkStorage.DM_OPERATION.INSERT); |
| 230 | doTestLinkIsInGraph(createFeasibleLink()); |
| 231 | doTestLinkIsInGraph(createExistingLink()); |
| 232 | } |
| 233 | |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 234 | /** |
| 235 | * Test if update() can correctly deletes multiple Links. |
| 236 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 237 | @Test |
| 238 | public void testUpdate_DeleteLinks(){ |
| 239 | List<Link> linksToDelete = createExistingLinks(); |
| 240 | List<Link> linksToVerify = createExistingLinks(); |
| 241 | |
| 242 | // Test deletion of existing links |
| 243 | linkStorage.update(linksToDelete, ILinkStorage.DM_OPERATION.DELETE); |
| 244 | for(Link l : linksToVerify) { |
| 245 | doTestLinkIsNotInGraph(l); |
| 246 | } |
| 247 | |
| 248 | // Test deletion of not-existing links |
| 249 | linksToDelete = createExistingLinks(); |
| 250 | linkStorage.update(linksToDelete, ILinkStorage.DM_OPERATION.DELETE); |
| 251 | for(Link l : linksToVerify) { |
| 252 | doTestLinkIsNotInGraph(l); |
| 253 | } |
| 254 | } |
| 255 | |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 256 | /** |
| 257 | * Test if update() can handle mixture of normal/abnormal input for deletion of Links. |
| 258 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 259 | @Test |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 260 | public void testUpdate_DeleteLinks_Mixuture(){ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 261 | List<Link> linksToDelete = new ArrayList<Link>(); |
| 262 | linksToDelete.add(createFeasibleLink()); |
| 263 | linksToDelete.add(createExistingLink()); |
| 264 | |
| 265 | // Test deletion of mixture of new/existing links |
| 266 | linkStorage.update(linksToDelete, ILinkStorage.DM_OPERATION.DELETE); |
| 267 | doTestLinkIsNotInGraph(createFeasibleLink()); |
| 268 | doTestLinkIsNotInGraph(createExistingLink()); |
| 269 | } |
| 270 | |
Naoki Shiota | cae568a | 2013-06-05 17:53:41 -0700 | [diff] [blame] | 271 | // TODO: remove @Ignore after UPDATE method is implemented |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 272 | /** |
| 273 | * Test if updateLink() can correctly updates LinkInfo for a Link. |
| 274 | */ |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 275 | @Ignore @Test |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 276 | public void testUpdateLink_Update() { |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 277 | Link linkToUpdate= createExistingLink(); |
Naoki Shiota | cae568a | 2013-06-05 17:53:41 -0700 | [diff] [blame] | 278 | long currentTime = System.currentTimeMillis(); |
| 279 | LinkInfo infoToUpdate = createFeasibleLinkInfo(currentTime); |
| 280 | LinkInfo infoToVerify = createFeasibleLinkInfo(currentTime); |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 281 | |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 282 | linkStorage.updateLink(linkToUpdate, infoToUpdate, ILinkStorage.DM_OPERATION.UPDATE); |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 283 | |
Naoki Shiota | cae568a | 2013-06-05 17:53:41 -0700 | [diff] [blame] | 284 | doTestLinkHasStateOf(linkToUpdate, infoToVerify); |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 285 | } |
| 286 | |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 287 | /** |
| 288 | * Test if updateLink() can correctly creates a Link. |
| 289 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 290 | @Test |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 291 | public void testUpdateLink_Create() { |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 292 | Link linkToCreate = createFeasibleLink(); |
| 293 | Link linkToVerify = createFeasibleLink(); |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 294 | |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 295 | //Use the link storage API to add the link |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 296 | linkStorage.updateLink(linkToCreate, null, ILinkStorage.DM_OPERATION.CREATE); |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 297 | doTestLinkIsInGraph(linkToVerify); |
| 298 | |
| 299 | // Add same link |
| 300 | Link linkToCreateTwice = createFeasibleLink(); |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 301 | linkStorage.updateLink(linkToCreateTwice, null, ILinkStorage.DM_OPERATION.CREATE); |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 302 | |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 303 | // this occurs assertion failure if there are two links in titanGraph |
| 304 | doTestLinkIsInGraph(linkToVerify); |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 305 | } |
| 306 | |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 307 | /** |
| 308 | * Test if updateLink() can correctly inserts a Link. |
| 309 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 310 | @Test |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 311 | public void testUpdateLink_Insert() { |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 312 | Link linkToInsert = createFeasibleLink(); |
| 313 | Link linkToVerify = createFeasibleLink(); |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 314 | |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 315 | //Use the link storage API to add the link |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 316 | linkStorage.updateLink(linkToInsert, null, ILinkStorage.DM_OPERATION.INSERT); |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 317 | |
| 318 | doTestLinkIsInGraph(linkToVerify); |
| 319 | |
| 320 | // Add same link |
| 321 | Link linkToInsertTwice = createFeasibleLink(); |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 322 | linkStorage.updateLink(linkToInsertTwice, null, ILinkStorage.DM_OPERATION.INSERT); |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 323 | |
| 324 | // this occurs assertion failure if there are two links in titanGraph |
| 325 | doTestLinkIsInGraph(linkToVerify); |
| 326 | } |
| 327 | |
| 328 | // TODO: Check if addOrUpdateLink() should accept DELETE operation. If not, remove this test. |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 329 | /** |
| 330 | * Test if updateLink() can correctly deletes a Link. |
| 331 | */ |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 332 | @Ignore @Test |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 333 | public void testUpdateLink_Delete() { |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 334 | Link linkToDelete = createExistingLink(); |
| 335 | Link linkToVerify = createExistingLink(); |
| 336 | |
| 337 | // Test deletion of existing link |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 338 | linkStorage.updateLink(linkToDelete, null, DM_OPERATION.DELETE); |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 339 | doTestLinkIsNotInGraph(linkToVerify); |
| 340 | |
| 341 | linkToDelete = createFeasibleLink(); |
| 342 | linkToVerify = createFeasibleLink(); |
| 343 | |
| 344 | // Test deletion of not-existing link |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 345 | linkStorage.updateLink(linkToDelete, null, DM_OPERATION.DELETE); |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 346 | doTestLinkIsNotInGraph(linkToVerify); |
| 347 | } |
| 348 | |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 349 | /** |
| 350 | * Test if getLinks() can correctly return Links connected to specific DPID and port. |
| 351 | */ |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 352 | @Test |
| 353 | public void testGetLinks_ByDpidPort(){ |
| 354 | Link linkToVerify = createExistingLink(); |
| 355 | Long dpid = linkToVerify.getSrc(); |
| 356 | short port = (short)linkToVerify.getSrcPort(); |
| 357 | |
| 358 | List<Link> list = linkStorage.getLinks(dpid, port); |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 359 | |
Jonathan Hart | c86a2ea | 2013-01-15 22:39:42 -0800 | [diff] [blame] | 360 | assertEquals(list.size(), 1); |
| 361 | |
| 362 | Link l = list.get(0); |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 363 | assertEquals(l.getSrc(), linkToVerify.getSrc()); |
| 364 | assertEquals(l.getSrcPort(), linkToVerify.getSrcPort()); |
| 365 | assertEquals(l.getDst(), linkToVerify.getDst()); |
| 366 | assertEquals(l.getDstPort(), linkToVerify.getDstPort()); |
| 367 | |
| 368 | Link linkToVerifyNot = createFeasibleLink(); |
| 369 | |
| 370 | List<Link> list2 = linkStorage.getLinks(linkToVerifyNot.getSrc(), (short)linkToVerifyNot.getSrcPort()); |
| 371 | |
| 372 | assertEquals(list2.size(), 0); |
Jonathan Hart | c86a2ea | 2013-01-15 22:39:42 -0800 | [diff] [blame] | 373 | } |
| 374 | |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 375 | /** |
| 376 | * Test if getLinks() can correctly return Links connected to specific MAC address. |
| 377 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 378 | @Test |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 379 | public void testGetLinks_ByString() { |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 380 | Link linkToVeryfy = createExistingLink(); |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 381 | String dpid = HexString.toHexString(linkToVeryfy.getSrc()); |
Jonathan Hart | c86a2ea | 2013-01-15 22:39:42 -0800 | [diff] [blame] | 382 | |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 383 | List<Link> links = linkStorage.getLinks(dpid); |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 384 | assertTrue(links.contains(linkToVeryfy)); |
| 385 | |
| 386 | Link linkToVerifyNot = createFeasibleLink(); |
| 387 | assertFalse(links.contains(linkToVerifyNot)); |
Jonathan Hart | c86a2ea | 2013-01-15 22:39:42 -0800 | [diff] [blame] | 388 | } |
| 389 | |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 390 | /** |
| 391 | * Test if deleteLink() can correctly delete a Link. |
| 392 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 393 | @Test |
| 394 | public void testDeleteLink() { |
| 395 | // Deletion of existing link |
| 396 | Link linkToDelete = createExistingLink(); |
| 397 | Link linkToVerify = createExistingLink(); |
| 398 | |
| 399 | linkStorage.deleteLink(linkToDelete); |
| 400 | doTestLinkIsNotInGraph(linkToVerify); |
| 401 | |
| 402 | // Deletion of not existing link |
| 403 | linkToDelete = createFeasibleLink(); |
| 404 | linkToVerify = createFeasibleLink(); |
| 405 | |
| 406 | linkStorage.deleteLink(linkToDelete); |
| 407 | doTestLinkIsNotInGraph(linkToVerify); |
| 408 | } |
| 409 | |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 410 | /** |
| 411 | * Test if deleteLinks() can correctly delete Links. |
| 412 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 413 | @Test |
Jonathan Hart | c86a2ea | 2013-01-15 22:39:42 -0800 | [diff] [blame] | 414 | public void testDeleteLinks(){ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 415 | List<Link> linksToDelete = createExistingLinks(); |
| 416 | List<Link> linksToVerify = createExistingLinks(); |
Jonathan Hart | c86a2ea | 2013-01-15 22:39:42 -0800 | [diff] [blame] | 417 | |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 418 | linkStorage.deleteLinks(linksToDelete); |
| 419 | for(Link l : linksToVerify) { |
| 420 | doTestLinkIsNotInGraph(l); |
| 421 | } |
| 422 | } |
| 423 | |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 424 | /** |
| 425 | * Test if deleteLinks() can handle mixture of normal/abnormal input. |
| 426 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 427 | @Test |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 428 | public void testDeleteLinks_Mixture(){ |
| 429 | List<Link> linksToDelete = new ArrayList<Link>(); |
| 430 | linksToDelete.add(createFeasibleLink()); |
| 431 | linksToDelete.add(createExistingLink()); |
| 432 | |
| 433 | // Test deletion of mixture of new/existing links |
| 434 | linkStorage.deleteLinks(linksToDelete); |
| 435 | doTestLinkIsNotInGraph(createFeasibleLink()); |
| 436 | doTestLinkIsNotInGraph(createExistingLink()); |
| 437 | } |
| 438 | |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 439 | /** |
| 440 | * Test if getActiveLinks() can correctly return active Links. |
| 441 | */ |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 442 | @Test |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 443 | public void testGetActiveLinks() { |
| 444 | Link existingLink = createExistingLink(); |
| 445 | Link notExistingLink = createFeasibleLink(); |
| 446 | |
| 447 | List<Link> links = linkStorage.getActiveLinks(); |
Jonathan Hart | c86a2ea | 2013-01-15 22:39:42 -0800 | [diff] [blame] | 448 | |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 449 | assertTrue(links.contains(existingLink)); |
| 450 | assertFalse(links.contains(notExistingLink)); |
| 451 | } |
| 452 | |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 453 | /** |
| 454 | * Test if deleteLinksOnPort() can delete Links. |
| 455 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 456 | @Test |
| 457 | public void testDeleteLinksOnPort() { |
| 458 | Link linkToDelete = createExistingLink(); |
| 459 | Link linkToVerify = createExistingLink(); |
| 460 | |
| 461 | linkStorage.deleteLinksOnPort(linkToDelete.getSrc(), linkToDelete.getSrcPort()); |
| 462 | |
| 463 | doTestLinkIsNotInGraph(linkToVerify); |
| 464 | } |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 465 | |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 466 | /** |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 467 | * Test if titanGraph has specific link |
| 468 | * @param link |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 469 | */ |
| 470 | private void doTestLinkIsInGraph(Link link) { |
| 471 | String src_dpid = HexString.toHexString(link.getSrc()); |
| 472 | String dst_dpid = HexString.toHexString(link.getDst()); |
| 473 | short src_port = link.getSrcPort(); |
| 474 | short dst_port = link.getDstPort(); |
| 475 | |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 476 | Iterator<Vertex> it = titanGraph.getVertices("dpid", src_dpid).iterator(); |
Jonathan Hart | c86a2ea | 2013-01-15 22:39:42 -0800 | [diff] [blame] | 477 | |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 478 | // Test if just one switch is found in the graph |
Jonathan Hart | c86a2ea | 2013-01-15 22:39:42 -0800 | [diff] [blame] | 479 | assertTrue(it.hasNext()); |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 480 | Vertex sw = it.next(); |
Jonathan Hart | c86a2ea | 2013-01-15 22:39:42 -0800 | [diff] [blame] | 481 | assertFalse(it.hasNext()); |
| 482 | |
Naoki Shiota | cae568a | 2013-06-05 17:53:41 -0700 | [diff] [blame] | 483 | GremlinPipeline<Vertex, Vertex> pipe = new GremlinPipeline<Vertex, Vertex>(); |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 484 | pipe.start(sw).out("on").has("number", src_port).out("link").has("number", dst_port).in("on").has("dpid", dst_dpid); |
Jonathan Hart | c86a2ea | 2013-01-15 22:39:42 -0800 | [diff] [blame] | 485 | |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 486 | // Test if just one link is found in the graph |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 487 | assertTrue(pipe.hasNext()); |
| 488 | pipe.next(); |
Jonathan Hart | c86a2ea | 2013-01-15 22:39:42 -0800 | [diff] [blame] | 489 | assertFalse(pipe.hasNext()); |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 490 | } |
| 491 | |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 492 | /** |
| 493 | * Test if titanGraph doesn't have specific link |
| 494 | * @param link |
| 495 | */ |
| 496 | private void doTestLinkIsNotInGraph(Link link) { |
| 497 | String src_dpid = HexString.toHexString(link.getSrc()); |
| 498 | String dst_dpid = HexString.toHexString(link.getDst()); |
| 499 | short src_port = link.getSrcPort(); |
| 500 | short dst_port = link.getDstPort(); |
| 501 | |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 502 | Iterator<Vertex> it = titanGraph.getVertices("dpid", src_dpid).iterator(); |
| 503 | |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 504 | // Test if just one switch is found in the graph |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 505 | assertTrue(it.hasNext()); |
| 506 | Vertex sw = it.next(); |
| 507 | assertFalse(it.hasNext()); |
| 508 | |
Naoki Shiota | cae568a | 2013-06-05 17:53:41 -0700 | [diff] [blame] | 509 | GremlinPipeline<Vertex, Vertex> pipe = new GremlinPipeline<Vertex, Vertex>(); |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 510 | pipe.start(sw).out("on").has("number", src_port).out("link").has("number", dst_port).in("on").has("dpid", dst_dpid); |
| 511 | |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 512 | // Test if no link is found in the graph |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 513 | assertFalse(pipe.hasNext()); |
| 514 | } |
Naoki Shiota | cae568a | 2013-06-05 17:53:41 -0700 | [diff] [blame] | 515 | |
| 516 | /** |
| 517 | * Test if titanGraph has specific Link with specific LinkInfo |
| 518 | * @param link |
| 519 | */ |
| 520 | private void doTestLinkHasStateOf(Link link, LinkInfo info) { |
| 521 | String src_dpid = HexString.toHexString(link.getSrc()); |
| 522 | String dst_dpid = HexString.toHexString(link.getDst()); |
| 523 | short src_port = link.getSrcPort(); |
| 524 | short dst_port = link.getDstPort(); |
| 525 | |
| 526 | Iterator<Vertex> it = titanGraph.getVertices("dpid", src_dpid).iterator(); |
| 527 | |
| 528 | // Test if just one switch is found in the graph |
| 529 | assertTrue(it.hasNext()); |
| 530 | Vertex sw = it.next(); |
| 531 | assertFalse(it.hasNext()); |
| 532 | |
| 533 | GremlinPipeline<Vertex, Edge> pipe = new GremlinPipeline<Vertex, Edge>(); |
| 534 | pipe.start(sw); |
| 535 | pipe.enablePath(); |
| 536 | pipe.out("on").has("number", src_port).out("link").has("number", dst_port).in("on").has("dpid", dst_dpid) |
| 537 | .path().step(new PipeFunction<PathPipe<Vertex>, Edge>() { |
| 538 | @Override |
| 539 | public Edge compute(PathPipe<Vertex> pipepath) { |
| 540 | List<Vertex> V = pipepath.next(); |
| 541 | |
| 542 | Vertex port_src = V.get(1); |
| 543 | Vertex port_dst = V.get(2); |
| 544 | |
| 545 | for(Edge e : port_src.getEdges(Direction.OUT)) { |
| 546 | if(e.getVertex(Direction.IN).equals(port_dst)) { |
| 547 | return e; |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | return null; |
| 552 | } |
| 553 | }); |
| 554 | |
| 555 | // Test if just one link is found in the graph |
| 556 | assertTrue(pipe.hasNext()); |
| 557 | Edge edge = pipe.next(); |
| 558 | assertTrue(edge != null); |
| 559 | assertFalse(pipe.hasNext()); |
| 560 | |
| 561 | // TODO: implement test code to check if update is correctly done. |
Naoki Shiota | 1b97286 | 2013-06-05 19:49:09 -0700 | [diff] [blame] | 562 | assertTrue(false); |
Naoki Shiota | cae568a | 2013-06-05 17:53:41 -0700 | [diff] [blame] | 563 | } |
| 564 | |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 565 | |
| 566 | //----------------- Creation of test data ----------------------- |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 567 | /** |
| 568 | * Returns new Link object which has information of existing link in titanGraph |
| 569 | * @return new Link object |
| 570 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 571 | private Link createExistingLink() { |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 572 | // Link from SEA switch port 2 to CHI switch port 1 |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 573 | return new Link(Long.decode("0x0000000000000a01"), 2, Long.decode("0x0000000000000a03"), 1); |
| 574 | } |
| 575 | |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 576 | /** |
| 577 | * Returns new Link object which has information of not-existing but feasible link in titanGraph |
| 578 | * @return new Link object |
| 579 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 580 | private Link createFeasibleLink() { |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 581 | // Link from SEA switch port 1 to LAX switch port 1 |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 582 | return new Link(Long.decode("0x0000000000000a01"), 4, Long.decode("0x0000000000000a02"), 1); |
| 583 | } |
| 584 | |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 585 | // make NO sense while test-network data doesn't define physical network (i.e. any link is feasible) |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 586 | @SuppressWarnings("unused") |
| 587 | private Link createInfeasibleLink() { |
| 588 | return new Link(Long.decode("0x0000000000000a01"), 1, Long.decode("0x0000000000000a02"), 1); |
| 589 | } |
| 590 | |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 591 | /** |
| 592 | * Returns list of Link objects which all has information of existing link in titanGraph |
| 593 | * @return ArrayList of new Link objects |
| 594 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 595 | private List<Link> createExistingLinks() { |
| 596 | List<Link> links = new ArrayList<Link>(); |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 597 | // Link from SEA switch port 2 to CHI switch port 1 |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 598 | links.add(new Link(Long.decode("0x0000000000000a01"), 2, Long.decode("0x0000000000000a03"), 1)); |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 599 | // Link from LAX switch port 1 to SEA switch port 3 |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 600 | links.add(new Link(Long.decode("0x0000000000000a02"), 1, Long.decode("0x0000000000000a01"), 3)); |
| 601 | return links; |
| 602 | } |
| 603 | |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 604 | /** |
| 605 | * Returns list of Link objects which all has information of not-existing but feasible link |
| 606 | * @return ArrayList of new Link objects |
| 607 | */ |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 608 | private List<Link> createFeasibleLinks() { |
| 609 | List<Link> links = new ArrayList<Link>(); |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 610 | // Link from CHI switch port 4 to NYC switch port 3 |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 611 | links.add(new Link(Long.decode("0x0000000000000a03"), 4, Long.decode("0x0000000000000a05"), 3)); |
mininet | 9d203de | 2013-06-05 08:40:45 -0700 | [diff] [blame] | 612 | // Link from SEA switch port 4 to LAX switch port 1 |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 613 | links.add(new Link(Long.decode("0x0000000000000a01"), 4, Long.decode("0x0000000000000a02"), 1)); |
| 614 | return links; |
| 615 | } |
Naoki Shiota | cae568a | 2013-06-05 17:53:41 -0700 | [diff] [blame] | 616 | |
| 617 | /** |
| 618 | * Returns new LinkInfo object with convenient values. |
| 619 | * @return LinkInfo object |
| 620 | */ |
| 621 | private LinkInfo createFeasibleLinkInfo(long time) { |
| 622 | long time_first = time; |
| 623 | long time_last_lldp = time + 50; |
| 624 | long time_last_bddp = time + 100; |
| 625 | int state_src = OFPhysicalPort.OFPortState.OFPPS_STP_FORWARD.getValue(); |
| 626 | int state_dst = OFPhysicalPort.OFPortState.OFPPS_STP_LISTEN.getValue(); |
| 627 | |
| 628 | return new LinkInfo(time_first, |
| 629 | time_last_lldp, |
| 630 | time_last_bddp, |
| 631 | state_src, |
| 632 | state_dst); |
| 633 | } |
mininet | 403d589 | 2013-06-05 03:48:17 -0700 | [diff] [blame] | 634 | //--------------------------------------------------------------- |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 635 | } |