Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.pce.pceservice; |
| 17 | |
| 18 | import static org.hamcrest.MatcherAssert.assertThat; |
| 19 | import static org.hamcrest.Matchers.is; |
| 20 | import static org.hamcrest.Matchers.notNullValue; |
| 21 | import static org.hamcrest.Matchers.nullValue; |
| 22 | |
| 23 | import static org.onosproject.net.Link.Type.DIRECT; |
| 24 | |
| 25 | import java.util.HashMap; |
| 26 | import java.util.Iterator; |
| 27 | import java.util.Map; |
| 28 | import java.util.List; |
| 29 | import java.util.LinkedList; |
| 30 | |
| 31 | import org.junit.After; |
| 32 | import org.junit.Before; |
| 33 | import org.junit.Test; |
| 34 | |
| 35 | import org.onosproject.incubator.net.resource.label.LabelResourceId; |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 36 | import org.onosproject.core.ApplicationId; |
| 37 | import org.onosproject.core.CoreService; |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 38 | import org.onosproject.incubator.net.resource.label.LabelResourceAdminService; |
| 39 | import org.onosproject.incubator.net.resource.label.LabelResourceService; |
| 40 | import org.onosproject.incubator.net.tunnel.LabelStack; |
| 41 | import org.onosproject.net.ConnectPoint; |
| 42 | import org.onosproject.net.DefaultAnnotations; |
| 43 | import org.onosproject.net.DefaultPath; |
| 44 | import org.onosproject.net.DeviceId; |
| 45 | import org.onosproject.net.PortNumber; |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 46 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 47 | import org.onosproject.net.Path; |
| 48 | import org.onosproject.pce.pcestore.api.PceStore; |
| 49 | import org.onosproject.net.provider.ProviderId; |
| 50 | import org.onosproject.pce.util.LabelResourceAdapter; |
| 51 | import org.onosproject.pce.util.PceStoreAdapter; |
| 52 | import org.onosproject.net.DefaultLink; |
| 53 | import org.onosproject.net.Link; |
| 54 | |
| 55 | /** |
| 56 | * Unit tests for PceccSrTeBeHandler class. |
| 57 | */ |
| 58 | public class PceccSrTeBeHandlerTest { |
| 59 | |
| 60 | public static final long GLOBAL_LABEL_SPACE_MIN = 4097; |
| 61 | public static final long GLOBAL_LABEL_SPACE_MAX = 5121; |
| 62 | |
| 63 | private PceccSrTeBeHandler srTeHandler; |
| 64 | protected LabelResourceAdminService labelRsrcAdminService; |
| 65 | protected LabelResourceService labelRsrcService; |
| 66 | protected PceStore pceStore; |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 67 | private FlowObjectiveService flowObjectiveService; |
| 68 | private CoreService coreService; |
| 69 | private ApplicationId appId; |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 70 | private ProviderId providerId; |
| 71 | private DeviceId deviceId1; |
| 72 | private DeviceId deviceId2; |
| 73 | private DeviceId deviceId3; |
| 74 | private DeviceId deviceId4; |
| 75 | private DeviceId deviceId5; |
| 76 | private PortNumber port1; |
| 77 | private PortNumber port2; |
| 78 | private PortNumber port3; |
| 79 | private PortNumber port4; |
| 80 | private PortNumber port5; |
| 81 | private Link link1; |
| 82 | private Link link2; |
| 83 | private Link link3; |
| 84 | private Link link4; |
| 85 | private Path path1; |
| 86 | LabelResourceId labelId; |
| 87 | private LabelResourceId labelId1 = LabelResourceId.labelResourceId(4098); |
| 88 | private LabelResourceId labelId2 = LabelResourceId.labelResourceId(4099); |
| 89 | private Map<DeviceId, String> deviceIdLsrIdMap; |
| 90 | |
| 91 | @Before |
| 92 | public void setUp() throws Exception { |
| 93 | // Initialization of member variables |
| 94 | srTeHandler = PceccSrTeBeHandler.getInstance(); |
| 95 | labelRsrcService = new LabelResourceAdapter(); |
| 96 | labelRsrcAdminService = new LabelResourceAdapter(); |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 97 | flowObjectiveService = new PceManagerTest.MockFlowObjService(); |
| 98 | coreService = new PceManagerTest.MockCoreService(); |
| 99 | appId = coreService.registerApplication("org.onosproject.pce"); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 100 | pceStore = new PceStoreAdapter(); |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 101 | srTeHandler.initialize(labelRsrcAdminService, labelRsrcService, flowObjectiveService, appId, pceStore); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 102 | |
| 103 | // Creates path |
| 104 | // Creates list of links |
| 105 | providerId = new ProviderId("of", "foo"); |
| 106 | deviceId1 = DeviceId.deviceId("of:A"); |
| 107 | deviceId2 = DeviceId.deviceId("of:B"); |
| 108 | deviceId3 = DeviceId.deviceId("of:C"); |
| 109 | deviceId4 = DeviceId.deviceId("of:D"); |
| 110 | deviceId5 = DeviceId.deviceId("of:E"); |
| 111 | port1 = PortNumber.portNumber(1); |
| 112 | port2 = PortNumber.portNumber(2); |
| 113 | port3 = PortNumber.portNumber(3); |
| 114 | port4 = PortNumber.portNumber(4); |
| 115 | port5 = PortNumber.portNumber(5); |
| 116 | List<Link> linkList = new LinkedList<>(); |
| 117 | |
| 118 | link1 = DefaultLink.builder() |
| 119 | .providerId(providerId) |
| 120 | .annotations(DefaultAnnotations.builder().set("key1", "yahoo").build()) |
| 121 | .src(new ConnectPoint(deviceId1, port1)) |
| 122 | .dst(new ConnectPoint(deviceId2, port2)) |
| 123 | .type(DIRECT) |
| 124 | .state(Link.State.ACTIVE) |
| 125 | .build(); |
| 126 | linkList.add(link1); |
| 127 | link2 = DefaultLink.builder() |
| 128 | .providerId(providerId) |
| 129 | .annotations(DefaultAnnotations.builder().set("key2", "yahoo").build()) |
| 130 | .src(new ConnectPoint(deviceId2, port2)) |
| 131 | .dst(new ConnectPoint(deviceId3, port3)) |
| 132 | .type(DIRECT) |
| 133 | .state(Link.State.ACTIVE) |
| 134 | .build(); |
| 135 | linkList.add(link2); |
| 136 | link3 = DefaultLink.builder() |
| 137 | .providerId(providerId) |
| 138 | .annotations(DefaultAnnotations.builder().set("key3", "yahoo").build()) |
| 139 | .src(new ConnectPoint(deviceId3, port3)) |
| 140 | .dst(new ConnectPoint(deviceId4, port4)) |
| 141 | .type(DIRECT) |
| 142 | .state(Link.State.ACTIVE) |
| 143 | .build(); |
| 144 | linkList.add(link3); |
| 145 | link4 = DefaultLink.builder() |
| 146 | .providerId(providerId) |
| 147 | .annotations(DefaultAnnotations.builder().set("key4", "yahoo").build()) |
| 148 | .src(new ConnectPoint(deviceId4, port4)) |
| 149 | .dst(new ConnectPoint(deviceId5, port5)) |
| 150 | .type(DIRECT) |
| 151 | .state(Link.State.ACTIVE) |
| 152 | .build(); |
| 153 | linkList.add(link4); |
| 154 | |
| 155 | // Path |
| 156 | path1 = new DefaultPath(providerId, linkList, 10); |
| 157 | } |
| 158 | |
| 159 | @After |
| 160 | public void tearDown() throws Exception { |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame^] | 161 | PceManagerTest.flowsDownloaded = 0; |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | /** |
| 165 | * Checks the operation of getInstance() method. |
| 166 | */ |
| 167 | @Test |
| 168 | public void testGetInstance() { |
| 169 | assertThat(srTeHandler, is(notNullValue())); |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * Checks the operation of reserveGlobalPool() method. |
| 174 | */ |
| 175 | @Test |
| 176 | public void testReserveGlobalPool() { |
| 177 | assertThat(srTeHandler.reserveGlobalPool(GLOBAL_LABEL_SPACE_MIN, |
| 178 | GLOBAL_LABEL_SPACE_MAX), is(true)); |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * Checks the operation of allocateNodeLabel() method on node label. |
| 183 | * Considered some nodes are already available before PceManager came up. |
| 184 | */ |
| 185 | @Test |
| 186 | public void testAllocateNodeLabel1() { |
| 187 | // Specific device deviceId1 |
| 188 | |
| 189 | // Devices mapping with lsr-id |
| 190 | deviceIdLsrIdMap = new HashMap<>(); |
| 191 | |
| 192 | //device 1 |
| 193 | String lsrId1 = "11.1.1.1"; |
| 194 | deviceIdLsrIdMap.put(deviceId1, lsrId1); |
| 195 | |
| 196 | // device 2 |
| 197 | String lsrId2 = "12.1.1.1"; |
| 198 | deviceIdLsrIdMap.put(deviceId2, lsrId2); |
| 199 | |
| 200 | // device 3 |
| 201 | String lsrId3 = "13.1.1.1"; |
| 202 | deviceIdLsrIdMap.put(deviceId3, lsrId3); |
| 203 | |
| 204 | // device 4 |
| 205 | String lsrId4 = "14.1.1.1"; |
| 206 | deviceIdLsrIdMap.put(deviceId4, lsrId4); |
| 207 | |
| 208 | // device 5 |
| 209 | String lsrId5 = "15.1.1.1"; |
| 210 | deviceIdLsrIdMap.put(deviceId5, lsrId5); |
| 211 | |
| 212 | // Considered devices are stored in deviceIdLsrIdMap. |
| 213 | // Creating temporary tempDeviceIdLsrIdMap to pass to allocateNodeLabel() |
| 214 | Map<DeviceId, String> tempDeviceIdLsrIdMap = new HashMap<>(); |
| 215 | for (Map.Entry element : deviceIdLsrIdMap.entrySet()) { |
| 216 | DeviceId devId = (DeviceId) element.getKey(); |
| 217 | String lsrId = (String) element.getValue(); |
| 218 | |
| 219 | // Allocate node label for specific device devId |
| 220 | assertThat(srTeHandler.allocateNodeLabel(devId, lsrId, tempDeviceIdLsrIdMap), is(true)); |
| 221 | |
| 222 | // Retrieve label from store |
| 223 | LabelResourceId labelId = pceStore.getGlobalNodeLabel(devId); |
| 224 | |
| 225 | // Check whether label is generated for this device devId |
| 226 | assertThat(labelId, is(notNullValue())); |
| 227 | |
| 228 | //Now add device to tempDeviceIdLsrIdMap |
| 229 | tempDeviceIdLsrIdMap.put(devId, lsrId); |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | /** |
| 234 | * Checks the operation of allocateNodeLabel() method on node label. |
| 235 | * Considered initially map is empty and keep on getting new devices from event. |
| 236 | */ |
| 237 | @Test |
| 238 | public void testAllocateNodeLabel2() { |
| 239 | // Specific device deviceId1 |
| 240 | |
| 241 | // Device-id mapping with lsr-id |
| 242 | deviceIdLsrIdMap = new HashMap<>(); |
| 243 | |
| 244 | //device 1 |
| 245 | String lsrId1 = "11.1.1.1"; |
| 246 | // Allocate node label for specific device deviceId1 |
| 247 | assertThat(srTeHandler.allocateNodeLabel(deviceId1, lsrId1, deviceIdLsrIdMap), is(true)); |
| 248 | // Retrieve label from store |
| 249 | LabelResourceId labelId = pceStore.getGlobalNodeLabel(deviceId1); |
| 250 | // Check whether label is generated for this device deviceId1 |
| 251 | assertThat(labelId, is(notNullValue())); |
| 252 | //Now add device to deviceIdLsrIdMap |
| 253 | deviceIdLsrIdMap.put(deviceId1, lsrId1); |
| 254 | |
| 255 | // device 2 |
| 256 | String lsrId2 = "12.1.1.1"; |
| 257 | // Allocate node label for specific device deviceId2 |
| 258 | assertThat(srTeHandler.allocateNodeLabel(deviceId2, lsrId2, deviceIdLsrIdMap), is(true)); |
| 259 | // Retrieve label from store |
| 260 | labelId = pceStore.getGlobalNodeLabel(deviceId2); |
| 261 | // Check whether label is generated for this device deviceId2 |
| 262 | assertThat(labelId, is(notNullValue())); |
| 263 | //Now add device to deviceIdLsrIdMap |
| 264 | deviceIdLsrIdMap.put(deviceId2, lsrId2); |
| 265 | |
| 266 | // device 3 |
| 267 | String lsrId3 = "13.1.1.1"; |
| 268 | // Allocate node label for specific device deviceId3 |
| 269 | assertThat(srTeHandler.allocateNodeLabel(deviceId3, lsrId3, deviceIdLsrIdMap), is(true)); |
| 270 | // Retrieve label from store |
| 271 | labelId = pceStore.getGlobalNodeLabel(deviceId3); |
| 272 | // Check whether label is generated for this device deviceId3 |
| 273 | assertThat(labelId, is(notNullValue())); |
| 274 | //Now add device to deviceIdLsrIdMap |
| 275 | deviceIdLsrIdMap.put(deviceId3, lsrId3); |
| 276 | |
| 277 | // device 4 |
| 278 | String lsrId4 = "14.1.1.1"; |
| 279 | // Allocate node label for specific device deviceId4 |
| 280 | assertThat(srTeHandler.allocateNodeLabel(deviceId4, lsrId4, deviceIdLsrIdMap), is(true)); |
| 281 | // Retrieve label from store |
| 282 | labelId = pceStore.getGlobalNodeLabel(deviceId4); |
| 283 | // Check whether label is generated for this device deviceId4 |
| 284 | assertThat(labelId, is(notNullValue())); |
| 285 | //Now add device to deviceIdLsrIdMap |
| 286 | deviceIdLsrIdMap.put(deviceId4, lsrId4); |
| 287 | |
| 288 | // device 5 |
| 289 | String lsrId5 = "15.1.1.1"; |
| 290 | // Allocate node label for specific device deviceId5 |
| 291 | assertThat(srTeHandler.allocateNodeLabel(deviceId5, lsrId5, deviceIdLsrIdMap), is(true)); |
| 292 | // Retrieve label from store |
| 293 | labelId = pceStore.getGlobalNodeLabel(deviceId5); |
| 294 | // Check whether label is generated for this device deviceId5 |
| 295 | assertThat(labelId, is(notNullValue())); |
| 296 | //Now add device to deviceIdLsrIdMap |
| 297 | deviceIdLsrIdMap.put(deviceId5, lsrId5); |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * Checks the operation of releaseNodeLabel() method on node label. |
| 302 | */ |
| 303 | @Test |
| 304 | public void testReleaseNodeLabelSuccess() { |
| 305 | testAllocateNodeLabel2(); |
| 306 | // Specific device deviceId1 |
| 307 | |
| 308 | //device 1 |
| 309 | String lsrId1 = "11.1.1.1"; |
| 310 | // Check whether successfully released node label |
| 311 | assertThat(srTeHandler.releaseNodeLabel(deviceId1, lsrId1, deviceIdLsrIdMap), is(true)); |
| 312 | // Check whether successfully removed label from store |
| 313 | LabelResourceId labelId = pceStore.getGlobalNodeLabel(deviceId1); |
| 314 | assertThat(labelId, is(nullValue())); |
| 315 | // Remove released deviceId1 |
| 316 | deviceIdLsrIdMap.remove(deviceId1); |
| 317 | |
| 318 | //device 2 |
| 319 | String lsrId2 = "12.1.1.1"; |
| 320 | // Check whether successfully released node label |
| 321 | assertThat(srTeHandler.releaseNodeLabel(deviceId2, lsrId2, deviceIdLsrIdMap), is(true)); |
| 322 | // Check whether successfully removed label from store |
| 323 | labelId = pceStore.getGlobalNodeLabel(deviceId2); |
| 324 | assertThat(labelId, is(nullValue())); |
| 325 | // Remove released deviceId2 |
| 326 | deviceIdLsrIdMap.remove(deviceId2); |
| 327 | |
| 328 | //device 3 |
| 329 | String lsrId3 = "13.1.1.1"; |
| 330 | // Check whether successfully released node label |
| 331 | assertThat(srTeHandler.releaseNodeLabel(deviceId3, lsrId3, deviceIdLsrIdMap), is(true)); |
| 332 | // Check whether successfully removed label from store |
| 333 | labelId = pceStore.getGlobalNodeLabel(deviceId3); |
| 334 | assertThat(labelId, is(nullValue())); |
| 335 | // Remove released deviceId3 |
| 336 | deviceIdLsrIdMap.remove(deviceId3); |
| 337 | |
| 338 | //device 4 |
| 339 | String lsrId4 = "14.1.1.1"; |
| 340 | // Check whether successfully released node label |
| 341 | assertThat(srTeHandler.releaseNodeLabel(deviceId4, lsrId4, deviceIdLsrIdMap), is(true)); |
| 342 | // Check whether successfully removed label from store |
| 343 | labelId = pceStore.getGlobalNodeLabel(deviceId4); |
| 344 | assertThat(labelId, is(nullValue())); |
| 345 | // Remove released deviceId4 |
| 346 | deviceIdLsrIdMap.remove(deviceId4); |
| 347 | |
| 348 | //device 5 |
| 349 | String lsrId5 = "15.1.1.1"; |
| 350 | // Check whether successfully released node label |
| 351 | assertThat(srTeHandler.releaseNodeLabel(deviceId5, lsrId5, deviceIdLsrIdMap), is(true)); |
| 352 | // Check whether successfully removed label from store |
| 353 | labelId = pceStore.getGlobalNodeLabel(deviceId5); |
| 354 | assertThat(labelId, is(nullValue())); |
| 355 | // Remove released deviceId5 |
| 356 | deviceIdLsrIdMap.remove(deviceId5); |
| 357 | } |
| 358 | |
| 359 | @Test |
| 360 | public void testReleaseNodeLabelFailure() { |
| 361 | testAllocateNodeLabel2(); |
| 362 | |
| 363 | //device 6 |
| 364 | String lsrId6 = "16.1.1.1"; |
| 365 | // Check whether successfully released node label |
| 366 | DeviceId deviceId6 = DeviceId.deviceId("foo6"); |
| 367 | assertThat(srTeHandler.releaseNodeLabel(deviceId6, lsrId6, deviceIdLsrIdMap), is(false)); |
| 368 | } |
| 369 | |
| 370 | /** |
| 371 | * Checks the operation of allocateAdjacencyLabel() method on adjacency label. |
| 372 | */ |
| 373 | @Test |
| 374 | public void testAllocateAdjacencyLabel() { |
| 375 | // test link1 |
| 376 | // Check whether adjacency label is allocated successfully. |
| 377 | assertThat(srTeHandler.allocateAdjacencyLabel(link1), is(true)); |
| 378 | // Retrieve from store and check whether adjacency label is generated successfully for this device. |
| 379 | LabelResourceId labelId = pceStore.getAdjLabel(link1); |
| 380 | assertThat(labelId, is(notNullValue())); |
| 381 | |
| 382 | // test link2 |
| 383 | // Check whether adjacency label is allocated successfully. |
| 384 | assertThat(srTeHandler.allocateAdjacencyLabel(link2), is(true)); |
| 385 | // Retrieve from store and check whether adjacency label is generated successfully for this device. |
| 386 | labelId = pceStore.getAdjLabel(link2); |
| 387 | assertThat(labelId, is(notNullValue())); |
| 388 | |
| 389 | // test link3 |
| 390 | // Check whether adjacency label is allocated successfully. |
| 391 | assertThat(srTeHandler.allocateAdjacencyLabel(link3), is(true)); |
| 392 | // Retrieve from store and check whether adjacency label is generated successfully for this device. |
| 393 | labelId = pceStore.getAdjLabel(link3); |
| 394 | assertThat(labelId, is(notNullValue())); |
| 395 | |
| 396 | // test link4 |
| 397 | // Check whether adjacency label is allocated successfully. |
| 398 | assertThat(srTeHandler.allocateAdjacencyLabel(link4), is(true)); |
| 399 | // Retrieve from store and check whether adjacency label is generated successfully for this device. |
| 400 | labelId = pceStore.getAdjLabel(link4); |
| 401 | assertThat(labelId, is(notNullValue())); |
| 402 | } |
| 403 | |
| 404 | /** |
| 405 | * Checks the operation of releaseAdjacencyLabel() method on adjacency label. |
| 406 | */ |
| 407 | @Test |
| 408 | public void testReleaseAdjacencyLabel() { |
| 409 | // Test link1 |
| 410 | // Check whether adjacency label is released successfully. |
| 411 | assertThat(srTeHandler.allocateAdjacencyLabel(link1), is(true)); |
| 412 | assertThat(srTeHandler.releaseAdjacencyLabel(link1), is(true)); |
| 413 | // Retrieve from store and check whether adjacency label is removed successfully for this device. |
| 414 | LabelResourceId labelId = pceStore.getAdjLabel(link1); |
| 415 | assertThat(labelId, is(nullValue())); |
| 416 | |
| 417 | // Test link2 |
| 418 | // Check whether adjacency label is released successfully. |
| 419 | assertThat(srTeHandler.allocateAdjacencyLabel(link2), is(true)); |
| 420 | assertThat(srTeHandler.releaseAdjacencyLabel(link2), is(true)); |
| 421 | // Retrieve from store and check whether adjacency label is removed successfully for this device. |
| 422 | labelId = pceStore.getAdjLabel(link2); |
| 423 | assertThat(labelId, is(nullValue())); |
| 424 | } |
| 425 | |
| 426 | /** |
| 427 | * Checks the operation of computeLabelStack() method. |
| 428 | */ |
| 429 | @Test |
| 430 | public void testComputeLabelStack() { |
| 431 | // Allocate node labels to each devices |
| 432 | labelId = LabelResourceId.labelResourceId(4097); |
| 433 | pceStore.addGlobalNodeLabel(deviceId1, labelId); |
| 434 | labelId = LabelResourceId.labelResourceId(4098); |
| 435 | pceStore.addGlobalNodeLabel(deviceId2, labelId); |
| 436 | labelId = LabelResourceId.labelResourceId(4099); |
| 437 | pceStore.addGlobalNodeLabel(deviceId3, labelId); |
| 438 | labelId = LabelResourceId.labelResourceId(4100); |
| 439 | pceStore.addGlobalNodeLabel(deviceId4, labelId); |
| 440 | labelId = LabelResourceId.labelResourceId(4101); |
| 441 | pceStore.addGlobalNodeLabel(deviceId5, labelId); |
| 442 | |
| 443 | // Allocate adjacency labels to each devices |
| 444 | labelId = LabelResourceId.labelResourceId(5122); |
| 445 | pceStore.addAdjLabel(link1, labelId); |
| 446 | labelId = LabelResourceId.labelResourceId(5123); |
| 447 | pceStore.addAdjLabel(link2, labelId); |
| 448 | labelId = LabelResourceId.labelResourceId(5124); |
| 449 | pceStore.addAdjLabel(link3, labelId); |
| 450 | labelId = LabelResourceId.labelResourceId(5125); |
| 451 | pceStore.addAdjLabel(link4, labelId); |
| 452 | |
| 453 | // Compute label stack |
| 454 | LabelStack labelStack = srTeHandler.computeLabelStack(path1); |
| 455 | |
| 456 | // check node-label of deviceId1 |
| 457 | List<LabelResourceId> labelList = labelStack.labelResources(); |
| 458 | Iterator<LabelResourceId> iterator = labelList.iterator(); |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 459 | labelId = iterator.next(); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 460 | assertThat(labelId, is(LabelResourceId.labelResourceId(4097))); |
| 461 | |
| 462 | // check adjacency label of deviceId1 |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 463 | labelId = iterator.next(); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 464 | assertThat(labelId, is(LabelResourceId.labelResourceId(5122))); |
| 465 | |
| 466 | // check node-label of deviceId2 |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 467 | labelId = iterator.next(); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 468 | assertThat(labelId, is(LabelResourceId.labelResourceId(4098))); |
| 469 | |
| 470 | // check adjacency label of deviceId2 |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 471 | labelId = iterator.next(); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 472 | assertThat(labelId, is(LabelResourceId.labelResourceId(5123))); |
| 473 | |
| 474 | // check node-label of deviceId3 |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 475 | labelId = iterator.next(); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 476 | assertThat(labelId, is(LabelResourceId.labelResourceId(4099))); |
| 477 | |
| 478 | // check adjacency label of deviceId3 |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 479 | labelId = iterator.next(); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 480 | assertThat(labelId, is(LabelResourceId.labelResourceId(5124))); |
| 481 | |
| 482 | // check node-label of deviceId4 |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 483 | labelId = iterator.next(); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 484 | assertThat(labelId, is(LabelResourceId.labelResourceId(4100))); |
| 485 | |
| 486 | // check adjacency label of deviceId4 |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 487 | labelId = iterator.next(); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 488 | assertThat(labelId, is(LabelResourceId.labelResourceId(5125))); |
| 489 | |
| 490 | // check node-label of deviceId5 |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 491 | labelId = iterator.next(); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 492 | assertThat(labelId, is(LabelResourceId.labelResourceId(4101))); |
| 493 | } |
| 494 | } |