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