Though it is an harmless constant string, it goes against the motivation of the library redesign to be
schema independent. Hence moving the schema string to a more appropriate place (to the applications),
in this case, to the Integration Test files.
Also, modified the initialize functionality to include a test to check for the list_dbs to contain Open_vSwitch
schema as all the tests in this file are based on Open_vSwitch schema tables.
Change-Id: I3210abf1fa18b5707a27b719f7d481b5de76d6be
Signed-off-by: Madhu Venugopal <mavenugo@gmail.com>
package org.opendaylight.ovsdb.lib;
-import com.google.common.util.concurrent.ListenableFuture;
+import java.util.List;
+
import org.opendaylight.ovsdb.lib.message.MonitorRequest;
import org.opendaylight.ovsdb.lib.operations.Operation;
import org.opendaylight.ovsdb.lib.operations.OperationResult;
import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
import org.opendaylight.ovsdb.lib.schema.TableSchema;
-import java.util.List;
+import com.google.common.util.concurrent.ListenableFuture;
/**
* The main interface to interact with a device speaking ovsdb protocol in an asynchronous fashion and hence most
*/
public interface OvsDBClient {
- /**
- * Represents the Open Vswitch Schema
- */
- String OPEN_VSWITCH_SCHEMA = "Open_vSwitch";
-
/**
* Gets the list of database names exposed by this ovsdb capable device
* @return list of database names
@Test
public void testTransact() throws IOException, InterruptedException, ExecutionException {
- ListenableFuture<DatabaseSchema> schema = ovs.getSchema(OvsDBClient.OPEN_VSWITCH_SCHEMA, true);
+ ListenableFuture<DatabaseSchema> schema = ovs.getSchema(OPEN_VSWITCH_SCHEMA, true);
TableSchema<GenericTableSchema> bridge = schema.get().table("Bridge", GenericTableSchema.class);
for (Map.Entry<String, ColumnSchema> names : bridge.getColumnSchemas().entrySet()) {
@Test
public void testMonitorRequest() throws ExecutionException, InterruptedException {
- DatabaseSchema dbSchema = ovs.getSchema(OvsDBClient.OPEN_VSWITCH_SCHEMA, true).get();
+ DatabaseSchema dbSchema = ovs.getSchema(OPEN_VSWITCH_SCHEMA, true).get();
GenericTableSchema bridge = dbSchema.table("Bridge", GenericTableSchema.class);
List<MonitorRequest<GenericTableSchema>> monitorRequests = Lists.newArrayList();
Assert.assertNotNull(bridgeUpdate);
}
- @Test
public void testGetDBs() throws ExecutionException, InterruptedException {
ListenableFuture<List<String>> databases = ovs.getDatabases();
List<String> dbNames = databases.get();
Assert.assertNotNull(dbNames);
- Assert.assertTrue(dbNames.size() > 0);
+ boolean hasOpenVswitchSchema = false;
+ for(String dbName : dbNames) {
+ if (dbName.equals(OPEN_VSWITCH_SCHEMA)) {
+ hasOpenVswitchSchema = true;
+ break;
+ }
+ }
+ Assert.assertTrue(OPEN_VSWITCH_SCHEMA+" schema is not supported by the switch", hasOpenVswitchSchema);
}
@Before
- public void initalize() throws IOException {
+ public void initalize() throws IOException, ExecutionException, InterruptedException {
if (ovs != null) {
return;
}
}
ExecutorService executorService = Executors.newFixedThreadPool(3);
ovs = new OvsDBClientImpl(rpc, executorService);
+ testGetDBs();
}
public void test() throws IOException, InterruptedException, ExecutionException {
OvsDBClientImpl ovs = getVswitch();
- Bridge bridge = ovs.getSchema(OvsDBClient.OPEN_VSWITCH_SCHEMA, true).get().table("Bridge", Bridge.class);
+ Bridge bridge = ovs.getSchema(OPEN_VSWITCH_SCHEMA, true).get().table("Bridge", Bridge.class);
ListenableFuture<List<OperationResult>> results = ovs.transactBuilder()
.add(op.insert(bridge).value(bridge.name(), "br-int"))
private final static String SERVER_PORT = "ovsdbserver.port";
private final static String DEFAULT_SERVER_PORT = "6640";
+ /**
+ * Represents the Open Vswitch Schema
+ */
+ public final static String OPEN_VSWITCH_SCHEMA = "Open_vSwitch";
+
public Properties loadProperties() {
Properties props = new Properties(System.getProperties());
return props;
*/
package org.opendaylight.ovsdb.lib.schema.temp;
-import org.opendaylight.ovsdb.lib.OvsDBClient;
+import java.util.concurrent.ExecutionException;
+
import org.opendaylight.ovsdb.lib.OvsDBClientImpl;
-import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
+import org.opendaylight.ovsdb.lib.OvsdbTestBase;
import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
+import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
import org.opendaylight.ovsdb.lib.schema.TableSchema;
-import java.util.concurrent.ExecutionException;
-
public class SchemaObjs {
-
public static class Bridge extends TableSchema<Bridge> {
public static String NAME = "Bridge";
TableSchema target;
public static void main(String[] args) throws ExecutionException, InterruptedException {
OvsDBClientImpl ovs = new OvsDBClientImpl(null, null);
- DatabaseSchema db = ovs.getSchema(OvsDBClient.OPEN_VSWITCH_SCHEMA, true).get();
+ DatabaseSchema db = ovs.getSchema(OvsdbTestBase.OPEN_VSWITCH_SCHEMA, true).get();
Bridge bridge = db.table(Bridge.NAME, Bridge.class);
Port port = db.table(Port.NAME, Port.class);