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