Version information/columns to FlowSampleCollector DB Table 87/8187/6
authorBrent Salisbury <brent.salisbury@gmail.com>
Fri, 20 Jun 2014 17:46:50 +0000 (13:46 -0400)
committerDave Tucker <djt@redhat.com>
Fri, 27 Jun 2014 19:35:34 +0000 (20:35 +0100)
Patchset2: Added versioning to the SetX methods

Note: Accompanying IT will be submitted shortly.

Change-Id: I53b06ce187a79d4a9cb34291b6eef4de88241997
Signed-off-by: Brent Salisbury <brent.salisbury@gmail.com>
Signed-off-by: Dave Tucker <djt@redhat.com>
schemas/Open_vSwitch/src/main/java/org/opendaylight/ovsdb/schema/openvswitch/FlowSampleCollectorSet.java
schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/FlowSampleCollectorSetTestCases.java [new file with mode: 0644]
schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/OpenVswitchSchemaSuiteIT.java
schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/TearDown.java

index 3ea0e3264521680d8692b16d4728c22a04d684e8..b0e5c4bd0e6aeead494a312ca0a5db847ca70718 100644 (file)
@@ -5,7 +5,7 @@
  * 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
+ *  Authors : Dave Tucker
  */
 
 package org.opendaylight.ovsdb.schema.openvswitch;
@@ -13,35 +13,40 @@ package org.opendaylight.ovsdb.schema.openvswitch;
 import java.util.Map;
 
 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;
 
-/*
- * Reusing the existing Table definitions and many of columns are not defined here
- * TODO : Fill up the missing Columns and include Supported DB Version
+/**
+ * This class is a typed interface to the Flow_Sample_Collector_Set Table
  */
-@TypedTable(name="Flow_Sample_Collector_Set", database="Open_vSwitch")
+@TypedTable(name="Flow_Sample_Collector_Set", database="Open_vSwitch", fromVersion="7.1.0")
 public interface FlowSampleCollectorSet extends TypedBaseTable<GenericTableSchema> {
-    @TypedColumn(name="id", method=MethodType.GETCOLUMN)
+
+    @TypedColumn(name="id", method=MethodType.GETCOLUMN, fromVersion="7.1.0")
     public Column<GenericTableSchema, Integer> getIdColumn();
-    @TypedColumn(name="id", method=MethodType.SETDATA)
+
+    @TypedColumn(name="id", method=MethodType.SETDATA, fromVersion="7.1.0")
     public void setId(Integer id);
 
-    @TypedColumn(name="bridge", method=MethodType.GETCOLUMN)
-    public Column<GenericTableSchema, Bridge> getBridgeColumn();
-    @TypedColumn(name="bridge", method=MethodType.SETDATA)
-    public void setBridge(Bridge bridge);
+    @TypedColumn(name="bridge", method=MethodType.GETCOLUMN, fromVersion="7.1.0")
+    public Column<GenericTableSchema, UUID> getBridgeColumn();
 
-    @TypedColumn(name="ipfix", method=MethodType.GETCOLUMN)
-    public Column<GenericTableSchema, IPFIX> getIpfixColumn();
-    @TypedColumn(name="ipfix", method=MethodType.SETDATA)
-    public void setIpfix(IPFIX ipfix);
+    @TypedColumn(name="bridge", method=MethodType.SETDATA, fromVersion="7.1.0")
+    public void setBridge(UUID bridge);
 
-    @TypedColumn(name="external_ids", method=MethodType.GETCOLUMN)
+    @TypedColumn(name="ipfix", method=MethodType.GETCOLUMN, fromVersion="7.1.0")
+    public Column<GenericTableSchema, UUID> getIpfixColumn();
+
+    @TypedColumn(name="ipfix", method=MethodType.SETDATA, fromVersion="7.1.0")
+    public void setIpfix(UUID ipfix);
+
+    @TypedColumn(name="external_ids", method=MethodType.GETCOLUMN, fromVersion="7.1.0")
     public Column<GenericTableSchema, Map<String, String>> getExternalIdsColumn();
-    @TypedColumn(name="external_ids", method=MethodType.SETDATA)
+
+    @TypedColumn(name="external_ids", method=MethodType.SETDATA, fromVersion="7.1.0")
     public void setExternalIds(Map<String, String> externalIds);
 }
