Fixes for DVR
[groupbasedpolicy.git] / renderers / vpp / src / test / java / org / opendaylight / groupbasedpolicy / renderer / vpp / policy / VppRendererPolicyManagerTest.java
index d23bcc94e1486e7f7226cfa0e245e2a51a96e0c8..5c24f4289e3bb558f1fcb79638b9d67bd091a75b 100644 (file)
@@ -8,9 +8,13 @@
 
 package org.opendaylight.groupbasedpolicy.renderer.vpp.policy;
 
+import java.util.AbstractMap;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.locks.ReentrantLock;
 import java.util.stream.Collectors;
 
 import org.junit.Assert;
@@ -22,24 +26,47 @@ import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.controller.config.yang.config.vpp_provider.impl.VppRenderer;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.DtoFactory;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.dhcp.DhcpRelayHandler;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.event.RendererPolicyConfEvent;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.event.VppEndpointConfEvent;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.iface.InterfaceManager;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.iface.VppEndpointLocationProvider;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.lisp.LispStateManager;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.lisp.flat.overlay.FlatOverlayManager;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.lisp.loopback.LoopbackManager;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.listener.VppEndpointListener;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.nat.CentralizedNatImpl;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.nat.NatManager;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.policy.acl.AclManager;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.routing.RoutingManager;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.util.KeyFactory;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.util.MountedDataBrokerProvider;
 import org.opendaylight.groupbasedpolicy.test.CustomDataBrokerTest;
 import org.opendaylight.groupbasedpolicy.util.IidFactory;
