Fix bug in Ipfix table and TearDown IT code 16/8416/4
authorDave Tucker <djt@redhat.com>
Fri, 27 Jun 2014 17:42:09 +0000 (18:42 +0100)
committerDave Tucker <djt@redhat.com>
Fri, 27 Jun 2014 22:16:09 +0000 (23:16 +0100)
The cache columns weren't added until schema version 7.3.0
This commit adds splits the IPFIX tests with Junit assumptions and as
such OVS 1.11.0 IT's will no longer fail

TearDown tries to delete a FlowSampleCollectorSet row which will not
have been created unless the schema version is greater than 7.1.0. This
commit conditionally adds this transaction in the teardown code.

Change-Id: I1dc5b13329f0f1f5bcee60625737871719d77df7
Signed-off-by: Dave Tucker <djt@redhat.com>
library/src/test/java/org/opendaylight/ovsdb/lib/notation/VersionTest.java
schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/IpfixTestCases.java
schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/TearDown.java

index d87525407889129fdbcc02c20935dfa9d135fb86..f36744dfbb8b97d64b96b9b379939d1c9b2ba631 100644 (file)
@@ -48,4 +48,10 @@ public class VersionTest {
         assertTrue(b.compareTo(d) < 0);
 
     }
+
+    @Test
+    public void testCompare() throws Exception {
+        Version a = Version.fromString("6.9.3");
+        Version b = Version.fromString("7.1.0");
+    }
 }
index e14fabe567d00202f0cd8a648e61be0b5abda727..2df638582c508b8a4068e50c647e2e9a321f9440 100644 (file)
@@ -40,7 +40,7 @@ public class IpfixTestCases extends OpenVswitchSchemaTestBase {
     Logger logger = LoggerFactory.getLogger(IpfixTestCases.class);
     Version schemaVersion;
     Version ipfixFromVersion = Version.fromString("7.1.0");
-
+    Version ipfixCacheFromVersion = Version.fromString("7.3.0");
 
     @Before
     public void setUp() throws ExecutionException, InterruptedException, TimeoutException, IOException {
@@ -65,7 +65,6 @@ public class IpfixTestCases extends OpenVswitchSchemaTestBase {
     public void testCreateTypedIpFix() throws InterruptedException, ExecutionException, IllegalArgumentException{
         // Don't run this test if the table is not supported
         Assume.assumeTrue(schemaVersion.compareTo(ipfixFromVersion) >= 0);
-
         String ipfixUuidStr = "testIpfix";
         String ipfixTarget = "172.16.20.1:4739";
         Integer obsDomainId = 112;
@@ -78,21 +77,17 @@ public class IpfixTestCases extends OpenVswitchSchemaTestBase {
         ipfix.setTargets(ImmutableSet.of(ipfixTarget));
         ipfix.setObsDomainId(ImmutableSet.of(obsDomainId));
         ipfix.setObsPointId(ImmutableSet.of(obsPointId));
-        ipfix.setCacheMaxFlows(ImmutableSet.of(cacheMax));
-        ipfix.setCacheActiveTimeout(ImmutableSet.of(cacheTimeout));
+        // Only set these rows if the schema version supports it
+        if (schemaVersion.compareTo(ipfixCacheFromVersion) >= 0) {
+            ipfix.setCacheMaxFlows(ImmutableSet.of(cacheMax));
+            ipfix.setCacheActiveTimeout(ImmutableSet.of(cacheTimeout));
+        }
         ipfix.setSampling(ImmutableSet.of(sampling));
         ipfix.setExternalIds(ImmutableMap.of("<3", "ovs"));
         Bridge bridge = ovs.getTypedRowWrapper(Bridge.class, null);
         TransactionBuilder transactionBuilder = ovs.transactBuilder()
-                .add(op.insert(ipfix.getSchema())
-                        .withId(ipfixUuidStr)
-                        .value(ipfix.getTargetsColumn())
-                        .value(ipfix.getObsDomainIdColumn())
-                        .value(ipfix.getObsPointIdColumn())
-                        .value(ipfix.getCacheMaxFlowsColumn())
-                        .value(ipfix.getCacheActiveTimeoutColumn())
-                        .value(ipfix.getSamplingColumn())
-                        .value(ipfix.getExternalIdsColumn()))
+                .add(op.insert(ipfix)
+                        .withId(ipfixUuidStr))
                 .add(op.mutate(bridge.getSchema())
                         .addMutation(bridge.getIpfixColumn().getSchema(), Mutator.INSERT,
                                 Sets.newHashSet(new UUID(ipfixUuidStr)))
index 439e53a7af2e8bb0e693d01b13c094e14bc7785d..5b074f7459f257fb23dbca6faf617ba8ac0429c5 100644 (file)
@@ -16,7 +16,9 @@ import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.ovsdb.lib.message.UpdateNotification;
 import org.opendaylight.ovsdb.lib.notation.Mutator;
+import org.opendaylight.ovsdb.lib.notation.Version;
 import org.opendaylight.ovsdb.lib.operations.OperationResult;
+import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
 
 import java.io.IOException;
 import java.util.List;
@@ -27,29 +29,37 @@ import static org.opendaylight.ovsdb.lib.operations.Operations.op;
 
 public class TearDown extends OpenVswitchSchemaTestBase {
 
+    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 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())
+        TransactionBuilder transactionBuilder = this.ovs.transactBuilder();
+
+        if (schemaVersion.compareTo(flowSampleCollectorSetFromVersion) >= 0) {
+            FlowSampleCollectorSet flowSampleCollectorSet = this.ovs.getTypedRowWrapper(FlowSampleCollectorSet.class, null);
+            transactionBuilder.add(op.delete(flowSampleCollectorSet.getSchema())
+                    .where(flowSampleCollectorSet.getBridgeColumn().getSchema().opEqual(OpenVswitchSchemaSuiteIT.getTestBridgeUuid()))
+                    .build());
+        }
+        transactionBuilder.add(op.delete(bridge.getSchema())
+                .where(bridge.getNameColumn().getSchema().opEqual(TEST_BRIDGE_NAME))
+                .build())
                 .add(op.mutate(openVSwitch.getSchema())
                         .addMutation(openVSwitch.getBridgesColumn().getSchema(), Mutator.DELETE, Sets.newHashSet(OpenVswitchSchemaSuiteIT.getTestBridgeUuid())))
                 .add(op.commit(true))
                 .execute();
 
+        ListenableFuture<List<OperationResult>> results = transactionBuilder.execute();
         List<OperationResult> operationResults = results.get();
         System.out.println("Delete operation results = " + operationResults);
         // tableCache = new HashMap<String, Map<UUID, Row>>();