X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=integrationtest%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fovsdb%2Fintegrationtest%2FOvsdbIntegrationTestBase.java;h=9a921cf56b4125926a33f07e9eea3bb4d840c65d;hb=0cd969cbef1ede69d6461d2fde58ad2af272989a;hp=76f7647916d65f538e3ca856b54971c80e16f9fd;hpb=da199f68ebdebb8d99f034243a073245a03fb24a;p=ovsdb.git diff --git a/integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/OvsdbIntegrationTestBase.java b/integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/OvsdbIntegrationTestBase.java index 76f764791..9a921cf56 100644 --- a/integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/OvsdbIntegrationTestBase.java +++ b/integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/OvsdbIntegrationTestBase.java @@ -10,10 +10,15 @@ package org.opendaylight.ovsdb.integrationtest; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.IOException; import java.net.InetAddress; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.Properties; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; @@ -23,10 +28,13 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.opendaylight.controller.sal.connection.ConnectionConstants; +import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.utils.ServiceHelper; import org.opendaylight.ovsdb.lib.OvsdbClient; import org.opendaylight.ovsdb.lib.OvsdbConnection; import org.opendaylight.ovsdb.lib.OvsdbConnectionListener; +import org.opendaylight.ovsdb.plugin.IConnectionServiceInternal; public abstract class OvsdbIntegrationTestBase { protected final static String IDENTIFIER = "TEST"; @@ -49,6 +57,35 @@ public abstract class OvsdbIntegrationTestBase { return props; } + public Node getPluginTestConnection() throws IOException, InterruptedException, ExecutionException, TimeoutException { + Properties props = loadProperties(); + String addressStr = props.getProperty(SERVER_IPADDRESS); + String portStr = props.getProperty(SERVER_PORT, DEFAULT_SERVER_PORT); + String connectionType = props.getProperty(CONNECTION_TYPE, "active"); + + IConnectionServiceInternal connection = (IConnectionServiceInternal)ServiceHelper.getGlobalInstance(IConnectionServiceInternal.class, this); + // If the connection type is active, controller connects to the ovsdb-server + if (connectionType.equalsIgnoreCase(CONNECTION_TYPE_ACTIVE)) { + if (addressStr == null) { + fail(usage()); + } + + Map params = new HashMap(); + params.put(ConnectionConstants.ADDRESS, addressStr); + params.put(ConnectionConstants.PORT, portStr); + return connection.connect(IDENTIFIER, params); + } else if (connectionType.equalsIgnoreCase(CONNECTION_TYPE_PASSIVE)) { + // Wait for 10 seconds for the Passive connection to be initiated by the ovsdb-server. + Thread.sleep(10000); + List nodes = connection.getNodes(); + assertNotNull(nodes); + assertTrue(nodes.size() > 0); + return nodes.get(0); + } + fail("Connection parameter ("+CONNECTION_TYPE+") must be active or passive"); + return null; + } + public OvsdbClient getTestConnection() throws IOException, InterruptedException, ExecutionException, TimeoutException { Properties props = loadProperties(); String addressStr = props.getProperty(SERVER_IPADDRESS);