+import org.opendaylight.vbd.impl.transaction.VbdNetconfTransaction;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.AccessLists;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.Endpoints;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.endpoints.AddressEndpoints;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.endpoints.address.endpoints.AddressEndpoint;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.endpoints.address.endpoints.AddressEndpointBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.endpoints.address.endpoints.AddressEndpointKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.has.absolute.location.AbsoluteLocation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.has.child.endpoints.ChildEndpointBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.has.child.endpoints.ChildEndpointKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint_location_provider.rev160419.LocationProviders;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint_location_provider.rev160419.location.providers.LocationProvider;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint_location_provider.rev160419.location.providers.location.provider.ProviderAddressEndpointLocation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.forwarding.l2_l3.rev160427.L2FloodDomain;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.forwarding.l2_l3.rev170511.L2FloodDomain;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.forwarding.l2_l3.rev170511.L2BridgeDomain;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.forwarding.l2_l3.rev170511.MacAddressType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.RendererPolicy;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.RendererPolicyBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.renderer.policy.Configuration;
@@ -47,31 +74,57 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.renderer.policy.configuration.endpoints.AddressEndpointWithLocationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.renderer.policy.configuration.endpoints.AddressEndpointWithLocationKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.Config;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425._interface.attributes._interface.type.choice.VhostUserCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.bridge.domain.base.attributes.PhysicalLocationRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.config.VppEndpoint;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.config.VppEndpointBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.config.VppEndpointKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.bridge.domain.base.attributes.PhysicalLocationRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425._interface.attributes._interface.type.choice.VhostUserCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VppInterfaceAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VxlanVni;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.L2;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.l2.base.attributes.Interconnection;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.l2.base.attributes.interconnection.BridgeBased;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.vpp.BridgeDomains;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.VppAclInterfaceAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.BridgeDomains;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.VppInterfaceAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.VxlanVni;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.interfaces._interface.L2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.l2.config.attributes.Interconnection;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.l2.config.attributes.interconnection.BridgeBased;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbridge.topology.rev160129.TopologyVbridgeAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbridge.tunnel.vxlan.rev160429.TunnelTypeVxlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbridge.tunnel.vxlan.rev170327.TunnelTypeVxlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbridge.tunnel.vxlan.rev170327.network.topology.topology.tunnel.parameters.VxlanTunnelParameters;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.VppAce;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.nat.rev170816._interface.nat.attributes.Nat;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Strings;
+import com.google.common.collect.Lists;
+import com.google.common.eventbus.EventBus;
 
 @RunWith(MockitoJUnitRunner.class)
 public class VppRendererPolicyManagerTest extends CustomDataBrokerTest {
 
+    private static final Logger LOG = LoggerFactory.getLogger(VppRendererPolicyManagerTest.class);
     private static final InstanceIdentifier<RendererPolicy> RENDERER_POLICY_IID =
             IidFactory.rendererIid(VppRenderer.NAME).child(RendererPolicy.class);
     private final static String SOCKET = "socket";
+    private static final String CLIENT_MAC = "10:00:00:00:00:01";
+    private static final String CLIENT_MAC_2 = "10:00:00:00:00:02";
+    private static final String WEB_MAC = "10:00:00:00:00:01";
+    private static final String WEB_MAC_2 = "10:00:00:00:00:02";
+    private static final String WEB_IP_2 = "20.0.0.2/32";
+    private static final String CLIENT_IP_2 = "10.0.0.2/32";
+    private static final String WEB_IP = "20.0.0.1/32";
+    private static final String CLIENT_IP = "10.0.0.1/32";
+    private static final String CLIENT_1_IFACE_NAME = "client1";
+    private static final String CLIENT_2_IFACE_NAME = "client2";
+    private static final String WEB_2_IFACE_NAME = "web2";
+    private static final String WEB_1_IFACE_NAME = "web1";
+
+    public static final TenantId TENANT = new TenantId("tenant");
+    public static final List<EndpointGroupId>
+        ENDPOINT_GROUP =
+        Collections.singletonList(new EndpointGroupId("default"));
 
     private MountedDataBrokerProvider mountedDataProviderMock;
     private DataBroker mountPointDataBroker;
@@ -79,49 +132,71 @@ public class VppRendererPolicyManagerTest extends CustomDataBrokerTest {
 
     private BridgeDomainManagerImpl bdManager;
     private InterfaceManager ifaceManager;
+    private AclManager aclManager;
     private ForwardingManager fwManager;
+    private NatManager natManager;
+    private RoutingManager routingManager;
+    private LispStateManager lispStateManager;
+    private LoopbackManager loopbackManager;
+    private FlatOverlayManager flatOverlayManager;
+    private DhcpRelayHandler dhcpRelayHandler;
     private VppRendererPolicyManager vppRendererPolicyManager;
+    private VppEndpointListener vppEndpointListener;
 
     @Override
     public Collection<Class<?>> getClassesFromModules() {
         return Arrays.asList(Node.class, VppEndpoint.class, Interfaces.class, BridgeDomains.class,
                 LocationProviders.class, L2FloodDomain.class, VxlanVni.class, TopologyVbridgeAugment.class,
-                TunnelTypeVxlan.class, PhysicalLocationRef.class);
-    }
+                TunnelTypeVxlan.class, PhysicalLocationRef.class, AccessLists.class, VppAce.class,
+                VppInterfaceAugmentation.class, VppAclInterfaceAugmentation.class, VxlanTunnelParameters.class,
+                PhysicalLocationRef.class, Nat.class);
+        }
 
     @Before
     public void init() throws Exception {
         mountedDataProviderMock = Mockito.mock(MountedDataBrokerProvider.class);
         mountPointDataBroker = getDataBroker();
+        EventBus dtoEventBus = new EventBus((exception, context) -> LOG.error("Could not dispatch event: {} to {}",
+            context.getSubscriber(), context.getSubscriberMethod(), exception));
         setup(); // initialize new data broker for ODL data store
         dataBroker = getDataBroker();
-        Mockito.when(mountedDataProviderMock.getDataBrokerForMountPoint(Mockito.any(InstanceIdentifier.class)))
+        Mockito.when(mountedDataProviderMock.resolveDataBrokerForMountPoint(Mockito.any(InstanceIdentifier.class)))
             .thenReturn(Optional.of(mountPointDataBroker));
-        ifaceManager =
-                new InterfaceManager(mountedDataProviderMock, dataBroker);
+        vppEndpointListener = new VppEndpointListener(dataBroker, dtoEventBus);
+        lispStateManager = new LispStateManager(mountedDataProviderMock);
+        loopbackManager = new LoopbackManager(mountedDataProviderMock);
+        flatOverlayManager = new FlatOverlayManager(dataBroker, mountedDataProviderMock, vppEndpointListener);
+        ifaceManager = new InterfaceManager(mountedDataProviderMock, dataBroker, flatOverlayManager);
+        aclManager = new AclManager(mountedDataProviderMock, ifaceManager);
+        natManager = new CentralizedNatImpl(dataBroker);
+        routingManager = new RoutingManager(dataBroker, mountedDataProviderMock);
         bdManager = new BridgeDomainManagerImpl(mountPointDataBroker);
-        fwManager = new ForwardingManager(ifaceManager, bdManager, dataBroker);
-        vppRendererPolicyManager = new VppRendererPolicyManager(fwManager, dataBroker);
+        dhcpRelayHandler = new DhcpRelayHandler(dataBroker);
+        fwManager = new ForwardingManager(ifaceManager, aclManager, natManager, routingManager, bdManager,
+                lispStateManager, loopbackManager, flatOverlayManager, dhcpRelayHandler, dataBroker);
+        vppRendererPolicyManager = new VppRendererPolicyManager(fwManager, aclManager, dataBroker);
         fwManager.setTimer((byte) 1);
+        VbdNetconfTransaction.NODE_DATA_BROKER_MAP.put(DtoFactory.VPP_NODE_1_IID,
+                new AbstractMap.SimpleEntry<DataBroker, ReentrantLock>(mountPointDataBroker, new ReentrantLock()));
+        VbdNetconfTransaction.NODE_DATA_BROKER_MAP.put(DtoFactory.VPP_NODE_2_IID,
+                new AbstractMap.SimpleEntry<DataBroker, ReentrantLock>(mountPointDataBroker, new ReentrantLock()));
     }
 
     @Test
     public void testRendererPolicyChanged_created_oneEpPerEpg() throws Exception {
-        String clientIp = "1.1.1.1";
-        String clientIfaceName = "client1";
-        AbsoluteLocation clientLocation = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, null, clientIfaceName);
+        AbsoluteLocation clientLocation =
+                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, null, CLIENT_1_IFACE_NAME);
         AddressEndpointWithLocation clientEp =
-                DtoFactory.createEndpoint(clientIp, DtoFactory.L2FD_CTX.getValue(), clientLocation);
-        String webIp = "2.2.2.2";
-        String webIfaceName = "web1";
-        AbsoluteLocation webLocation = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, null, webIfaceName);
+                DtoFactory.createEndpoint(CLIENT_IP, CLIENT_MAC, DtoFactory.L2FD_CTX.getValue(), clientLocation);
+        AbsoluteLocation webLocation = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, null, WEB_1_IFACE_NAME);
         AddressEndpointWithLocation webEp =
-                DtoFactory.createEndpoint(webIp, DtoFactory.L2FD_CTX.getValue(), webLocation);
+                DtoFactory.createEndpoint(WEB_IP, WEB_MAC, DtoFactory.L2FD_CTX.getValue(), webLocation);
 
-        storeVppEndpoint(clientEp.getKey(), clientIfaceName, createVppEndpointIid(clientEp.getKey()));
-        storeVppEndpoint(webEp.getKey(), webIfaceName, createVppEndpointIid(webEp.getKey()));
+        storeVppEndpoint(clientEp.getKey(), CLIENT_MAC, CLIENT_1_IFACE_NAME, createVppEndpointIid(clientEp.getKey()));
+        storeVppEndpoint(webEp.getKey(), WEB_MAC, WEB_1_IFACE_NAME, createVppEndpointIid(webEp.getKey()));
 
-        Configuration configuration = DtoFactory.createConfiguration(Arrays.asList(clientEp), Arrays.asList(webEp));
+        Configuration configuration = DtoFactory.createConfiguration(Collections.singletonList(clientEp),
+            Collections.singletonList(webEp));
         RendererPolicy rendererPolicy =
                 new RendererPolicyBuilder().setVersion(1L).setConfiguration(configuration).build();
         RendererPolicyConfEvent event = new RendererPolicyConfEvent(RENDERER_POLICY_IID, null, rendererPolicy);
@@ -129,9 +204,9 @@ public class VppRendererPolicyManagerTest extends CustomDataBrokerTest {
         vppRendererPolicyManager.rendererPolicyChanged(event);
 
         // assert state on data store behind mount point
-        Interface clientIface = readAndAssertInterface(clientIfaceName);
+        Interface clientIface = readAndAssertInterface(CLIENT_1_IFACE_NAME);
         assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), clientIface);
