Bug 7757 -Removing qos deprecations in carbon
[ovsdb.git] / southbound / southbound-it / src / test / java / org / opendaylight / ovsdb / southbound / it / SouthboundIT.java
index 1bd2f48344d50d8aa6513b05af7b5270333fb3a3..a182c7b78c69a2fdd8ee5913df785baabcaaca7f 100644 (file)
@@ -48,6 +48,7 @@ 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.notation.Version;
+import org.opendaylight.ovsdb.schema.openvswitch.Queue;
 import org.opendaylight.ovsdb.southbound.SouthboundConstants;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
 import org.opendaylight.ovsdb.southbound.SouthboundUtil;
@@ -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;
@@ -186,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<>();
@@ -808,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);
@@ -953,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);
@@ -1131,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.
@@ -1155,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 =
@@ -1173,6 +1177,9 @@ public class SouthboundIT extends AbstractMdsalTestBase {
             }
         }
 
+        public InstanceIdentifier<Queues> getInstanceIdentifier() {
+            return qIid;
+        }
         @Override
         public void close() {
             InstanceIdentifier<Queues> qIid = SouthboundUtils.createInstanceIdentifier(connectionInfo)
@@ -1512,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);
@@ -1746,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);
@@ -1816,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);
@@ -1843,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));
@@ -1859,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;
@@ -1910,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);
@@ -1937,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);
@@ -1956,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 =
@@ -1986,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
         }
@@ -2491,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,
@@ -2523,7 +2529,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
 
             // 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);
 
@@ -2535,10 +2541,11 @@ public class SouthboundIT extends AbstractMdsalTestBase {
             Assert.assertNotNull(operQos);
             operQueueList = operQos.getQueueList();
             Assert.assertNotNull(operQueueList);
+
             for (QueueList queueEntry : queueList) {
-                if (queueEntry.getQueueUuid().equals(queue2Uuid)) {
+                if (queueEntry.getQueueRef().equals(queue2Ref)) {
                     Assert.assertTrue(isQueueInList(operQueueList, queueEntry));
-                } else if (queueEntry.getQueueUuid().equals(queue1Uuid)) {
+                } else if (queueEntry.getQueueRef().equals(queue1Ref)) {
                     Assert.assertFalse(isQueueInList(operQueueList, queueEntry));
                 } else {
                     Assert.assertTrue("Unknown queue entry in qos queue list", false);
@@ -2561,10 +2568,11 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         }
     }
 
+
+
     private Boolean isQueueInList(List<QueueList> queueList, QueueList queue) {
         for (QueueList queueEntry : queueList) {
-            if (queueEntry.getQueueNumber().equals(queue.getQueueNumber())
-                && queueEntry.getQueueUuid().equals(queue.getQueueUuid())) {
+            if (queueEntry.getQueueNumber().equals(queue.getQueueNumber())&& queueEntry.getQueueRef().equals(queue.getQueueRef())) {
                 return true;
             }
         }