From f498ff1157cf27543c66e7d8d6b1de1a5ceeed40 Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Fri, 27 Jun 2014 18:42:09 +0100 Subject: [PATCH] Fix bug in Ipfix table and TearDown IT code 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 --- .../ovsdb/lib/notation/VersionTest.java | 6 +++++ .../schema/openvswitch/IpfixTestCases.java | 21 ++++++--------- .../ovsdb/schema/openvswitch/TearDown.java | 26 +++++++++++++------ 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/library/src/test/java/org/opendaylight/ovsdb/lib/notation/VersionTest.java b/library/src/test/java/org/opendaylight/ovsdb/lib/notation/VersionTest.java index d87525407..f36744dfb 100644 --- a/library/src/test/java/org/opendaylight/ovsdb/lib/notation/VersionTest.java +++ b/library/src/test/java/org/opendaylight/ovsdb/lib/notation/VersionTest.java @@ -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"); + } } diff --git a/schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/IpfixTestCases.java b/schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/IpfixTestCases.java index e14fabe56..2df638582 100644 --- a/schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/IpfixTestCases.java +++ b/schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/IpfixTestCases.java @@ -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))) diff --git a/schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/TearDown.java b/schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/TearDown.java index 439e53a7a..5b074f745 100644 --- a/schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/TearDown.java +++ b/schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/TearDown.java @@ -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> 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> results = transactionBuilder.execute(); List operationResults = results.get(); System.out.println("Delete operation results = " + operationResults); // tableCache = new HashMap>(); -- 2.36.6