-        Interface webIface = readAndAssertInterface(webIfaceName);
+        Interface webIface = readAndAssertInterface(WEB_1_IFACE_NAME);
         assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), webIface);
         // assert state on ODL data store
         ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction();
@@ -142,41 +217,36 @@ public class VppRendererPolicyManagerTest extends CustomDataBrokerTest {
         List<ProviderAddressEndpointLocation> epLocs = optLocationProvider.get().getProviderAddressEndpointLocation();
         Assert.assertNotNull(epLocs);
         Assert.assertEquals(2, epLocs.size());
-        assertProviderAddressEndpointLocation(clientEp.getKey(),
-                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, DtoFactory.L2FD_CTX.getValue(), clientIfaceName),
-                epLocs);
-        assertProviderAddressEndpointLocation(webEp.getKey(),
-                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, DtoFactory.L2FD_CTX.getValue(), webIfaceName),
-                epLocs);
+        assertProviderAddressEndpointLocation(clientEp.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID,
+                DtoFactory.L2FD_CTX.getValue(), CLIENT_1_IFACE_NAME), epLocs);
+        assertProviderAddressEndpointLocation(webEp.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID,
+                DtoFactory.L2FD_CTX.getValue(), WEB_1_IFACE_NAME), epLocs);
     }
 
     @Test
     public void testRendererPolicyChanged_update() throws Exception {
-        String client1IfaceName = "client1";
         AbsoluteLocation client1LocationNodeNull =
-                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, null, client1IfaceName);
-        AddressEndpointWithLocation client1Ep =
-                DtoFactory.createEndpoint("10.0.0.1", DtoFactory.L2FD_CTX.getValue(), client1LocationNodeNull);
-        String web1IfaceName = "web1";
+                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, null, CLIENT_1_IFACE_NAME);
+        AddressEndpointWithLocation client1Ep = DtoFactory.createEndpoint(CLIENT_IP, CLIENT_MAC,
+                DtoFactory.L2FD_CTX.getValue(), client1LocationNodeNull);
         AbsoluteLocation web1LocationNodeNull =
-                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, null, web1IfaceName);
+                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, null, WEB_1_IFACE_NAME);
         AddressEndpointWithLocation web1Ep =
-                DtoFactory.createEndpoint("20.0.0.1", DtoFactory.L2FD_CTX.getValue(), web1LocationNodeNull);
-        String client2IfaceName = "client2";
+                DtoFactory.createEndpoint(WEB_IP, WEB_MAC, DtoFactory.L2FD_CTX.getValue(), web1LocationNodeNull);
         AbsoluteLocation client2LocationNodeNull =
-                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, null, client2IfaceName);
-        AddressEndpointWithLocation client2Ep =
-                DtoFactory.createEndpoint("10.0.0.2", DtoFactory.L2FD_CTX.getValue(), client2LocationNodeNull);
-        String web2IfaceName = "web2";
+                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, null, CLIENT_2_IFACE_NAME);
+        AddressEndpointWithLocation client2Ep = DtoFactory.createEndpoint(CLIENT_IP_2, CLIENT_MAC_2,
+                DtoFactory.L2FD_CTX.getValue(), client2LocationNodeNull);
         AbsoluteLocation web2LocationNodeNull =
-                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, null, web2IfaceName);
+                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, null, WEB_2_IFACE_NAME);
         AddressEndpointWithLocation web2Ep =
-                DtoFactory.createEndpoint("20.0.0.2", DtoFactory.L2FD_CTX.getValue(), web2LocationNodeNull);
+                DtoFactory.createEndpoint(WEB_IP_2, WEB_MAC_2, DtoFactory.L2FD_CTX.getValue(), web2LocationNodeNull);
 
