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