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