-        storeVppEndpoint(client1Ep.getKey(), client1IfaceName, createVppEndpointIid(client1Ep.getKey()));
-        storeVppEndpoint(web1Ep.getKey(), web1IfaceName, createVppEndpointIid(web1Ep.getKey()));
-        storeVppEndpoint(client2Ep.getKey(), client2IfaceName, createVppEndpointIid(client2Ep.getKey()));
-        storeVppEndpoint(web2Ep.getKey(), web2IfaceName, createVppEndpointIid(web2Ep.getKey()));
+        storeVppEndpoint(client1Ep.getKey(), CLIENT_MAC, CLIENT_1_IFACE_NAME, createVppEndpointIid(client1Ep.getKey()));
+        storeVppEndpoint(web1Ep.getKey(), WEB_MAC, WEB_1_IFACE_NAME, createVppEndpointIid(web1Ep.getKey()));
+        storeVppEndpoint(client2Ep.getKey(), CLIENT_MAC_2, CLIENT_2_IFACE_NAME,
+                createVppEndpointIid(client2Ep.getKey()));
+        storeVppEndpoint(web2Ep.getKey(), WEB_MAC_2, WEB_2_IFACE_NAME, createVppEndpointIid(web2Ep.getKey()));
 
         Configuration configuration =
                 DtoFactory.createConfiguration(Arrays.asList(client1Ep, client2Ep), Arrays.asList(web1Ep, web2Ep));
@@ -187,13 +257,13 @@ public class VppRendererPolicyManagerTest extends CustomDataBrokerTest {
         vppRendererPolicyManager.rendererPolicyChanged(event);
 
         // assert state on data store behind mount point ######################################
-        Interface client1Iface = readAndAssertInterface(client1IfaceName);
+        Interface client1Iface = readAndAssertInterface(CLIENT_1_IFACE_NAME);
         assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), client1Iface);
-        Interface web1Iface = readAndAssertInterface(web1IfaceName);
+        Interface web1Iface = readAndAssertInterface(WEB_1_IFACE_NAME);
         assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), web1Iface);
-        Interface client2Iface = readAndAssertInterface(client2IfaceName);
+        Interface client2Iface = readAndAssertInterface(CLIENT_2_IFACE_NAME);
         assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), client2Iface);
-        Interface web2Iface = readAndAssertInterface(web2IfaceName);
+        Interface web2Iface = readAndAssertInterface(WEB_2_IFACE_NAME);
         assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), web2Iface);
         // assert state on ODL data store
         ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction();
@@ -205,23 +275,21 @@ public class VppRendererPolicyManagerTest extends CustomDataBrokerTest {
         Assert.assertNotNull(epLocs);
         Assert.assertEquals(4, epLocs.size());
         assertProviderAddressEndpointLocation(client1Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID,
-                DtoFactory.L2FD_CTX.getValue(), client1IfaceName), epLocs);
-        assertProviderAddressEndpointLocation(web1Ep.getKey(),
-                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), web1IfaceName),
-                epLocs);
+                DtoFactory.L2FD_CTX.getValue(), CLIENT_1_IFACE_NAME), epLocs);
+        assertProviderAddressEndpointLocation(web1Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID,
+                DtoFactory.L2FD_CTX.getValue(), WEB_1_IFACE_NAME), epLocs);
         assertProviderAddressEndpointLocation(client2Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID,
-                DtoFactory.L2FD_CTX.getValue(), client2IfaceName), epLocs);
-        assertProviderAddressEndpointLocation(web2Ep.getKey(),
-                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), web2IfaceName),
-                epLocs);
+                DtoFactory.L2FD_CTX.getValue(), CLIENT_2_IFACE_NAME), epLocs);
+        assertProviderAddressEndpointLocation(web2Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID,
+                DtoFactory.L2FD_CTX.getValue(), WEB_2_IFACE_NAME), epLocs);
         // #####################################################################################
 
         AbsoluteLocation client1Location = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID,
