Bug 7757 -Removing qos deprecations in carbon
[ovsdb.git] / southbound / southbound-it / src / test / java / org / opendaylight / ovsdb / southbound / it / SouthboundIT.java
index d930d2fe9137f72eefd1e1559de089c755a13cef..a182c7b78c69a2fdd8ee5913df785baabcaaca7f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Red Hat, Inc. and others.  All rights reserved.
+ * Copyright © 2015, 2017 Red Hat, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -8,6 +8,7 @@
 package org.opendaylight.ovsdb.southbound.it;
 
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.ops4j.pax.exam.CoreOptions.composite;
 import static org.ops4j.pax.exam.CoreOptions.maven;
@@ -16,6 +17,10 @@ import static org.ops4j.pax.exam.CoreOptions.vmOption;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
 
+import com.google.common.collect.ImmutableBiMap;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.net.InetAddress;
@@ -26,10 +31,8 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Properties;
 import java.util.Set;
-
 import javax.annotation.Nullable;
 import javax.inject.Inject;
-
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Assume;
@@ -44,18 +47,16 @@ import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
-import org.opendaylight.ovsdb.lib.OvsdbClient;
 import org.opendaylight.ovsdb.lib.notation.Version;
-import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
+import org.opendaylight.ovsdb.schema.openvswitch.Queue;
 import org.opendaylight.ovsdb.southbound.SouthboundConstants;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
-import org.opendaylight.ovsdb.southbound.SouthboundProvider;
 import org.opendaylight.ovsdb.southbound.SouthboundUtil;
 import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
 import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathTypeBase;
