Added missing columns to flow table db and tests 83/8283/7
authorBrent Salisbury <brent.salisbury@gmail.com>
Tue, 24 Jun 2014 09:36:48 +0000 (05:36 -0400)
committerMadhu Venugopal <mavenugo@gmail.com>
Sat, 28 Jun 2014 05:57:17 +0000 (22:57 -0700)
Changed external-id column insert from 7.4.0 to 7.5.0
Changed prefixes insert from 7.3.0 to 7.4.0

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

index f3202fb022c5a63c66ea117e8333c3e9a4a06d22..bcff88dd8669f2a99d011df07ae5d72802cc37a1 100644 (file)
@@ -27,10 +27,10 @@ import org.opendaylight.ovsdb.lib.schema.typed.TypedTable;
 public interface FlowTable extends TypedBaseTable<GenericTableSchema> {
 
     @TypedColumn(name="flow_limit", method=MethodType.GETCOLUMN, fromVersion="6.5.0")
-    public Column<GenericTableSchema, Integer> getFlowLimitColumn() ;
+    public Column<GenericTableSchema, Set<Integer>> getFlowLimitColumn() ;
 
     @TypedColumn(name="flow_limit", method=MethodType.SETDATA, fromVersion="6.5.0")
-    public void setFlowLimit(Integer flowLimit) ;
+    public void setFlowLimit(Set<Integer> flowLimit) ;
 
     @TypedColumn(name="overflow_policy", method=MethodType.GETCOLUMN, fromVersion="6.5.0")
     public Column<GenericTableSchema, Set<String>> getOverflowPolicyColumn() ;
@@ -62,4 +62,4 @@ public interface FlowTable extends TypedBaseTable<GenericTableSchema> {
     @TypedColumn(name="external_ids", method=MethodType.SETDATA, fromVersion="7.5.0")
     public void setExternalIds(Map<String, String> externalIds);
 
-}
\ No newline at end of file
+}
diff --git a/schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/FlowTableTestCases.java b/schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/FlowTableTestCases.java
new file mode 100644 (file)
index 0000000..2ffe9b8
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * 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.collect.ImmutableSet;
+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.Mutator;
+import org.opendaylight.ovsdb.lib.notation.UUID;
+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.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+import static org.opendaylight.ovsdb.lib.operations.Operations.op;
+
+public class FlowTableTestCases extends OpenVswitchSchemaTestBase {
+
+    Logger logger = LoggerFactory.getLogger(IpfixTestCases.class);
+    Version schemaVersion;
+    Version flowTableFromVersion = Version.fromString("6.5.0");
+    Version prefixesAddedVersion = Version.fromString("7.4.0");
+    Version externalIdAddedVerson = Version.fromString("7.5.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(flowTableFromVersion) < 0);
+        boolean isExceptionRaised = false;
+        try {
+            FlowTable flowTable = ovs.createTypedRowWrapper(FlowTable.class);
+        } catch (SchemaVersionMismatchException e) {
+            isExceptionRaised = true;
+        }
+        Assert.assertTrue(isExceptionRaised);
+    }
+
+    @Test
+    public void testCreateTypeFlowTable() throws InterruptedException, ExecutionException, IllegalArgumentException{
+        // Don't run this test if the table is not supported
+        Assume.assumeTrue(schemaVersion.compareTo(flowTableFromVersion) >= 0);
+
+        String flowTableUuidStr = "testFlowTable";
+        String tableName = "flow_table_row_name";
+        String overflowPolicy = "evict";
+        String groups = "group name";
+        String prefixes = "wildcarding prefixes";
+        Integer flowLimit = 50000;
+        Map<Integer, UUID> flowTableBrRef = new HashMap<>();
+        flowTableBrRef.put(1, new UUID(flowTableUuidStr));
+        FlowTable flowTable = ovs.createTypedRowWrapper(FlowTable.class);
+        flowTable.setName(ImmutableSet.of(tableName));
+        flowTable.setOverflowPolicy(ImmutableSet.of(overflowPolicy));
+        flowTable.setGroups(ImmutableSet.of(groups));
+        if (schemaVersion.compareTo(prefixesAddedVersion) >= 0) {
+            flowTable.setPrefixes(ImmutableSet.of(prefixes));
+        }
+        if (schemaVersion.compareTo(externalIdAddedVerson) >= 0) {
+            flowTable.setExternalIds(ImmutableMap.of("I <3", "OVS"));
+        }
+        flowTable.setFlowLimit(ImmutableSet.of(flowLimit));
+        Bridge bridge = ovs.getTypedRowWrapper(Bridge.class, null);
+        TransactionBuilder transactionBuilder = ovs.transactBuilder()
+                .add(op.insert(flowTable)
+                        .withId(flowTableUuidStr))
+                .add(op.mutate(bridge.getSchema())
+                        .addMutation(bridge.getFlowTablesColumn().getSchema(), Mutator.INSERT,(flowTableBrRef))
+                        .where(bridge.getNameColumn().getSchema().opEqual(TEST_BRIDGE_NAME))
+                        .build());
+        ListenableFuture<List<OperationResult>> results = transactionBuilder.execute();
+        List<OperationResult> operationResults = results.get();
+        for (OperationResult result : operationResults) Assert.assertNull(result.getError());
+        Assert.assertFalse(operationResults.isEmpty());
+        // Check if Results matches the number of operations in transaction
+        Assert.assertEquals(transactionBuilder.getOperations().size(), operationResults.size());
+        logger.info("Insert & Mutate operation results for Flow Table = {} ", 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 007585bb25ef9d38322ec819fc3fe68b334587c9..94583813d4cd7aab0b74020771475c0b0526a9e3 100644 (file)
@@ -28,6 +28,7 @@ import java.util.Map;
         SflowTestCases.class,
         IpfixTestCases.class,
         FlowSampleCollectorSetTestCases.class,
+        FlowTableTestCases.class,
         TearDown.class
 })
 public class OpenVswitchSchemaSuiteIT {