-                DtoFactory.L2FD_CTX.getValue(), client1IfaceName);
-        AbsoluteLocation web1Location =
-                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), web1IfaceName);
-        AbsoluteLocation web2Location =
-                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), web2IfaceName);
+                DtoFactory.L2FD_CTX.getValue(), CLIENT_1_IFACE_NAME);
+        AbsoluteLocation web1Location = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID,
+                DtoFactory.L2FD_CTX.getValue(), WEB_1_IFACE_NAME);
+        AbsoluteLocation web2Location = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID,
+                DtoFactory.L2FD_CTX.getValue(), WEB_2_IFACE_NAME);
         configuration = DtoFactory.createConfiguration(
                 Arrays.asList(new AddressEndpointWithLocationBuilder(client1Ep).setAbsoluteLocation(client1Location)
                     .build(),
@@ -237,13 +305,13 @@ public class VppRendererPolicyManagerTest extends CustomDataBrokerTest {
         vppRendererPolicyManager.rendererPolicyChanged(event2);
 
         // assert state on data store behind mount point ######################################
-        client1Iface = readAndAssertInterface(client1IfaceName);
+        client1Iface = readAndAssertInterface(CLIENT_1_IFACE_NAME);
         assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), client1Iface);
-        web1Iface = readAndAssertInterface(web1IfaceName);
+        web1Iface = readAndAssertInterface(WEB_1_IFACE_NAME);
         assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), web1Iface);
-        client2Iface = readAndAssertInterface(client2IfaceName);
+        client2Iface = readAndAssertInterface(CLIENT_2_IFACE_NAME);
         assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), client2Iface);
-        web2Iface = readAndAssertInterface(web2IfaceName);
+        web2Iface = readAndAssertInterface(WEB_2_IFACE_NAME);
         assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), web2Iface);
         // assert state on ODL data store
         rTx = dataBroker.newReadOnlyTransaction();
@@ -255,19 +323,17 @@ public class VppRendererPolicyManagerTest extends CustomDataBrokerTest {
         Assert.assertNotNull(epLocs);
         Assert.assertEquals(4, epLocs.size());
         assertProviderAddressEndpointLocation(client1Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID,
-                DtoFactory.L2FD_CTX.getValue(), client1IfaceName), epLocs);
-        assertProviderAddressEndpointLocation(web1Ep.getKey(),
-                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), web1IfaceName),
-                epLocs);
+                DtoFactory.L2FD_CTX.getValue(), CLIENT_1_IFACE_NAME), epLocs);
+        assertProviderAddressEndpointLocation(web1Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID,
+                DtoFactory.L2FD_CTX.getValue(), WEB_1_IFACE_NAME), epLocs);
         assertProviderAddressEndpointLocation(client2Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID,
-                DtoFactory.L2FD_CTX.getValue(), client2IfaceName), epLocs);
-        assertProviderAddressEndpointLocation(web2Ep.getKey(),
-                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), web2IfaceName),
-                epLocs);
+                DtoFactory.L2FD_CTX.getValue(), CLIENT_2_IFACE_NAME), epLocs);
+        assertProviderAddressEndpointLocation(web2Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID,
+                DtoFactory.L2FD_CTX.getValue(), WEB_2_IFACE_NAME), epLocs);
         // #####################################################################################
 
         AbsoluteLocation client2Location = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID,
-                DtoFactory.L2FD_CTX.getValue(), client2IfaceName);
+                DtoFactory.L2FD_CTX.getValue(), CLIENT_2_IFACE_NAME);
         configuration = DtoFactory.createConfiguration(
                 Arrays.asList(new AddressEndpointWithLocationBuilder(client1Ep).setAbsoluteLocation(client1Location)
                     .build(),
@@ -282,13 +348,13 @@ public class VppRendererPolicyManagerTest extends CustomDataBrokerTest {
         vppRendererPolicyManager.rendererPolicyChanged(event3);
 
         // assert state on data store behind mount point ######################################
-        client1Iface = readAndAssertInterface(client1IfaceName);
+        client1Iface = readAndAssertInterface(CLIENT_1_IFACE_NAME);
         assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), client1Iface);
-        web1Iface = readAndAssertInterface(web1IfaceName);
+        web1Iface = readAndAssertInterface(WEB_1_IFACE_NAME);
         assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), web1Iface);
-        client2Iface = readAndAssertInterface(client2IfaceName);
+        client2Iface = readAndAssertInterface(CLIENT_2_IFACE_NAME);
         assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), client2Iface);
-        web2Iface = readAndAssertInterface(web2IfaceName);
+        web2Iface = readAndAssertInterface(WEB_2_IFACE_NAME);
         assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), web2Iface);
         // assert state on ODL data store
         rTx = dataBroker.newReadOnlyTransaction();
