2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.groupbasedpolicy.renderer.vpp.policy;
11 import java.util.Arrays;
12 import java.util.Collection;
13 import java.util.List;
14 import java.util.stream.Collectors;
16 import org.junit.Assert;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.junit.runner.RunWith;
20 import org.mockito.Mockito;
21 import org.mockito.runners.MockitoJUnitRunner;
22 import org.opendaylight.controller.config.yang.config.vpp_provider.impl.VppRenderer;
23 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
24 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
25 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
26 import org.opendaylight.groupbasedpolicy.renderer.vpp.DtoFactory;
27 import org.opendaylight.groupbasedpolicy.renderer.vpp.event.RendererPolicyConfEvent;
28 import org.opendaylight.groupbasedpolicy.renderer.vpp.event.VppEndpointConfEvent;
29 import org.opendaylight.groupbasedpolicy.renderer.vpp.iface.InterfaceManager;
30 import org.opendaylight.groupbasedpolicy.renderer.vpp.iface.VppEndpointLocationProvider;
31 import org.opendaylight.groupbasedpolicy.renderer.vpp.util.KeyFactory;
32 import org.opendaylight.groupbasedpolicy.renderer.vpp.util.MountedDataBrokerProvider;
33 import org.opendaylight.groupbasedpolicy.test.CustomDataBrokerTest;
34 import org.opendaylight.groupbasedpolicy.util.IidFactory;
35 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
36 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
37 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.has.absolute.location.AbsoluteLocation;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint_location_provider.rev160419.LocationProviders;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint_location_provider.rev160419.location.providers.LocationProvider;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint_location_provider.rev160419.location.providers.location.provider.ProviderAddressEndpointLocation;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.forwarding.l2_l3.rev160427.L2FloodDomain;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.RendererPolicy;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.RendererPolicyBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.renderer.policy.Configuration;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.renderer.policy.configuration.endpoints.AddressEndpointWithLocation;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.renderer.policy.configuration.endpoints.AddressEndpointWithLocationBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.renderer.policy.configuration.endpoints.AddressEndpointWithLocationKey;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.Config;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.config.VppEndpoint;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.config.VppEndpointBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.config.VppEndpointKey;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.bridge.domain.base.attributes.PhysicalLocationRef;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425._interface.attributes._interface.type.choice.VhostUserCaseBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VppInterfaceAugmentation;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VxlanVni;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.L2;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.l2.base.attributes.Interconnection;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.l2.base.attributes.interconnection.BridgeBased;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.vpp.BridgeDomains;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbridge.topology.rev160129.TopologyVbridgeAugment;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbridge.tunnel.vxlan.rev160429.TunnelTypeVxlan;
63 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
64 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
66 import com.google.common.base.Optional;
67 import com.google.common.base.Strings;
69 @RunWith(MockitoJUnitRunner.class)
70 public class VppRendererPolicyManagerTest extends CustomDataBrokerTest {
72 private static final InstanceIdentifier<RendererPolicy> RENDERER_POLICY_IID =
73 IidFactory.rendererIid(VppRenderer.NAME).child(RendererPolicy.class);
74 private final static String SOCKET = "socket";
76 private MountedDataBrokerProvider mountedDataProviderMock;
77 private DataBroker mountPointDataBroker;
78 private DataBroker dataBroker;
80 private BridgeDomainManagerImpl bdManager;
81 private InterfaceManager ifaceManager;
82 private ForwardingManager fwManager;
83 private VppRendererPolicyManager vppRendererPolicyManager;
86 public Collection<Class<?>> getClassesFromModules() {
87 return Arrays.asList(Node.class, VppEndpoint.class, Interfaces.class, BridgeDomains.class,
88 LocationProviders.class, L2FloodDomain.class, VxlanVni.class, TopologyVbridgeAugment.class,
89 TunnelTypeVxlan.class, PhysicalLocationRef.class);
93 public void init() throws Exception {
94 mountedDataProviderMock = Mockito.mock(MountedDataBrokerProvider.class);
95 mountPointDataBroker = getDataBroker();
96 setup(); // initialize new data broker for ODL data store
97 dataBroker = getDataBroker();
98 Mockito.when(mountedDataProviderMock.getDataBrokerForMountPoint(Mockito.any(InstanceIdentifier.class)))
99 .thenReturn(Optional.of(mountPointDataBroker));
101 new InterfaceManager(mountedDataProviderMock, dataBroker);
102 bdManager = new BridgeDomainManagerImpl(mountPointDataBroker);
103 fwManager = new ForwardingManager(ifaceManager, bdManager, dataBroker);
104 vppRendererPolicyManager = new VppRendererPolicyManager(fwManager, dataBroker);
105 fwManager.setTimer((byte) 1);
109 public void testRendererPolicyChanged_created_oneEpPerEpg() throws Exception {
110 String clientIp = "1.1.1.1";
111 String clientIfaceName = "client1";
112 AbsoluteLocation clientLocation = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, null, clientIfaceName);
113 AddressEndpointWithLocation clientEp =
114 DtoFactory.createEndpoint(clientIp, DtoFactory.L2FD_CTX.getValue(), clientLocation);
115 String webIp = "2.2.2.2";
116 String webIfaceName = "web1";
117 AbsoluteLocation webLocation = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, null, webIfaceName);
118 AddressEndpointWithLocation webEp =
119 DtoFactory.createEndpoint(webIp, DtoFactory.L2FD_CTX.getValue(), webLocation);
121 storeVppEndpoint(clientEp.getKey(), clientIfaceName, createVppEndpointIid(clientEp.getKey()));
122 storeVppEndpoint(webEp.getKey(), webIfaceName, createVppEndpointIid(webEp.getKey()));
124 Configuration configuration = DtoFactory.createConfiguration(Arrays.asList(clientEp), Arrays.asList(webEp));
125 RendererPolicy rendererPolicy =
126 new RendererPolicyBuilder().setVersion(1L).setConfiguration(configuration).build();
127 RendererPolicyConfEvent event = new RendererPolicyConfEvent(RENDERER_POLICY_IID, null, rendererPolicy);
129 vppRendererPolicyManager.rendererPolicyChanged(event);
131 // assert state on data store behind mount point
132 Interface clientIface = readAndAssertInterface(clientIfaceName);
133 assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), clientIface);
134 Interface webIface = readAndAssertInterface(webIfaceName);
135 assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), webIface);
136 // assert state on ODL data store
137 ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction();
138 Optional<LocationProvider> optLocationProvider = rTx.read(LogicalDatastoreType.CONFIGURATION,
139 IidFactory.locationProviderIid(VppEndpointLocationProvider.VPP_ENDPOINT_LOCATION_PROVIDER))
141 Assert.assertTrue(optLocationProvider.isPresent());
142 List<ProviderAddressEndpointLocation> epLocs = optLocationProvider.get().getProviderAddressEndpointLocation();
143 Assert.assertNotNull(epLocs);
144 Assert.assertEquals(2, epLocs.size());
145 assertProviderAddressEndpointLocation(clientEp.getKey(),
146 DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, DtoFactory.L2FD_CTX.getValue(), clientIfaceName),
148 assertProviderAddressEndpointLocation(webEp.getKey(),
149 DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, DtoFactory.L2FD_CTX.getValue(), webIfaceName),
154 public void testRendererPolicyChanged_update() throws Exception {
155 String client1IfaceName = "client1";
156 AbsoluteLocation client1LocationNodeNull =
157 DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, null, client1IfaceName);
158 AddressEndpointWithLocation client1Ep =
159 DtoFactory.createEndpoint("10.0.0.1", DtoFactory.L2FD_CTX.getValue(), client1LocationNodeNull);
160 String web1IfaceName = "web1";
161 AbsoluteLocation web1LocationNodeNull =
162 DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, null, web1IfaceName);
163 AddressEndpointWithLocation web1Ep =
164 DtoFactory.createEndpoint("20.0.0.1", DtoFactory.L2FD_CTX.getValue(), web1LocationNodeNull);
165 String client2IfaceName = "client2";
166 AbsoluteLocation client2LocationNodeNull =
167 DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, null, client2IfaceName);
168 AddressEndpointWithLocation client2Ep =
169 DtoFactory.createEndpoint("10.0.0.2", DtoFactory.L2FD_CTX.getValue(), client2LocationNodeNull);
170 String web2IfaceName = "web2";
171 AbsoluteLocation web2LocationNodeNull =
172 DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, null, web2IfaceName);
173 AddressEndpointWithLocation web2Ep =
174 DtoFactory.createEndpoint("20.0.0.2", DtoFactory.L2FD_CTX.getValue(), web2LocationNodeNull);
176 storeVppEndpoint(client1Ep.getKey(), client1IfaceName, createVppEndpointIid(client1Ep.getKey()));
177 storeVppEndpoint(web1Ep.getKey(), web1IfaceName, createVppEndpointIid(web1Ep.getKey()));
178 storeVppEndpoint(client2Ep.getKey(), client2IfaceName, createVppEndpointIid(client2Ep.getKey()));
179 storeVppEndpoint(web2Ep.getKey(), web2IfaceName, createVppEndpointIid(web2Ep.getKey()));
181 Configuration configuration =
182 DtoFactory.createConfiguration(Arrays.asList(client1Ep, client2Ep), Arrays.asList(web1Ep, web2Ep));
183 RendererPolicy rendererPolicy =
184 new RendererPolicyBuilder().setVersion(1L).setConfiguration(configuration).build();
185 RendererPolicyConfEvent event = new RendererPolicyConfEvent(RENDERER_POLICY_IID, null, rendererPolicy);
187 vppRendererPolicyManager.rendererPolicyChanged(event);
189 // assert state on data store behind mount point ######################################
190 Interface client1Iface = readAndAssertInterface(client1IfaceName);
191 assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), client1Iface);
192 Interface web1Iface = readAndAssertInterface(web1IfaceName);
193 assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), web1Iface);
194 Interface client2Iface = readAndAssertInterface(client2IfaceName);
195 assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), client2Iface);
196 Interface web2Iface = readAndAssertInterface(web2IfaceName);
197 assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), web2Iface);
198 // assert state on ODL data store
199 ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction();
200 Optional<LocationProvider> optLocationProvider = rTx.read(LogicalDatastoreType.CONFIGURATION,
201 IidFactory.locationProviderIid(VppEndpointLocationProvider.VPP_ENDPOINT_LOCATION_PROVIDER))
203 Assert.assertTrue(optLocationProvider.isPresent());
204 List<ProviderAddressEndpointLocation> epLocs = optLocationProvider.get().getProviderAddressEndpointLocation();
205 Assert.assertNotNull(epLocs);
206 Assert.assertEquals(4, epLocs.size());
207 assertProviderAddressEndpointLocation(client1Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID,
208 DtoFactory.L2FD_CTX.getValue(), client1IfaceName), epLocs);
209 assertProviderAddressEndpointLocation(web1Ep.getKey(),
210 DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), web1IfaceName),
212 assertProviderAddressEndpointLocation(client2Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID,
213 DtoFactory.L2FD_CTX.getValue(), client2IfaceName), epLocs);
214 assertProviderAddressEndpointLocation(web2Ep.getKey(),
215 DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), web2IfaceName),
217 // #####################################################################################
219 AbsoluteLocation client1Location = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID,
220 DtoFactory.L2FD_CTX.getValue(), client1IfaceName);
221 AbsoluteLocation web1Location =
222 DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), web1IfaceName);
223 AbsoluteLocation web2Location =
224 DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), web2IfaceName);
225 configuration = DtoFactory.createConfiguration(
226 Arrays.asList(new AddressEndpointWithLocationBuilder(client1Ep).setAbsoluteLocation(client1Location)
228 new AddressEndpointWithLocationBuilder(client2Ep).setAbsoluteLocation(client2LocationNodeNull)
230 Arrays.asList(new AddressEndpointWithLocationBuilder(web1Ep).setAbsoluteLocation(web1Location).build(),
231 new AddressEndpointWithLocationBuilder(web2Ep).setAbsoluteLocation(web2Location).build()));
232 RendererPolicy rendererPolicy2 =
233 new RendererPolicyBuilder().setVersion(2L).setConfiguration(configuration).build();
234 RendererPolicyConfEvent event2 =
235 new RendererPolicyConfEvent(RENDERER_POLICY_IID, rendererPolicy, rendererPolicy2);
237 vppRendererPolicyManager.rendererPolicyChanged(event2);
239 // assert state on data store behind mount point ######################################
240 client1Iface = readAndAssertInterface(client1IfaceName);
241 assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), client1Iface);
242 web1Iface = readAndAssertInterface(web1IfaceName);
243 assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), web1Iface);
244 client2Iface = readAndAssertInterface(client2IfaceName);
245 assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), client2Iface);
246 web2Iface = readAndAssertInterface(web2IfaceName);
247 assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), web2Iface);
248 // assert state on ODL data store
249 rTx = dataBroker.newReadOnlyTransaction();
250 optLocationProvider = rTx.read(LogicalDatastoreType.CONFIGURATION,
251 IidFactory.locationProviderIid(VppEndpointLocationProvider.VPP_ENDPOINT_LOCATION_PROVIDER))
253 Assert.assertTrue(optLocationProvider.isPresent());
254 epLocs = optLocationProvider.get().getProviderAddressEndpointLocation();
255 Assert.assertNotNull(epLocs);
256 Assert.assertEquals(4, epLocs.size());
257 assertProviderAddressEndpointLocation(client1Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID,
258 DtoFactory.L2FD_CTX.getValue(), client1IfaceName), epLocs);
259 assertProviderAddressEndpointLocation(web1Ep.getKey(),
260 DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), web1IfaceName),
262 assertProviderAddressEndpointLocation(client2Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID,
263 DtoFactory.L2FD_CTX.getValue(), client2IfaceName), epLocs);
264 assertProviderAddressEndpointLocation(web2Ep.getKey(),
265 DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), web2IfaceName),
267 // #####################################################################################
269 AbsoluteLocation client2Location = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID,
270 DtoFactory.L2FD_CTX.getValue(), client2IfaceName);
271 configuration = DtoFactory.createConfiguration(
272 Arrays.asList(new AddressEndpointWithLocationBuilder(client1Ep).setAbsoluteLocation(client1Location)
274 new AddressEndpointWithLocationBuilder(client2Ep).setAbsoluteLocation(client2Location).build()),
275 Arrays.asList(new AddressEndpointWithLocationBuilder(web1Ep).setAbsoluteLocation(web1Location).build(),
276 new AddressEndpointWithLocationBuilder(web2Ep).setAbsoluteLocation(web2Location).build()));
277 RendererPolicy rendererPolicy3 =
278 new RendererPolicyBuilder().setVersion(3L).setConfiguration(configuration).build();
279 RendererPolicyConfEvent event3 =
280 new RendererPolicyConfEvent(RENDERER_POLICY_IID, rendererPolicy2, rendererPolicy3);
282 vppRendererPolicyManager.rendererPolicyChanged(event3);
284 // assert state on data store behind mount point ######################################
285 client1Iface = readAndAssertInterface(client1IfaceName);
286 assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), client1Iface);
287 web1Iface = readAndAssertInterface(web1IfaceName);
288 assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), web1Iface);
289 client2Iface = readAndAssertInterface(client2IfaceName);
290 assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), client2Iface);
291 web2Iface = readAndAssertInterface(web2IfaceName);
292 assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), web2Iface);
293 // assert state on ODL data store
294 rTx = dataBroker.newReadOnlyTransaction();
295 optLocationProvider = rTx.read(LogicalDatastoreType.CONFIGURATION,
296 IidFactory.locationProviderIid(VppEndpointLocationProvider.VPP_ENDPOINT_LOCATION_PROVIDER))
298 Assert.assertTrue(optLocationProvider.isPresent());
299 epLocs = optLocationProvider.get().getProviderAddressEndpointLocation();
300 Assert.assertNotNull(epLocs);
301 Assert.assertEquals(4, epLocs.size());
302 assertProviderAddressEndpointLocation(client1Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID,
303 DtoFactory.L2FD_CTX.getValue(), client1IfaceName), epLocs);
304 assertProviderAddressEndpointLocation(web1Ep.getKey(),
305 DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), web1IfaceName),
307 assertProviderAddressEndpointLocation(client2Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID,
308 DtoFactory.L2FD_CTX.getValue(), client2IfaceName), epLocs);
309 assertProviderAddressEndpointLocation(web2Ep.getKey(),
310 DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), web2IfaceName),
312 // #####################################################################################
315 private InstanceIdentifier<VppEndpoint> createVppEndpointIid(AddressEndpointWithLocationKey key) {
316 return InstanceIdentifier.builder(Config.class)
317 .child(VppEndpoint.class, new VppEndpointKey(key.getAddress(), key.getAddressType(), key.getContextId(),
318 key.getContextType()))
322 private void assertProviderAddressEndpointLocation(AddressEndpointWithLocationKey expectedEpKey,
323 AbsoluteLocation expectedEpLoc, List<ProviderAddressEndpointLocation> providerEpLocs) {
324 List<ProviderAddressEndpointLocation> expectedProvEpLoc =
325 providerEpLocs.stream()
326 .filter(provEpLoc -> provEpLoc.getKey()
327 .equals(KeyFactory.providerAddressEndpointLocationKey(expectedEpKey)))
328 .collect(Collectors.toList());
329 Assert.assertFalse(expectedProvEpLoc.isEmpty());
330 Assert.assertEquals(1, expectedProvEpLoc.size());
331 Assert.assertEquals(expectedEpLoc, expectedProvEpLoc.get(0).getAbsoluteLocation());
334 private Interface readAndAssertInterface(String expectedInterface) throws Exception {
335 ReadOnlyTransaction rTxMount = mountPointDataBroker.newReadOnlyTransaction();
336 Optional<Interface> potentialIface = rTxMount.read(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier
337 .builder(Interfaces.class).child(Interface.class, new InterfaceKey(expectedInterface)).build()).get();
338 Assert.assertTrue(potentialIface.isPresent());
339 return potentialIface.get();
342 private static void assertBridgeDomainOnInterface(String expectedBridgeDomain, Interface actualIface) {
343 VppInterfaceAugmentation vppIfaceAug = actualIface.getAugmentation(VppInterfaceAugmentation.class);
344 Assert.assertNotNull(vppIfaceAug);
345 if (!Strings.isNullOrEmpty(expectedBridgeDomain)) {
346 Interconnection interconnection = vppIfaceAug.getL2().getInterconnection();
347 Assert.assertNotNull(interconnection);
348 Assert.assertTrue(interconnection instanceof BridgeBased);
349 Assert.assertEquals(expectedBridgeDomain, ((BridgeBased) interconnection).getBridgeDomain());
351 if (vppIfaceAug != null) {
352 L2 l2 = vppIfaceAug.getL2();
354 Assert.assertNull(l2.getInterconnection());
360 private void storeVppEndpoint(AddressEndpointWithLocationKey epKey, String ifaceName,
361 InstanceIdentifier<VppEndpoint> vppEpIid) {
362 VppEndpoint vhostEp = new VppEndpointBuilder().setAddress(epKey.getAddress())
363 .setAddressType(epKey.getAddressType())
364 .setContextId(epKey.getContextId())
365 .setContextType(epKey.getContextType())
366 .setVppInterfaceName(ifaceName)
367 .setVppNodeId(DtoFactory.VPP_NODE_1_IID.firstKeyOf(Node.class).getNodeId())
368 .setInterfaceTypeChoice(new VhostUserCaseBuilder().setSocket(SOCKET).build())
370 VppEndpointConfEvent vppEpEvent = new VppEndpointConfEvent(vppEpIid, null, vhostEp);
371 ifaceManager.vppEndpointChanged(vppEpEvent);