diff --git a/schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/FlowSampleCollectorSetTestCases.java b/schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/FlowSampleCollectorSetTestCases.java
new file mode 100644 (file)
index 0000000..a4af837
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * 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 : Brent Salisbury, Dave Tucker
+ */
+
+package org.opendaylight.ovsdb.schema.openvswitch;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.ListenableFuture;
+import junit.framework.Assert;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.ovsdb.lib.error.SchemaVersionMismatchException;
+import org.opendaylight.ovsdb.lib.message.UpdateNotification;
+import org.opendaylight.ovsdb.lib.notation.Version;
+import org.opendaylight.ovsdb.lib.operations.OperationResult;
+import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+import static org.opendaylight.ovsdb.lib.operations.Operations.op;
+
+public class FlowSampleCollectorSetTestCases extends OpenVswitchSchemaTestBase {
+    Logger logger = LoggerFactory.getLogger(FlowSampleCollectorSet.class);
+    Version schemaVersion;
+    Version flowSampleCollectorSetFromVersion = Version.fromString("7.1.0");
+
+    @Before
+    public void setUp() throws ExecutionException, InterruptedException, TimeoutException, IOException {
+        super.setUp();
+        schemaVersion = ovs.getDatabaseSchema("Open_vSwitch").getVersion();
+    }
+
+    @Test
+    public void testTableNotSupported() {
+        // Don't run this test if the table is supported
+        Assume.assumeTrue(schemaVersion.compareTo(flowSampleCollectorSetFromVersion) < 0);
+        boolean isExceptionRaised = false;
+        try {
+            FlowSampleCollectorSet flowSampleCollectorSet = ovs.createTypedRowWrapper(FlowSampleCollectorSet.class);
+        } catch (SchemaVersionMismatchException e) {
+            isExceptionRaised = true;
+        }
+        Assert.assertTrue(isExceptionRaised);
+    }
+
+
+    @Test
+    public void testCreateTypedFlowSampleCollectorSet() throws InterruptedException, ExecutionException, IllegalArgumentException{
+        // Don't run this test if the table is not supported
+        Assume.assumeTrue(schemaVersion.compareTo(flowSampleCollectorSetFromVersion) >= 0);
+        FlowSampleCollectorSet flowSampleCollectorSet = ovs.createTypedRowWrapper(FlowSampleCollectorSet.class);
+        flowSampleCollectorSet.setId(1);
+        flowSampleCollectorSet.setExternalIds(ImmutableMap.of("<3", "ovs"));
+        flowSampleCollectorSet.setBridge(OpenVswitchSchemaSuiteIT.getTestBridgeUuid());
+        Bridge bridge = ovs.getTypedRowWrapper(Bridge.class, null);
+        TransactionBuilder transactionBuilder = ovs.transactBuilder()
+                .add(op.insert(flowSampleCollectorSet.getSchema())
+                        .value(flowSampleCollectorSet.getIdColumn())
+                        .value(flowSampleCollectorSet.getExternalIdsColumn())
+                        .value(flowSampleCollectorSet.getBridgeColumn()));
+        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());
+        for (OperationResult result : operationResults) Assert.assertNull(result.getError());
+        logger.info("Insert operation results for FlowSampleCollectorSet = {} ", operationResults);
+    }
+
+    @Override
+    public void update(Object context, UpdateNotification upadateNotification) {
+
+    }
+
+    @Override
+    public void locked(Object context, List<String> ids) {
+
+    }
+
+    @Override
+    public void stolen(Object context, List<String> ids) {
+
+    }
+}
index 35d6b95156db81388a622d3f43b3ebdc50836aae..007585bb25ef9d38322ec819fc3fe68b334587c9 100644 (file)
@@ -27,6 +27,7 @@ import java.util.Map;
         NetflowTestCases.class,
         SflowTestCases.class,
         IpfixTestCases.class,
+        FlowSampleCollectorSetTestCases.class,
         TearDown.class
 })
 public class OpenVswitchSchemaSuiteIT {
index 9b70fdfff37160918c543825ac0247259afd53c4..439e53a7af2e8bb0e693d01b13c094e14bc7785d 100644 (file)
@@ -35,9 +35,13 @@ public class TearDown extends OpenVswitchSchemaTestBase {
     @Test
     public void tearDown() throws InterruptedException, ExecutionException, IOException, TimeoutException {
         Bridge bridge = this.ovs.getTypedRowWrapper(Bridge.class, null);
+        FlowSampleCollectorSet flowSampleCollectorSet = this.ovs.getTypedRowWrapper(FlowSampleCollectorSet.class, null);
         OpenVSwitch openVSwitch = this.ovs.getTypedRowWrapper(OpenVSwitch.class, null);
 
         ListenableFuture<List<OperationResult>> results = this.ovs.transactBuilder()
+                .add(op.delete(flowSampleCollectorSet.getSchema())
+                        .where(flowSampleCollectorSet.getBridgeColumn().getSchema().opEqual(OpenVswitchSchemaSuiteIT.getTestBridgeUuid()))
+                        .build())
                 .add(op.delete(bridge.getSchema())
                         .where(bridge.getNameColumn().getSchema().opEqual(OpenVswitchSchemaTestBase.TEST_BRIDGE_NAME))
                         .build())