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