Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +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 | |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 18 | import org.junit.After; |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 19 | import org.junit.Before; |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 20 | import org.junit.Test; |
Ray Milkey | a7cf8c8 | 2018-02-08 15:07:06 -0800 | [diff] [blame] | 21 | import org.onlab.graph.ScalarWeight; |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 22 | import org.onlab.packet.IpAddress; |
chengfan | 2fff70f | 2015-08-24 18:20:19 -0500 | [diff] [blame] | 23 | import org.onosproject.cfg.ComponentConfigAdapter; |
Yi Tseng | fa394de | 2017-02-01 11:26:40 -0800 | [diff] [blame] | 24 | import org.onosproject.core.GroupId; |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 25 | import org.onosproject.incubator.net.tunnel.DefaultTunnel; |
| 26 | import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; |
| 27 | import org.onosproject.incubator.net.tunnel.Tunnel; |
| 28 | import org.onosproject.incubator.net.tunnel.TunnelId; |
| 29 | import org.onosproject.incubator.net.tunnel.TunnelName; |
Ray Milkey | d1c34da | 2018-06-22 18:10:53 -0700 | [diff] [blame] | 30 | import org.onosproject.incubator.net.tunnel.TunnelServiceAdapter; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 31 | import org.onosproject.mastership.MastershipServiceAdapter; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 32 | import org.onosproject.net.Annotations; |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 33 | import org.onosproject.net.ConnectPoint; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 34 | import org.onosproject.net.DefaultAnnotations; |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 35 | import org.onosproject.net.DefaultLink; |
| 36 | import org.onosproject.net.DefaultPath; |
| 37 | import org.onosproject.net.IpElementId; |
| 38 | import org.onosproject.net.Link; |
| 39 | import org.onosproject.net.Path; |
| 40 | import org.onosproject.net.PortNumber; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 41 | import org.onosproject.net.device.DeviceServiceAdapter; |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 42 | import org.onosproject.net.provider.ProviderId; |
Ray Milkey | d1c34da | 2018-06-22 18:10:53 -0700 | [diff] [blame] | 43 | import org.onosproject.pcep.api.PcepControllerAdapter; |
harikrushna-Huawei | a2c7c20 | 2017-04-10 18:22:00 +0530 | [diff] [blame] | 44 | import org.onosproject.pcep.server.ClientCapability; |
| 45 | import org.onosproject.pcep.server.PccId; |
Ray Milkey | d1c34da | 2018-06-22 18:10:53 -0700 | [diff] [blame] | 46 | import org.onosproject.pcep.server.PcepClientControllerAdapter; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 47 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv; |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 48 | |
Ray Milkey | d1c34da | 2018-06-22 18:10:53 -0700 | [diff] [blame] | 49 | import java.io.IOException; |
| 50 | import java.util.ArrayList; |
| 51 | import java.util.List; |
| 52 | |
| 53 | import static org.hamcrest.MatcherAssert.assertThat; |
| 54 | import static org.hamcrest.Matchers.nullValue; |
| 55 | import static org.hamcrest.core.Is.is; |
| 56 | import static org.hamcrest.core.IsNot.not; |
| 57 | import static org.onosproject.net.DefaultAnnotations.EMPTY; |
| 58 | import static org.onosproject.pcep.server.LspType.SR_WITHOUT_SIGNALLING; |
| 59 | import static org.onosproject.pcep.server.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; |
| 60 | import static org.onosproject.pcep.server.LspType.WITH_SIGNALLING; |
| 61 | import static org.onosproject.pcep.server.PcepAnnotationKeys.LSP_SIG_TYPE; |
| 62 | |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 63 | /** |
| 64 | * Test for PCEP release tunnel. |
| 65 | */ |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 66 | public class PcepReleaseTunnelProviderTest { |
| 67 | |
Brian Stanke | 9a10897 | 2016-04-11 15:25:17 -0400 | [diff] [blame] | 68 | private static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep"; |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 69 | private PcepTunnelProvider tunnelProvider = new PcepTunnelProvider(); |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 70 | private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter(); |
| 71 | private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); |
| 72 | private final PcepControllerAdapter ctl = new PcepControllerAdapter(); |
| 73 | private final PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper(); |
Ray Milkey | d1c34da | 2018-06-22 18:10:53 -0700 | [diff] [blame] | 74 | private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter(); |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 75 | private final DeviceServiceAdapter deviceService = new DeviceServiceAdapter(); |
| 76 | private final MastershipServiceAdapter mastershipService = new MastershipServiceAdapter(); |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 77 | |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 78 | @Before |
| 79 | public void setUp() throws IOException { |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 80 | tunnelProvider.tunnelProviderRegistry = registry; |
| 81 | tunnelProvider.pcepClientController = controller; |
| 82 | tunnelProvider.controller = ctl; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 83 | tunnelProvider.deviceService = deviceService; |
| 84 | tunnelProvider.mastershipService = mastershipService; |
chengfan | 2fff70f | 2015-08-24 18:20:19 -0500 | [diff] [blame] | 85 | tunnelProvider.tunnelService = tunnelService; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 86 | tunnelProvider.pcepTunnelApiMapper = pcepTunnelAPIMapper; |
chengfan | 2fff70f | 2015-08-24 18:20:19 -0500 | [diff] [blame] | 87 | tunnelProvider.cfgService = new ComponentConfigAdapter(); |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 88 | tunnelProvider.activate(); |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 89 | } |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 90 | |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 91 | /** |
| 92 | * Release tunnel with negotiated capability. |
| 93 | */ |
| 94 | @Test |
| 95 | public void testCasePcepReleaseTunnel() { |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 96 | Tunnel tunnel; |
| 97 | Path path; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 98 | List<Link> links = new ArrayList<>(); |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 99 | |
| 100 | ProviderId pid = new ProviderId("pcep", PROVIDER_ID); |
| 101 | |
| 102 | IpAddress srcIp = IpAddress.valueOf(0xB6024E20); |
| 103 | IpElementId srcElementId = IpElementId.ipElement(srcIp); |
| 104 | |
| 105 | IpAddress dstIp = IpAddress.valueOf(0xB6024E21); |
| 106 | IpElementId dstElementId = IpElementId.ipElement(dstIp); |
| 107 | |
| 108 | IpTunnelEndPoint ipTunnelEndPointSrc; |
| 109 | ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp); |
| 110 | |
| 111 | IpTunnelEndPoint ipTunnelEndPointDst; |
| 112 | ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp); |
| 113 | |
| 114 | ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); |
| 115 | |
| 116 | ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023)); |
| 117 | |
Ray Milkey | 2693bda | 2016-01-22 16:08:14 -0800 | [diff] [blame] | 118 | Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst) |
| 119 | .type(Link.Type.DIRECT).build(); |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 120 | links.add(link); |
| 121 | |
Ray Milkey | a7cf8c8 | 2018-02-08 15:07:06 -0800 | [diff] [blame] | 122 | path = new DefaultPath(pid, links, ScalarWeight.toWeight(20), EMPTY); |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 123 | |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 124 | Annotations annotations = DefaultAnnotations.builder() |
| 125 | .set(LSP_SIG_TYPE, WITH_SIGNALLING.name()) |
| 126 | .build(); |
| 127 | |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 128 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, |
Yi Tseng | fa394de | 2017-02-01 11:26:40 -0800 | [diff] [blame] | 129 | new GroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 130 | path, annotations); |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 131 | |
| 132 | // for releasing tunnel tunnel should exist in db |
| 133 | PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE); |
| 134 | pcepTunnelData.setPlspId(1); |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 135 | StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4); |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 136 | pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv); |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 137 | tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 138 | |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 139 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 140 | controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E20))).setCapability( |
| 141 | new ClientCapability(true, true, true, true, true)); |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 142 | |
| 143 | tunnelProvider.releaseTunnel(tunnel); |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 144 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 145 | } |
| 146 | |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 147 | /** |
| 148 | * Doesn't send initiate message because PCC doesn't supports PCInitiate and stateful capability. |
| 149 | */ |
| 150 | @Test |
| 151 | public void testCasePcepReleaseTunnel2() { |
| 152 | Tunnel tunnel; |
| 153 | Path path; |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 154 | List<Link> links = new ArrayList<>(); |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 155 | |
| 156 | ProviderId pid = new ProviderId("pcep", PROVIDER_ID); |
| 157 | |
| 158 | IpAddress srcIp = IpAddress.valueOf(0xB6024E22); |
| 159 | IpElementId srcElementId = IpElementId.ipElement(srcIp); |
| 160 | |
| 161 | IpAddress dstIp = IpAddress.valueOf(0xB6024E21); |
| 162 | IpElementId dstElementId = IpElementId.ipElement(dstIp); |
| 163 | |
| 164 | IpTunnelEndPoint ipTunnelEndPointSrc; |
| 165 | ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp); |
| 166 | |
| 167 | IpTunnelEndPoint ipTunnelEndPointDst; |
| 168 | ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp); |
| 169 | |
| 170 | ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); |
| 171 | |
| 172 | ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023)); |
| 173 | |
| 174 | Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst) |
| 175 | .type(Link.Type.DIRECT).build(); |
| 176 | links.add(link); |
| 177 | |
Ray Milkey | a7cf8c8 | 2018-02-08 15:07:06 -0800 | [diff] [blame] | 178 | path = new DefaultPath(pid, links, ScalarWeight.toWeight(20), EMPTY); |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 179 | |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 180 | Annotations annotations = DefaultAnnotations.builder() |
| 181 | .set(LSP_SIG_TYPE, WITH_SIGNALLING.name()) |
| 182 | .build(); |
| 183 | |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 184 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, |
Yi Tseng | fa394de | 2017-02-01 11:26:40 -0800 | [diff] [blame] | 185 | new GroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 186 | path, annotations); |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 187 | |
| 188 | // for releasing tunnel tunnel should exist in db |
| 189 | PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE); |
| 190 | pcepTunnelData.setPlspId(1); |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 191 | StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4); |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 192 | pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv); |
| 193 | tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); |
| 194 | |
| 195 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 196 | controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E22))).setCapability( |
| 197 | new ClientCapability(true, false, false, true, true)); |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 198 | |
| 199 | tunnelProvider.releaseTunnel(tunnel); |
| 200 | assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false)); |
| 201 | } |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 202 | |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 203 | /** |
| 204 | * Tests releasing SR based tunnel. |
| 205 | */ |
| 206 | @Test |
| 207 | public void testCasePcepReleaseSrTunnel() { |
| 208 | Tunnel tunnel; |
| 209 | Path path; |
| 210 | List<Link> links = new ArrayList<>(); |
| 211 | |
| 212 | ProviderId pid = new ProviderId("pcep", PROVIDER_ID); |
| 213 | |
| 214 | IpAddress srcIp = IpAddress.valueOf(0xB6024E20); |
| 215 | IpElementId srcElementId = IpElementId.ipElement(srcIp); |
| 216 | |
| 217 | IpAddress dstIp = IpAddress.valueOf(0xB6024E21); |
| 218 | IpElementId dstElementId = IpElementId.ipElement(dstIp); |
| 219 | |
| 220 | IpTunnelEndPoint ipTunnelEndPointSrc; |
| 221 | ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp); |
| 222 | |
| 223 | IpTunnelEndPoint ipTunnelEndPointDst; |
| 224 | ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp); |
| 225 | |
| 226 | ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); |
| 227 | |
| 228 | ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023)); |
| 229 | |
| 230 | Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst) |
| 231 | .type(Link.Type.DIRECT).build(); |
| 232 | links.add(link); |
| 233 | |
Ray Milkey | a7cf8c8 | 2018-02-08 15:07:06 -0800 | [diff] [blame] | 234 | path = new DefaultPath(pid, links, ScalarWeight.toWeight(20), EMPTY); |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 235 | |
| 236 | Annotations annotations = DefaultAnnotations.builder() |
| 237 | .set(LSP_SIG_TYPE, SR_WITHOUT_SIGNALLING.name()) |
| 238 | .build(); |
| 239 | |
| 240 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, |
Yi Tseng | fa394de | 2017-02-01 11:26:40 -0800 | [diff] [blame] | 241 | new GroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 242 | path, annotations); |
| 243 | |
| 244 | // for releasing tunnel tunnel should exist in db |
| 245 | PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE); |
| 246 | pcepTunnelData.setPlspId(1); |
| 247 | StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4); |
| 248 | pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv); |
| 249 | tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); |
| 250 | |
| 251 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 252 | controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E20))).setCapability( |
| 253 | new ClientCapability(true, true, true, true, true)); |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 254 | |
| 255 | tunnelProvider.releaseTunnel(tunnel); |
| 256 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); |
| 257 | } |
| 258 | |
| 259 | /** |
| 260 | * Tests releasing tunnel without SR and without signalling. |
| 261 | */ |
| 262 | @Test |
| 263 | public void testCasePcepReleaseTunnelWithoutSigSr() { |
| 264 | Tunnel tunnel; |
| 265 | Path path; |
| 266 | List<Link> links = new ArrayList<>(); |
| 267 | |
| 268 | ProviderId pid = new ProviderId("pcep", PROVIDER_ID); |
| 269 | |
| 270 | IpAddress srcIp = IpAddress.valueOf(0xB6024E20); |
| 271 | IpElementId srcElementId = IpElementId.ipElement(srcIp); |
| 272 | |
| 273 | IpAddress dstIp = IpAddress.valueOf(0xB6024E21); |
| 274 | IpElementId dstElementId = IpElementId.ipElement(dstIp); |
| 275 | |
| 276 | IpTunnelEndPoint ipTunnelEndPointSrc; |
| 277 | ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp); |
| 278 | |
| 279 | IpTunnelEndPoint ipTunnelEndPointDst; |
| 280 | ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp); |
| 281 | |
| 282 | ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); |
| 283 | |
| 284 | ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023)); |
| 285 | |
| 286 | Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst) |
| 287 | .type(Link.Type.DIRECT).build(); |
| 288 | links.add(link); |
| 289 | |
Ray Milkey | a7cf8c8 | 2018-02-08 15:07:06 -0800 | [diff] [blame] | 290 | path = new DefaultPath(pid, links, ScalarWeight.toWeight(20), EMPTY); |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 291 | |
| 292 | Annotations annotations = DefaultAnnotations.builder() |
| 293 | .set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name()) |
| 294 | .build(); |
| 295 | |
| 296 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, |
Yi Tseng | fa394de | 2017-02-01 11:26:40 -0800 | [diff] [blame] | 297 | new GroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 298 | path, annotations); |
| 299 | |
| 300 | // for releasing tunnel tunnel should exist in db |
| 301 | PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE); |
| 302 | pcepTunnelData.setPlspId(1); |
| 303 | StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4); |
| 304 | pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv); |
| 305 | tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); |
| 306 | |
| 307 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 308 | controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E20))).setCapability( |
| 309 | new ClientCapability(true, true, true, true, true)); |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 310 | |
| 311 | tunnelProvider.releaseTunnel(tunnel); |
| 312 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); |
| 313 | } |
| 314 | |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 315 | @After |
| 316 | public void tearDown() throws IOException { |
| 317 | tunnelProvider.deactivate(); |
| 318 | tunnelProvider.controller = null; |
| 319 | tunnelProvider.pcepClientController = null; |
| 320 | tunnelProvider.tunnelProviderRegistry = null; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 321 | tunnelProvider.deviceService = null; |
| 322 | tunnelProvider.mastershipService = null; |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 323 | } |
| 324 | } |