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