Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +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.provider.pcep.tunnel.impl; |
| 17 | |
| 18 | import static org.hamcrest.MatcherAssert.assertThat; |
| 19 | import static org.hamcrest.core.Is.is; |
| 20 | import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS; |
| 21 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT; |
Avantika-Huawei | fc10dca | 2016-06-10 16:13:55 +0530 | [diff] [blame] | 22 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.BANDWIDTH; |
| 23 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.LOCAL_LSP_ID; |
| 24 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE; |
| 25 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.PCC_TUNNEL_ID; |
| 26 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.PLSP_ID; |
| 27 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.DELEGATE; |
Avantika-Huawei | 3c2d3eb | 2016-06-22 09:34:00 +0530 | [diff] [blame] | 28 | import static org.onosproject.pcep.controller.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; |
Avantika-Huawei | 7f7376a | 2016-05-11 17:07:50 +0530 | [diff] [blame] | 29 | import static org.onosproject.pcep.controller.PcepSyncStatus.SYNCED; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 30 | import static org.onosproject.net.Device.Type.ROUTER; |
Priyanka B | c1e4e4c | 2016-07-01 14:57:19 +0530 | [diff] [blame] | 31 | import static org.onosproject.net.Link.State.ACTIVE; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 32 | import static org.onosproject.net.MastershipRole.MASTER; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 33 | |
| 34 | import java.io.IOException; |
| 35 | import java.util.Collection; |
| 36 | import java.util.Collections; |
| 37 | import java.util.HashMap; |
| 38 | import java.util.HashSet; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 39 | import java.util.LinkedList; |
| 40 | import java.util.List; |
| 41 | import java.util.concurrent.TimeUnit; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 42 | |
| 43 | import org.jboss.netty.buffer.ChannelBuffer; |
| 44 | import org.jboss.netty.buffer.ChannelBuffers; |
| 45 | import org.junit.After; |
| 46 | import org.junit.Before; |
| 47 | import org.junit.Test; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 48 | import org.onlab.packet.ChassisId; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 49 | import org.onlab.packet.IpAddress; |
| 50 | import org.onosproject.cfg.ComponentConfigAdapter; |
| 51 | import org.onosproject.core.ApplicationId; |
| 52 | import org.onosproject.incubator.net.tunnel.DefaultTunnel; |
| 53 | import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; |
| 54 | import org.onosproject.incubator.net.tunnel.Tunnel; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 55 | import org.onosproject.incubator.net.tunnel.Tunnel.Type; |
| 56 | import org.onosproject.incubator.net.tunnel.TunnelAdminService; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 57 | import org.onosproject.incubator.net.tunnel.TunnelDescription; |
| 58 | import org.onosproject.incubator.net.tunnel.TunnelEndPoint; |
| 59 | import org.onosproject.incubator.net.tunnel.TunnelId; |
| 60 | import org.onosproject.incubator.net.tunnel.TunnelName; |
| 61 | import org.onosproject.incubator.net.tunnel.TunnelProvider; |
| 62 | import org.onosproject.incubator.net.tunnel.TunnelProviderService; |
| 63 | import org.onosproject.incubator.net.tunnel.Tunnel.State; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 64 | import org.onosproject.mastership.MastershipServiceAdapter; |
| 65 | import org.onosproject.net.AnnotationKeys; |
Priyanka B | c1e4e4c | 2016-07-01 14:57:19 +0530 | [diff] [blame] | 66 | import org.onosproject.net.ConnectPoint; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 67 | import org.onosproject.net.DefaultAnnotations; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 68 | import org.onosproject.net.DefaultDevice; |
Priyanka B | c1e4e4c | 2016-07-01 14:57:19 +0530 | [diff] [blame] | 69 | import org.onosproject.net.DefaultLink; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 70 | import org.onosproject.net.Device; |
| 71 | import org.onosproject.net.DeviceId; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 72 | import org.onosproject.net.ElementId; |
Priyanka B | c1e4e4c | 2016-07-01 14:57:19 +0530 | [diff] [blame] | 73 | import org.onosproject.net.Link; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 74 | import org.onosproject.net.MastershipRole; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 75 | import org.onosproject.net.Path; |
Priyanka B | c1e4e4c | 2016-07-01 14:57:19 +0530 | [diff] [blame] | 76 | import org.onosproject.net.PortNumber; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 77 | import org.onosproject.net.SparseAnnotations; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 78 | import org.onosproject.net.device.DeviceServiceAdapter; |
Priyanka B | c1e4e4c | 2016-07-01 14:57:19 +0530 | [diff] [blame] | 79 | import org.onosproject.net.link.LinkServiceAdapter; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 80 | import org.onosproject.net.provider.ProviderId; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 81 | import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException; |
| 82 | import org.onosproject.pcepio.exceptions.PcepParseException; |
| 83 | import org.onosproject.pcepio.protocol.PcepFactories; |
| 84 | import org.onosproject.pcepio.protocol.PcepMessage; |
| 85 | import org.onosproject.pcepio.protocol.PcepMessageReader; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 86 | import org.onosproject.pcepio.protocol.PcepVersion; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 87 | import org.onosproject.pcep.controller.ClientCapability; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 88 | import org.onosproject.pcep.controller.LspKey; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 89 | import org.onosproject.pcep.controller.PccId; |
| 90 | |
Priyanka B | c1e4e4c | 2016-07-01 14:57:19 +0530 | [diff] [blame] | 91 | import com.google.common.collect.FluentIterable; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 92 | import com.google.common.collect.ImmutableSet; |
| 93 | |
| 94 | /** |
| 95 | * Tests handling of PCEP report message. |
| 96 | */ |
| 97 | public class PcepTunnelAddedTest { |
| 98 | |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 99 | public static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep"; |
| 100 | public static final String UNKOWN = "UNKOWN"; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 101 | PcepTunnelProvider tunnelProvider = new PcepTunnelProvider(); |
| 102 | private final MockTunnelProviderRegistryAdapter registry = new MockTunnelProviderRegistryAdapter(); |
| 103 | private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); |
| 104 | private final PcepControllerAdapter ctl = new PcepControllerAdapter(); |
| 105 | private final PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper(); |
| 106 | private final MockTunnelServiceAdapter tunnelService = new MockTunnelServiceAdapter(); |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 107 | public final MockDeviceService deviceService = new MockDeviceService(); |
| 108 | private final MockMasterShipService masterShipService = new MockMasterShipService(); |
Priyanka B | c1e4e4c | 2016-07-01 14:57:19 +0530 | [diff] [blame] | 109 | private final MockLinkService linkService = new MockLinkService(); |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 110 | private final MockTunnelAdminService tunnelAdminService = new MockTunnelAdminService(); |
| 111 | |
Priyanka B | c1e4e4c | 2016-07-01 14:57:19 +0530 | [diff] [blame] | 112 | private class MockLinkService extends LinkServiceAdapter { |
| 113 | LinkedList<Link> links = new LinkedList<>(); |
| 114 | void addLink(Link link) { |
| 115 | links.add(link); |
| 116 | } |
| 117 | |
| 118 | @Override |
| 119 | public Iterable<Link> getActiveLinks() { |
| 120 | |
| 121 | return FluentIterable.from(links) |
| 122 | .filter(input -> input.state() == ACTIVE); |
| 123 | } |
| 124 | } |
| 125 | |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 126 | private class MockTunnelAdminService implements TunnelAdminService { |
| 127 | |
| 128 | @Override |
| 129 | public void removeTunnel(TunnelId tunnelId) { |
| 130 | // TODO Auto-generated method stub |
| 131 | } |
| 132 | |
| 133 | @Override |
| 134 | public void removeTunnels(TunnelEndPoint src, TunnelEndPoint dst, ProviderId producerName) { |
| 135 | // TODO Auto-generated method stub |
| 136 | } |
| 137 | |
| 138 | @Override |
| 139 | public void removeTunnels(TunnelEndPoint src, TunnelEndPoint dst, Type type, ProviderId producerName) { |
| 140 | // TODO Auto-generated method stub |
| 141 | } |
| 142 | |
| 143 | @Override |
| 144 | public void updateTunnel(Tunnel tunnel, Path path) { |
| 145 | if (tunnelService.tunnelIdAsKeyStore.containsKey(tunnel.tunnelId())) { |
| 146 | tunnelService.tunnelIdAsKeyStore.replace(tunnel.tunnelId(), tunnel); |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | private class MockMasterShipService extends MastershipServiceAdapter { |
| 152 | boolean set; |
| 153 | |
| 154 | private void setMaster(boolean isMaster) { |
| 155 | this.set = isMaster; |
| 156 | } |
| 157 | |
| 158 | @Override |
| 159 | public MastershipRole getLocalRole(DeviceId deviceId) { |
| 160 | return set ? MastershipRole.MASTER : MastershipRole.STANDBY; |
| 161 | } |
| 162 | |
| 163 | @Override |
| 164 | public boolean isLocalMaster(DeviceId deviceId) { |
| 165 | return getLocalRole(deviceId) == MASTER; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | private class MockDeviceService extends DeviceServiceAdapter { |
| 170 | List<Device> devices = new LinkedList<>(); |
| 171 | |
| 172 | private void addDevice(Device dev) { |
| 173 | devices.add(dev); |
| 174 | } |
| 175 | |
| 176 | @Override |
| 177 | public Iterable<Device> getAvailableDevices() { |
| 178 | return devices; |
| 179 | } |
| 180 | } |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 181 | |
| 182 | private class MockTunnelProviderRegistryAdapter extends TunnelProviderRegistryAdapter { |
| 183 | public long tunnelIdCounter; |
| 184 | |
| 185 | @Override |
| 186 | public TunnelProviderService register(TunnelProvider provider) { |
| 187 | this.provider = provider; |
| 188 | return new TestProviderService(); |
| 189 | } |
| 190 | |
| 191 | private class TestProviderService implements TunnelProviderService { |
| 192 | |
| 193 | @Override |
| 194 | public TunnelProvider provider() { |
| 195 | return null; |
| 196 | } |
| 197 | |
| 198 | @Override |
| 199 | public TunnelId tunnelAdded(TunnelDescription tunnel) { |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 200 | TunnelId id = TunnelId.valueOf(String.valueOf(++tunnelIdCounter)); |
| 201 | Tunnel storedTunnel = new DefaultTunnel(ProviderId.NONE, |
| 202 | tunnel.src(), tunnel.dst(), |
| 203 | tunnel.type(), |
| 204 | tunnel.groupId(), |
| 205 | id, |
| 206 | tunnel.tunnelName(), |
| 207 | tunnel.path(), |
| 208 | tunnel.resource(), |
| 209 | tunnel.annotations()); |
| 210 | tunnelService.tunnelIdAsKeyStore.put(id, storedTunnel); |
| 211 | return id; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | @Override |
| 215 | public TunnelId tunnelAdded(TunnelDescription tunnel, State state) { |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 216 | TunnelId id = TunnelId.valueOf(String.valueOf(++tunnelIdCounter)); |
| 217 | Tunnel storedTunnel = new DefaultTunnel(ProviderId.NONE, |
| 218 | tunnel.src(), tunnel.dst(), |
| 219 | tunnel.type(), |
| 220 | tunnel.groupId(), |
| 221 | id, |
| 222 | tunnel.tunnelName(), |
| 223 | tunnel.path(), |
| 224 | tunnel.resource(), |
| 225 | tunnel.annotations()); |
| 226 | tunnelService.tunnelIdAsKeyStore.put(id, storedTunnel); |
| 227 | return id; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | @Override |
| 231 | public void tunnelRemoved(TunnelDescription tunnel) { |
| 232 | } |
| 233 | |
| 234 | @Override |
| 235 | public void tunnelUpdated(TunnelDescription tunnel) { |
| 236 | } |
| 237 | |
| 238 | @Override |
| 239 | public void tunnelUpdated(TunnelDescription tunnel, State state) { |
| 240 | } |
| 241 | |
| 242 | @Override |
| 243 | public Tunnel tunnelQueryById(TunnelId tunnelId) { |
| 244 | return null; |
| 245 | } |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | private class MockTunnelServiceAdapter extends TunnelServiceAdapter { |
| 250 | private HashMap<TunnelId, Tunnel> tunnelIdAsKeyStore = new HashMap<>(); |
| 251 | private int tunnelIdCounter = 0; |
| 252 | |
| 253 | @Override |
| 254 | public TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path) { |
| 255 | TunnelId tunnelId = TunnelId.valueOf(String.valueOf(++tunnelIdCounter)); |
| 256 | tunnelIdAsKeyStore.put(tunnelId, tunnel); |
| 257 | return tunnelId; |
| 258 | } |
| 259 | |
| 260 | @Override |
| 261 | public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) { |
| 262 | Collection<Tunnel> result = new HashSet<>(); |
| 263 | Tunnel tunnel = null; |
| 264 | for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) { |
| 265 | tunnel = tunnelIdAsKeyStore.get(tunnelId); |
| 266 | |
| 267 | if ((null != tunnel) && (src.equals(tunnel.src())) && (dst.equals(tunnel.dst()))) { |
| 268 | result.add(tunnel); |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | return result.isEmpty() ? Collections.emptySet() : ImmutableSet.copyOf(result); |
| 273 | } |
| 274 | |
| 275 | @Override |
| 276 | public Collection<Tunnel> queryAllTunnels() { |
| 277 | Collection<Tunnel> result = new HashSet<>(); |
| 278 | |
| 279 | for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) { |
| 280 | result.add(tunnelIdAsKeyStore.get(tunnelId)); |
| 281 | } |
| 282 | |
| 283 | return result.isEmpty() ? Collections.emptySet() : ImmutableSet.copyOf(result); |
| 284 | |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | @Before |
| 289 | public void preSetup() { |
| 290 | tunnelProvider.tunnelProviderRegistry = registry; |
| 291 | tunnelProvider.pcepClientController = controller; |
| 292 | tunnelProvider.controller = ctl; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 293 | tunnelProvider.deviceService = deviceService; |
| 294 | tunnelProvider.mastershipService = masterShipService; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 295 | tunnelProvider.pcepTunnelApiMapper = pcepTunnelAPIMapper; |
| 296 | tunnelProvider.cfgService = new ComponentConfigAdapter(); |
| 297 | tunnelProvider.tunnelService = tunnelService; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 298 | tunnelProvider.tunnelAdminService = tunnelAdminService; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 299 | tunnelProvider.service = registry.register(tunnelProvider); |
Priyanka B | c1e4e4c | 2016-07-01 14:57:19 +0530 | [diff] [blame] | 300 | tunnelProvider.linkService = linkService; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 301 | tunnelProvider.activate(); |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * Tests PCRpt msg with sync flag set. |
| 306 | */ |
| 307 | @Test |
| 308 | public void tunnelProviderAddedTest1() throws PcepParseException, PcepOutOfBoundMessageException { |
| 309 | byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84, |
| 310 | 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
| 311 | 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV |
| 312 | 0x00, 0x00, 0x00, 0x02, |
| 313 | 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 314 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 315 | 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV |
| 316 | 0x01, 0x01, 0x01, 0x01, |
| 317 | 0x00, 0x01, 0x00, 0x01, |
| 318 | 0x01, 0x01, 0x01, 0x01, |
| 319 | 0x05, 0x05, 0x05, 0x05, |
| 320 | |
| 321 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 322 | 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects |
| 323 | 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, |
| 324 | |
| 325 | 0x08, 0x10, 0x00, 0x34, //RRO object |
| 326 | 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects |
| 327 | 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00, |
| 328 | 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00, |
| 329 | 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00, |
| 330 | 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00, |
| 331 | 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00 |
| 332 | }; |
| 333 | |
| 334 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 335 | buffer.writeBytes(reportMsg); |
| 336 | |
| 337 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 338 | PcepMessage message = reader.readFrom(buffer); |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 339 | |
| 340 | DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder(); |
| 341 | newBuilder.set(PcepTunnelProvider.LSRID, "1.1.1.1"); |
| 342 | newBuilder.set(AnnotationKeys.TYPE, "L3"); |
| 343 | Device device = new DefaultDevice(ProviderId.NONE, DeviceId.deviceId("1.1.1.1"), ROUTER, |
| 344 | UNKOWN, UNKOWN, UNKOWN, |
| 345 | UNKOWN, new ChassisId(), |
| 346 | newBuilder.build()); |
| 347 | |
| 348 | deviceService.addDevice(device); |
| 349 | controller.getClient(PccId.pccId(IpAddress.valueOf("1.1.1.1"))).setCapability( |
| 350 | new ClientCapability(true, true, true, true, true)); |
| 351 | masterShipService.setMaster(true); |
Priyanka B | c1e4e4c | 2016-07-01 14:57:19 +0530 | [diff] [blame] | 352 | Link link = DefaultLink.builder() |
| 353 | .src(new ConnectPoint(device.id(), PortNumber.portNumber(16843009))) |
| 354 | .dst(new ConnectPoint(device.id(), PortNumber.portNumber(84215045))) |
| 355 | .state(ACTIVE) |
| 356 | .type(Link.Type.DIRECT) |
| 357 | .providerId(ProviderId.NONE) |
| 358 | .build(); |
| 359 | linkService.addLink(link); |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 360 | controller.processClientMessage(PccId.pccId(IpAddress.valueOf("1.1.1.1")), message); |
| 361 | |
| 362 | assertThat(registry.tunnelIdCounter, is((long) 1)); |
| 363 | } |
| 364 | |
| 365 | /** |
| 366 | * Tests updating an existing tunnel on receiving asynchronous PCRpt msg, |
| 367 | * i.e. without any SRP id. |
| 368 | */ |
| 369 | @Test |
| 370 | public void tunnelProviderAddedTest2() throws PcepParseException, PcepOutOfBoundMessageException { |
| 371 | byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x50, |
| 372 | 0x21, 0x10, 0x00, 0x14, //SRP object |
| 373 | 0x00, 0x00, 0x00, 0x00, |
| 374 | 0x00, 0x00, 0x00, 0x00, |
| 375 | 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV |
| 376 | 0x00, 0x00, 0x00, 0x02, |
| 377 | 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x19, //LSP object |
| 378 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path TLV |
| 379 | 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV |
| 380 | 0x4e, 0x1f, 0x04, 0x00, |
| 381 | 0x00, 0x01, 0x00, 0x01, |
| 382 | 0x4e, 0x1f, 0x04, 0x00, |
| 383 | 0x4e, 0x20, 0x04, 0x00, |
| 384 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 385 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, // ERO IPv4 sub objects |
| 386 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, |
| 387 | }; |
| 388 | |
| 389 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 390 | buffer.writeBytes(reportMsg); |
| 391 | |
| 392 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 393 | PcepMessage message = reader.readFrom(buffer); |
| 394 | |
| 395 | // create an existing tunnel. |
| 396 | IpTunnelEndPoint tunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(0x4e1f0400)); |
| 397 | IpTunnelEndPoint tunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(0x4e200400)); |
| 398 | |
| 399 | SparseAnnotations annotations = DefaultAnnotations.builder() |
| 400 | .set(BANDWIDTH, (new Integer(1)).toString()) |
| 401 | .set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name()) |
| 402 | .set(PCC_TUNNEL_ID, String.valueOf(1)) |
| 403 | .set(PLSP_ID, String.valueOf(1)) |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 404 | .set(LOCAL_LSP_ID, String.valueOf(1)) |
| 405 | .set(DELEGATE, String.valueOf("true")) |
| 406 | .build(); |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 407 | |
| 408 | Tunnel tunnel = new DefaultTunnel(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, INIT, null, null, |
| 409 | TunnelName.tunnelName("T123"), null, annotations); |
| 410 | tunnelService.setupTunnel(null, null, tunnel, null); |
| 411 | |
| 412 | PccId pccId = PccId.pccId(IpAddress.valueOf(0x4e1f0400)); |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 413 | PcepClientAdapter pc = new PcepClientAdapter(); |
| 414 | pc.init(pccId, PcepVersion.PCEP_1); |
| 415 | masterShipService.setMaster(true); |
| 416 | controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true); |
| 417 | controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true)); |
Avantika-Huawei | 7f7376a | 2016-05-11 17:07:50 +0530 | [diff] [blame] | 418 | controller.getClient(pccId).setLspDbSyncStatus(SYNCED); |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 419 | |
| 420 | // Process update message. |
| 421 | controller.processClientMessage(pccId, message); |
| 422 | assertThat(tunnelService.queryAllTunnels().size(), is(1)); |
| 423 | } |
| 424 | |
| 425 | /** |
| 426 | * Tests adding a new tunnel on receiving asynchronous PCRpt msg, |
| 427 | * i.e. without any SRP id. |
| 428 | */ |
| 429 | @Test |
| 430 | public void tunnelProviderAddedTest3() throws PcepParseException, PcepOutOfBoundMessageException { |
| 431 | byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84, |
| 432 | 0x21, 0x10, 0x00, 0x14, //SRP object |
| 433 | 0x00, 0x00, 0x00, 0x00, |
| 434 | 0x00, 0x00, 0x00, 0x00, |
| 435 | 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV |
| 436 | 0x00, 0x00, 0x00, 0x02, |
Avantika-Huawei | d1e36bd | 2016-05-26 12:47:16 +0530 | [diff] [blame] | 437 | 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x1B, // LSP object |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 438 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV |
| 439 | 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV |
| 440 | 0x01, 0x01, 0x01, 0x01, |
| 441 | 0x00, 0x01, 0x00, 0x01, |
| 442 | 0x01, 0x01, 0x01, 0x01, |
| 443 | 0x05, 0x05, 0x05, 0x05, |
| 444 | |
| 445 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 446 | 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects |
| 447 | 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, |
| 448 | |
| 449 | 0x08, 0x10, 0x00, 0x34, //RRO object |
| 450 | 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects |
| 451 | 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00, |
| 452 | 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00, |
| 453 | 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00, |
| 454 | 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00, |
| 455 | 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00 |
| 456 | }; |
| 457 | |
| 458 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 459 | buffer.writeBytes(reportMsg); |
| 460 | |
| 461 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 462 | PcepMessage message = reader.readFrom(buffer); |
| 463 | |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 464 | DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder(); |
| 465 | newBuilder.set(PcepTunnelProvider.LSRID, "1.1.1.1"); |
| 466 | newBuilder.set(AnnotationKeys.TYPE, "L3"); |
| 467 | Device device = new DefaultDevice(ProviderId.NONE, DeviceId.deviceId("1.1.1.1"), ROUTER, |
| 468 | UNKOWN, UNKOWN, UNKOWN, |
| 469 | UNKOWN, new ChassisId(), |
| 470 | newBuilder.build()); |
| 471 | |
| 472 | deviceService.addDevice(device); |
| 473 | |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 474 | PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1")); |
Avantika-Huawei | 7f7376a | 2016-05-11 17:07:50 +0530 | [diff] [blame] | 475 | controller.getClient(pccId).setLspDbSyncStatus(SYNCED); |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 476 | controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true)); |
| 477 | |
Priyanka B | c1e4e4c | 2016-07-01 14:57:19 +0530 | [diff] [blame] | 478 | Link link = DefaultLink.builder() |
| 479 | .src(new ConnectPoint(device.id(), PortNumber.portNumber(16843009))) |
| 480 | .dst(new ConnectPoint(device.id(), PortNumber.portNumber(84215045))) |
| 481 | .state(ACTIVE) |
| 482 | .type(Link.Type.DIRECT) |
| 483 | .providerId(ProviderId.NONE) |
| 484 | .build(); |
| 485 | linkService.addLink(link); |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 486 | PcepClientAdapter pc = new PcepClientAdapter(); |
| 487 | pc.init(pccId, PcepVersion.PCEP_1); |
| 488 | controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true); |
| 489 | masterShipService.setMaster(true); |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 490 | controller.processClientMessage(pccId, message); |
| 491 | |
| 492 | assertThat(registry.tunnelIdCounter, is((long) 1)); |
| 493 | } |
| 494 | |
Avantika-Huawei | 7f7376a | 2016-05-11 17:07:50 +0530 | [diff] [blame] | 495 | /** |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 496 | * Tests PCRpt msg with D flag set and delegated to non-master. |
| 497 | * |
| 498 | * @throws InterruptedException while waiting for delay |
| 499 | */ |
| 500 | @Test |
| 501 | public void tunnelProviderAddedTest4() throws PcepParseException, PcepOutOfBoundMessageException, |
| 502 | InterruptedException { |
| 503 | byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84, |
| 504 | 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
| 505 | 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV |
| 506 | 0x00, 0x00, 0x00, 0x02, |
| 507 | 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x02, //LSP object |
| 508 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 509 | 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV |
| 510 | 0x01, 0x01, 0x01, 0x01, |
| 511 | 0x00, 0x01, 0x00, 0x01, |
| 512 | 0x01, 0x01, 0x01, 0x01, |
| 513 | 0x05, 0x05, 0x05, 0x05, |
| 514 | |
| 515 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 516 | 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects |
| 517 | 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, |
| 518 | |
| 519 | 0x08, 0x10, 0x00, 0x34, //RRO object |
| 520 | 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects |
| 521 | 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00, |
| 522 | 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00, |
| 523 | 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00, |
| 524 | 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00, |
| 525 | 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00 |
| 526 | }; |
| 527 | |
| 528 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 529 | buffer.writeBytes(reportMsg); |
| 530 | |
| 531 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 532 | PcepMessage message = reader.readFrom(buffer); |
| 533 | |
| 534 | //PCC 1.1.1.1, D=0, ONOS as master |
| 535 | masterShipService.setMaster(true); |
| 536 | DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder(); |
| 537 | newBuilder.set(PcepTunnelProvider.LSRID, "1.1.1.1"); |
| 538 | newBuilder.set(AnnotationKeys.TYPE, "L3"); |
| 539 | Device device = new DefaultDevice(ProviderId.NONE, DeviceId.deviceId("1.1.1.1"), ROUTER, |
| 540 | UNKOWN, UNKOWN, UNKOWN, |
| 541 | UNKOWN, new ChassisId(), |
| 542 | newBuilder.build()); |
| 543 | |
| 544 | deviceService.addDevice(device); |
| 545 | controller.getClient(PccId.pccId(IpAddress.valueOf("1.1.1.1"))).setCapability( |
| 546 | new ClientCapability(true, true, true, true, true)); |
Priyanka B | c1e4e4c | 2016-07-01 14:57:19 +0530 | [diff] [blame] | 547 | Link link = DefaultLink.builder() |
| 548 | .src(new ConnectPoint(device.id(), PortNumber.portNumber(16843009))) |
| 549 | .dst(new ConnectPoint(device.id(), PortNumber.portNumber(84215045))) |
| 550 | .state(ACTIVE) |
| 551 | .type(Link.Type.DIRECT) |
| 552 | .providerId(ProviderId.NONE) |
| 553 | .build(); |
| 554 | linkService.addLink(link); |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 555 | controller.processClientMessage(PccId.pccId(IpAddress.valueOf("1.1.1.1")), message); |
| 556 | assertThat(tunnelService.tunnelIdAsKeyStore.values().iterator().next().annotations().value(DELEGATE), |
| 557 | is("false")); |
| 558 | |
| 559 | //PCC 1.1.1.1, D=1, non-master |
| 560 | masterShipService.setMaster(false); |
| 561 | |
| 562 | reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84, |
| 563 | 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
| 564 | 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV |
| 565 | 0x00, 0x00, 0x00, 0x02, |
| 566 | 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 567 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 568 | 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV |
| 569 | 0x01, 0x01, 0x01, 0x01, |
| 570 | 0x00, 0x01, 0x00, 0x01, |
| 571 | 0x01, 0x01, 0x01, 0x01, |
| 572 | 0x05, 0x05, 0x05, 0x05, |
| 573 | |
| 574 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 575 | 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects |
| 576 | 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, |
| 577 | |
| 578 | 0x08, 0x10, 0x00, 0x34, //RRO object |
| 579 | 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects |
| 580 | 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00, |
| 581 | 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00, |
| 582 | 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00, |
| 583 | 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00, |
| 584 | 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00 |
| 585 | }; |
| 586 | |
| 587 | buffer = ChannelBuffers.dynamicBuffer(); |
| 588 | buffer.writeBytes(reportMsg); |
| 589 | |
| 590 | reader = PcepFactories.getGenericReader(); |
| 591 | message = reader.readFrom(buffer); |
| 592 | |
| 593 | controller.processClientMessage(PccId.pccId(IpAddress.valueOf("1.1.1.1")), message); |
| 594 | TimeUnit.MILLISECONDS.sleep(4000); |
| 595 | assertThat(registry.tunnelIdCounter, is((long) 1)); |
| 596 | assertThat(tunnelService.tunnelIdAsKeyStore.values().iterator().next().annotations().value(DELEGATE), |
| 597 | is("true")); |
| 598 | } |
| 599 | |
| 600 | /** |
Avantika-Huawei | d1e36bd | 2016-05-26 12:47:16 +0530 | [diff] [blame] | 601 | * Tests adding PCC Init LSP after LSP DB sync is over. |
Avantika-Huawei | 7f7376a | 2016-05-11 17:07:50 +0530 | [diff] [blame] | 602 | */ |
| 603 | @Test |
Avantika-Huawei | d1e36bd | 2016-05-26 12:47:16 +0530 | [diff] [blame] | 604 | public void tunnelProviderAddedTest5() throws PcepParseException, PcepOutOfBoundMessageException { |
| 605 | byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84, |
Avantika-Huawei | 7f7376a | 2016-05-11 17:07:50 +0530 | [diff] [blame] | 606 | 0x21, 0x10, 0x00, 0x14, //SRP object |
| 607 | 0x00, 0x00, 0x00, 0x00, |
| 608 | 0x00, 0x00, 0x00, 0x00, |
| 609 | 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV |
Avantika-Huawei | d1e36bd | 2016-05-26 12:47:16 +0530 | [diff] [blame] | 610 | 0x00, 0x00, 0x00, 0x02, |
Avantika-Huawei | 7f7376a | 2016-05-11 17:07:50 +0530 | [diff] [blame] | 611 | 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x19, // LSP object |
Avantika-Huawei | d1e36bd | 2016-05-26 12:47:16 +0530 | [diff] [blame] | 612 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV |
Avantika-Huawei | 7f7376a | 2016-05-11 17:07:50 +0530 | [diff] [blame] | 613 | 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV |
| 614 | 0x01, 0x01, 0x01, 0x01, |
| 615 | 0x00, 0x01, 0x00, 0x01, |
| 616 | 0x01, 0x01, 0x01, 0x01, |
| 617 | 0x05, 0x05, 0x05, 0x05, |
| 618 | |
| 619 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 620 | 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects |
| 621 | 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, |
| 622 | |
| 623 | 0x08, 0x10, 0x00, 0x34, //RRO object |
| 624 | 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects |
| 625 | 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00, |
| 626 | 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00, |
| 627 | 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00, |
| 628 | 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00, |
| 629 | 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00 |
| 630 | }; |
| 631 | |
Avantika-Huawei | d1e36bd | 2016-05-26 12:47:16 +0530 | [diff] [blame] | 632 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 633 | buffer.writeBytes(reportMsg); |
Avantika-Huawei | 7f7376a | 2016-05-11 17:07:50 +0530 | [diff] [blame] | 634 | |
Avantika-Huawei | d1e36bd | 2016-05-26 12:47:16 +0530 | [diff] [blame] | 635 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 636 | PcepMessage message = reader.readFrom(buffer); |
Avantika-Huawei | 7f7376a | 2016-05-11 17:07:50 +0530 | [diff] [blame] | 637 | |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 638 | DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder(); |
| 639 | newBuilder.set(PcepTunnelProvider.LSRID, "1.1.1.1"); |
| 640 | newBuilder.set(AnnotationKeys.TYPE, "L3"); |
| 641 | Device device = new DefaultDevice(ProviderId.NONE, DeviceId.deviceId("1.1.1.1"), ROUTER, |
| 642 | UNKOWN, UNKOWN, UNKOWN, |
| 643 | UNKOWN, new ChassisId(), |
| 644 | newBuilder.build()); |
| 645 | |
| 646 | deviceService.addDevice(device); |
| 647 | |
Avantika-Huawei | 7f7376a | 2016-05-11 17:07:50 +0530 | [diff] [blame] | 648 | PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1")); |
Avantika-Huawei | d1e36bd | 2016-05-26 12:47:16 +0530 | [diff] [blame] | 649 | controller.getClient(pccId).setLspDbSyncStatus(SYNCED); |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 650 | controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true)); |
| 651 | |
| 652 | PcepClientAdapter pc = new PcepClientAdapter(); |
| 653 | pc.init(pccId, PcepVersion.PCEP_1); |
Avantika-Huawei | d1e36bd | 2016-05-26 12:47:16 +0530 | [diff] [blame] | 654 | controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true); |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 655 | masterShipService.setMaster(true); |
Avantika-Huawei | d1e36bd | 2016-05-26 12:47:16 +0530 | [diff] [blame] | 656 | controller.processClientMessage(pccId, message); |
Avantika-Huawei | 7f7376a | 2016-05-11 17:07:50 +0530 | [diff] [blame] | 657 | |
Avantika-Huawei | d1e36bd | 2016-05-26 12:47:16 +0530 | [diff] [blame] | 658 | assertThat(registry.tunnelIdCounter, is((long) 0)); |
Avantika-Huawei | 7f7376a | 2016-05-11 17:07:50 +0530 | [diff] [blame] | 659 | } |
| 660 | |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 661 | @After |
| 662 | public void tearDown() throws IOException { |
| 663 | tunnelProvider.deactivate(); |
| 664 | tunnelProvider.controller = null; |
| 665 | tunnelProvider.pcepClientController = null; |
| 666 | tunnelProvider.tunnelProviderRegistry = null; |
| 667 | |
| 668 | tunnelProvider.pcepTunnelApiMapper = null; |
| 669 | tunnelProvider.cfgService = null; |
| 670 | tunnelProvider.tunnelService = null; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 671 | tunnelProvider.tunnelAdminService = null; |
| 672 | tunnelProvider.deviceService = null; |
| 673 | tunnelProvider.mastershipService = null; |
Priyanka B | c1e4e4c | 2016-07-01 14:57:19 +0530 | [diff] [blame] | 674 | tunnelProvider.linkService = null; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 675 | tunnelProvider.service = null; |
| 676 | } |
| 677 | } |