Move OvsdbClient it under library-it 61/27461/1
authorSam Hague <shague@redhat.com>
Fri, 25 Sep 2015 18:46:59 +0000 (14:46 -0400)
committerSam Hague <shague@redhat.com>
Fri, 25 Sep 2015 18:47:07 +0000 (14:47 -0400)
A following commit will remove the integrationtest dir. With this commit here there
are no longer any tests in integrationtest. They have all been moved into the respective
bundles.

Change-Id: I40e7dccd6e5ee7ea362d75a422610fbdfe5e55cc
Signed-off-by: Sam Hague <shague@redhat.com>
library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestIT.java [new file with mode: 0644]
library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestTypedIT.java [new file with mode: 0644]
library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/TestBridge.java [new file with mode: 0644]
library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/VersionIncompatibleBridge.java [new file with mode: 0644]

diff --git a/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestIT.java b/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestIT.java
new file mode 100644 (file)
index 0000000..32d5f87
--- /dev/null
@@ -0,0 +1,360 @@
+/*
+ * Copyright (C) 2014 EBay Software Foundation
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Authors : Ashwin Raveendran
+ */
+package org.opendaylight.ovsdb.integrationtest.ovsdbclient;
+
+import static org.opendaylight.ovsdb.lib.operations.Operations.op;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.ListenableFuture;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.opendaylight.ovsdb.lib.MonitorCallBack;
+import org.opendaylight.ovsdb.lib.OvsdbClient;
+import org.opendaylight.ovsdb.lib.it.LibraryIntegrationTestBase;
+import org.opendaylight.ovsdb.lib.it.LibraryIntegrationTestUtils;
+import org.opendaylight.ovsdb.lib.message.MonitorRequest;
+import org.opendaylight.ovsdb.lib.message.MonitorRequestBuilder;
+import org.opendaylight.ovsdb.lib.message.MonitorSelect;
+import org.opendaylight.ovsdb.lib.message.TableUpdate;
+import org.opendaylight.ovsdb.lib.message.TableUpdates;
+import org.opendaylight.ovsdb.lib.notation.Column;
+import org.opendaylight.ovsdb.lib.notation.Mutator;
+import org.opendaylight.ovsdb.lib.notation.Row;
+import org.opendaylight.ovsdb.lib.notation.UUID;
+import org.opendaylight.ovsdb.lib.operations.OperationResult;
+import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
+import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
+import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
+import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerSuite;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerSuite.class)
+public class OvsdbClientTestIT extends LibraryIntegrationTestBase {
+
+    OvsdbClient ovs;
+    DatabaseSchema dbSchema = null;
+    static String testBridgeName = "br-test";
+    static UUID testBridgeUuid = null;
+
+    /**
+     * Test general OVSDB transactions (viz., insert, select, update,
+     * mutate, comment, delete, where, commit) as well as the special
+     * transactions (viz., abort and assert)
+     */
+    @Test
+    public void testTransact() throws IOException, InterruptedException, ExecutionException {
+        Assert.assertNotNull(dbSchema);
+        TableSchema<GenericTableSchema> bridge = dbSchema.table("Bridge", GenericTableSchema.class);
+        ColumnSchema<GenericTableSchema, String> name = bridge.column("name", String.class);
+
+        createBridgeTransaction();
+        abortTransaction();
+        assertTransaction();
+    }
+
+    /**
+     * Test OVS monitor request and reply, with and without specific column filters,
+     * for the Bridge table in the OVSDB. The setup involves creating a test bridge with 5
+     * flood_vlans and 2 key-value pairs, and monitoring the DB update.
+     */
+    @Test
+    public void testMonitorRequest() throws ExecutionException, InterruptedException, IOException {
+        Assert.assertNotNull(dbSchema);
+        // Create Test Bridge before testing the Monitor operation
+        createBridgeTransaction();
+        sendBridgeMonitorRequest(true); // Test monitor request with Column filters
+        sendBridgeMonitorRequest(false); // Test monitor request without filters
+    }
+
+    public void sendBridgeMonitorRequest(boolean filter) throws ExecutionException, InterruptedException, IOException {
+        Assert.assertNotNull(dbSchema);
+        GenericTableSchema bridge = dbSchema.table("Bridge", GenericTableSchema.class);
+
+        List<MonitorRequest<GenericTableSchema>> monitorRequests = Lists.newArrayList();
+        ColumnSchema<GenericTableSchema, Set<Integer>> flood_vlans = bridge.multiValuedColumn("flood_vlans", Integer.class);
+        ColumnSchema<GenericTableSchema, Map<String, String>> externalIds = bridge.multiValuedColumn("external_ids", String.class, String.class);
+        ColumnSchema<GenericTableSchema, String> name = bridge.column("name", String.class);
+        MonitorRequestBuilder<GenericTableSchema> builder = MonitorRequestBuilder.builder(bridge);
+        if (filter) {
+            builder.addColumn(bridge.column("name"))
+                   .addColumn(bridge.column("fail_mode", String.class))
+                   .addColumn(flood_vlans)
+                   .addColumn(externalIds);
+        }
+        monitorRequests.add(builder.with(new MonitorSelect(true, true, true, true))
+                                   .build());
+
+        final List<Object> results = Lists.newArrayList();
+
+        TableUpdates updates = ovs.monitor(dbSchema, monitorRequests, new MonitorCallBack() {
+            @Override
+            public void update(TableUpdates result, DatabaseSchema dbSchema) {
+                results.add(result);
+                System.out.println("result = " + result);
+            }
+
+            @Override
+            public void exception(Throwable t) {
+                results.add(t);
+                System.out.println("t = " + t);
+            }
+        });
+        if (updates != null) {
+            results.add(updates);
+        }
+        for (int i = 0; i < 3 ; i++) { //wait 3 seconds to get a result
+            System.out.println("waiting on monitor response for Bridge Table...");
+            if (!results.isEmpty()) {
+                break;
+            }
+            Thread.sleep(1000);
+        }
+
+        Assert.assertTrue(!results.isEmpty());
+        Object result = results.get(0);
+        Assert.assertTrue(result instanceof TableUpdates);
+        updates = (TableUpdates) result;
+        TableUpdate<GenericTableSchema> update = updates.getUpdate(bridge);
+        Assert.assertTrue(update.getRows().size() > 0);
+        for (UUID uuid : update.getRows().keySet()) {
+            Row<GenericTableSchema> aNew = update.getNew(uuid);
+            if (!aNew.getColumn(name).getData().equals(testBridgeName)) {
+                continue;
+            }
+            if (filter) {
+                Assert.assertEquals(builder.getColumns().size(), aNew.getColumns().size());
+            } else {
+                // As per RFC7047, Section 4.1.5 : If "columns" is omitted, all columns in the table, except for "_uuid", are monitored.
+                Assert.assertEquals(bridge.getColumns().size() - 1, aNew.getColumns().size());
+            }
+            for (Column<GenericTableSchema, ?> column: aNew.getColumns()) {
+                if (column.getSchema().equals(flood_vlans)) {
+                    // Test for the 5 flood_vlans inserted in Bridge br-test in createBridgeTransaction
+                    Set<Integer> data = column.getData(flood_vlans);
+                    Assert.assertNotNull(data);
+                    Assert.assertTrue(!data.isEmpty());
+                    Assert.assertEquals(5, data.size());
+                } else if (column.getSchema().equals(externalIds)) {
+                    // Test for the {"key", "value"} external_ids inserted in Bridge br-test in createBridgeTransaction
+                    Map<String, String> data = column.getData(externalIds);
+                    Assert.assertNotNull(data);
+                    Assert.assertNotNull(data.get("key"));
+                    Assert.assertEquals("value", data.get("key"));
+                    // Test for {"key2", "value2"} external_ids mutation-inserted in Bridge br-test in createBridgeTransaction
+                    Assert.assertNotNull(data.get("key2"));
+                    Assert.assertEquals("value2", data.get("key2"));
+                }
+            }
+            return;
+        }
+        Assert.fail("Bridge being monitored :"+testBridgeName+" Not found");
+    }
+
+    /*
+     * TODO : selectOpenVSwitchTableUuid method isn't working as expected due to the Jackson
+     * parsing challenges on the Row object returned by the Select operation.
+     */
+    private UUID selectOpenVSwitchTableUuid() throws ExecutionException, InterruptedException {
+        Assert.assertNotNull(dbSchema);
+        GenericTableSchema ovsTable = dbSchema.table("Open_vSwitch", GenericTableSchema.class);
+
+        List<MonitorRequest<GenericTableSchema>> monitorRequests = Lists.newArrayList();
+        ColumnSchema<GenericTableSchema, UUID> _uuid = ovsTable.column("_uuid", UUID.class);
+
+        List<OperationResult> results = ovs.transactBuilder(dbSchema)
+               .add(op.select(ovsTable)
+                      .column(_uuid))
+                      .execute()
+                      .get();
+
+        Assert.assertTrue(!results.isEmpty());
+        OperationResult result = results.get(0);
+        List<Row<GenericTableSchema>> rows = result.getRows();
+        Row<GenericTableSchema> ovsTableRow = rows.get(0);
+        return ovsTableRow.getColumn(_uuid).getData();
+    }
+
+    private void createBridgeTransaction() throws IOException, InterruptedException, ExecutionException {
+        Assert.assertNotNull(dbSchema);
+        TableSchema<GenericTableSchema> bridge = dbSchema.table("Bridge", GenericTableSchema.class);
+        GenericTableSchema ovsTable = dbSchema.table("Open_vSwitch", GenericTableSchema.class);
+
+        ColumnSchema<GenericTableSchema, String> name = bridge.column("name", String.class);
+        ColumnSchema<GenericTableSchema, String> fail_mode = bridge.column("fail_mode", String.class);
+        ColumnSchema<GenericTableSchema, Set<Integer>> flood_vlans = bridge.multiValuedColumn("flood_vlans", Integer.class);
+        ColumnSchema<GenericTableSchema, Map<String, String>> externalIds = bridge.multiValuedColumn("external_ids", String.class, String.class);
+        ColumnSchema<GenericTableSchema, Set<UUID>> bridges = ovsTable.multiValuedColumn("bridges", UUID.class);
+        ColumnSchema<GenericTableSchema, UUID> _uuid = ovsTable.column("_uuid", UUID.class);
+
+        String namedUuid = "br_test";
+        int insertOperationIndex = 0;
+        UUID parentTable = selectOpenVSwitchTableUuid();
+        TransactionBuilder transactionBuilder = ovs.transactBuilder(dbSchema)
+                 /*
+                  * Make sure that the position of insert operation matches the insertOperationIndex.
+                  * This will be used later when the Results are processed.
+                  */
+                .add(op.insert(bridge)
+                        .withId(namedUuid)
+                        .value(name, testBridgeName)
+                        .value(flood_vlans, Sets.newHashSet(100, 101, 4001))
+                        .value(externalIds, ImmutableMap.of("key","value")))
+                .add(op.comment("Inserting Bridge br-int"))
+                .add(op.update(bridge)
+                        .set(fail_mode, "secure")
+                        .where(name.opEqual(testBridgeName))
+                        .build())
+                .add(op.select(bridge)
+                        .column(name)
+                        .column(_uuid)
+                        .where(name.opEqual(testBridgeName))
+                        .build())
+                .add(op.mutate(bridge)
+                        .addMutation(flood_vlans, Mutator.INSERT, Sets.newHashSet(200,400))
+                        .where(name.opEqual(testBridgeName))
+                        .build())
+                .add(op.mutate(bridge)
+                        .addMutation(externalIds, Mutator.INSERT, ImmutableMap.of("key2","value2"))
+                        .where(name.opEqual(testBridgeName))
+                        .build())
+                .add(op.mutate(ovsTable)
+                        .addMutation(bridges, Mutator.INSERT, Sets.newHashSet(new UUID(namedUuid)))
+                        .where(_uuid.opEqual(parentTable))
+                        .build())
+                .add(op.commit(true));
+
+        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 & Update operation results = " + operationResults);
+        for (OperationResult result : operationResults) {
+            Assert.assertNull(result.getError());
+        }
+        testBridgeUuid = operationResults.get(insertOperationIndex).getUuid();
+    }
+
+    private void assertTransaction() throws InterruptedException, ExecutionException {
+        Assert.assertNotNull(dbSchema);
+        TableSchema<GenericTableSchema> bridge = dbSchema.table("Bridge", GenericTableSchema.class);
+        ColumnSchema<GenericTableSchema, String> name = bridge.column("name", String.class);
+
+        /*
+         * Adding a separate Assert operation in a transaction. Lets not mix this with other
+         * valid transactions as above.
+         */
+        ListenableFuture<List<OperationResult>> results = ovs.transactBuilder(dbSchema)
+                .add(op.delete(bridge)
+                        .where(name.opEqual(testBridgeName))
+                        .build())
+                .add(op.assertion("Assert12345")) // Failing intentionally
+                .execute();
+
+        List<OperationResult> operationResults = results.get();
+        Assert.assertFalse(operationResults.isEmpty());
+        /* Testing for an Assertion Error */
+        Assert.assertFalse(operationResults.get(1).getError() == null);
+        System.out.println("Assert operation results = " + operationResults);
+    }
+
+    private void abortTransaction() throws InterruptedException, ExecutionException {
+        Assert.assertNotNull(dbSchema);
+        TableSchema<GenericTableSchema> bridge = dbSchema.table("Bridge", GenericTableSchema.class);
+        ColumnSchema<GenericTableSchema, String> name = bridge.column("name", String.class);
+
+        /*
+         * Adding a separate Abort operation in a transaction. Lets not mix this with other
+         * valid transactions as above.
+         */
+        ListenableFuture<List<OperationResult>> results = ovs.transactBuilder(dbSchema)
+                .add(op.delete(bridge)
+                        .where(name.opEqual(testBridgeName))
+                        .build())
+                .add(op.abort())
+                .execute();
+
+        List<OperationResult> operationResults = results.get();
+        Assert.assertFalse(operationResults.isEmpty());
+        /* Testing for Abort Error */
+        Assert.assertFalse(operationResults.get(1).getError() == null);
+        System.out.println("Abort operation results = " + operationResults);
+    }
+
+    public void testGetDBs() throws ExecutionException, InterruptedException {
+        ListenableFuture<List<String>> databases = ovs.getDatabases();
+        List<String> dbNames = databases.get();
+        Assert.assertNotNull(dbNames);
+        boolean hasOpenVswitchSchema = false;
+        for(String dbName : dbNames) {
+           if (dbName.equals(LibraryIntegrationTestUtils.OPEN_VSWITCH_SCHEMA)) {
+                hasOpenVswitchSchema = true;
+                break;
+           }
+        }
+        Assert.assertTrue(LibraryIntegrationTestUtils.OPEN_VSWITCH_SCHEMA
+                + " schema is not supported by the switch", hasOpenVswitchSchema);
+    }
+
+    @Before
+    public  void setUp() throws IOException, ExecutionException, InterruptedException, TimeoutException {
+        if (ovs != null) {
+            return;
+        }
+
+        ovs = LibraryIntegrationTestUtils.getTestConnection(this);
+        System.out.println("Connection Info :" + ovs.getConnectionInfo().toString());
+        testGetDBs();
+        dbSchema = ovs.getSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH_SCHEMA).get();
+    }
+
+    @After
+    public void tearDown() throws InterruptedException, ExecutionException {
+        if (dbSchema == null) {
+            return;
+        }
+        TableSchema<GenericTableSchema> bridge = dbSchema.table("Bridge", GenericTableSchema.class);
+        ColumnSchema<GenericTableSchema, String> name = bridge.column("name", String.class);
+        GenericTableSchema ovsTable = dbSchema.table("Open_vSwitch", GenericTableSchema.class);
+        ColumnSchema<GenericTableSchema, Set<UUID>> bridges = ovsTable.multiValuedColumn("bridges", UUID.class);
+        ColumnSchema<GenericTableSchema, UUID> _uuid = ovsTable.column("_uuid", UUID.class);
+        UUID parentTable = selectOpenVSwitchTableUuid();
+
+        ListenableFuture<List<OperationResult>> results = ovs.transactBuilder(dbSchema)
+                .add(op.delete(bridge)
+                        .where(name.opEqual(testBridgeName))
+                        .build())
+                .add(op.mutate(ovsTable)
+                        .addMutation(bridges, Mutator.DELETE, Sets.newHashSet(testBridgeUuid))
+                        .where(_uuid.opEqual(parentTable))
+                        .build())
+                .add(op.commit(true))
+                .execute();
+
+        List<OperationResult> operationResults = results.get();
+        System.out.println("Delete operation results = " + operationResults);
+        ovs.disconnect();
+    }
+}
diff --git a/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestTypedIT.java b/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestTypedIT.java
new file mode 100644 (file)
index 0000000..15f64fb
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2014 EBay Software Foundation
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Authors : Ashwin Raveendran, Madhu Venugopal
+ */
+
+package org.opendaylight.ovsdb.integrationtest.ovsdbclient;
+
+import static org.opendaylight.ovsdb.lib.operations.Operations.op;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.ListenableFuture;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.opendaylight.ovsdb.lib.OvsdbClient;
+import org.opendaylight.ovsdb.lib.it.LibraryIntegrationTestBase;
+import org.opendaylight.ovsdb.lib.it.LibraryIntegrationTestUtils;
+import org.opendaylight.ovsdb.lib.notation.Mutator;
+import org.opendaylight.ovsdb.lib.notation.UUID;
+import org.opendaylight.ovsdb.lib.operations.OperationResult;
+import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
+import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
+import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
+import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerSuite;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerSuite.class)
+public class OvsdbClientTestTypedIT extends LibraryIntegrationTestBase {
+
+    OvsdbClient ovs;
+    DatabaseSchema dbSchema = null;
+    static String testBridgeName = "br_test";
+    static UUID testBridgeUuid = null;
+
+    /**
+     * Test creation of statically typed bridge table as defined in
+     * ovs-vswitchd.conf.db with get/set for all relevant columns. The
+     * SETDATA methods for "name", "status" and "flood_vlans" columns
+     * are verified.
+     */
+    @Test
+    public void testTypedBridgeCreate() throws IOException, InterruptedException, ExecutionException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+        TestBridge rBridge = ovs.createTypedRowWrapper(TestBridge.class);
+        rBridge.setName(testBridgeName);
+        rBridge.setStatus(ImmutableMap.of("key","value"));
+        rBridge.setFloodVlans(Sets.newHashSet(34));
+
+        GenericTableSchema ovsTable = dbSchema.table("Open_vSwitch", GenericTableSchema.class);
+        ColumnSchema<GenericTableSchema, Set<UUID>> bridges = ovsTable.multiValuedColumn("bridges", UUID.class);
+
+        String namedUuid = "br_test";
+        int insertOperationIndex = 0;
+
+        TransactionBuilder transactionBuilder = ovs.transactBuilder(dbSchema)
+                .add(op.insert(rBridge)
+                        .withId(namedUuid))
+                .add(op.mutate(ovsTable)
+                        .addMutation(bridges, Mutator.INSERT, Sets.newHashSet(new UUID(namedUuid))));
+
+        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 & Update operation results = " + operationResults);
+        testBridgeUuid = operationResults.get(insertOperationIndex).getUuid();
+    }
+
+    public void testGetDBs() throws ExecutionException, InterruptedException {
+        ListenableFuture<List<String>> databases = ovs.getDatabases();
+        List<String> dbNames = databases.get();
+        Assert.assertNotNull(dbNames);
+        boolean hasOpenVswitchSchema = false;
+        for(String dbName : dbNames) {
+           if (dbName.equals(LibraryIntegrationTestUtils.OPEN_VSWITCH_SCHEMA)) {
+                hasOpenVswitchSchema = true;
+                break;
+           }
+        }
+        Assert.assertTrue(LibraryIntegrationTestUtils.OPEN_VSWITCH_SCHEMA
+                + " schema is not supported by the switch", hasOpenVswitchSchema);
+    }
+
+    @Before
+    public  void setUp() throws IOException, ExecutionException, InterruptedException, TimeoutException {
+        if (ovs != null) {
+            return;
+        }
+        ovs = LibraryIntegrationTestUtils.getTestConnection(this);
+        testGetDBs();
+        dbSchema = ovs.getSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH_SCHEMA).get();
+    }
+
+    @After
+    public void tearDown() throws InterruptedException, ExecutionException {
+        TableSchema<GenericTableSchema> bridge = dbSchema.table("Bridge", GenericTableSchema.class);
+        ColumnSchema<GenericTableSchema, String> name = bridge.column("name", String.class);
+        GenericTableSchema ovsTable = dbSchema.table("Open_vSwitch", GenericTableSchema.class);
+        ColumnSchema<GenericTableSchema, Set<UUID>> bridges = ovsTable.multiValuedColumn("bridges", UUID.class);
+
+        ListenableFuture<List<OperationResult>> results = ovs.transactBuilder(dbSchema)
+                .add(op.delete(bridge)
+                        .where(name.opEqual(testBridgeName))
+                        .build())
+                .add(op.mutate(ovsTable)
+                        .addMutation(bridges, Mutator.DELETE, Sets.newHashSet(testBridgeUuid)))
+                .add(op.commit(true))
+                .execute();
+
+        List<OperationResult> operationResults = results.get();
+        System.out.println("Delete operation results = " + operationResults);
+        ovs.disconnect();
+    }
+}
diff --git a/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/TestBridge.java b/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/TestBridge.java
new file mode 100644 (file)
index 0000000..2ccae3f
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Authors : Madhu Venugopal
+ */
+
+package org.opendaylight.ovsdb.integrationtest.ovsdbclient;
+
+import java.util.Map;
+import java.util.Set;
+import org.opendaylight.ovsdb.lib.notation.Column;
+import org.opendaylight.ovsdb.lib.notation.UUID;
+import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
+import org.opendaylight.ovsdb.lib.schema.typed.MethodType;
+import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable;
+import org.opendaylight.ovsdb.lib.schema.typed.TypedColumn;
+import org.opendaylight.ovsdb.lib.schema.typed.TypedTable;
+
+/**
+ * Statically Typed Bridge Table as defined in ovs-vswitchd.conf.db
+ */
+
+/*
+ * Interface name was set to TestBridge on purpose to test the @TypeTable annotation
+ * functionality of TyperHelper.java
+ */
+@TypedTable(name="Bridge", database="Open_vSwitch")
+public interface TestBridge extends TypedBaseTable {
+    /*
+     * Its a good practice to set the @TypedColumn to these Statically typed Tables & Columns.
+     * Implementations can choose to use GETDATA or GETCOLUMN or both to get the data.
+     * But GETCOLUMN gives more info on ColumnSchema.
+     * The following "name" column is decorated with both GETDATA and GETCOLUMN and the corresponding test
+     * will test both the options.
+     */
+    @TypedColumn(name="name", method=MethodType.GETDATA)
+    String getName();
+
+    @TypedColumn(name="name", method=MethodType.GETCOLUMN)
+    Column<GenericTableSchema, String> getNameColumn();
+
+    @TypedColumn(name="name", method=MethodType.SETDATA)
+    void setName(String name);
+
+   /*
+    * Annotations are NOT added to the Status column on purpose to test the backup
+    * functionality on getter, setter, column name derivation etc.  TyperHelper.java.
+    */
+   Column<GenericTableSchema, Map<String, String>> getStatusColumn();
+    void setStatus(Map<String, String> status);
+
+    /*
+     * TypedColumn's name Annotation should override the method name based Column derivation.
+     * The method name and TypedColumn name was kept different on purpose to test the name
+     * resolution priority of TyperHelper.java
+     */
+    @TypedColumn(name="flood_vlans", method=MethodType.GETCOLUMN)
+    Column<GenericTableSchema, Set<Integer>> getFloodVlansColumn();
+
+    @TypedColumn(name="flood_vlans", method=MethodType.SETDATA)
+    void setFloodVlans(Set<Integer> vlans);
+
+
+    @TypedColumn(name="ports", method=MethodType.GETCOLUMN)
+    Column<GenericTableSchema, Set<UUID>> getPortsColumn();
+
+    @TypedColumn(name="ports", method=MethodType.SETDATA)
+    void setPorts(Set<UUID> ports);
+
+
+    @TypedColumn(name="mirrors", method=MethodType.GETCOLUMN)
+    Column<GenericTableSchema, Set<UUID>> getMirrorsColumn();
+
+    @TypedColumn(name="mirrors", method=MethodType.SETDATA)
+    void setMirrors(Set<UUID> mirrors);
+
+
+    @TypedColumn(name="controller", method=MethodType.GETCOLUMN)
+    Column<GenericTableSchema, Set<UUID>> getControllerColumn();
+
+    @TypedColumn(name="controller", method=MethodType.SETDATA)
+    void setController(Set<UUID> controller);
+
+
+    @TypedColumn(name="datapath_id", method=MethodType.GETCOLUMN)
+    Column<GenericTableSchema, Set<String>> getDatapathIdColumn();
+
+    @TypedColumn(name="datapath_id", method=MethodType.SETDATA)
+    void setDatapathId(Set<String> datapathId);
+
+
+    @TypedColumn(name="datapath_type", method=MethodType.GETCOLUMN)
+    Column<GenericTableSchema, String> getDatapathTypeColumn();
+
+    @TypedColumn(name="datapath_type", method=MethodType.SETDATA)
+    void setDatapathType(String datapathType);
+
+
+    @TypedColumn(name="fail_mode", method=MethodType.GETCOLUMN)
+    Column<GenericTableSchema, Set<String>> getFailModeColumn();
+
+    @TypedColumn(name="fail_mode", method=MethodType.SETDATA)
+    void setFailMode(Set<String> failMode);
+
+
+    @TypedColumn(name="sflow", method=MethodType.GETCOLUMN)
+    Column<GenericTableSchema, Set<UUID>> getSflowColumn();
+
+    @TypedColumn(name="sflow", method=MethodType.SETDATA)
+    void setSflow(Set<UUID> sflow);
+
+
+    @TypedColumn(name="netflow", method=MethodType.GETCOLUMN)
+    Column<GenericTableSchema, Set<UUID>> getNetflowColumn();
+
+    @TypedColumn(name="netflow", method=MethodType.SETDATA)
+    void setNetflow(Set<UUID> netflow);
+
+
+    @TypedColumn(name="flow_tables", method=MethodType.GETCOLUMN)
+    Column<GenericTableSchema, Map<Integer, UUID>> getFlowTablesColumn();
+
+    @TypedColumn(name="flow_tables", method=MethodType.SETDATA)
+    void setFlowTables(Map<Integer, UUID> flowTables);
+
+
+    @TypedColumn(name="stp_enable", method=MethodType.GETCOLUMN)
+    Column<GenericTableSchema, Boolean> getStpEnableColumn();
+
+    @TypedColumn(name="stp_enable", method=MethodType.SETDATA)
+    void setStpEnable(Boolean stp_enable);
+
+
+    @TypedColumn(name="protocols", method=MethodType.GETCOLUMN)
+    Column<GenericTableSchema, Set<String>> getProtocolsColumn();
+
+    @TypedColumn(name="protocols", method=MethodType.SETDATA)
+    void setProtocols(Set<String> protocols);
+
+
+    @TypedColumn(name="other_config", method=MethodType.GETCOLUMN)
+    Column<GenericTableSchema, Map<String, String>> getOtherConfigColumn();
+
+    @TypedColumn(name="other_config", method=MethodType.SETDATA)
+    void setOtherConfig(Map<String, String> other_config);
+
+
+    @TypedColumn(name="external_ids", method=MethodType.GETCOLUMN)
+    Column<GenericTableSchema, Map<String, String>> getExternalIdsColumn();
+
+    @TypedColumn(name="external_ids", method=MethodType.SETDATA)
+    void setExternalIds(Map<String, String> externalIds);
+
+
+    @TypedColumn(name="ipfix", method=MethodType.GETCOLUMN)
+    Column<GenericTableSchema, Set<UUID>> getIpfixColumn();
+
+    @TypedColumn(name="ipfix", method=MethodType.SETDATA)
+    void setIpfix(Set<UUID> ipfix);
+}
diff --git a/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/VersionIncompatibleBridge.java b/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/VersionIncompatibleBridge.java
new file mode 100644 (file)
index 0000000..4fdc93a
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Authors : Madhu Venugopal
+ */
+
+package org.opendaylight.ovsdb.integrationtest.ovsdbclient;
+import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable;
+import org.opendaylight.ovsdb.lib.schema.typed.TypedTable;
+
+/**
+ * VersionIncompatibleBridge is used to test the Version Compatibility logic in the Library
+ * with an absurdly low fromVersion and untilVersion which will fail for all the OVS versions.
+ */
+@TypedTable(name="Bridge", database="Open_vSwitch", fromVersion="0.0.1", untilVersion="0.0.2")
+public interface VersionIncompatibleBridge extends TypedBaseTable {
+}