* 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;
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);
}
--- /dev/null
+/*
+ * 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) {
+
+ }
+}
NetflowTestCases.class,
SflowTestCases.class,
IpfixTestCases.class,
+ FlowSampleCollectorSetTestCases.class,
TearDown.class
})
public class OpenVswitchSchemaSuiteIT {
@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())