@@ -300,15 +366,13 @@ public class VppRendererPolicyManagerTest extends CustomDataBrokerTest {
         Assert.assertNotNull(epLocs);
         Assert.assertEquals(4, epLocs.size());
         assertProviderAddressEndpointLocation(client1Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID,
-                DtoFactory.L2FD_CTX.getValue(), client1IfaceName), epLocs);
-        assertProviderAddressEndpointLocation(web1Ep.getKey(),
-                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), web1IfaceName),
-                epLocs);
+                DtoFactory.L2FD_CTX.getValue(), CLIENT_1_IFACE_NAME), epLocs);
+        assertProviderAddressEndpointLocation(web1Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID,
+                DtoFactory.L2FD_CTX.getValue(), WEB_1_IFACE_NAME), epLocs);
         assertProviderAddressEndpointLocation(client2Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID,
-                DtoFactory.L2FD_CTX.getValue(), client2IfaceName), epLocs);
-        assertProviderAddressEndpointLocation(web2Ep.getKey(),
-                DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), web2IfaceName),
-                epLocs);
+                DtoFactory.L2FD_CTX.getValue(), CLIENT_2_IFACE_NAME), epLocs);
+        assertProviderAddressEndpointLocation(web2Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID,
+                DtoFactory.L2FD_CTX.getValue(), WEB_2_IFACE_NAME), epLocs);
         // #####################################################################################
     }
 
@@ -348,21 +412,39 @@ public class VppRendererPolicyManagerTest extends CustomDataBrokerTest {
             Assert.assertTrue(interconnection instanceof BridgeBased);
             Assert.assertEquals(expectedBridgeDomain, ((BridgeBased) interconnection).getBridgeDomain());
         } else {
-            if (vppIfaceAug != null) {
-                L2 l2 = vppIfaceAug.getL2();
-                if (l2 != null) {
-                    Assert.assertNull(l2.getInterconnection());
-                }
+            L2 l2 = vppIfaceAug.getL2();
+            if (l2 != null) {
+                Assert.assertNull(l2.getInterconnection());
             }
         }
     }
 
-    private void storeVppEndpoint(AddressEndpointWithLocationKey epKey, String ifaceName,
+    private void storeVppEndpoint(AddressEndpointWithLocationKey clientEp, String mac, String ifaceName,
             InstanceIdentifier<VppEndpoint> vppEpIid) {
-        VppEndpoint vhostEp = new VppEndpointBuilder().setAddress(epKey.getAddress())
-            .setAddressType(epKey.getAddressType())
-            .setContextId(epKey.getContextId())
-            .setContextType(epKey.getContextType())
+        AddressEndpoint addrEp = new AddressEndpointBuilder()
+            .setKey(new AddressEndpointKey(clientEp.getAddress(), clientEp.getAddressType(), clientEp.getContextId(),
+                    clientEp.getContextType()))
+            .setTenant(TENANT)
+            .setEndpointGroup(ENDPOINT_GROUP)
+            .setChildEndpoint(Lists.newArrayList(new ChildEndpointBuilder()
+                .setKey(new ChildEndpointKey(mac, MacAddressType.class, clientEp.getContextId(), L2BridgeDomain.class))
+                .build()))
+            .build();
+        InstanceIdentifier<AddressEndpoint> iid = InstanceIdentifier.create(Endpoints.class)
+            .child(AddressEndpoints.class)
+            .child(AddressEndpoint.class, addrEp.getKey());
+        WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();
+        wTx.put(LogicalDatastoreType.OPERATIONAL, iid, addrEp);
+        try {
+            wTx.submit().get();
+        } catch (InterruptedException | ExecutionException e) {
+            e.printStackTrace();
+        }
+
+        VppEndpoint vhostEp = new VppEndpointBuilder().setAddress(mac)
+            .setAddressType(MacAddressType.class)
+            .setContextId(clientEp.getContextId())
+            .setContextType(L2BridgeDomain.class)
             .setVppInterfaceName(ifaceName)
             .setVppNodeId(DtoFactory.VPP_NODE_1_IID.firstKeyOf(Node.class).getNodeId())
             .setInterfaceTypeChoice(new VhostUserCaseBuilder().setSocket(SOCKET).build())