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 {
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;
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)))
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;
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>>();