IT for Typed schema Table : Controller 83/8183/2
authorMadhu Venugopal <mavenugo@gmail.com>
Fri, 20 Jun 2014 16:49:05 +0000 (09:49 -0700)
committerMadhu Venugopal <mavenugo@gmail.com>
Fri, 20 Jun 2014 17:10:32 +0000 (10:10 -0700)
Change-Id: I6244de556684ea4148bed4c658b1bcd68dedef66
Signed-off-by: Madhu Venugopal <mavenugo@gmail.com>
library/src/test/java/org/opendaylight/ovsdb/lib/OvsDBClientTestIT.java
schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/TypedVSwitchdSchemaIT.java

index 46242bd0c1e3eb230b40ba56a00289b655fa88eb..c21efd8f68e5f0389ff738ed579d107b97c37ef6 100644 (file)
@@ -274,6 +274,9 @@ public class OvsDBClientTestIT extends OvsdbTestBase {
         // Check if Results matches the number of operations in transaction
         Assert.assertEquals(transactionBuilder.getOperations().size(), operationResults.size());
         System.out.println("Insert & Update operation results = " + operationResults);
+        for (OperationResult result : operationResults) {
+            Assert.assertNull(result.getError());
+        }
         testBridgeUuid = operationResults.get(insertOperationIndex).getUuid();
     }
 
index 3e762fb62b60eaa320cb13c5f131c012c678a64d..9ceeb6309b58c4ff19b3fd602d0d30b261456eb7 100644 (file)
@@ -49,6 +49,7 @@ public class TypedVSwitchdSchemaIT extends OvsdbTestBase {
     @Test
     public void testTypedBridgeOperations() throws IOException, InterruptedException, ExecutionException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
         this.createTypedBridge();
+        this.createTypedController();
     }
 
     private void createTypedBridge() throws IOException, InterruptedException, ExecutionException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
@@ -81,8 +82,64 @@ public class TypedVSwitchdSchemaIT extends OvsdbTestBase {
         // Check if Results matches the number of operations in transaction
         Assert.assertEquals(transactionBuilder.getOperations().size(), operationResults.size());
         System.out.println("Insert & Update operation results = " + operationResults);
+        for (OperationResult result : operationResults) {
+            Assert.assertNull(result.getError());
+        }
         testBridgeUuid = operationResults.get(insertOperationIndex).getUuid();
     }
+
+    private void createTypedController() throws IOException, InterruptedException, ExecutionException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+        Controller controller1 = ovs.createTypedRowWrapper(Controller.class);
+        controller1.setTarget("tcp:1.1.1.1:6640");
+        Controller controller2 = ovs.createTypedRowWrapper(Controller.class);
+        controller2.setTarget("tcp:2.2.2.2:6640");
+
+        Bridge bridge = ovs.getTypedRowWrapper(Bridge.class, null);
+
+        String transactionUuidStr = "controller";
+        TransactionBuilder transactionBuilder = ovs.transactBuilder()
+                .add(op.insert(controller1.getSchema())
+                        .withId(transactionUuidStr)
+                        .value(controller1.getTargetColumn()))
+                .add(op.mutate(bridge.getSchema())
+                        .addMutation(bridge.getControllerColumn().getSchema(), Mutator.INSERT,
+                                     Sets.newHashSet(new UUID(transactionUuidStr)))
+                        .where(bridge.getNameColumn().getSchema().opEqual(testBridgeName))
+                        .build());
+
+        ListenableFuture<List<OperationResult>> results = transactionBuilder.execute();
+        List<OperationResult> operationResults = results.get();
+        Assert.assertFalse(operationResults.isEmpty());
+        // Check if Results matches the number of operations in transaction
+        Assert.assertEquals(transactionBuilder.getOperations().size(), operationResults.size());
+        System.out.println("Insert & Mutate operation results for controller1 = " + operationResults);
+        // Check for any errors
+        for (OperationResult result : operationResults) {
+            Assert.assertNull(result.getError());
+        }
+
+        transactionBuilder = ovs.transactBuilder()
+                .add(op.insert(controller2.getSchema())
+                        .withId(transactionUuidStr)
+                        .value(controller2.getTargetColumn()))
+                .add(op.mutate(bridge.getSchema())
+                        .addMutation(bridge.getControllerColumn().getSchema(), Mutator.INSERT,
+                                     Sets.newHashSet(new UUID(transactionUuidStr)))
+                        .where(bridge.getNameColumn().getSchema().opEqual(testBridgeName))
+                        .build());
+
+        results = transactionBuilder.execute();
+        operationResults = results.get();
+        Assert.assertFalse(operationResults.isEmpty());
+        // Check if Results matches the number of operations in transaction
+        Assert.assertEquals(transactionBuilder.getOperations().size(), operationResults.size());
+        System.out.println("Insert & Mutate operation results for controller2 = " + operationResults);
+        // Check for any errors
+        for (OperationResult result : operationResults) {
+            Assert.assertNull(result.getError());
+        }
+    }
+
     public void testGetDBs() throws ExecutionException, InterruptedException {
         ListenableFuture<List<String>> databases = ovs.getDatabases();
         List<String> dbNames = databases.get();