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