Andreas Pantelopoulos | 5e7be3d | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Foundation |
| 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 | |
| 17 | package org.onosproject.segmentrouting; |
| 18 | |
| 19 | import com.fasterxml.jackson.databind.JsonNode; |
| 20 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 21 | import com.google.common.collect.Lists; |
| 22 | import com.google.common.collect.Sets; |
| 23 | import org.junit.Before; |
| 24 | import org.junit.Test; |
| 25 | import org.onlab.packet.IpAddress; |
| 26 | import org.onlab.packet.IpPrefix; |
| 27 | import org.onlab.packet.MacAddress; |
| 28 | import org.onlab.packet.MplsLabel; |
| 29 | import org.onlab.packet.VlanId; |
| 30 | import org.onosproject.TestApplicationId; |
| 31 | import org.onosproject.core.ApplicationId; |
| 32 | import org.onosproject.net.ConnectPoint; |
| 33 | import org.onosproject.net.DefaultAnnotations; |
| 34 | import org.onosproject.net.DefaultHost; |
| 35 | import org.onosproject.net.Device; |
| 36 | import org.onosproject.net.DeviceId; |
| 37 | import org.onosproject.net.Host; |
| 38 | import org.onosproject.net.HostId; |
| 39 | import org.onosproject.net.HostLocation; |
| 40 | import org.onosproject.net.PortNumber; |
| 41 | import org.onosproject.net.config.Config; |
| 42 | import org.onosproject.net.config.ConfigApplyDelegate; |
| 43 | import org.onosproject.net.device.DeviceService; |
| 44 | import org.onosproject.net.host.InterfaceIpAddress; |
| 45 | import org.onosproject.net.intf.Interface; |
| 46 | import org.onosproject.net.intf.InterfaceService; |
| 47 | import org.onosproject.net.provider.ProviderId; |
| 48 | import org.onosproject.segmentrouting.config.PwaasConfig; |
Andreas Pantelopoulos | 4c7de13 | 2018-02-22 12:32:42 -0800 | [diff] [blame^] | 49 | |
| 50 | import org.onosproject.segmentrouting.pwaas.L2Tunnel; |
| 51 | import org.onosproject.segmentrouting.pwaas.L2TunnelDescription; |
| 52 | import org.onosproject.segmentrouting.pwaas.L2TunnelPolicy; |
Andreas Pantelopoulos | 5e7be3d | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 53 | import org.onosproject.segmentrouting.pwaas.DefaultL2Tunnel; |
Andreas Pantelopoulos | 5e7be3d | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 54 | import org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy; |
| 55 | import org.onosproject.segmentrouting.pwaas.L2Mode; |
| 56 | |
| 57 | import java.io.InputStream; |
| 58 | import java.util.Set; |
| 59 | |
| 60 | import static org.hamcrest.Matchers.is; |
| 61 | import static org.junit.Assert.*; |
| 62 | |
| 63 | /** |
| 64 | * Unit tests for class {@link PwaasConfig}. |
| 65 | */ |
| 66 | public class PwaasConfigTest { |
| 67 | |
| 68 | private static final String TUNNEL_ID_1 = "1"; |
| 69 | private static final String TUNNEL_ID_2 = "20"; |
| 70 | private static final String NOT_PRESENT_TUNNEL_ID = "2"; |
| 71 | private static final ConnectPoint INGRESS_1 = ConnectPoint.deviceConnectPoint("of:0000000000000001/1"); |
| 72 | private static final ConnectPoint INGRESS_2 = ConnectPoint.deviceConnectPoint("of:0000000000000001/1"); |
| 73 | private static final ConnectPoint EGRESS_1 = ConnectPoint.deviceConnectPoint("of:0000000000000002/1"); |
| 74 | private static final ConnectPoint EGRESS_2 = ConnectPoint.deviceConnectPoint("of:0000000000000002/1"); |
| 75 | private static final VlanId INGRESS_INNER_TAG_1 = VlanId.vlanId("10"); |
| 76 | private static final VlanId INGRESS_INNER_TAG_2 = VlanId.vlanId("100"); |
| 77 | private static final VlanId INGRESS_OUTER_TAG_1 = VlanId.vlanId("20"); |
| 78 | private static final VlanId INGRESS_OUTER_TAG_2 = VlanId.vlanId("200"); |
| 79 | private static final VlanId EGRESS_INNER_TAG_1 = VlanId.vlanId("10"); |
| 80 | private static final VlanId EGRESS_INNER_TAG_2 = VlanId.vlanId("100"); |
| 81 | private static final VlanId EGRESS_OUTER_TAG_1 = VlanId.vlanId("21"); |
| 82 | private static final VlanId EGRESS_OUTER_TAG_2 = VlanId.vlanId("210"); |
| 83 | private static final String MODE_1 = "RAW"; |
| 84 | private static final String MODE_2 = "RAW"; |
| 85 | private static final VlanId SD_TAG_1 = VlanId.NONE; |
| 86 | private static final VlanId SD_TAG_2 = VlanId.NONE; |
| 87 | private static final MplsLabel PW_LABEL_1 = MplsLabel.mplsLabel("255"); |
| 88 | private static final MplsLabel PW_LABEL_2 = MplsLabel.mplsLabel("1255"); |
| 89 | |
| 90 | /* |
| 91 | * Configuration below copied from host handler test. |
| 92 | */ |
| 93 | |
| 94 | // Host Mac, VLAN |
| 95 | private static final ProviderId PROVIDER_ID = ProviderId.NONE; |
| 96 | private static final MacAddress HOST_MAC = MacAddress.valueOf("00:00:00:00:00:01"); |
| 97 | private static final VlanId HOST_VLAN_UNTAGGED = VlanId.NONE; |
| 98 | private static final HostId HOST_ID_UNTAGGED = HostId.hostId(HOST_MAC, HOST_VLAN_UNTAGGED); |
| 99 | private static final VlanId HOST_VLAN_TAGGED = VlanId.vlanId((short) 20); |
| 100 | private static final HostId HOST_ID_TAGGED = HostId.hostId(HOST_MAC, HOST_VLAN_TAGGED); |
| 101 | // Host IP |
| 102 | private static final IpAddress HOST_IP11 = IpAddress.valueOf("10.0.1.1"); |
| 103 | private static final IpAddress HOST_IP21 = IpAddress.valueOf("10.0.2.1"); |
| 104 | private static final IpAddress HOST_IP12 = IpAddress.valueOf("10.0.1.2"); |
| 105 | private static final IpAddress HOST_IP13 = IpAddress.valueOf("10.0.1.3"); |
| 106 | private static final IpAddress HOST_IP14 = IpAddress.valueOf("10.0.1.4"); |
| 107 | private static final IpAddress HOST_IP32 = IpAddress.valueOf("10.0.3.2"); |
| 108 | // Device |
| 109 | private static final DeviceId DEV1 = DeviceId.deviceId("of:0000000000000001"); |
| 110 | private static final DeviceId DEV2 = DeviceId.deviceId("of:0000000000000002"); |
| 111 | private static final DeviceId DEV3 = DeviceId.deviceId("of:0000000000000003"); |
| 112 | private static final DeviceId DEV4 = DeviceId.deviceId("of:0000000000000004"); |
| 113 | private static final DeviceId DEV5 = DeviceId.deviceId("of:0000000000000005"); |
| 114 | private static final DeviceId DEV6 = DeviceId.deviceId("of:0000000000000006"); |
| 115 | // Port |
| 116 | private static final PortNumber P1 = PortNumber.portNumber(1); |
| 117 | private static final PortNumber P2 = PortNumber.portNumber(2); |
| 118 | private static final PortNumber P3 = PortNumber.portNumber(3); |
| 119 | private static final PortNumber P9 = PortNumber.portNumber(9); |
| 120 | // Connect Point |
| 121 | private static final ConnectPoint CP11 = new ConnectPoint(DEV1, P1); |
| 122 | private static final HostLocation HOST_LOC11 = new HostLocation(CP11, 0); |
| 123 | private static final ConnectPoint CP12 = new ConnectPoint(DEV1, P2); |
| 124 | private static final HostLocation HOST_LOC12 = new HostLocation(CP12, 0); |
| 125 | private static final ConnectPoint CP13 = new ConnectPoint(DEV1, P3); |
| 126 | private static final HostLocation HOST_LOC13 = new HostLocation(CP13, 0); |
| 127 | private static final ConnectPoint CP21 = new ConnectPoint(DEV2, P1); |
| 128 | private static final HostLocation HOST_LOC21 = new HostLocation(CP21, 0); |
| 129 | private static final ConnectPoint CP22 = new ConnectPoint(DEV2, P2); |
| 130 | private static final HostLocation HOST_LOC22 = new HostLocation(CP22, 0); |
| 131 | // Connect Point for dual-homed host failover |
| 132 | private static final ConnectPoint CP31 = new ConnectPoint(DEV3, P1); |
| 133 | private static final HostLocation HOST_LOC31 = new HostLocation(CP31, 0); |
| 134 | private static final ConnectPoint CP32 = new ConnectPoint(DEV3, P2); |
| 135 | private static final HostLocation HOST_LOC32 = new HostLocation(CP32, 0); |
| 136 | private static final ConnectPoint CP41 = new ConnectPoint(DEV4, P1); |
| 137 | private static final HostLocation HOST_LOC41 = new HostLocation(CP41, 0); |
| 138 | private static final ConnectPoint CP39 = new ConnectPoint(DEV3, P9); |
| 139 | private static final ConnectPoint CP49 = new ConnectPoint(DEV4, P9); |
| 140 | // Conenct Point for mastership test |
| 141 | private static final ConnectPoint CP51 = new ConnectPoint(DEV5, P1); |
| 142 | private static final HostLocation HOST_LOC51 = new HostLocation(CP51, 0); |
| 143 | private static final ConnectPoint CP61 = new ConnectPoint(DEV6, P1); |
| 144 | private static final HostLocation HOST_LOC61 = new HostLocation(CP61, 0); |
| 145 | // Interface VLAN |
| 146 | private static final VlanId INTF_VLAN_UNTAGGED = VlanId.vlanId((short) 10); |
| 147 | private static final Set<VlanId> INTF_VLAN_TAGGED = Sets.newHashSet(VlanId.vlanId((short) 20)); |
| 148 | private static final VlanId INTF_VLAN_NATIVE = VlanId.vlanId((short) 30); |
| 149 | private static final Set<VlanId> INTF_VLAN_PAIR = Sets.newHashSet(VlanId.vlanId((short) 10), |
| 150 | VlanId.vlanId((short) 20), VlanId.vlanId((short) 30)); |
| 151 | private static final VlanId INTF_VLAN_OTHER = VlanId.vlanId((short) 40); |
| 152 | // Interface subnet |
| 153 | private static final IpPrefix INTF_PREFIX1 = IpPrefix.valueOf("10.0.1.254/24"); |
| 154 | private static final IpPrefix INTF_PREFIX2 = IpPrefix.valueOf("10.0.2.254/24"); |
| 155 | private static final IpPrefix INTF_PREFIX3 = IpPrefix.valueOf("10.0.3.254/24"); |
| 156 | private static final InterfaceIpAddress INTF_IP1 = |
| 157 | new InterfaceIpAddress(INTF_PREFIX1.address(), INTF_PREFIX1); |
| 158 | private static final InterfaceIpAddress INTF_IP2 = |
| 159 | new InterfaceIpAddress(INTF_PREFIX2.address(), INTF_PREFIX2); |
| 160 | private static final InterfaceIpAddress INTF_IP3 = |
| 161 | new InterfaceIpAddress(INTF_PREFIX3.address(), INTF_PREFIX3); |
| 162 | // Interfaces |
| 163 | private static final Interface INTF11 = |
| 164 | new Interface(null, CP11, Lists.newArrayList(INTF_IP1), MacAddress.NONE, null, |
| 165 | INTF_VLAN_UNTAGGED, null, null); |
| 166 | private static final Interface INTF12 = |
| 167 | new Interface(null, CP12, Lists.newArrayList(INTF_IP1), MacAddress.NONE, null, |
| 168 | INTF_VLAN_UNTAGGED, null, null); |
| 169 | private static final Interface INTF13 = |
| 170 | new Interface(null, CP13, Lists.newArrayList(INTF_IP2), MacAddress.NONE, null, |
| 171 | null, INTF_VLAN_TAGGED, INTF_VLAN_NATIVE); |
| 172 | private static final Interface INTF21 = |
| 173 | new Interface(null, CP21, Lists.newArrayList(INTF_IP1), MacAddress.NONE, null, |
| 174 | INTF_VLAN_UNTAGGED, null, null); |
| 175 | private static final Interface INTF22 = |
| 176 | new Interface(null, CP22, Lists.newArrayList(INTF_IP1), MacAddress.NONE, null, |
| 177 | INTF_VLAN_UNTAGGED, null, null); |
| 178 | private static final Interface INTF31 = |
| 179 | new Interface(null, CP31, Lists.newArrayList(INTF_IP1), MacAddress.NONE, null, |
| 180 | INTF_VLAN_UNTAGGED, null, null); |
| 181 | private static final Interface INTF32 = |
| 182 | new Interface(null, CP32, Lists.newArrayList(INTF_IP3), MacAddress.NONE, null, |
| 183 | INTF_VLAN_OTHER, null, null); |
| 184 | private static final Interface INTF39 = |
| 185 | new Interface(null, CP39, Lists.newArrayList(INTF_IP1), MacAddress.NONE, null, |
| 186 | null, INTF_VLAN_PAIR, null); |
| 187 | private static final Interface INTF41 = |
| 188 | new Interface(null, CP41, Lists.newArrayList(INTF_IP1), MacAddress.NONE, null, |
| 189 | INTF_VLAN_UNTAGGED, null, null); |
| 190 | private static final Interface INTF49 = |
| 191 | new Interface(null, CP49, Lists.newArrayList(INTF_IP1), MacAddress.NONE, null, |
| 192 | null, INTF_VLAN_PAIR, null); |
| 193 | // Host |
| 194 | private static final Host HOST1 = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, |
| 195 | HOST_VLAN_UNTAGGED, |
| 196 | Sets.newHashSet(HOST_LOC11, HOST_LOC21), |
| 197 | Sets.newHashSet(HOST_IP11), |
| 198 | false); |
| 199 | |
| 200 | // A set of hosts |
| 201 | private static final Set<Host> HOSTS = Sets.newHashSet(HOST1); |
| 202 | // A set of devices of which we have mastership |
| 203 | private static final Set<DeviceId> LOCAL_DEVICES = Sets.newHashSet(DEV1, DEV2, DEV3, DEV4); |
| 204 | // A set of interfaces |
| 205 | private static final Set<Interface> INTERFACES = Sets.newHashSet(INTF11, INTF12, INTF13, INTF21, |
| 206 | INTF22, INTF31, INTF32, INTF39, INTF41, INTF49); |
| 207 | |
| 208 | private PwaasConfig config; |
| 209 | private PwaasConfig invalidConfigVlan; |
| 210 | private PwaasConfig invalidConfigMode; |
| 211 | private PwaasConfig invalidConfigLabel; |
| 212 | private PwaasConfig invalidConfigConflictingVlan; |
| 213 | |
| 214 | @Before |
| 215 | public void setUp() throws Exception { |
| 216 | InputStream jsonStream = PwaasConfig.class |
| 217 | .getResourceAsStream("/pwaas.json"); |
| 218 | InputStream jsonStreamInvalid1 = PwaasConfig.class |
| 219 | .getResourceAsStream("/pwaas-invalid-mode.json"); |
| 220 | InputStream jsonStreamInvalid2 = PwaasConfig.class |
| 221 | .getResourceAsStream("/pwaas-invalid-pwlabel.json"); |
| 222 | InputStream jsonStreamInvalid3 = PwaasConfig.class |
| 223 | .getResourceAsStream("/pwaas-invalid-vlan.json"); |
| 224 | InputStream jsonStreamInvalid4 = PwaasConfig.class |
| 225 | .getResourceAsStream("/pwaas-conflicting-vlan.json"); |
| 226 | |
| 227 | String key = SegmentRoutingManager.APP_NAME; |
| 228 | ApplicationId subject = new TestApplicationId(key); |
| 229 | ObjectMapper mapper = new ObjectMapper(); |
| 230 | |
| 231 | JsonNode jsonNode = mapper.readTree(jsonStream); |
| 232 | JsonNode jsonNodeInvalid1 = mapper.readTree(jsonStreamInvalid1); |
| 233 | JsonNode jsonNodeInvalid2 = mapper.readTree(jsonStreamInvalid2); |
| 234 | JsonNode jsonNodeInvalid3 = mapper.readTree(jsonStreamInvalid3); |
| 235 | JsonNode jsonNodeInvalid4 = mapper.readTree(jsonStreamInvalid4); |
| 236 | |
| 237 | ConfigApplyDelegate delegate = new MockDelegate(); |
| 238 | |
| 239 | DeviceService devService = new MockDeviceService(); |
| 240 | InterfaceService infService = new MockInterfaceService(INTERFACES); |
| 241 | |
| 242 | // create two devices and add them |
| 243 | DefaultAnnotations.Builder builderDev1 = DefaultAnnotations.builder(); |
| 244 | DefaultAnnotations.Builder builderDev2 = DefaultAnnotations.builder(); |
| 245 | |
| 246 | Device dev1 = new MockDevice(DEV1, builderDev1.build()); |
| 247 | Device dev2 = new MockDevice(DEV2, builderDev2.build()); |
| 248 | ((MockDeviceService) devService).addDevice(dev1); |
| 249 | ((MockDeviceService) devService).addDevice(dev2); |
| 250 | |
| 251 | config = new PwaasConfig(devService, infService); |
| 252 | invalidConfigVlan = new PwaasConfig(devService, infService); |
| 253 | invalidConfigMode = new PwaasConfig(devService, infService); |
| 254 | invalidConfigLabel = new PwaasConfig(devService, infService); |
| 255 | invalidConfigConflictingVlan = new PwaasConfig(devService, infService); |
| 256 | |
| 257 | config.init(subject, key, jsonNode, mapper, delegate); |
| 258 | invalidConfigVlan.init(subject, key, jsonNodeInvalid1, mapper, delegate); |
| 259 | invalidConfigMode.init(subject, key, jsonNodeInvalid2, mapper, delegate); |
| 260 | invalidConfigLabel.init(subject, key, jsonNodeInvalid3, mapper, delegate); |
| 261 | invalidConfigConflictingVlan.init(subject, key, jsonNodeInvalid4, mapper, delegate); |
| 262 | |
| 263 | config.deviceService = devService; |
| 264 | config.intfService = infService; |
| 265 | |
| 266 | invalidConfigVlan.deviceService = devService; |
| 267 | invalidConfigVlan.intfService = infService; |
| 268 | |
| 269 | invalidConfigLabel.deviceService = devService; |
| 270 | invalidConfigLabel.intfService = infService; |
| 271 | |
| 272 | invalidConfigMode.deviceService = devService; |
| 273 | invalidConfigMode.intfService = infService; |
| 274 | |
| 275 | invalidConfigConflictingVlan.deviceService = devService; |
| 276 | invalidConfigConflictingVlan.intfService = infService; |
| 277 | } |
| 278 | |
| 279 | /** |
| 280 | * Tests config validity. |
| 281 | */ |
| 282 | @Test |
| 283 | public void testIsValid() { |
| 284 | try { |
| 285 | assertTrue(config.isValid()); |
| 286 | } catch (IllegalArgumentException e) { |
| 287 | assertTrue(false); |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | /** |
| 292 | * Tests config in-validity. |
| 293 | */ |
| 294 | @Test |
| 295 | public void testValid1() { |
| 296 | assertFalse(invalidConfigVlan.isValid()); |
| 297 | } |
| 298 | |
| 299 | @Test |
| 300 | public void testValid2() { |
| 301 | assertFalse(invalidConfigMode.isValid()); |
| 302 | } |
| 303 | |
| 304 | @Test |
| 305 | public void testValid3() { |
| 306 | assertFalse(invalidConfigLabel.isValid()); |
| 307 | } |
| 308 | |
Andreas Pantelopoulos | b3e45a3 | 2018-01-16 11:51:32 -0800 | [diff] [blame] | 309 | @Test |
Andreas Pantelopoulos | 5e7be3d | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 310 | public void testValid4() { |
Andreas Pantelopoulos | b3e45a3 | 2018-01-16 11:51:32 -0800 | [diff] [blame] | 311 | assertFalse(invalidConfigConflictingVlan.isValid()); |
Andreas Pantelopoulos | 5e7be3d | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | /** |
| 315 | * Tests getPwIds. |
| 316 | */ |
| 317 | @Test |
| 318 | public void testGetPwIds() { |
| 319 | Set<Long> pwIds = config.getPwIds(); |
| 320 | |
| 321 | assertThat(pwIds.size(), is(2)); |
| 322 | assertTrue(pwIds.contains(Long.parseLong(TUNNEL_ID_1))); |
| 323 | assertTrue(pwIds.contains(Long.parseLong(TUNNEL_ID_2))); |
| 324 | assertFalse(pwIds.contains(Long.parseLong(NOT_PRESENT_TUNNEL_ID))); |
| 325 | } |
| 326 | |
| 327 | /** |
| 328 | * Tests getPwDescription. |
| 329 | */ |
| 330 | @Test |
| 331 | public void testGetPwDescription() { |
Andreas Pantelopoulos | 4c7de13 | 2018-02-22 12:32:42 -0800 | [diff] [blame^] | 332 | L2TunnelDescription l2TunnelDescription = null; |
Andreas Pantelopoulos | 5e7be3d | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 333 | |
Andreas Pantelopoulos | 4c7de13 | 2018-02-22 12:32:42 -0800 | [diff] [blame^] | 334 | L2Tunnel l2Tunnel = new DefaultL2Tunnel( |
Andreas Pantelopoulos | 5e7be3d | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 335 | L2Mode.valueOf(MODE_1), |
| 336 | SD_TAG_1, |
| 337 | Long.parseLong(TUNNEL_ID_1), |
| 338 | PW_LABEL_1 |
| 339 | ); |
Andreas Pantelopoulos | 4c7de13 | 2018-02-22 12:32:42 -0800 | [diff] [blame^] | 340 | L2TunnelPolicy l2TunnelPolicy = new DefaultL2TunnelPolicy( |
Andreas Pantelopoulos | 5e7be3d | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 341 | Long.parseLong(TUNNEL_ID_1), |
| 342 | INGRESS_1, |
| 343 | INGRESS_INNER_TAG_1, |
| 344 | INGRESS_OUTER_TAG_1, |
| 345 | EGRESS_1, |
| 346 | EGRESS_INNER_TAG_1, |
| 347 | EGRESS_OUTER_TAG_1 |
| 348 | ); |
| 349 | |
| 350 | l2TunnelDescription = config.getPwDescription(Long.parseLong(TUNNEL_ID_1)); |
| 351 | assertThat(l2TunnelDescription.l2Tunnel().pwMode(), is(l2Tunnel.pwMode())); |
| 352 | assertThat(l2TunnelDescription.l2Tunnel().sdTag(), is(l2Tunnel.sdTag())); |
| 353 | assertThat(l2TunnelDescription.l2Tunnel().tunnelId(), is(l2Tunnel.tunnelId())); |
| 354 | assertThat(l2TunnelDescription.l2Tunnel().pwLabel(), is(l2Tunnel.pwLabel())); |
| 355 | assertThat(l2TunnelDescription.l2TunnelPolicy().tunnelId(), is(l2TunnelPolicy.tunnelId())); |
| 356 | assertThat(l2TunnelDescription.l2TunnelPolicy().cP1InnerTag(), is(l2TunnelPolicy.cP1InnerTag())); |
| 357 | assertThat(l2TunnelDescription.l2TunnelPolicy().cP1OuterTag(), is(l2TunnelPolicy.cP1OuterTag())); |
| 358 | assertThat(l2TunnelDescription.l2TunnelPolicy().cP2InnerTag(), is(l2TunnelPolicy.cP2InnerTag())); |
| 359 | assertThat(l2TunnelDescription.l2TunnelPolicy().cP2OuterTag(), is(l2TunnelPolicy.cP2OuterTag())); |
| 360 | assertThat(l2TunnelDescription.l2TunnelPolicy().cP1(), is(l2TunnelPolicy.cP1())); |
| 361 | assertThat(l2TunnelDescription.l2TunnelPolicy().cP2(), is(l2TunnelPolicy.cP2())); |
| 362 | |
| 363 | l2Tunnel = new DefaultL2Tunnel( |
| 364 | L2Mode.valueOf(MODE_2), |
| 365 | SD_TAG_2, |
| 366 | Long.parseLong(TUNNEL_ID_2), |
| 367 | PW_LABEL_2 |
| 368 | ); |
| 369 | l2TunnelPolicy = new DefaultL2TunnelPolicy( |
| 370 | Long.parseLong(TUNNEL_ID_2), |
| 371 | INGRESS_2, |
| 372 | INGRESS_INNER_TAG_2, |
| 373 | INGRESS_OUTER_TAG_2, |
| 374 | EGRESS_2, |
| 375 | EGRESS_INNER_TAG_2, |
| 376 | EGRESS_OUTER_TAG_2 |
| 377 | ); |
| 378 | |
| 379 | l2TunnelDescription = config.getPwDescription(Long.parseLong(TUNNEL_ID_2)); |
| 380 | assertThat(l2TunnelDescription.l2Tunnel().pwMode(), is(l2Tunnel.pwMode())); |
| 381 | assertThat(l2TunnelDescription.l2Tunnel().sdTag(), is(l2Tunnel.sdTag())); |
| 382 | assertThat(l2TunnelDescription.l2Tunnel().tunnelId(), is(l2Tunnel.tunnelId())); |
| 383 | assertThat(l2TunnelDescription.l2Tunnel().pwLabel(), is(l2Tunnel.pwLabel())); |
| 384 | assertThat(l2TunnelDescription.l2TunnelPolicy().tunnelId(), is(l2TunnelPolicy.tunnelId())); |
| 385 | assertThat(l2TunnelDescription.l2TunnelPolicy().cP1InnerTag(), is(l2TunnelPolicy.cP1InnerTag())); |
| 386 | assertThat(l2TunnelDescription.l2TunnelPolicy().cP1OuterTag(), is(l2TunnelPolicy.cP1OuterTag())); |
| 387 | assertThat(l2TunnelDescription.l2TunnelPolicy().cP2OuterTag(), is(l2TunnelPolicy.cP2OuterTag())); |
| 388 | assertThat(l2TunnelDescription.l2TunnelPolicy().cP2OuterTag(), is(l2TunnelPolicy.cP2OuterTag())); |
| 389 | assertThat(l2TunnelDescription.l2TunnelPolicy().cP1(), is(l2TunnelPolicy.cP1())); |
| 390 | assertThat(l2TunnelDescription.l2TunnelPolicy().cP2(), is(l2TunnelPolicy.cP2())); |
| 391 | } |
| 392 | |
| 393 | private class MockDelegate implements ConfigApplyDelegate { |
| 394 | @Override |
| 395 | public void onApply(Config config) { |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | } |