Priyanka B | b696358 | 2016-05-20 20:21:20 +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 org.junit.After; |
| 19 | import org.junit.Before; |
| 20 | import org.junit.Test; |
| 21 | import org.onlab.graph.AbstractGraphPathSearch; |
| 22 | import org.onlab.graph.AdjacencyListsGraph; |
| 23 | import org.onlab.graph.DijkstraGraphSearch; |
| 24 | import org.onlab.graph.Graph; |
| 25 | import org.onlab.graph.GraphPathSearch; |
| 26 | import org.onlab.packet.ChassisId; |
| 27 | import org.onlab.util.Bandwidth; |
| 28 | import org.onlab.util.Tools; |
| 29 | import org.onosproject.net.AnnotationKeys; |
| 30 | import org.onosproject.net.ConnectPoint; |
| 31 | import org.onosproject.net.DefaultAnnotations; |
| 32 | import org.onosproject.net.DefaultDevice; |
| 33 | import org.onosproject.net.DefaultLink; |
| 34 | import org.onosproject.net.DefaultPath; |
| 35 | import org.onosproject.net.Device; |
| 36 | import org.onosproject.net.DeviceId; |
| 37 | import org.onosproject.net.Link; |
| 38 | import org.onosproject.net.Path; |
| 39 | import org.onosproject.net.PortNumber; |
| 40 | import org.onosproject.net.intent.Constraint; |
| 41 | import org.onosproject.net.intent.IntentId; |
| 42 | import org.onosproject.net.Device.Type; |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 43 | import org.onosproject.net.config.Config; |
| 44 | import org.onosproject.net.config.ConfigApplyDelegate; |
| 45 | import org.onosproject.net.config.ConfigFactory; |
| 46 | import org.onosproject.net.config.NetworkConfigRegistryAdapter; |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 47 | import org.onosproject.net.intent.constraint.BandwidthConstraint; |
| 48 | import org.onosproject.net.device.DeviceServiceAdapter; |
| 49 | import org.onosproject.net.resource.ContinuousResource; |
| 50 | import org.onosproject.net.resource.ContinuousResourceId; |
| 51 | import org.onosproject.net.resource.DiscreteResource; |
| 52 | import org.onosproject.net.resource.DiscreteResourceId; |
| 53 | import org.onosproject.net.resource.Resource; |
| 54 | import org.onosproject.net.resource.ResourceAllocation; |
| 55 | import org.onosproject.net.resource.ResourceConsumer; |
| 56 | import org.onosproject.net.resource.ResourceId; |
| 57 | import org.onosproject.net.resource.Resources; |
| 58 | import org.onosproject.net.provider.ProviderId; |
| 59 | import org.onosproject.net.topology.DefaultTopologyEdge; |
| 60 | import org.onosproject.net.topology.DefaultTopologyVertex; |
| 61 | import org.onosproject.net.topology.LinkWeight; |
| 62 | import org.onosproject.net.topology.TopologyEdge; |
| 63 | import org.onosproject.net.topology.TopologyVertex; |
| 64 | import org.onosproject.pce.pceservice.constraint.CapabilityConstraint; |
| 65 | import org.onosproject.pce.pceservice.constraint.CostConstraint; |
| 66 | import org.onosproject.pce.pceservice.constraint.SharedBandwidthConstraint; |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 67 | import org.onosproject.pcep.api.DeviceCapability; |
| 68 | import com.fasterxml.jackson.databind.JsonNode; |
| 69 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 70 | import com.fasterxml.jackson.databind.node.JsonNodeFactory; |
| 71 | import com.fasterxml.jackson.databind.node.ObjectNode; |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 72 | import com.google.common.collect.ImmutableList; |
| 73 | import com.google.common.collect.ImmutableSet; |
| 74 | |
| 75 | import java.util.Collections; |
| 76 | import java.util.HashMap; |
| 77 | import java.util.HashSet; |
| 78 | import java.util.Iterator; |
| 79 | import java.util.LinkedList; |
| 80 | import java.util.List; |
| 81 | import java.util.Map; |
| 82 | import java.util.Optional; |
| 83 | import java.util.Set; |
| 84 | import java.util.stream.Collectors; |
| 85 | |
| 86 | import static org.hamcrest.MatcherAssert.assertThat; |
| 87 | import static org.hamcrest.core.Is.is; |
| 88 | import static org.onlab.graph.GraphPathSearch.ALL_PATHS; |
| 89 | import static org.onosproject.core.CoreService.CORE_PROVIDER_ID; |
| 90 | import static com.google.common.collect.ImmutableSet.of; |
| 91 | import static org.onosproject.net.resource.Resources.continuous; |
| 92 | import static org.onosproject.net.Link.Type.DIRECT; |
| 93 | import static org.onosproject.net.Link.State.ACTIVE; |
| 94 | import static org.onosproject.net.DeviceId.deviceId; |
| 95 | import static org.onosproject.pce.pceservice.constraint.CostConstraint.Type.COST; |
| 96 | import static org.onosproject.pce.pceservice.constraint.CostConstraint.Type.TE_COST; |
| 97 | |
| 98 | /** |
| 99 | * Test for CSPF path computation. |
| 100 | */ |
| 101 | public class PathComputationTest { |
| 102 | |
| 103 | private final MockPathResourceService resourceService = new MockPathResourceService(); |
| 104 | private final MockDeviceService deviceService = new MockDeviceService(); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 105 | private final MockNetConfigRegistryAdapter netConfigRegistry = new MockNetConfigRegistryAdapter(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 106 | private PceManager pceManager = new PceManager(); |
| 107 | public static ProviderId providerId = new ProviderId("pce", "foo"); |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 108 | public static final String DEVICE1 = "D001"; |
| 109 | public static final String DEVICE2 = "D002"; |
| 110 | public static final String DEVICE3 = "D003"; |
| 111 | public static final String DEVICE4 = "D004"; |
| 112 | public static final String DEVICE5 = "D005"; |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 113 | public static final String PCEPDEVICE1 = "PD001"; |
| 114 | public static final String PCEPDEVICE2 = "PD002"; |
| 115 | public static final String PCEPDEVICE3 = "PD003"; |
| 116 | public static final String PCEPDEVICE4 = "PD004"; |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 117 | public static final TopologyVertex D1 = new DefaultTopologyVertex(DeviceId.deviceId("D001")); |
| 118 | public static final TopologyVertex D2 = new DefaultTopologyVertex(DeviceId.deviceId("D002")); |
| 119 | public static final TopologyVertex D3 = new DefaultTopologyVertex(DeviceId.deviceId("D003")); |
| 120 | public static final TopologyVertex D4 = new DefaultTopologyVertex(DeviceId.deviceId("D004")); |
| 121 | public static final TopologyVertex D5 = new DefaultTopologyVertex(DeviceId.deviceId("D005")); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 122 | private static final String ANNOTATION_COST = "cost"; |
| 123 | private static final String ANNOTATION_TE_COST = "teCost"; |
| 124 | private static final String UNKNOWN = "unknown"; |
| 125 | public static final String LSRID = "lsrId"; |
| 126 | public static final String L3 = "L3"; |
| 127 | public static final String PCECC_CAPABILITY = "pceccCapability"; |
| 128 | public static final String SR_CAPABILITY = "srCapability"; |
| 129 | public static final String LABEL_STACK_CAPABILITY = "labelStackCapability"; |
| 130 | |
| 131 | @Before |
| 132 | public void startUp() { |
| 133 | pceManager.resourceService = resourceService; |
| 134 | pceManager.deviceService = deviceService; |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 135 | pceManager.netCfgService = netConfigRegistry; |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Selects path computation algorithm. |
| 140 | * |
| 141 | * @return graph path search algorithm |
| 142 | */ |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 143 | public static AbstractGraphPathSearch<TopologyVertex, TopologyEdge> graphSearch() { |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 144 | return new DijkstraGraphSearch<>(); |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Returns link for two devices. |
| 149 | * |
| 150 | * @param device source device |
| 151 | * @param port source port |
| 152 | * @param device2 destination device |
| 153 | * @param port2 destination port |
| 154 | * @return link |
| 155 | */ |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 156 | public static Link addLink(String device, long port, String device2, long port2, boolean setCost, int value) { |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 157 | ConnectPoint src = new ConnectPoint(DeviceId.deviceId(device), PortNumber.portNumber(port)); |
| 158 | ConnectPoint dst = new ConnectPoint(DeviceId.deviceId(device2), PortNumber.portNumber(port2)); |
| 159 | Link curLink; |
| 160 | DefaultAnnotations.Builder annotationBuilder = DefaultAnnotations.builder(); |
| 161 | if (setCost) { |
| 162 | annotationBuilder.set(ANNOTATION_COST, String.valueOf(value)); |
| 163 | } else { |
| 164 | annotationBuilder.set(ANNOTATION_TE_COST, String.valueOf(value)); |
| 165 | } |
| 166 | |
| 167 | //TODO:If cost not set cost : default value case |
| 168 | curLink = DefaultLink.builder().src(src).dst(dst).state(ACTIVE).type(DIRECT) |
| 169 | .providerId(PathComputationTest.providerId).annotations(annotationBuilder.build()).build(); |
| 170 | return curLink; |
| 171 | } |
| 172 | |
| 173 | @After |
| 174 | public void tearDown() { |
| 175 | pceManager.resourceService = null; |
| 176 | pceManager.deviceService = null; |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 177 | pceManager.netCfgService = null; |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | /** |
| 181 | * Returns an edge-weight capable of evaluating links on the basis of the |
| 182 | * specified constraints. |
| 183 | * |
| 184 | * @param constraints path constraints |
| 185 | * @return edge-weight function |
| 186 | */ |
| 187 | private LinkWeight weight(List<Constraint> constraints) { |
| 188 | return new MockTeConstraintBasedLinkWeight(constraints); |
| 189 | } |
| 190 | |
| 191 | private Set<Path> computePath(Link link1, Link link2, Link link3, Link link4, List<Constraint> constraints) { |
| 192 | Graph<TopologyVertex, TopologyEdge> graph = new AdjacencyListsGraph<>(of(D1, D2, D3, D4), |
| 193 | of(new DefaultTopologyEdge(D1, D2, link1), |
| 194 | new DefaultTopologyEdge(D2, D4, link2), |
| 195 | new DefaultTopologyEdge(D1, D3, link3), |
| 196 | new DefaultTopologyEdge(D3, D4, link4))); |
| 197 | |
| 198 | GraphPathSearch.Result<TopologyVertex, TopologyEdge> result = |
| 199 | graphSearch().search(graph, D1, D4, weight(constraints), ALL_PATHS); |
| 200 | ImmutableSet.Builder<Path> builder = ImmutableSet.builder(); |
| 201 | for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) { |
| 202 | builder.add(networkPath(path)); |
| 203 | } |
| 204 | return builder.build(); |
| 205 | } |
| 206 | |
| 207 | private class MockDeviceService extends DeviceServiceAdapter { |
| 208 | List<Device> devices = new LinkedList<>(); |
| 209 | |
| 210 | private void addDevice(Device dev) { |
| 211 | devices.add(dev); |
| 212 | } |
| 213 | |
| 214 | @Override |
| 215 | public Device getDevice(DeviceId deviceId) { |
| 216 | for (Device dev : devices) { |
| 217 | if (dev.id().equals(deviceId)) { |
| 218 | return dev; |
| 219 | } |
| 220 | } |
| 221 | return null; |
| 222 | } |
| 223 | |
| 224 | @Override |
| 225 | public Iterable<Device> getAvailableDevices() { |
| 226 | return devices; |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | private class MockTeConstraintBasedLinkWeight implements LinkWeight { |
| 231 | |
| 232 | private final List<Constraint> constraints; |
| 233 | |
| 234 | /** |
| 235 | * Creates a new edge-weight function capable of evaluating links |
| 236 | * on the basis of the specified constraints. |
| 237 | * |
| 238 | * @param constraints path constraints |
| 239 | */ |
| 240 | MockTeConstraintBasedLinkWeight(List<Constraint> constraints) { |
| 241 | if (constraints == null) { |
| 242 | this.constraints = Collections.emptyList(); |
| 243 | } else { |
| 244 | this.constraints = ImmutableList.copyOf(constraints); |
| 245 | } |
| 246 | } |
| 247 | |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 248 | @Override |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 249 | public double weight(TopologyEdge edge) { |
| 250 | if (!constraints.iterator().hasNext()) { |
| 251 | //Takes default cost/hopcount as 1 if no constraints specified |
| 252 | return 1.0; |
| 253 | } |
| 254 | |
| 255 | Iterator<Constraint> it = constraints.iterator(); |
| 256 | double cost = 1; |
| 257 | |
| 258 | //If any constraint fails return -1 also value of cost returned from cost constraint can't be negative |
| 259 | while (it.hasNext() && cost > 0) { |
| 260 | Constraint constraint = it.next(); |
| 261 | if (constraint instanceof CapabilityConstraint) { |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 262 | cost = ((CapabilityConstraint) constraint).isValidLink(edge.link(), deviceService, |
| 263 | netConfigRegistry) ? 1 : -1; |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 264 | } else { |
| 265 | cost = constraint.cost(edge.link(), resourceService::isAvailable); |
| 266 | } |
| 267 | } |
| 268 | return cost; |
| 269 | } |
| 270 | } |
| 271 | |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 272 | /** |
| 273 | * Returns the path in Path object format. |
| 274 | */ |
| 275 | public static Path networkPath(org.onlab.graph.Path<TopologyVertex, TopologyEdge> path) { |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 276 | List<Link> links = path.edges().stream().map(TopologyEdge::link).collect(Collectors.toList()); |
| 277 | return new DefaultPath(CORE_PROVIDER_ID, links, path.cost()); |
| 278 | } |
| 279 | |
| 280 | /** |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 281 | * Tests Resource service for path computation. |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 282 | */ |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 283 | public class MockPathResourceService extends ResourceServiceAdapter { |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 284 | private final Map<Resource, ResourceConsumer> assignment = new HashMap<>(); |
| 285 | private Map<ResourceId, List<ResourceAllocation>> resourcesAllocations = new HashMap<>(); |
| 286 | |
| 287 | @Override |
Avantika-Huawei | dbdf772 | 2016-05-21 14:20:31 +0530 | [diff] [blame] | 288 | public Optional<ResourceAllocation> allocate(ResourceConsumer consumer, Resource resources) { |
| 289 | List<ResourceAllocation> allocations = allocate(consumer, ImmutableList.of(resources)); |
| 290 | if (allocations.isEmpty()) { |
| 291 | return Optional.empty(); |
| 292 | } |
| 293 | |
| 294 | assert allocations.size() == 1; |
| 295 | ResourceAllocation allocation = allocations.get(0); |
| 296 | assert allocation.resource().equals(resources); |
| 297 | |
| 298 | // cast is ensured by the assertions above |
| 299 | return Optional.of(allocation); |
| 300 | } |
| 301 | |
| 302 | @Override |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 303 | public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) { |
| 304 | for (Resource resource: resources) { |
| 305 | if (resource instanceof ContinuousResource) { |
| 306 | List<ResourceAllocation> allocs = new LinkedList<>(); |
| 307 | allocs.add(new ResourceAllocation(resource, consumer)); |
| 308 | resourcesAllocations.put(resource.id(), allocs); |
| 309 | } |
| 310 | } |
| 311 | return resources.stream() |
| 312 | .map(x -> new ResourceAllocation(x, consumer)) |
| 313 | .collect(Collectors.toList()); |
| 314 | } |
| 315 | |
| 316 | @Override |
| 317 | public List<ResourceAllocation> getResourceAllocations(ResourceId id) { |
| 318 | if (id instanceof ContinuousResourceId) { |
| 319 | return resourcesAllocations.get(id); |
| 320 | } |
| 321 | DiscreteResource discrete = Resources.discrete((DiscreteResourceId) id).resource(); |
| 322 | return Optional.ofNullable(assignment.get(discrete)) |
| 323 | .map(x -> ImmutableList.of(new ResourceAllocation(discrete, x))) |
| 324 | .orElse(ImmutableList.of()); |
| 325 | } |
| 326 | |
| 327 | @Override |
| 328 | public <T> Set<Resource> getAvailableResources(DiscreteResourceId parent, Class<T> cls) { |
| 329 | return getAvailableResources(parent).stream() |
| 330 | .filter(x -> x.isTypeOf(cls)) |
| 331 | .collect(Collectors.toSet()); |
| 332 | } |
| 333 | |
| 334 | @Override |
| 335 | public <T> Set<T> getAvailableResourceValues(DiscreteResourceId parent, Class<T> cls) { |
| 336 | return getAvailableResources(parent).stream() |
| 337 | .filter(x -> x.isTypeOf(cls)) |
| 338 | .flatMap(x -> Tools.stream(x.valueAs(cls))) |
| 339 | .collect(Collectors.toSet()); |
| 340 | } |
| 341 | |
| 342 | @Override |
| 343 | public boolean isAvailable(Resource resource) { |
| 344 | if (resource instanceof DiscreteResource) { |
| 345 | return true; |
| 346 | } |
| 347 | |
| 348 | if (resource instanceof ContinuousResource) { |
| 349 | List<ResourceAllocation> resalloc = resourcesAllocations.get(resource.id()); |
| 350 | |
| 351 | if ((resalloc != null) && (!resalloc.isEmpty())) { |
| 352 | if (((ContinuousResource) resalloc.iterator().next().resource()).value() |
| 353 | >= ((ContinuousResource) resource).value()) { |
| 354 | return true; |
| 355 | } |
| 356 | } |
| 357 | } |
| 358 | return false; |
| 359 | } |
| 360 | } |
| 361 | |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 362 | /* Mock test for network config registry. */ |
| 363 | public static class MockNetConfigRegistryAdapter extends NetworkConfigRegistryAdapter { |
| 364 | private ConfigFactory cfgFactory; |
| 365 | private Map<DeviceId, DeviceCapability> classConfig = new HashMap<>(); |
| 366 | |
| 367 | @Override |
| 368 | public void registerConfigFactory(ConfigFactory configFactory) { |
| 369 | cfgFactory = configFactory; |
| 370 | } |
| 371 | |
| 372 | @Override |
| 373 | public void unregisterConfigFactory(ConfigFactory configFactory) { |
| 374 | cfgFactory = null; |
| 375 | } |
| 376 | |
| 377 | @Override |
| 378 | public <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass) { |
| 379 | if (configClass == DeviceCapability.class) { |
| 380 | DeviceCapability devCap = new DeviceCapability(); |
| 381 | classConfig.put((DeviceId) subject, devCap); |
| 382 | |
| 383 | JsonNode node = new ObjectNode(new MockJsonNode()); |
| 384 | ObjectMapper mapper = new ObjectMapper(); |
| 385 | ConfigApplyDelegate delegate = new InternalApplyDelegate(); |
| 386 | devCap.init((DeviceId) subject, null, node, mapper, delegate); |
| 387 | return (C) devCap; |
| 388 | } |
| 389 | |
| 390 | return null; |
| 391 | } |
| 392 | |
| 393 | @Override |
| 394 | public <S, C extends Config<S>> void removeConfig(S subject, Class<C> configClass) { |
| 395 | classConfig.remove(subject); |
| 396 | } |
| 397 | |
| 398 | @Override |
| 399 | public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) { |
| 400 | if (configClass == DeviceCapability.class) { |
| 401 | return (C) classConfig.get(subject); |
| 402 | } |
| 403 | return null; |
| 404 | } |
| 405 | |
| 406 | private class MockJsonNode extends JsonNodeFactory { |
| 407 | } |
| 408 | |
| 409 | // Auxiliary delegate to receive notifications about changes applied to |
| 410 | // the network configuration - by the apps. |
| 411 | private class InternalApplyDelegate implements ConfigApplyDelegate { |
| 412 | @Override |
| 413 | public void onApply(Config config) { |
| 414 | //configs.put(config.subject(), config.node()); |
| 415 | } |
| 416 | } |
| 417 | } |
| 418 | |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 419 | /** |
| 420 | * All links with different costs with L1-L2 as least cost path. |
| 421 | */ |
| 422 | @Test |
| 423 | public void testpathComputationCase1() { |
| 424 | Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50); |
| 425 | Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 20); |
| 426 | Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100); |
| 427 | Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 50); |
| 428 | |
| 429 | CostConstraint costConst = CostConstraint.of(COST); |
| 430 | List<Constraint> constraints = new LinkedList<>(); |
| 431 | constraints.add(costConst); |
| 432 | |
| 433 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 434 | |
| 435 | List<Link> links = new LinkedList<>(); |
| 436 | |
| 437 | links.add(link1); |
| 438 | links.add(link2); |
| 439 | |
| 440 | assertThat(paths.iterator().next().links(), is(links)); |
| 441 | assertThat(paths.iterator().next().cost(), is((double) 70)); |
| 442 | } |
| 443 | |
| 444 | /** |
| 445 | * Links with same cost 100 except link3. |
| 446 | */ |
| 447 | @Test |
| 448 | public void testpathComputationCase2() { |
| 449 | Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 100); |
| 450 | Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 100); |
| 451 | Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 1000); |
| 452 | Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 100); |
| 453 | |
| 454 | CostConstraint costConst = CostConstraint.of(COST); |
| 455 | List<Constraint> constraints = new LinkedList<>(); |
| 456 | constraints.add(costConst); |
| 457 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 458 | |
| 459 | List<Link> links = new LinkedList<>(); |
| 460 | links.add(link1); |
| 461 | links.add(link2); |
| 462 | |
| 463 | assertThat(paths.iterator().next().links(), is(links)); |
| 464 | assertThat(paths.iterator().next().cost(), is((double) 200)); |
| 465 | } |
| 466 | |
| 467 | /** |
| 468 | * Path which satisfy bandwidth as a constraint with 10bps. |
| 469 | */ |
| 470 | @Test |
| 471 | public void testpathComputationCase3() { |
| 472 | Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50); |
| 473 | Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 20); |
| 474 | Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100); |
| 475 | Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 50); |
| 476 | |
| 477 | List<Resource> resources = new LinkedList<>(); |
| 478 | |
| 479 | resources.add(continuous(link1.src().deviceId(), link1.src().port(), Bandwidth.class) |
| 480 | .resource(50)); |
| 481 | resources.add(continuous(link2.src().deviceId(), link2.src().port(), Bandwidth.class) |
| 482 | .resource(50)); |
| 483 | resources.add(continuous(link3.src().deviceId(), link3.src().port(), Bandwidth.class) |
| 484 | .resource(100)); |
| 485 | resources.add(continuous(link4.src().deviceId(), link4.src().port(), Bandwidth.class) |
| 486 | .resource(100)); |
| 487 | |
| 488 | resources.add(continuous(link1.dst().deviceId(), link1.dst().port(), Bandwidth.class) |
| 489 | .resource(50)); |
| 490 | resources.add(continuous(link2.dst().deviceId(), link2.dst().port(), Bandwidth.class) |
| 491 | .resource(50)); |
| 492 | resources.add(continuous(link3.dst().deviceId(), link3.src().port(), Bandwidth.class) |
| 493 | .resource(100)); |
| 494 | resources.add(continuous(link4.dst().deviceId(), link4.dst().port(), Bandwidth.class) |
| 495 | .resource(100)); |
| 496 | |
| 497 | resourceService.allocate(IntentId.valueOf(70), resources); |
| 498 | |
| 499 | BandwidthConstraint bandwidthConst = new BandwidthConstraint(Bandwidth.bps(10.0)); |
| 500 | |
| 501 | List<Constraint> constraints = new LinkedList<>(); |
| 502 | constraints.add(bandwidthConst); |
| 503 | |
| 504 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 505 | |
| 506 | assertThat(paths.iterator().next().cost(), is((double) 2)); |
| 507 | } |
| 508 | |
| 509 | /** |
| 510 | * Path which satisfy bandwidth as a constraint with 60bps. |
| 511 | */ |
| 512 | @Test |
| 513 | public void testpathComputationCase4() { |
| 514 | Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50); |
| 515 | Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 50); |
| 516 | Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100); |
| 517 | Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 100); |
| 518 | |
| 519 | List<Resource> resources = new LinkedList<>(); |
| 520 | |
| 521 | resources.add(continuous(link1.src().deviceId(), link1.src().port(), Bandwidth.class).resource(50)); |
| 522 | resources.add(continuous(link2.src().deviceId(), link2.src().port(), Bandwidth.class).resource(50)); |
| 523 | resources.add(continuous(link3.src().deviceId(), link3.src().port(), Bandwidth.class).resource(100)); |
| 524 | resources.add(continuous(link4.src().deviceId(), link4.src().port(), Bandwidth.class).resource(100)); |
| 525 | |
| 526 | resources.add(continuous(link1.dst().deviceId(), link1.dst().port(), Bandwidth.class).resource(50)); |
| 527 | resources.add(continuous(link2.dst().deviceId(), link2.dst().port(), Bandwidth.class).resource(50)); |
| 528 | resources.add(continuous(link3.dst().deviceId(), link3.dst().port(), Bandwidth.class).resource(100)); |
| 529 | resources.add(continuous(link4.dst().deviceId(), link4.dst().port(), Bandwidth.class).resource(100)); |
| 530 | |
| 531 | resourceService.allocate(IntentId.valueOf(70), resources); |
| 532 | |
| 533 | BandwidthConstraint bandwidthConst = new BandwidthConstraint(Bandwidth.bps(60.0)); |
| 534 | |
| 535 | List<Constraint> constraints = new LinkedList<>(); |
| 536 | constraints.add(bandwidthConst); |
| 537 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 538 | |
| 539 | assertThat(paths.iterator().next().cost(), is((double) 2)); |
| 540 | } |
| 541 | |
| 542 | /** |
| 543 | * Shared bandwidth as L1, L2 with its value 10 bps and bandwidth constraint as 20 bps. |
| 544 | */ |
| 545 | @Test |
| 546 | public void testpathComputationCase5() { |
| 547 | Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50); |
| 548 | Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 20); |
| 549 | Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100); |
| 550 | Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 80); |
| 551 | |
| 552 | List<Resource> resources = new LinkedList<>(); |
| 553 | |
| 554 | resources.add(continuous(link1.src().deviceId(), link1.src().port(), Bandwidth.class).resource(50)); |
| 555 | resources.add(continuous(link2.src().deviceId(), link2.src().port(), Bandwidth.class).resource(50)); |
| 556 | resources.add(continuous(link3.src().deviceId(), link3.src().port(), Bandwidth.class).resource(100)); |
| 557 | resources.add(continuous(link4.src().deviceId(), link4.src().port(), Bandwidth.class).resource(100)); |
| 558 | |
| 559 | resources.add(continuous(link1.dst().deviceId(), link1.dst().port(), Bandwidth.class).resource(50)); |
| 560 | resources.add(continuous(link2.dst().deviceId(), link2.dst().port(), Bandwidth.class).resource(50)); |
| 561 | resources.add(continuous(link3.dst().deviceId(), link3.dst().port(), Bandwidth.class).resource(100)); |
| 562 | resources.add(continuous(link4.dst().deviceId(), link4.dst().port(), Bandwidth.class).resource(100)); |
| 563 | resourceService.allocate(IntentId.valueOf(70), resources); |
| 564 | |
| 565 | List<Constraint> constraints = new LinkedList<>(); |
| 566 | |
| 567 | List<Link> sharedLinks = new LinkedList<>(); |
| 568 | |
| 569 | List<Link> links = new LinkedList<>(); |
| 570 | links.add(link1); |
| 571 | links.add(link2); |
| 572 | |
| 573 | CostConstraint costConst = CostConstraint.of(COST); |
| 574 | sharedLinks.addAll(links); |
| 575 | SharedBandwidthConstraint sharedBw = new SharedBandwidthConstraint(sharedLinks, Bandwidth.bps(10), |
| 576 | Bandwidth.bps(20.0)); |
| 577 | constraints.add(sharedBw); |
| 578 | constraints.add(costConst); |
| 579 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 580 | assertThat(paths.iterator().next().links(), is(links)); |
| 581 | assertThat(paths.iterator().next().cost(), is((double) 70)); |
| 582 | } |
| 583 | |
| 584 | /** |
| 585 | * Shared bandwidth as L1, L2 with its value 20 bps and bandwidth constraint as 10 bps. |
| 586 | */ |
| 587 | @Test |
| 588 | public void testpathComputationCase6() { |
| 589 | Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50); |
| 590 | Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 20); |
| 591 | Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100); |
| 592 | Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 80); |
| 593 | |
| 594 | List<Resource> resources = new LinkedList<>(); |
| 595 | |
| 596 | resources.add(continuous(link1.src().deviceId(), link1.src().port(), Bandwidth.class).resource(50)); |
| 597 | resources.add(continuous(link2.src().deviceId(), link2.src().port(), Bandwidth.class).resource(50)); |
| 598 | resources.add(continuous(link3.src().deviceId(), link3.src().port(), Bandwidth.class).resource(100)); |
| 599 | resources.add(continuous(link4.src().deviceId(), link4.src().port(), Bandwidth.class).resource(100)); |
| 600 | |
| 601 | resources.add(continuous(link1.dst().deviceId(), link1.dst().port(), Bandwidth.class).resource(50)); |
| 602 | resources.add(continuous(link2.dst().deviceId(), link2.dst().port(), Bandwidth.class).resource(50)); |
| 603 | resources.add(continuous(link3.dst().deviceId(), link3.dst().port(), Bandwidth.class).resource(100)); |
| 604 | resources.add(continuous(link4.dst().deviceId(), link4.dst().port(), Bandwidth.class).resource(100)); |
| 605 | resourceService.allocate(IntentId.valueOf(70), resources); |
| 606 | |
| 607 | List<Constraint> constraints = new LinkedList<>(); |
| 608 | |
| 609 | List<Link> sharedLinks = new LinkedList<>(); |
| 610 | |
| 611 | List<Link> links = new LinkedList<>(); |
| 612 | links.add(link1); |
| 613 | links.add(link2); |
| 614 | CostConstraint costConst = CostConstraint.of(COST); |
| 615 | sharedLinks.addAll(links); |
| 616 | SharedBandwidthConstraint sharedBwConst = new SharedBandwidthConstraint(sharedLinks, Bandwidth.bps(20), |
| 617 | Bandwidth.bps(10.0)); |
| 618 | constraints.add(sharedBwConst); |
| 619 | constraints.add(costConst); |
| 620 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 621 | |
| 622 | assertThat(paths.iterator().next().links(), is(links)); |
| 623 | assertThat(paths.iterator().next().cost(), is((double) 70)); |
| 624 | } |
| 625 | |
| 626 | /** |
| 627 | * Path without constraints. |
| 628 | */ |
| 629 | @Test |
| 630 | public void testpathComputationCase7() { |
| 631 | Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50); |
| 632 | Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 20); |
| 633 | Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100); |
| 634 | Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 80); |
| 635 | List<Constraint> constraints = new LinkedList<>(); |
| 636 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 637 | |
| 638 | assertThat(paths.iterator().next().cost(), is((double) 2)); |
| 639 | } |
| 640 | |
| 641 | /** |
| 642 | * With TeCost as a constraints. |
| 643 | */ |
| 644 | @Test |
| 645 | public void testpathComputationCase8() { |
| 646 | Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, false, 50); |
| 647 | Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, false, 20); |
| 648 | Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, false, 100); |
| 649 | Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, false, 80); |
| 650 | |
| 651 | CostConstraint tecostConst = CostConstraint.of(TE_COST); |
| 652 | |
| 653 | List<Constraint> constraints = new LinkedList<>(); |
| 654 | constraints.add(tecostConst); |
| 655 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 656 | |
| 657 | List<Link> links = new LinkedList<>(); |
| 658 | links.add(link1); |
| 659 | links.add(link2); |
| 660 | assertThat(paths.iterator().next().links(), is(links)); |
| 661 | assertThat(paths.iterator().next().cost(), is((double) 70)); |
| 662 | } |
| 663 | |
| 664 | /** |
| 665 | * With device supporting RSVP capability as a constraints. |
| 666 | */ |
| 667 | @Test |
| 668 | public void testpathComputationCase9() { |
| 669 | Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, false, 50); |
| 670 | Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, false, 20); |
| 671 | Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, false, 100); |
| 672 | Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, false, 80); |
| 673 | |
| 674 | CostConstraint tecostConst = CostConstraint.of(TE_COST); |
| 675 | CapabilityConstraint capabilityConst = CapabilityConstraint |
| 676 | .of(CapabilityConstraint.CapabilityType.WITH_SIGNALLING); |
| 677 | |
| 678 | List<Constraint> constraints = new LinkedList<>(); |
| 679 | constraints.add(capabilityConst); |
| 680 | constraints.add(tecostConst); |
| 681 | //Device1 |
| 682 | DefaultAnnotations.Builder builder = DefaultAnnotations.builder(); |
| 683 | builder.set(AnnotationKeys.TYPE, L3); |
| 684 | builder.set(LSRID, "1.1.1.1"); |
| 685 | addDevice(DEVICE1, builder); |
| 686 | |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 687 | DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class); |
| 688 | device1Cap.setLabelStackCap(false) |
| 689 | .setLocalLabelCap(false) |
| 690 | .setSrCap(false) |
| 691 | .apply(); |
| 692 | |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 693 | //Device2 |
| 694 | builder = DefaultAnnotations.builder(); |
| 695 | builder.set(AnnotationKeys.TYPE, L3); |
| 696 | builder.set(LSRID, "2.2.2.2"); |
| 697 | addDevice(DEVICE2, builder); |
| 698 | |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 699 | DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class); |
| 700 | device2Cap.setLabelStackCap(false) |
| 701 | .setLocalLabelCap(false) |
| 702 | .setSrCap(false) |
| 703 | .apply(); |
| 704 | |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 705 | //Device3 |
| 706 | builder = DefaultAnnotations.builder(); |
| 707 | builder.set(AnnotationKeys.TYPE, L3); |
| 708 | builder.set(LSRID, "3.3.3.3"); |
| 709 | addDevice(DEVICE3, builder); |
| 710 | |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 711 | DeviceCapability device3Cap = netConfigRegistry.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class); |
| 712 | device3Cap.setLabelStackCap(false) |
| 713 | .setLocalLabelCap(false) |
| 714 | .setSrCap(false) |
| 715 | .apply(); |
| 716 | |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 717 | //Device4 |
| 718 | builder = DefaultAnnotations.builder(); |
| 719 | builder.set(AnnotationKeys.TYPE, L3); |
| 720 | builder.set(LSRID, "4.4.4.4"); |
| 721 | addDevice(DEVICE4, builder); |
| 722 | |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 723 | DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class); |
| 724 | device4Cap.setLabelStackCap(false) |
| 725 | .setLocalLabelCap(false) |
| 726 | .setSrCap(false) |
| 727 | .apply(); |
| 728 | |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 729 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 730 | |
| 731 | List<Link> links = new LinkedList<>(); |
| 732 | links.add(link1); |
| 733 | links.add(link2); |
| 734 | assertThat(paths.iterator().next().links(), is(links)); |
| 735 | assertThat(paths.iterator().next().cost(), is((double) 70)); |
| 736 | } |
| 737 | |
| 738 | /** |
| 739 | * Devices supporting CR capability. |
| 740 | */ |
| 741 | @Test |
| 742 | public void testpathComputationCase10() { |
| 743 | Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50); |
| 744 | Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 20); |
| 745 | Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100); |
| 746 | Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 80); |
| 747 | |
| 748 | CapabilityConstraint capabilityConst = CapabilityConstraint |
| 749 | .of(CapabilityConstraint.CapabilityType.WITHOUT_SIGNALLING_AND_WITHOUT_SR); |
| 750 | |
| 751 | List<Constraint> constraints = new LinkedList<>(); |
| 752 | constraints.add(capabilityConst); |
| 753 | CostConstraint costConst = CostConstraint.of(COST); |
| 754 | constraints.add(costConst); |
| 755 | //Device1 |
| 756 | DefaultAnnotations.Builder builder = DefaultAnnotations.builder(); |
| 757 | builder.set(AnnotationKeys.TYPE, L3); |
| 758 | builder.set(LSRID, "1.1.1.1"); |
| 759 | addDevice(DEVICE1, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 760 | DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class); |
| 761 | device1Cap.setLabelStackCap(false) |
| 762 | .setLocalLabelCap(true) |
| 763 | .setSrCap(false) |
| 764 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 765 | |
| 766 | //Device2 |
| 767 | builder = DefaultAnnotations.builder(); |
| 768 | builder.set(AnnotationKeys.TYPE, L3); |
| 769 | builder.set(LSRID, "2.2.2.2"); |
| 770 | addDevice(DEVICE2, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 771 | DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class); |
| 772 | device2Cap.setLabelStackCap(false) |
| 773 | .setLocalLabelCap(true) |
| 774 | .setSrCap(false) |
| 775 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 776 | |
| 777 | //Device3 |
| 778 | builder = DefaultAnnotations.builder(); |
| 779 | builder.set(AnnotationKeys.TYPE, L3); |
| 780 | builder.set(LSRID, "3.3.3.3"); |
| 781 | addDevice(DEVICE3, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 782 | DeviceCapability device3Cap = netConfigRegistry.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class); |
| 783 | device3Cap.setLabelStackCap(false) |
| 784 | .setLocalLabelCap(true) |
| 785 | .setSrCap(false) |
| 786 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 787 | |
| 788 | //Device4 |
| 789 | builder = DefaultAnnotations.builder(); |
| 790 | builder.set(AnnotationKeys.TYPE, L3); |
| 791 | builder.set(LSRID, "4.4.4.4"); |
| 792 | addDevice(DEVICE4, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 793 | DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class); |
| 794 | device4Cap.setLabelStackCap(false) |
| 795 | .setLocalLabelCap(true) |
| 796 | .setSrCap(false) |
| 797 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 798 | |
| 799 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 800 | |
| 801 | List<Link> links = new LinkedList<>(); |
| 802 | links.add(link1); |
| 803 | links.add(link2); |
| 804 | assertThat(paths.iterator().next().links(), is(links)); |
| 805 | assertThat(paths.iterator().next().cost(), is((double) 70)); |
| 806 | } |
| 807 | |
| 808 | /** |
| 809 | * Device supporting SR capability. |
| 810 | */ |
| 811 | @Test |
| 812 | public void testpathComputationCase11() { |
| 813 | Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50); |
| 814 | Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 20); |
| 815 | Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100); |
| 816 | Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 80); |
| 817 | |
| 818 | CapabilityConstraint capabilityConst = CapabilityConstraint |
| 819 | .of(CapabilityConstraint.CapabilityType.SR_WITHOUT_SIGNALLING); |
| 820 | |
| 821 | List<Constraint> constraints = new LinkedList<>(); |
| 822 | constraints.add(capabilityConst); |
| 823 | CostConstraint costConst = CostConstraint.of(COST); |
| 824 | constraints.add(costConst); |
| 825 | //Device1 |
| 826 | DefaultAnnotations.Builder builder = DefaultAnnotations.builder(); |
| 827 | builder.set(AnnotationKeys.TYPE, L3); |
| 828 | builder.set(LSRID, "1.1.1.1"); |
| 829 | addDevice(DEVICE1, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 830 | DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class); |
| 831 | device1Cap.setLabelStackCap(true) |
| 832 | .setLocalLabelCap(false) |
| 833 | .setSrCap(true) |
| 834 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 835 | |
| 836 | //Device2 |
| 837 | builder = DefaultAnnotations.builder(); |
| 838 | builder.set(AnnotationKeys.TYPE, L3); |
| 839 | builder.set(LSRID, "2.2.2.2"); |
| 840 | addDevice(DEVICE2, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 841 | DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class); |
| 842 | device2Cap.setLabelStackCap(true) |
| 843 | .setLocalLabelCap(false) |
| 844 | .setSrCap(true) |
| 845 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 846 | |
| 847 | //Device3 |
| 848 | builder = DefaultAnnotations.builder(); |
| 849 | builder.set(AnnotationKeys.TYPE, L3); |
| 850 | builder.set(LSRID, "3.3.3.3"); |
| 851 | addDevice(DEVICE3, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 852 | DeviceCapability device3Cap = netConfigRegistry.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class); |
| 853 | device3Cap.setLabelStackCap(true) |
| 854 | .setLocalLabelCap(false) |
| 855 | .setSrCap(true) |
| 856 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 857 | |
| 858 | //Device4 |
| 859 | builder = DefaultAnnotations.builder(); |
| 860 | builder.set(AnnotationKeys.TYPE, L3); |
| 861 | builder.set(LSRID, "4.4.4.4"); |
| 862 | addDevice(DEVICE4, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 863 | DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class); |
| 864 | device4Cap.setLabelStackCap(true) |
| 865 | .setLocalLabelCap(false) |
| 866 | .setSrCap(true) |
| 867 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 868 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 869 | |
| 870 | List<Link> links = new LinkedList<>(); |
| 871 | links.add(link1); |
| 872 | links.add(link2); |
| 873 | assertThat(paths.iterator().next().links(), is(links)); |
| 874 | assertThat(paths.iterator().next().cost(), is((double) 70)); |
| 875 | } |
| 876 | |
| 877 | /** |
| 878 | * Path with TE and SR capability constraint. |
| 879 | */ |
| 880 | @Test |
| 881 | public void testpathComputationCase12() { |
| 882 | Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, false, 50); |
| 883 | Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, false, 20); |
| 884 | Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, false, 100); |
| 885 | Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, false, 80); |
| 886 | |
| 887 | CostConstraint tecostConst = CostConstraint.of(TE_COST); |
| 888 | CapabilityConstraint capabilityConst = CapabilityConstraint |
| 889 | .of(CapabilityConstraint.CapabilityType.SR_WITHOUT_SIGNALLING); |
| 890 | |
| 891 | List<Constraint> constraints = new LinkedList<>(); |
| 892 | |
| 893 | constraints.add(capabilityConst); |
| 894 | constraints.add(tecostConst); |
| 895 | //Device1 |
| 896 | DefaultAnnotations.Builder builder = DefaultAnnotations.builder(); |
| 897 | builder.set(AnnotationKeys.TYPE, L3); |
| 898 | builder.set(LSRID, "1.1.1.1"); |
| 899 | addDevice(DEVICE1, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 900 | DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class); |
| 901 | device1Cap.setLabelStackCap(true) |
| 902 | .setLocalLabelCap(false) |
| 903 | .setSrCap(true) |
| 904 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 905 | |
| 906 | //Device2 |
| 907 | builder = DefaultAnnotations.builder(); |
| 908 | builder.set(AnnotationKeys.TYPE, L3); |
| 909 | builder.set(LSRID, "2.2.2.2"); |
| 910 | addDevice(DEVICE2, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 911 | DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class); |
| 912 | device2Cap.setLabelStackCap(true) |
| 913 | .setLocalLabelCap(false) |
| 914 | .setSrCap(true) |
| 915 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 916 | |
| 917 | //Device3 |
| 918 | builder = DefaultAnnotations.builder(); |
| 919 | builder.set(AnnotationKeys.TYPE, L3); |
| 920 | builder.set(LSRID, "3.3.3.3"); |
| 921 | addDevice(DEVICE3, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 922 | DeviceCapability device3Cap = netConfigRegistry.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class); |
| 923 | device3Cap.setLabelStackCap(true) |
| 924 | .setLocalLabelCap(false) |
| 925 | .setSrCap(true) |
| 926 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 927 | |
| 928 | //Device4 |
| 929 | builder = DefaultAnnotations.builder(); |
| 930 | builder.set(AnnotationKeys.TYPE, L3); |
| 931 | builder.set(LSRID, "4.4.4.4"); |
| 932 | addDevice(DEVICE4, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 933 | DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class); |
| 934 | device4Cap.setLabelStackCap(true) |
| 935 | .setLocalLabelCap(false) |
| 936 | .setSrCap(true) |
| 937 | .apply(); |
| 938 | |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 939 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 940 | |
| 941 | List<Link> links = new LinkedList<>(); |
| 942 | links.add(link1); |
| 943 | links.add(link2); |
| 944 | assertThat(paths.iterator().next().links(), is(links)); |
| 945 | assertThat(paths.iterator().next().cost(), is((double) 70)); |
| 946 | } |
| 947 | |
| 948 | /** |
| 949 | * Path with capability constraint and with default cost. |
| 950 | */ |
| 951 | @Test |
| 952 | public void testpathComputationCase13() { |
| 953 | Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, false, 50); |
| 954 | Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, false, 20); |
| 955 | Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, false, 100); |
| 956 | Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, false, 80); |
| 957 | |
| 958 | CapabilityConstraint capabilityConst = CapabilityConstraint |
| 959 | .of(CapabilityConstraint.CapabilityType.SR_WITHOUT_SIGNALLING); |
| 960 | |
| 961 | List<Constraint> constraints = new LinkedList<>(); |
| 962 | constraints.add(capabilityConst); |
| 963 | //Device1 |
| 964 | DefaultAnnotations.Builder builder = DefaultAnnotations.builder(); |
| 965 | builder.set(AnnotationKeys.TYPE, L3); |
| 966 | builder.set(LSRID, "1.1.1.1"); |
| 967 | addDevice(DEVICE1, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 968 | DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class); |
| 969 | device1Cap.setLabelStackCap(true) |
| 970 | .setLocalLabelCap(false) |
| 971 | .setSrCap(true) |
| 972 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 973 | |
| 974 | //Device2 |
| 975 | builder = DefaultAnnotations.builder(); |
| 976 | builder.set(AnnotationKeys.TYPE, L3); |
| 977 | builder.set(LSRID, "2.2.2.2"); |
| 978 | addDevice(DEVICE2, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 979 | DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class); |
| 980 | device2Cap.setLabelStackCap(true) |
| 981 | .setLocalLabelCap(false) |
| 982 | .setSrCap(true) |
| 983 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 984 | |
| 985 | //Device3 |
| 986 | builder = DefaultAnnotations.builder(); |
| 987 | builder.set(AnnotationKeys.TYPE, L3); |
| 988 | builder.set(LSRID, "3.3.3.3"); |
| 989 | addDevice(DEVICE3, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 990 | DeviceCapability device3Cap = netConfigRegistry.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class); |
| 991 | device3Cap.setLabelStackCap(true) |
| 992 | .setLocalLabelCap(false) |
| 993 | .setSrCap(true) |
| 994 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 995 | |
| 996 | //Device4 |
| 997 | builder = DefaultAnnotations.builder(); |
| 998 | builder.set(AnnotationKeys.TYPE, L3); |
| 999 | builder.set(LSRID, "4.4.4.4"); |
| 1000 | addDevice(DEVICE4, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 1001 | DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class); |
| 1002 | device4Cap.setLabelStackCap(true) |
| 1003 | .setLocalLabelCap(false) |
| 1004 | .setSrCap(true) |
| 1005 | .apply(); |
| 1006 | |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 1007 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 1008 | |
| 1009 | List<Link> links = new LinkedList<>(); |
| 1010 | links.add(link1); |
| 1011 | links.add(link2); |
| 1012 | assertThat(paths.iterator().next().cost(), is((double) 2)); |
| 1013 | } |
| 1014 | |
| 1015 | /** |
| 1016 | * Test case with empty constraints. |
| 1017 | */ |
| 1018 | @Test |
| 1019 | public void testpathComputationCase14() { |
| 1020 | Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, false, 50); |
| 1021 | Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, false, 20); |
| 1022 | Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, false, 100); |
| 1023 | Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, false, 80); |
| 1024 | |
| 1025 | List<Constraint> constraints = new LinkedList<>(); |
| 1026 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 1027 | |
| 1028 | assertThat(paths.iterator().next().cost(), is((double) 2)); |
| 1029 | } |
| 1030 | |
| 1031 | /** |
| 1032 | * Test case with constraints as null. |
| 1033 | */ |
| 1034 | @Test |
| 1035 | public void testpathComputationCase15() { |
| 1036 | Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, false, 50); |
| 1037 | Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, false, 20); |
| 1038 | Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, false, 100); |
| 1039 | Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, false, 80); |
| 1040 | |
| 1041 | List<Constraint> constraints = null; |
| 1042 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 1043 | |
| 1044 | assertThat(paths.iterator().next().cost(), is((double) 2)); |
| 1045 | } |
| 1046 | |
| 1047 | /** |
| 1048 | * Path with cost constraint. |
| 1049 | */ |
| 1050 | @Test |
| 1051 | public void testpathComputationCase16() { |
| 1052 | Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50); |
| 1053 | Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 100); |
| 1054 | Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 10); |
| 1055 | Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 10); |
| 1056 | Link link5 = addLink(DEVICE4, 90, DEVICE5, 100, true, 20); |
| 1057 | |
| 1058 | CostConstraint costConst = CostConstraint.of(COST); |
| 1059 | |
| 1060 | List<Constraint> constraints = new LinkedList<>(); |
| 1061 | constraints.add(costConst); |
| 1062 | Graph<TopologyVertex, TopologyEdge> graph = new AdjacencyListsGraph<>(of(D1, D2, D3, D4, D5), |
| 1063 | of(new DefaultTopologyEdge(D1, D2, link1), |
| 1064 | new DefaultTopologyEdge(D2, D4, link2), |
| 1065 | new DefaultTopologyEdge(D1, D3, link3), |
| 1066 | new DefaultTopologyEdge(D3, D4, link4), |
| 1067 | new DefaultTopologyEdge(D4, D5, link5))); |
| 1068 | |
| 1069 | GraphPathSearch.Result<TopologyVertex, TopologyEdge> result = |
| 1070 | graphSearch().search(graph, D1, D5, weight(constraints), ALL_PATHS); |
| 1071 | ImmutableSet.Builder<Path> builder = ImmutableSet.builder(); |
| 1072 | for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) { |
| 1073 | builder.add(networkPath(path)); |
| 1074 | } |
| 1075 | |
| 1076 | List<Link> links = new LinkedList<>(); |
| 1077 | links.add(link3); |
| 1078 | links.add(link4); |
| 1079 | links.add(link5); |
| 1080 | assertThat(builder.build().iterator().next().links(), is(links)); |
| 1081 | assertThat(builder.build().iterator().next().cost(), is((double) 40)); |
| 1082 | } |
| 1083 | |
| 1084 | /** |
| 1085 | * D3 doesn't support capability constraint, so path is L1-L2. |
| 1086 | */ |
| 1087 | @Test |
| 1088 | public void testpathComputationCase17() { |
| 1089 | Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, false, 50); |
| 1090 | Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, false, 20); |
| 1091 | Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, false, 100); |
| 1092 | Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, false, 80); |
| 1093 | |
| 1094 | CapabilityConstraint capabilityConst = CapabilityConstraint |
| 1095 | .of(CapabilityConstraint.CapabilityType.WITHOUT_SIGNALLING_AND_WITHOUT_SR); |
| 1096 | |
| 1097 | List<Constraint> constraints = new LinkedList<>(); |
| 1098 | constraints.add(capabilityConst); |
| 1099 | //Device1 |
| 1100 | DefaultAnnotations.Builder builder = DefaultAnnotations.builder(); |
| 1101 | builder.set(AnnotationKeys.TYPE, L3); |
| 1102 | builder.set(LSRID, "1.1.1.1"); |
| 1103 | addDevice(DEVICE1, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 1104 | DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class); |
| 1105 | device1Cap.setLabelStackCap(false) |
| 1106 | .setLocalLabelCap(true) |
| 1107 | .setSrCap(false) |
| 1108 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 1109 | |
| 1110 | //Device2 |
| 1111 | builder = DefaultAnnotations.builder(); |
| 1112 | builder.set(AnnotationKeys.TYPE, L3); |
| 1113 | builder.set(LSRID, "2.2.2.2"); |
| 1114 | addDevice(DEVICE2, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 1115 | DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class); |
| 1116 | device2Cap.setLabelStackCap(false) |
| 1117 | .setLocalLabelCap(true) |
| 1118 | .setSrCap(false) |
| 1119 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 1120 | |
| 1121 | //Device4 |
| 1122 | builder = DefaultAnnotations.builder(); |
| 1123 | builder.set(AnnotationKeys.TYPE, L3); |
| 1124 | builder.set(LSRID, "4.4.4.4"); |
| 1125 | addDevice(DEVICE4, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 1126 | DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class); |
| 1127 | device4Cap.setLabelStackCap(false) |
| 1128 | .setLocalLabelCap(true) |
| 1129 | .setSrCap(false) |
| 1130 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 1131 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 1132 | |
| 1133 | List<Link> links = new LinkedList<>(); |
| 1134 | links.add(link1); |
| 1135 | links.add(link2); |
| 1136 | |
| 1137 | assertThat(paths.iterator().next().links(), is(links)); |
| 1138 | assertThat(paths.iterator().next().cost(), is((double) 2)); |
| 1139 | } |
| 1140 | |
| 1141 | /** |
| 1142 | * L2 doesn't support cost constraint and D3 doesn't support capability constraint, both constraint fails hence no |
| 1143 | * path. |
| 1144 | */ |
| 1145 | @Test |
| 1146 | public void testpathComputationCase18() { |
| 1147 | Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50); |
| 1148 | Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, false, 20); |
| 1149 | Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 10); |
| 1150 | Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 10); |
| 1151 | |
| 1152 | CapabilityConstraint capabilityConst = CapabilityConstraint |
| 1153 | .of(CapabilityConstraint.CapabilityType.WITHOUT_SIGNALLING_AND_WITHOUT_SR); |
| 1154 | CostConstraint costConst = CostConstraint.of(COST); |
| 1155 | List<Constraint> constraints = new LinkedList<>(); |
| 1156 | constraints.add(capabilityConst); |
| 1157 | constraints.add(costConst); |
| 1158 | //Device1 |
| 1159 | DefaultAnnotations.Builder builder = DefaultAnnotations.builder(); |
| 1160 | builder.set(AnnotationKeys.TYPE, L3); |
| 1161 | builder.set(LSRID, "1.1.1.1"); |
| 1162 | addDevice(DEVICE2, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 1163 | DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class); |
| 1164 | device1Cap.setLabelStackCap(false) |
| 1165 | .setLocalLabelCap(true) |
| 1166 | .setSrCap(false) |
| 1167 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 1168 | |
| 1169 | //Device2 |
| 1170 | builder = DefaultAnnotations.builder(); |
| 1171 | builder.set(AnnotationKeys.TYPE, L3); |
| 1172 | builder.set(LSRID, "2.2.2.2"); |
| 1173 | addDevice(DEVICE2, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 1174 | DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class); |
| 1175 | device2Cap.setLabelStackCap(false) |
| 1176 | .setLocalLabelCap(true) |
| 1177 | .setSrCap(false) |
| 1178 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 1179 | |
| 1180 | //Device4 |
| 1181 | builder = DefaultAnnotations.builder(); |
| 1182 | builder.set(AnnotationKeys.TYPE, L3); |
| 1183 | builder.set(LSRID, "4.4.4.4"); |
| 1184 | addDevice(DEVICE4, builder); |
Avantika-Huawei | 032a987 | 2016-05-27 22:57:38 +0530 | [diff] [blame] | 1185 | DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class); |
| 1186 | device4Cap.setLabelStackCap(false) |
| 1187 | .setLocalLabelCap(true) |
| 1188 | .setSrCap(false) |
| 1189 | .apply(); |
Priyanka B | b696358 | 2016-05-20 20:21:20 +0530 | [diff] [blame] | 1190 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 1191 | |
| 1192 | assertThat(paths, is(new HashSet<>())); |
| 1193 | } |
| 1194 | |
| 1195 | private void addDevice(String device, DefaultAnnotations.Builder builder) { |
| 1196 | deviceService.addDevice(new DefaultDevice(ProviderId.NONE, deviceId(device), Type.ROUTER, |
| 1197 | UNKNOWN, UNKNOWN, UNKNOWN, |
| 1198 | UNKNOWN, new ChassisId(), builder.build())); |
| 1199 | } |
| 1200 | } |