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 { |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Checks the operation of getInstance() method. |
| 165 | */ |
| 166 | @Test |
| 167 | public void testGetInstance() { |
| 168 | assertThat(srTeHandler, is(notNullValue())); |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * Checks the operation of reserveGlobalPool() method. |
| 173 | */ |
| 174 | @Test |
| 175 | public void testReserveGlobalPool() { |
| 176 | assertThat(srTeHandler.reserveGlobalPool(GLOBAL_LABEL_SPACE_MIN, |
| 177 | GLOBAL_LABEL_SPACE_MAX), is(true)); |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * Checks the operation of allocateNodeLabel() method on node label. |
| 182 | * Considered some nodes are already available before PceManager came up. |
| 183 | */ |
| 184 | @Test |
| 185 | public void testAllocateNodeLabel1() { |
| 186 | // Specific device deviceId1 |
| 187 | |
| 188 | // Devices mapping with lsr-id |
| 189 | deviceIdLsrIdMap = new HashMap<>(); |
| 190 | |
| 191 | //device 1 |
| 192 | String lsrId1 = "11.1.1.1"; |
| 193 | deviceIdLsrIdMap.put(deviceId1, lsrId1); |
| 194 | |
| 195 | // device 2 |
| 196 | String lsrId2 = "12.1.1.1"; |
| 197 | deviceIdLsrIdMap.put(deviceId2, lsrId2); |
| 198 | |
| 199 | // device 3 |
| 200 | String lsrId3 = "13.1.1.1"; |
| 201 | deviceIdLsrIdMap.put(deviceId3, lsrId3); |
| 202 | |
| 203 | // device 4 |
| 204 | String lsrId4 = "14.1.1.1"; |
| 205 | deviceIdLsrIdMap.put(deviceId4, lsrId4); |
| 206 | |
| 207 | // device 5 |
| 208 | String lsrId5 = "15.1.1.1"; |
| 209 | deviceIdLsrIdMap.put(deviceId5, lsrId5); |
| 210 | |
| 211 | // Considered devices are stored in deviceIdLsrIdMap. |
| 212 | // Creating temporary tempDeviceIdLsrIdMap to pass to allocateNodeLabel() |
| 213 | Map<DeviceId, String> tempDeviceIdLsrIdMap = new HashMap<>(); |
| 214 | for (Map.Entry element : deviceIdLsrIdMap.entrySet()) { |
| 215 | DeviceId devId = (DeviceId) element.getKey(); |
| 216 | String lsrId = (String) element.getValue(); |
| 217 | |
| 218 | // Allocate node label for specific device devId |
| 219 | assertThat(srTeHandler.allocateNodeLabel(devId, lsrId, tempDeviceIdLsrIdMap), is(true)); |
| 220 | |
| 221 | // Retrieve label from store |
| 222 | LabelResourceId labelId = pceStore.getGlobalNodeLabel(devId); |
| 223 | |
| 224 | // Check whether label is generated for this device devId |
| 225 | assertThat(labelId, is(notNullValue())); |
| 226 | |
| 227 | //Now add device to tempDeviceIdLsrIdMap |
| 228 | tempDeviceIdLsrIdMap.put(devId, lsrId); |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * Checks the operation of allocateNodeLabel() method on node label. |
| 234 | * Considered initially map is empty and keep on getting new devices from event. |
| 235 | */ |
| 236 | @Test |
| 237 | public void testAllocateNodeLabel2() { |
| 238 | // Specific device deviceId1 |
| 239 | |
| 240 | // Device-id mapping with lsr-id |
| 241 | deviceIdLsrIdMap = new HashMap<>(); |
| 242 | |
| 243 | //device 1 |
| 244 | String lsrId1 = "11.1.1.1"; |
| 245 | // Allocate node label for specific device deviceId1 |
| 246 | assertThat(srTeHandler.allocateNodeLabel(deviceId1, lsrId1, deviceIdLsrIdMap), is(true)); |
| 247 | // Retrieve label from store |
| 248 | LabelResourceId labelId = pceStore.getGlobalNodeLabel(deviceId1); |
| 249 | // Check whether label is generated for this device deviceId1 |
| 250 | assertThat(labelId, is(notNullValue())); |
| 251 | //Now add device to deviceIdLsrIdMap |
| 252 | deviceIdLsrIdMap.put(deviceId1, lsrId1); |
| 253 | |
| 254 | // device 2 |
| 255 | String lsrId2 = "12.1.1.1"; |
| 256 | // Allocate node label for specific device deviceId2 |
| 257 | assertThat(srTeHandler.allocateNodeLabel(deviceId2, lsrId2, deviceIdLsrIdMap), is(true)); |
| 258 | // Retrieve label from store |
| 259 | labelId = pceStore.getGlobalNodeLabel(deviceId2); |
| 260 | // Check whether label is generated for this device deviceId2 |
| 261 | assertThat(labelId, is(notNullValue())); |
| 262 | //Now add device to deviceIdLsrIdMap |
| 263 | deviceIdLsrIdMap.put(deviceId2, lsrId2); |
| 264 | |
| 265 | // device 3 |
| 266 | String lsrId3 = "13.1.1.1"; |
| 267 | // Allocate node label for specific device deviceId3 |
| 268 | assertThat(srTeHandler.allocateNodeLabel(deviceId3, lsrId3, deviceIdLsrIdMap), is(true)); |
| 269 | // Retrieve label from store |
| 270 | labelId = pceStore.getGlobalNodeLabel(deviceId3); |
| 271 | // Check whether label is generated for this device deviceId3 |
| 272 | assertThat(labelId, is(notNullValue())); |
| 273 | //Now add device to deviceIdLsrIdMap |
| 274 | deviceIdLsrIdMap.put(deviceId3, lsrId3); |
| 275 | |
| 276 | // device 4 |
| 277 | String lsrId4 = "14.1.1.1"; |
| 278 | // Allocate node label for specific device deviceId4 |
| 279 | assertThat(srTeHandler.allocateNodeLabel(deviceId4, lsrId4, deviceIdLsrIdMap), is(true)); |
| 280 | // Retrieve label from store |
| 281 | labelId = pceStore.getGlobalNodeLabel(deviceId4); |
| 282 | // Check whether label is generated for this device deviceId4 |
| 283 | assertThat(labelId, is(notNullValue())); |
| 284 | //Now add device to deviceIdLsrIdMap |
| 285 | deviceIdLsrIdMap.put(deviceId4, lsrId4); |
| 286 | |
| 287 | // device 5 |
| 288 | String lsrId5 = "15.1.1.1"; |
| 289 | // Allocate node label for specific device deviceId5 |
| 290 | assertThat(srTeHandler.allocateNodeLabel(deviceId5, lsrId5, deviceIdLsrIdMap), is(true)); |
| 291 | // Retrieve label from store |
| 292 | labelId = pceStore.getGlobalNodeLabel(deviceId5); |
| 293 | // Check whether label is generated for this device deviceId5 |
| 294 | assertThat(labelId, is(notNullValue())); |
| 295 | //Now add device to deviceIdLsrIdMap |
| 296 | deviceIdLsrIdMap.put(deviceId5, lsrId5); |
| 297 | } |
| 298 | |
| 299 | /** |
| 300 | * Checks the operation of releaseNodeLabel() method on node label. |
| 301 | */ |
| 302 | @Test |
| 303 | public void testReleaseNodeLabelSuccess() { |
| 304 | testAllocateNodeLabel2(); |
| 305 | // Specific device deviceId1 |
| 306 | |
| 307 | //device 1 |
| 308 | String lsrId1 = "11.1.1.1"; |
| 309 | // Check whether successfully released node label |
| 310 | assertThat(srTeHandler.releaseNodeLabel(deviceId1, lsrId1, deviceIdLsrIdMap), is(true)); |
| 311 | // Check whether successfully removed label from store |
| 312 | LabelResourceId labelId = pceStore.getGlobalNodeLabel(deviceId1); |
| 313 | assertThat(labelId, is(nullValue())); |
| 314 | // Remove released deviceId1 |
| 315 | deviceIdLsrIdMap.remove(deviceId1); |
| 316 | |
| 317 | //device 2 |
| 318 | String lsrId2 = "12.1.1.1"; |
| 319 | // Check whether successfully released node label |
| 320 | assertThat(srTeHandler.releaseNodeLabel(deviceId2, lsrId2, deviceIdLsrIdMap), is(true)); |
| 321 | // Check whether successfully removed label from store |
| 322 | labelId = pceStore.getGlobalNodeLabel(deviceId2); |
| 323 | assertThat(labelId, is(nullValue())); |
| 324 | // Remove released deviceId2 |
| 325 | deviceIdLsrIdMap.remove(deviceId2); |
| 326 | |
| 327 | //device 3 |
| 328 | String lsrId3 = "13.1.1.1"; |
| 329 | // Check whether successfully released node label |
| 330 | assertThat(srTeHandler.releaseNodeLabel(deviceId3, lsrId3, deviceIdLsrIdMap), is(true)); |
| 331 | // Check whether successfully removed label from store |
| 332 | labelId = pceStore.getGlobalNodeLabel(deviceId3); |
| 333 | assertThat(labelId, is(nullValue())); |
| 334 | // Remove released deviceId3 |
| 335 | deviceIdLsrIdMap.remove(deviceId3); |
| 336 | |
| 337 | //device 4 |
| 338 | String lsrId4 = "14.1.1.1"; |
| 339 | // Check whether successfully released node label |
| 340 | assertThat(srTeHandler.releaseNodeLabel(deviceId4, lsrId4, deviceIdLsrIdMap), is(true)); |
| 341 | // Check whether successfully removed label from store |
| 342 | labelId = pceStore.getGlobalNodeLabel(deviceId4); |
| 343 | assertThat(labelId, is(nullValue())); |
| 344 | // Remove released deviceId4 |
| 345 | deviceIdLsrIdMap.remove(deviceId4); |
| 346 | |
| 347 | //device 5 |
| 348 | String lsrId5 = "15.1.1.1"; |
| 349 | // Check whether successfully released node label |
| 350 | assertThat(srTeHandler.releaseNodeLabel(deviceId5, lsrId5, deviceIdLsrIdMap), is(true)); |
| 351 | // Check whether successfully removed label from store |
| 352 | labelId = pceStore.getGlobalNodeLabel(deviceId5); |
| 353 | assertThat(labelId, is(nullValue())); |
| 354 | // Remove released deviceId5 |
| 355 | deviceIdLsrIdMap.remove(deviceId5); |
| 356 | } |
| 357 | |
| 358 | @Test |
| 359 | public void testReleaseNodeLabelFailure() { |
| 360 | testAllocateNodeLabel2(); |
| 361 | |
| 362 | //device 6 |
| 363 | String lsrId6 = "16.1.1.1"; |
| 364 | // Check whether successfully released node label |
| 365 | DeviceId deviceId6 = DeviceId.deviceId("foo6"); |
| 366 | assertThat(srTeHandler.releaseNodeLabel(deviceId6, lsrId6, deviceIdLsrIdMap), is(false)); |
| 367 | } |
| 368 | |
| 369 | /** |
| 370 | * Checks the operation of allocateAdjacencyLabel() method on adjacency label. |
| 371 | */ |
| 372 | @Test |
| 373 | public void testAllocateAdjacencyLabel() { |
| 374 | // test link1 |
| 375 | // Check whether adjacency label is allocated successfully. |
| 376 | assertThat(srTeHandler.allocateAdjacencyLabel(link1), is(true)); |
| 377 | // Retrieve from store and check whether adjacency label is generated successfully for this device. |
| 378 | LabelResourceId labelId = pceStore.getAdjLabel(link1); |
| 379 | assertThat(labelId, is(notNullValue())); |
| 380 | |
| 381 | // test link2 |
| 382 | // Check whether adjacency label is allocated successfully. |
| 383 | assertThat(srTeHandler.allocateAdjacencyLabel(link2), is(true)); |
| 384 | // Retrieve from store and check whether adjacency label is generated successfully for this device. |
| 385 | labelId = pceStore.getAdjLabel(link2); |
| 386 | assertThat(labelId, is(notNullValue())); |
| 387 | |
| 388 | // test link3 |
| 389 | // Check whether adjacency label is allocated successfully. |
| 390 | assertThat(srTeHandler.allocateAdjacencyLabel(link3), is(true)); |
| 391 | // Retrieve from store and check whether adjacency label is generated successfully for this device. |
| 392 | labelId = pceStore.getAdjLabel(link3); |
| 393 | assertThat(labelId, is(notNullValue())); |
| 394 | |
| 395 | // test link4 |
| 396 | // Check whether adjacency label is allocated successfully. |
| 397 | assertThat(srTeHandler.allocateAdjacencyLabel(link4), is(true)); |
| 398 | // Retrieve from store and check whether adjacency label is generated successfully for this device. |
| 399 | labelId = pceStore.getAdjLabel(link4); |
| 400 | assertThat(labelId, is(notNullValue())); |
| 401 | } |
| 402 | |
| 403 | /** |
| 404 | * Checks the operation of releaseAdjacencyLabel() method on adjacency label. |
| 405 | */ |
| 406 | @Test |
| 407 | public void testReleaseAdjacencyLabel() { |
| 408 | // Test link1 |
| 409 | // Check whether adjacency label is released successfully. |
| 410 | assertThat(srTeHandler.allocateAdjacencyLabel(link1), is(true)); |
| 411 | assertThat(srTeHandler.releaseAdjacencyLabel(link1), is(true)); |
| 412 | // Retrieve from store and check whether adjacency label is removed successfully for this device. |
| 413 | LabelResourceId labelId = pceStore.getAdjLabel(link1); |
| 414 | assertThat(labelId, is(nullValue())); |
| 415 | |
| 416 | // Test link2 |
| 417 | // Check whether adjacency label is released successfully. |
| 418 | assertThat(srTeHandler.allocateAdjacencyLabel(link2), is(true)); |
| 419 | assertThat(srTeHandler.releaseAdjacencyLabel(link2), is(true)); |
| 420 | // Retrieve from store and check whether adjacency label is removed successfully for this device. |
| 421 | labelId = pceStore.getAdjLabel(link2); |
| 422 | assertThat(labelId, is(nullValue())); |
| 423 | } |
| 424 | |
| 425 | /** |
| 426 | * Checks the operation of computeLabelStack() method. |
| 427 | */ |
| 428 | @Test |
| 429 | public void testComputeLabelStack() { |
| 430 | // Allocate node labels to each devices |
| 431 | labelId = LabelResourceId.labelResourceId(4097); |
| 432 | pceStore.addGlobalNodeLabel(deviceId1, labelId); |
| 433 | labelId = LabelResourceId.labelResourceId(4098); |
| 434 | pceStore.addGlobalNodeLabel(deviceId2, labelId); |
| 435 | labelId = LabelResourceId.labelResourceId(4099); |
| 436 | pceStore.addGlobalNodeLabel(deviceId3, labelId); |
| 437 | labelId = LabelResourceId.labelResourceId(4100); |
| 438 | pceStore.addGlobalNodeLabel(deviceId4, labelId); |
| 439 | labelId = LabelResourceId.labelResourceId(4101); |
| 440 | pceStore.addGlobalNodeLabel(deviceId5, labelId); |
| 441 | |
| 442 | // Allocate adjacency labels to each devices |
| 443 | labelId = LabelResourceId.labelResourceId(5122); |
| 444 | pceStore.addAdjLabel(link1, labelId); |
| 445 | labelId = LabelResourceId.labelResourceId(5123); |
| 446 | pceStore.addAdjLabel(link2, labelId); |
| 447 | labelId = LabelResourceId.labelResourceId(5124); |
| 448 | pceStore.addAdjLabel(link3, labelId); |
| 449 | labelId = LabelResourceId.labelResourceId(5125); |
| 450 | pceStore.addAdjLabel(link4, labelId); |
| 451 | |
| 452 | // Compute label stack |
| 453 | LabelStack labelStack = srTeHandler.computeLabelStack(path1); |
| 454 | |
| 455 | // check node-label of deviceId1 |
| 456 | List<LabelResourceId> labelList = labelStack.labelResources(); |
| 457 | Iterator<LabelResourceId> iterator = labelList.iterator(); |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 458 | labelId = iterator.next(); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 459 | assertThat(labelId, is(LabelResourceId.labelResourceId(4097))); |
| 460 | |
| 461 | // check adjacency label of deviceId1 |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 462 | labelId = iterator.next(); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 463 | assertThat(labelId, is(LabelResourceId.labelResourceId(5122))); |
| 464 | |
| 465 | // check node-label of deviceId2 |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 466 | labelId = iterator.next(); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 467 | assertThat(labelId, is(LabelResourceId.labelResourceId(4098))); |
| 468 | |
| 469 | // check adjacency label of deviceId2 |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 470 | labelId = iterator.next(); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 471 | assertThat(labelId, is(LabelResourceId.labelResourceId(5123))); |
| 472 | |
| 473 | // check node-label of deviceId3 |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 474 | labelId = iterator.next(); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 475 | assertThat(labelId, is(LabelResourceId.labelResourceId(4099))); |
| 476 | |
| 477 | // check adjacency label of deviceId3 |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 478 | labelId = iterator.next(); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 479 | assertThat(labelId, is(LabelResourceId.labelResourceId(5124))); |
| 480 | |
| 481 | // check node-label of deviceId4 |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 482 | labelId = iterator.next(); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 483 | assertThat(labelId, is(LabelResourceId.labelResourceId(4100))); |
| 484 | |
| 485 | // check adjacency label of deviceId4 |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 486 | labelId = iterator.next(); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 487 | assertThat(labelId, is(LabelResourceId.labelResourceId(5125))); |
| 488 | |
| 489 | // check node-label of deviceId5 |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 490 | labelId = iterator.next(); |
Mahesh Poojary S | a4df1aa | 2016-05-13 08:53:53 +0530 | [diff] [blame] | 491 | assertThat(labelId, is(LabelResourceId.labelResourceId(4101))); |
| 492 | } |
| 493 | } |