@@ -67,6 +68,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.re
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbFailModeBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbQueueRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbPortInterfaceAttributes.VlanMode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder;
@@ -125,12 +127,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.re
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.TrunksBuilder;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
@@ -145,15 +147,11 @@ import org.ops4j.pax.exam.karaf.options.LogLevelOption;
 import org.ops4j.pax.exam.options.MavenUrlReference;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.exam.util.Filter;
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.ImmutableBiMap;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-
 /**
  * Integration tests for southbound-impl
  *
@@ -168,6 +166,9 @@ public class SouthboundIT extends AbstractMdsalTestBase {
     private static final int OVSDB_ROUNDTRIP_TIMEOUT = 10000;
     private static final String FORMAT_STR = "%s_%s_%d";
     private static final Version AUTOATTACH_FROM_VERSION = Version.fromString("7.11.2");
+    private static final Version IF_INDEX_FROM_VERSION = Version.fromString("7.2.1");
+    private static final Long MAX_BACKOFF = 10000L;
+    private static final Long INACTIVITY_PROBE = 30000L;
     private static String addressStr;
     private static int portNumber;
     private static String connectionType;
@@ -175,10 +176,9 @@ public class SouthboundIT extends AbstractMdsalTestBase {
     private static MdsalUtils mdsalUtils = null;
     private static Node ovsdbNode;
     private static int testMethodsRemaining;
-    private static DataBroker dataBroker;
     private static Version schemaVersion;
-    private static OvsdbClient ovsdbClient;
-    private static DatabaseSchema dbSchema;
+    @Inject @Filter(timeout=60000)
+    private static DataBroker dataBroker = null;
 
     @Inject
     private BundleContext bundleContext;
@@ -188,6 +188,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
     private static final NotifyingDataChangeListener OPERATIONAL_LISTENER =
             new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL);
 
+
     private static class NotifyingDataChangeListener implements DataChangeListener {
         private final LogicalDatastoreType type;
         private final Set<InstanceIdentifier<?>> createdIids = new HashSet<>();
@@ -315,16 +316,6 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                 .getURL();
     }
 
-    @Override
-    public String getModuleName() {
-        return "southbound-impl";
-    }
-
-    @Override
-    public String getInstanceName() {
-        return "southbound-default";
-    }
-
     @Override
     public MavenUrlReference getFeatureRepo() {
         return maven()
@@ -394,11 +385,11 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         } catch (Exception e) {
             LOG.warn("Failed to setup test", e);
         }
-        //dataBroker = getSession().getSALService(DataBroker.class);
-        Thread.sleep(3000);
-        dataBroker = SouthboundProvider.getDb();
         Assert.assertNotNull("db should not be null", dataBroker);
 
+        LOG.info("sleeping for 10s to let the features finish installing");
+        Thread.sleep(10000);
+
         addressStr = bundleContext.getProperty(SouthboundITConstants.SERVER_IPADDRESS);
         String portStr = bundleContext.getProperty(SouthboundITConstants.SERVER_PORT);
         try {
@@ -417,6 +408,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         }
 
         mdsalUtils = new MdsalUtils(dataBroker);
+        assertTrue("Did not find " + SouthboundUtils.OVSDB_TOPOLOGY_ID.getValue(), getOvsdbTopology());
         final ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
         final InstanceIdentifier<Node> iid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
         dataBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
@@ -425,17 +417,10 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                 iid, OPERATIONAL_LISTENER, AsyncDataBroker.DataChangeScope.SUBTREE);
 
         ovsdbNode = connectOvsdbNode(connectionInfo);
-        try {
-            ovsdbClient = SouthboundIntegrationTestUtils.getTestConnection(this);
-            assertNotNull("Invalid Client. Check connection params", ovsdbClient);
-
-            dbSchema = ovsdbClient.getSchema(SouthboundIntegrationTestUtils.OPEN_VSWITCH_SCHEMA).get();
-            assertNotNull("Invalid dbSchema.", dbSchema);
-            schemaVersion = dbSchema.getVersion();
-            LOG.info("{} schema version = {}", SouthboundIntegrationTestUtils.OPEN_VSWITCH_SCHEMA, schemaVersion);
-        } catch (Exception e) {
-            fail("Error accessing schemaVersion in SouthboundIT setUp()." + usage());
-        }
+        OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class);
+        assertNotNull("The OvsdbNodeAugmentation cannot be null", ovsdbNodeAugmentation);
+        schemaVersion = Version.fromString(ovsdbNodeAugmentation.getDbVersion());
+        LOG.info("schemaVersion = {}", schemaVersion);
 
         // Let's count the test methods (we need to use this instead of @AfterClass on teardown() since the latter is
         // useless with pax-exam)
@@ -472,6 +457,30 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         }
     }
 
+    private Boolean getOvsdbTopology() {
+        LOG.info("getOvsdbTopology: looking for {}...", SouthboundUtils.OVSDB_TOPOLOGY_ID.getValue());
+        Boolean found = false;
+        final TopologyId topologyId = SouthboundUtils.OVSDB_TOPOLOGY_ID;
+        InstanceIdentifier<Topology> path =
+                InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(topologyId));
+        for (int i = 0; i < 60; i++) {
+            Topology topology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, path);
+            if (topology != null) {
+                LOG.info("getOvsdbTopology: found {}...", SouthboundUtils.OVSDB_TOPOLOGY_ID.getValue());
+                found = true;
+                break;
+            } else {
+                LOG.info("getOvsdbTopology: still looking ({})...", i);
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException e) {
+                    LOG.warn("Interrupted while waiting for {}", SouthboundUtils.OVSDB_TOPOLOGY_ID.getValue(), e);
+                }
+            }
+        }
+        return found;
+    }
+
     /**
      * Test passive connection mode. The southbound starts in a listening mode waiting for connections on port
      * 6640. This test will wait for incoming connections for {@link SouthboundITConstants#CONNECTION_INIT_TIMEOUT} ms.
@@ -624,7 +633,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                         Assert.assertEquals(dpType, bridge.getDatapathType());
 
                         // Add port for all dpdk interface types (dpdkvhost not supported in existing dpdk ovs)
-                        List<String> dpdkTypes = new ArrayList<String>();
+                        List<String> dpdkTypes = new ArrayList<>();
                         dpdkTypes.add("dpdk");
                         dpdkTypes.add("dpdkr");
                         dpdkTypes.add("dpdkvhostuser");
@@ -678,6 +687,13 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         assertNotNull(ovsdbNodeAugmentation.getOvsVersion());
     }
 
+    @Test
+    public void testOvsdbNodeDbVersion() throws InterruptedException {
+        OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class);
+        Assert.assertNotNull(ovsdbNodeAugmentation);
+        assertNotNull(ovsdbNodeAugmentation.getDbVersion());
+    }
+
     @Test
     public void testOpenVSwitchOtherConfig() throws InterruptedException {
         OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class);
@@ -716,6 +732,12 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                 if (entry.getTarget() != null) {
                     Assert.assertEquals(setUri.toString(), entry.getTarget().toString());
                 }
+                if (entry.getMaxBackoff() != null) {
+                    Assert.assertEquals(entry.getMaxBackoff(), MAX_BACKOFF);
+                }
+                if (entry.getInactivityProbe() != null) {
+                    Assert.assertEquals(entry.getInactivityProbe(),INACTIVITY_PROBE);
+                }
             }
         }
     }
@@ -724,6 +746,8 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         List<ControllerEntry> controllerEntriesList = new ArrayList<>();
         controllerEntriesList.add(new ControllerEntryBuilder()
                 .setTarget(new Uri(controllerTarget))
+                .setMaxBackoff(MAX_BACKOFF)
+                .setInactivityProbe(INACTIVITY_PROBE)
                 .build());
         return controllerEntriesList;
     }
@@ -787,7 +811,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         entry.addAugmentation(
                 OvsdbTerminationPointAugmentation.class,
                 ovsdbTerminationPointAugmentationBuilder.build());
-        portNodeBuilder.setTerminationPoint(Lists.newArrayList(entry.build()));
+        portNodeBuilder.setTerminationPoint(Collections.singletonList(entry.build()));
         boolean result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
                 portIid, portNodeBuilder.build());
         Thread.sleep(OVSDB_UPDATE_TIMEOUT);
@@ -932,11 +956,11 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         final boolean isOldSchema = schemaVersion.compareTo(AUTOATTACH_FROM_VERSION) < 0;
 
         ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
-        String testAutoattachId = new String("testAutoattachEntry");
-        String testSystemName = new String("testSystemName");
-        String testSystemDescription = new String("testSystemDescription");
-        String testAutoattachExternalKey = new String("testAutoattachExternalKey");
-        String testAutoattachExternalValue = new String("testAutoattachExternalValue");
+        String testAutoattachId = "testAutoattachEntry";
+        String testSystemName = "testSystemName";
+        String testSystemDescription = "testSystemDescription";
+        String testAutoattachExternalKey = "testAutoattachExternalKey";
+        String testAutoattachExternalValue = "testAutoattachExternalValue";
 
         try (TestBridge testBridge = new TestBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME)) {
             OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
@@ -1110,6 +1134,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
     private static class TestQueue implements AutoCloseable {
         private final ConnectionInfo connectionInfo;
         private final Uri queueId;
+        private final InstanceIdentifier<Queues> qIid;
 
         /**
          * Creates a test queue entry which can be automatically removed when no longer necessary.
@@ -1134,7 +1159,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                 .setQueuesExternalIds(externalIds)
                 .setQueuesOtherConfig(otherConfigs)
                 .build();
-            InstanceIdentifier<Queues> qIid = SouthboundUtils.createInstanceIdentifier(connectionInfo)
+            qIid = SouthboundUtils.createInstanceIdentifier(connectionInfo)
                     .augmentation(OvsdbNodeAugmentation.class)
                     .child(Queues.class, queue.getKey());
             final NotifyingDataChangeListener queueOperationalListener =
@@ -1152,6 +1177,9 @@ public class SouthboundIT extends AbstractMdsalTestBase {
             }
         }
 
+        public InstanceIdentifier<Queues> getInstanceIdentifier() {
+            return qIid;
+        }
         @Override
         public void close() {
             InstanceIdentifier<Queues> qIid = SouthboundUtils.createInstanceIdentifier(connectionInfo)
@@ -1276,6 +1304,45 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         return tpList.get(index).getAugmentation(OvsdbTerminationPointAugmentation.class);
     }
 
+    @Test
+    public void testCRUDTerminationPointIfIndex() throws InterruptedException {
+        final boolean isOldSchema = schemaVersion.compareTo(IF_INDEX_FROM_VERSION) < 0;
+        Assume.assumeFalse(isOldSchema);
+        ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
+
+        // Test create ifIndex
+        try (TestBridge testBridge = new TestBridge(connectionInfo, null, SouthboundITConstants.BRIDGE_NAME, null, true,
+                SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"),
+                true, SouthboundMapper.createDatapathType("netdev"), null, null, null)) {
+            OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
+            Assert.assertNotNull(bridge);
+            LOG.info("bridge: {}", bridge);
+            NodeId nodeId = SouthboundMapper.createManagedNodeId(SouthboundUtils.createInstanceIdentifier(
+                    connectionInfo, bridge.getBridgeName()));
+            OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
+                    createGenericOvsdbTerminationPointAugmentationBuilder();
+            String portName = "testIfIndex";
+            ovsdbTerminationBuilder.setName(portName);
+
+            Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
+            InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
+            Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
+            Assert.assertNotNull(terminationPointNode);
+
+            // Test read ifIndex
+            List<TerminationPoint> terminationPoints = terminationPointNode.getTerminationPoint();
+            for (TerminationPoint terminationPoint : terminationPoints) {
+                OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
+                        terminationPoint.getAugmentation(OvsdbTerminationPointAugmentation.class);
+                if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
+                    Long ifIndex = ovsdbTerminationPointAugmentation.getIfindex();
+                    Assert.assertNotNull(ifIndex);
+                    LOG.info("ifIndex: {} for the port:{}", ifIndex, portName);
+                }
+            }
+        }
+    }
+
     @Test
     public void testCRDTerminationPointOfPort() throws InterruptedException {
         final Long OFPORT_EXPECTED = 45002L;
@@ -1452,7 +1519,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                     tpUpdateBuilder.addAugmentation(
                             OvsdbTerminationPointAugmentation.class,
                             tpUpdateAugmentationBuilder.build());
-                    portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
+                    portUpdateNodeBuilder.setTerminationPoint(Collections.singletonList(tpUpdateBuilder.build()));
                     Assert.assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
                             portIid, portUpdateNodeBuilder.build()));
                     Thread.sleep(OVSDB_UPDATE_TIMEOUT);
@@ -1551,6 +1618,89 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                 new PortOtherConfigsSouthboundHelper());
     }
 
+    @Test
+    public void testCRUDTerminationPoints() throws InterruptedException {
+        String port1 = "vx1";
+        String port2 = "vxlanport";
+        ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
+
+        try (TestBridge testBridge = new TestBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME)) {
+            OvsdbBridgeAugmentation bridge = getBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME);
+            Assert.assertNotNull(bridge);
+            NodeId nodeId = SouthboundUtils.createManagedNodeId(SouthboundUtils.createInstanceIdentifier(
+                    connectionInfo, bridge.getBridgeName()));
+            OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
+                    createGenericOvsdbTerminationPointAugmentationBuilder();
+
+            // add and delete a single port
+            String portName = port1;
+            ovsdbTerminationBuilder.setName(portName);
+            Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
+            InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
+            Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
+            Assert.assertNotNull(terminationPointNode);
+
+            SouthboundUtils.createInstanceIdentifier(connectionInfo,
+                    new OvsdbBridgeName(SouthboundITConstants.BRIDGE_NAME));
+            portName = port1;
+            InstanceIdentifier<TerminationPoint> nodePath =
+                    SouthboundUtils.createInstanceIdentifier(connectionInfo,
+                            new OvsdbBridgeName(SouthboundITConstants.BRIDGE_NAME))
+                            .child(TerminationPoint.class, new TerminationPointKey(new TpId(portName)));
+
+            Assert.assertTrue("failed to delete port " + portName,
+                    mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, nodePath));
+            LOG.info("shague: waiting for delete {}", portName);
+            Thread.sleep(1000);
+            TerminationPoint terminationPoint = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, nodePath);
+            Assert.assertNull(terminationPoint);
+
+            // add two ports, then delete them
+            portName = port1;
+            ovsdbTerminationBuilder.setName(portName);
+            Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
+            terminationPointIid = getTpIid(connectionInfo, bridge);
+            terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
+            Assert.assertNotNull(terminationPointNode);
+
+            portName = port2;
+            ovsdbTerminationBuilder.setName(portName);
+            Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
+            terminationPointIid = getTpIid(connectionInfo, bridge);
+            terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
+            Assert.assertNotNull(terminationPointNode);
+
+            SouthboundUtils.createInstanceIdentifier(connectionInfo,
+                    new OvsdbBridgeName(SouthboundITConstants.BRIDGE_NAME));
+            portName = port1;
+            nodePath =
+                    SouthboundUtils.createInstanceIdentifier(connectionInfo,
+                            new OvsdbBridgeName(SouthboundITConstants.BRIDGE_NAME))
+                            .child(TerminationPoint.class, new TerminationPointKey(new TpId(portName)));
+
+            Assert.assertTrue("failed to delete port " + portName,
+                    mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, nodePath));
+            LOG.info("shague: waiting for delete {}", portName);
+            Thread.sleep(1000);
+            terminationPoint = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, nodePath);
+            Assert.assertNull(terminationPoint);
+
+            portName = port2;
+            nodePath = SouthboundUtils.createInstanceIdentifier(connectionInfo,
+                    new OvsdbBridgeName(SouthboundITConstants.BRIDGE_NAME))
+                    .child(TerminationPoint.class, new TerminationPointKey(new TpId(portName)));
+
+            Assert.assertTrue("failed to delete port " + portName,
+                    mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, nodePath));
+            LOG.info("shague: waiting for delete {}", portName);
+            Thread.sleep(1000);
+            terminationPoint = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, nodePath);
+            Assert.assertNull(terminationPoint);
+
+            // DELETE handled by TestBridge
+        }
+    }
+
     @Test
     public void testCRUDTerminationPointVlan() throws InterruptedException {
         final Integer CREATED_VLAN_ID = 4000;
@@ -1603,7 +1753,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                     OvsdbTerminationPointAugmentation.class,
                     tpUpdateAugmentationBuilder.build());
             tpUpdateBuilder.setTpId(new TpId(portName));
-            portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
+            portUpdateNodeBuilder.setTerminationPoint(Collections.singletonList(tpUpdateBuilder.build()));
             Assert.assertTrue(
                     mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, portIid, portUpdateNodeBuilder.build()));
             Thread.sleep(OVSDB_UPDATE_TIMEOUT);
@@ -1673,7 +1823,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                         OvsdbTerminationPointAugmentation.class,
                         tpUpdateAugmentationBuilder.build());
                 tpUpdateBuilder.setTpId(new TpId(portName));
-                portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
+                portUpdateNodeBuilder.setTerminationPoint(Collections.singletonList(tpUpdateBuilder.build()));
                 Assert.assertTrue(
                         mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, portIid, portUpdateNodeBuilder.build()));
                 Thread.sleep(OVSDB_UPDATE_TIMEOUT);
@@ -1700,12 +1850,12 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         int max = 4095;
         return Lists.newArrayList(
                 Collections.<Integer>emptySet(),
-                Sets.newHashSet(2222),
+                Collections.singleton(2222),
                 Sets.newHashSet(min, max, min + 1, max - 1, (max - min) / 2));
     }
 
     private List<Trunks> buildTrunkList(Set<Integer> trunkSet) {
-        List<Trunks> trunkList = Lists.newArrayList();
+        List<Trunks> trunkList = new ArrayList<>();
         for (Integer trunk : trunkSet) {
             TrunksBuilder trunkBuilder = new TrunksBuilder();
             trunkBuilder.setTrunk(new VlanId(trunk));
@@ -1716,7 +1866,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
 
     @Test
     public void testCRUDTerminationPointVlanTrunks() throws InterruptedException {
-        final List<Trunks> UPDATED_TRUNKS = buildTrunkList(Sets.newHashSet(2011));
+        final List<Trunks> UPDATED_TRUNKS = buildTrunkList(Collections.singleton(2011));
         ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
         Iterable<Set<Integer>> vlanSets = generateVlanSets();
         int testCase = 0;
@@ -1767,7 +1917,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                         OvsdbTerminationPointAugmentation.class,
                         tpUpdateAugmentationBuilder.build());
                 tpUpdateBuilder.setTpId(new TpId(portName));
-                portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
+                portUpdateNodeBuilder.setTerminationPoint(Collections.singletonList(tpUpdateBuilder.build()));
                 Assert.assertTrue(
                         mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, portIid, portUpdateNodeBuilder.build()));
                 Thread.sleep(OVSDB_UPDATE_TIMEOUT);
@@ -1794,7 +1944,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
     @Test
     public void testCRUDTerminationPointQos() throws InterruptedException {
         ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
-        String testQosId = new String("testQosEntry");
+        String testQosId = "testQosEntry";
 
         // CREATE
         try (TestBridge testBridge = new TestBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME);
@@ -1813,17 +1963,14 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                     createGenericOvsdbTerminationPointAugmentationBuilder();
             String portName = "testTerminationPointQos";
             ovsdbTerminationBuilder.setName(portName);
-            ovsdbTerminationBuilder.setQos(qosUuid);
             Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
 
-            // READ and check that qos uuid has been added to the port
+
+           // READ and check that qos uuid has been added to the port
             InstanceIdentifier<TerminationPoint> tpEntryIid = getTpIid(connectionInfo, bridge)
                     .child(TerminationPoint.class, new TerminationPointKey(new TpId(portName)));
             TerminationPoint terminationPoint = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, tpEntryIid);
             Assert.assertNotNull(terminationPoint);
-            OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
-                    terminationPoint.getAugmentation(OvsdbTerminationPointAugmentation.class);
-            Assert.assertEquals(ovsdbTerminationPointAugmentation.getQos(), qosUuid);
 
             // UPDATE - remove the qos entry from the port
             OvsdbTerminationPointAugmentationBuilder tpUpdateAugmentationBuilder =
@@ -1843,9 +1990,6 @@ public class SouthboundIT extends AbstractMdsalTestBase {
             // READ and verify that qos uuid has been removed from port
             TerminationPoint terminationPointUpdate = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, tpEntryIid);
             Assert.assertNotNull(terminationPointUpdate);
-            OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentationUpdate =
-                    terminationPointUpdate.getAugmentation(OvsdbTerminationPointAugmentation.class);
-            Assert.assertNull(ovsdbTerminationPointAugmentationUpdate.getQos());
 
             // DELETE handled by TestBridge
         }
@@ -1860,7 +2004,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
 
         Topology topology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, topologyPath);
         InstanceIdentifier<Node> expectedNodeIid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
-        NodeId expectedNodeId = expectedNodeIid.firstKeyOf(Node.class, NodeKey.class).getNodeId();
+        NodeId expectedNodeId = expectedNodeIid.firstKeyOf(Node.class).getNodeId();
         Node foundNode = null;
         Assert.assertNotNull("Expected to find topology: " + topologyPath, topology);
         Assert.assertNotNull("Expected to find some nodes" + topology.getNode());
@@ -1975,7 +2119,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
         OvsdbNodeAugmentation ovsdbNodeAugmentation;
         Uri qosUri = new Uri("QOS-ROW");
-        List<String> typeList = new ArrayList<String>();
+        List<String> typeList = new ArrayList<>();
         typeList.add(SouthboundConstants.QOS_LINUX_HTB);
         typeList.add(SouthboundConstants.QOS_LINUX_HFSC);
 
@@ -2041,7 +2185,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
 
     private Queues getQueue(Uri queueId, OvsdbNodeAugmentation node) {
         for (Queues queue : node.getQueues()) {
-            if (queue.getKey().getQueueId().equals(queueId))
+            if (queue.getKey().getQueueId().getValue().equals(queueId.getValue()))
                 return queue;
         }
         return null;
@@ -2348,18 +2492,23 @@ public class SouthboundIT extends AbstractMdsalTestBase {
             // configuration of the Qos row.
             OvsdbNodeAugmentation ovsdbNodeAugmentation = getOvsdbNode(connectionInfo,
                     LogicalDatastoreType.OPERATIONAL);
+
             Queues operQueue1 = getQueue(new Uri("queue1"), ovsdbNodeAugmentation);
+
             Assert.assertNotNull(operQueue1);
-            Uuid queue1Uuid = new Uuid(operQueue1.getQueueUuid().getValue());
+
+            InstanceIdentifier<Queues> queue1Iid = testQueue1.getInstanceIdentifier();
+            OvsdbQueueRef queue1Ref = new OvsdbQueueRef(queue1Iid);
+
             Queues operQueue2 = getQueue(new Uri("queue2"), ovsdbNodeAugmentation);
             Assert.assertNotNull(operQueue2);
-            Uuid queue2Uuid = new Uuid(operQueue2.getQueueUuid().getValue());
+            InstanceIdentifier<Queues> queue2Iid = testQueue2.getInstanceIdentifier();
+            OvsdbQueueRef queue2Ref = new OvsdbQueueRef(queue2Iid);
 
             List<QueueList> queueList = new ArrayList<>();
-            queueList.add(new QueueListBuilder().setQueueNumber(new Long("0"))
-                    .setQueueUuid(queue1Uuid).build());
-            queueList.add(new QueueListBuilder().setQueueNumber(new Long("1"))
-                    .setQueueUuid(queue2Uuid).build());
+            queueList.add(new QueueListBuilder().setQueueNumber(new Long("1")).setQueueRef(queue1Ref).build());
+            queueList.add(new QueueListBuilder().setQueueNumber(new Long("2")).setQueueRef(queue2Ref).build());
+
             qosBuilder.setQueueList(queueList);
 
             Assert.assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
@@ -2375,12 +2524,12 @@ public class SouthboundIT extends AbstractMdsalTestBase {
             List<QueueList> operQueueList = operQos.getQueueList();
             Assert.assertNotNull(operQueueList);
             for (QueueList queueEntry : queueList) {
-                Assert.assertTrue(operQueueList.contains(queueEntry));
+                Assert.assertTrue(isQueueInList(operQueueList, queueEntry));
             }
 
             // DELETE one queue from queue list and check that one remains
             KeyedInstanceIdentifier<QueueList, QueueListKey> qosQueueIid = qosIid
-                        .child(QueueList.class, new QueueListKey(new Long("0")));
+                    .child(QueueList.class, new QueueListKey(new Long("1")));
             Assert.assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, qosQueueIid));
             qosOperationalListener.waitForUpdate(OVSDB_UPDATE_TIMEOUT);
 
@@ -2392,11 +2541,12 @@ public class SouthboundIT extends AbstractMdsalTestBase {
             Assert.assertNotNull(operQos);
             operQueueList = operQos.getQueueList();
             Assert.assertNotNull(operQueueList);
+
             for (QueueList queueEntry : queueList) {
-                if (queueEntry.getQueueUuid().equals(queue2Uuid))
-                    Assert.assertTrue(operQueueList.contains(queueEntry));
-                else if (queueEntry.getQueueUuid().equals(queue1Uuid)) {
-                    Assert.assertFalse(operQueueList.contains(queueEntry));
+                if (queueEntry.getQueueRef().equals(queue2Ref)) {
+                    Assert.assertTrue(isQueueInList(operQueueList, queueEntry));
+                } else if (queueEntry.getQueueRef().equals(queue1Ref)) {
+                    Assert.assertFalse(isQueueInList(operQueueList, queueEntry));
                 } else {
                     Assert.assertTrue("Unknown queue entry in qos queue list", false);
                 }
@@ -2418,6 +2568,17 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         }
     }
 
+
+
+    private Boolean isQueueInList(List<QueueList> queueList, QueueList queue) {
+        for (QueueList queueEntry : queueList) {
+            if (queueEntry.getQueueNumber().equals(queue.getQueueNumber())&& queueEntry.getQueueRef().equals(queue.getQueueRef())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     /**
      * <p>
      * Representation of a southbound test case. Each test case has a name, a list of input values and a list of