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