From: <tho...@us...> - 2011-01-18 17:37:07
|
Revision: 4122 http://bigdata.svn.sourceforge.net/bigdata/?rev=4122&view=rev Author: thompsonbry Date: 2011-01-18 17:36:58 +0000 (Tue, 18 Jan 2011) Log Message: ----------- Working on removing zookeeper start/stop from the individual unit tests. It will now be started/stopped once per CI run by the top-level ant build. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/jini/start/AbstractFedZooTestCase.java branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/jini/start/testfed.config branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/service/jini/util/JiniServicesHelper.java branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/zookeeper/AbstractZooTestCase.java branches/QUADS_QUERY_BRANCH/build.properties branches/QUADS_QUERY_BRANCH/build.xml Modified: branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/jini/start/AbstractFedZooTestCase.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/jini/start/AbstractFedZooTestCase.java 2011-01-18 15:30:00 UTC (rev 4121) +++ branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/jini/start/AbstractFedZooTestCase.java 2011-01-18 17:36:58 UTC (rev 4122) @@ -28,6 +28,7 @@ package com.bigdata.jini.start; import java.io.File; +import java.net.InetAddress; import java.util.List; import java.util.UUID; @@ -35,18 +36,17 @@ import net.jini.config.Configuration; import net.jini.config.ConfigurationProvider; -import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.ZooKeeper; -import org.apache.zookeeper.KeeperException.NodeExistsException; import org.apache.zookeeper.ZooDefs.Ids; import org.apache.zookeeper.data.ACL; import com.bigdata.jini.start.config.ZookeeperClientConfig; import com.bigdata.jini.start.process.ProcessHelper; -import com.bigdata.jini.start.process.ZookeeperProcessHelper; import com.bigdata.resources.ResourceFileFilter; import com.bigdata.service.jini.JiniClient; import com.bigdata.service.jini.JiniFederation; +import com.bigdata.util.config.NicUtil; +import com.bigdata.zookeeper.ZooHelper; /** * Abstract base class for unit tests requiring a running zookeeper and a @@ -122,9 +122,24 @@ config = ConfigurationProvider.getInstance(args); - // if necessary, start zookeeper (a server instance). - ZookeeperProcessHelper.startZookeeper(config, listener); +// // if necessary, start zookeeper (a server instance). +// ZookeeperProcessHelper.startZookeeper(config, listener); + final int clientPort = Integer.valueOf(System + .getProperty("test.zookeeper.clientPort","2181")); + + // Verify zookeeper is running on the local host at the client port. + { + final InetAddress localIpAddr = NicUtil.getInetAddress(null, 0, + null, true); + try { + ZooHelper.ruok(localIpAddr, clientPort); + } catch (Throwable t) { + fail("Zookeeper not running:: " + localIpAddr + ":" + + clientPort, t); + } + } + /* * FIXME We need to start a jini lookup service for groups = {fedname} * for this test to succeed. Modified: branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/jini/start/testfed.config =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/jini/start/testfed.config 2011-01-18 15:30:00 UTC (rev 4121) +++ branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/jini/start/testfed.config 2011-01-18 17:36:58 UTC (rev 4122) @@ -39,11 +39,10 @@ /** * Zookeeper server configuration. - */ + * org.apache.zookeeper.server.quorum.QuorumPeerMain { - /* Directory for zookeeper's persistent state. - */ + // Directory for zookeeper's persistent state. dataDir = new File(bigdata.fedname+"/zookeeper"); // required. @@ -60,19 +59,14 @@ //classpath = new String[] { "${zookeeper.jar}", "${log4j.jar}" }; - /* Optional command line arguments for the JVM used to execute - * zookeeper. - * - * Note: swapping for zookeeper is especially bad since the - * operations are serialized, so if anything hits then disk then - * all operations in the queue will have that latency as well. - */ + // Optional command line arguments for the JVM used to execute //args=new String[]{"-Xmx2G"}; // zookeeper server logging configuration (value is a URI!) log4j = bigdata.log4j; } +*/ /* * Service configuration defaults. These can also be specified on a @@ -127,15 +121,14 @@ */ org.apache.zookeeper.ZooKeeper { - /* Root znode for the federation instance. */ + // Root znode for the federation instance. zroot = "/test/"+bigdata.fedname; - /* A comma separated list of host:port pairs, where the port is - * the CLIENT port for the zookeeper server instance. - */ + // A comma separated list of host:port pairs, where the port is + // the CLIENT port for the zookeeper server instance. servers="localhost:2181"; - /* Session timeout (optional). */ + // Session timeout (optional). //sessionTimeout=xxxx; } Modified: branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/service/jini/util/JiniServicesHelper.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/service/jini/util/JiniServicesHelper.java 2011-01-18 15:30:00 UTC (rev 4121) +++ branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/service/jini/util/JiniServicesHelper.java 2011-01-18 17:36:58 UTC (rev 4122) @@ -10,6 +10,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.BindException; +import java.net.InetAddress; import java.net.ServerSocket; import java.util.Arrays; import java.util.Queue; @@ -32,7 +33,6 @@ import com.bigdata.jini.start.config.ZookeeperClientConfig; import com.bigdata.jini.start.config.ZookeeperServerConfiguration; import com.bigdata.jini.start.process.ProcessHelper; -import com.bigdata.jini.start.process.ZookeeperProcessHelper; import com.bigdata.jini.util.ConfigMath; import com.bigdata.jini.util.JiniUtil; import com.bigdata.resources.ResourceFileFilter; @@ -47,6 +47,7 @@ import com.bigdata.service.jini.MetadataServer; import com.bigdata.service.jini.TransactionServer; import com.bigdata.util.concurrent.DaemonThreadFactory; +import com.bigdata.util.config.NicUtil; import com.bigdata.zookeeper.ZooHelper; /** @@ -267,10 +268,10 @@ */ private int clientPort; - /** - * The directory in which zookeeper is running. - */ - private File zooDataDir; +// /** +// * The directory in which zookeeper is running. +// */ +// private File zooDataDir; /** * Starts all services and connects the {@link JiniClient} to the @@ -374,43 +375,46 @@ final String[] options; { - // the zookeeper service directory. - zooDataDir = new File(fedServiceDir, "zookeeper"); - - if(zooDataDir.exists()) { - - // clear out old zookeeper state first. - recursiveDelete(zooDataDir); - - } - - // create. - zooDataDir.mkdirs(); +// // the zookeeper service directory. +// zooDataDir = new File(fedServiceDir, "zookeeper"); +// +// if(zooDataDir.exists()) { +// +// // clear out old zookeeper state first. +// recursiveDelete(zooDataDir); +// +// } +// +// // create. +// zooDataDir.mkdirs(); - try { +// try { - // find ports that are not in use. - clientPort = getPort(2181/* suggestedPort */); - final int peerPort = getPort(2888/* suggestedPort */); - final int leaderPort = getPort(3888/* suggestedPort */); - final String servers = "1=localhost:" + peerPort + ":" - + leaderPort; +// // find ports that are not in use. +// clientPort = getPort(2181/* suggestedPort */); +// final int peerPort = getPort(2888/* suggestedPort */); +// final int leaderPort = getPort(3888/* suggestedPort */); +// final String servers = "1=localhost:" + peerPort + ":" +// + leaderPort; + clientPort = Integer.valueOf(System + .getProperty("test.zookeeper.clientPort","2181")); + options = new String[] { // overrides the clientPort to be unique. QuorumPeerMain.class.getName() + "." + ZookeeperServerConfiguration.Options.CLIENT_PORT + "=" + clientPort, - // overrides servers declaration. - QuorumPeerMain.class.getName() + "." - + ZookeeperServerConfiguration.Options.SERVERS - + "=\"" + servers + "\"", - // overrides the dataDir - QuorumPeerMain.class.getName() + "." - + ZookeeperServerConfiguration.Options.DATA_DIR - + "=new java.io.File(" - + ConfigMath.q(zooDataDir.toString()) + ")"// +// // overrides servers declaration. +// QuorumPeerMain.class.getName() + "." +// + ZookeeperServerConfiguration.Options.SERVERS +// + "=\"" + servers + "\"", +// // overrides the dataDir +// QuorumPeerMain.class.getName() + "." +// + ZookeeperServerConfiguration.Options.DATA_DIR +// + "=new java.io.File(" +// + ConfigMath.q(zooDataDir.toString()) + ")"// }; System.err.println("options=" + Arrays.toString(options)); @@ -418,27 +422,39 @@ final Configuration config = ConfigurationProvider .getInstance(concat(args, options)); - // start zookeeper (a server instance). - final int nstarted = ZookeeperProcessHelper.startZookeeper( - config, serviceListener); +// // start zookeeper (a server instance). +// final int nstarted = ZookeeperProcessHelper.startZookeeper( +// config, serviceListener); +// +// if (nstarted != 1) { +// +// throw new RuntimeException( +// "Expected to start one zookeeper instance, not " +// + nstarted); +// +// } - if (nstarted != 1) { - - throw new RuntimeException( - "Expected to start one zookeeper instance, not " - + nstarted); - + // Verify zookeeper is running on the local host at the client port. + { + final InetAddress localIpAddr = NicUtil.getInetAddress(null, 0, + null, true); + try { + ZooHelper.ruok(localIpAddr, clientPort); + } catch (Throwable t) { + throw new RuntimeException("Zookeeper not running:: " + + localIpAddr + ":" + clientPort, t); + } } - } catch (Throwable t) { +// } catch (Throwable t) { +// +// // don't leave around the dataDir if the setup fails. +// recursiveDelete(zooDataDir); +// +// throw new RuntimeException(t); +// +// } - // don't leave around the dataDir if the setup fails. - recursiveDelete(zooDataDir); - - throw new RuntimeException(t); - - } - } /* @@ -679,30 +695,30 @@ } - try { - - ZooHelper.kill(clientPort); - - } catch (Throwable t) { - log.error("Could not kill zookeeper: clientPort=" + clientPort - + " : " + t, t); - } - - if (zooDataDir != null && zooDataDir.exists()) { - - /* - * Wait a bit and then try and delete the zookeeper directory. - */ - - try { - Thread.sleep(250); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - - recursiveDelete(zooDataDir); - - } +// try { +// +// ZooHelper.kill(clientPort); +// +// } catch (Throwable t) { +// log.error("Could not kill zookeeper: clientPort=" + clientPort +// + " : " + t, t); +// } +// +// if (zooDataDir != null && zooDataDir.exists()) { +// +// /* +// * Wait a bit and then try and delete the zookeeper directory. +// */ +// +// try { +// Thread.sleep(250); +// } catch (InterruptedException e) { +// throw new RuntimeException(e); +// } +// +// recursiveDelete(zooDataDir); +// +// } // // Stop the lookup service. // new Thread(new Runnable() { Modified: branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/zookeeper/AbstractZooTestCase.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/zookeeper/AbstractZooTestCase.java 2011-01-18 15:30:00 UTC (rev 4121) +++ branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/zookeeper/AbstractZooTestCase.java 2011-01-18 17:36:58 UTC (rev 4122) @@ -32,6 +32,7 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.net.BindException; +import java.net.InetAddress; import java.net.ServerSocket; import java.util.Arrays; import java.util.List; @@ -60,6 +61,7 @@ import com.bigdata.jini.start.process.ZookeeperProcessHelper; import com.bigdata.jini.util.ConfigMath; import com.bigdata.resources.ResourceFileFilter; +import com.bigdata.util.config.NicUtil; /** * Abstract base class for zookeeper integration tests. @@ -145,7 +147,7 @@ protected final MockListener listener = new MockListener(); - private File dataDir = null; +// private File dataDir = null; // the chosen client port. int clientPort = -1; @@ -157,53 +159,71 @@ if (log.isInfoEnabled()) log.info(getName()); - // find ports that are not in use. - clientPort = getPort(2181/* suggestedPort */); - final int peerPort = getPort(2888/* suggestedPort */); - final int leaderPort = getPort(3888/* suggestedPort */); - final String servers = "1=localhost:" + peerPort + ":" + leaderPort; +// // find ports that are not in use. +// clientPort = getPort(2181/* suggestedPort */); +// final int peerPort = getPort(2888/* suggestedPort */); +// final int leaderPort = getPort(3888/* suggestedPort */); +// final String servers = "1=localhost:" + peerPort + ":" + leaderPort; +// +//// // create a temporary file for zookeeper's state. +//// dataDir = File.createTempFile("test", ".zoo"); +//// // delete the file so that it can be re-created as a directory. +//// dataDir.delete(); +//// // recreate the file as a directory. +//// dataDir.mkdirs(); +// +// final String[] args = new String[] { +// // The configuration file (overrides follow). +// configFile, +// // overrides the clientPort to be unique. +// QuorumPeerMain.class.getName() + "." +// + ZookeeperServerConfiguration.Options.CLIENT_PORT + "=" +// + clientPort, +// // overrides servers declaration. +// QuorumPeerMain.class.getName() + "." +// + ZookeeperServerConfiguration.Options.SERVERS + "=\"" +// + servers + "\"", +//// // overrides the dataDir +//// QuorumPeerMain.class.getName() + "." +//// + ZookeeperServerConfiguration.Options.DATA_DIR +//// + "=new java.io.File(" +//// + ConfigMath.q(dataDir.toString()) + ")"// +// }; +// +// System.err.println("args=" + Arrays.toString(args)); +// +// final Configuration config = ConfigurationProvider.getInstance(args); + +// final int tickTime = (Integer) config.getEntry(QuorumPeerMain.class +// .getName(), ZookeeperServerConfiguration.Options.TICK_TIME, +// Integer.TYPE); - // create a temporary file for zookeeper's state. - dataDir = File.createTempFile("test", ".zoo"); - // delete the file so that it can be re-created as a directory. - dataDir.delete(); - // recreate the file as a directory. - dataDir.mkdirs(); + final int tickTime = Integer.valueOf(System + .getProperty("test.zookeeper.tickTime","2000")); - final String[] args = new String[] { - // The configuration file (overrides follow). - configFile, - // overrides the clientPort to be unique. - QuorumPeerMain.class.getName() + "." - + ZookeeperServerConfiguration.Options.CLIENT_PORT + "=" - + clientPort, - // overrides servers declaration. - QuorumPeerMain.class.getName() + "." - + ZookeeperServerConfiguration.Options.SERVERS + "=\"" - + servers + "\"", - // overrides the dataDir - QuorumPeerMain.class.getName() + "." - + ZookeeperServerConfiguration.Options.DATA_DIR - + "=new java.io.File(" - + ConfigMath.q(dataDir.toString()) + ")"// - }; - - System.err.println("args=" + Arrays.toString(args)); + clientPort = Integer.valueOf(System.getProperty( + "test.zookeeper.clientPort", "2181")); - final Configuration config = ConfigurationProvider.getInstance(args); - - final int tickTime = (Integer) config.getEntry(QuorumPeerMain.class - .getName(), ZookeeperServerConfiguration.Options.TICK_TIME, - Integer.TYPE); - /* - * Note: This is the actual session timeout that the zookeeper service - * will impose on the client. + * Note: This MUST be the actual session timeout that the zookeeper + * service will impose on the client. Some unit tests depend on this. */ this.sessionTimeout = tickTime * 2; - // if necessary, start zookeeper (a server instance). - ZookeeperProcessHelper.startZookeeper(config, listener); + // Verify zookeeper is running on the local host at the client port. + { + final InetAddress localIpAddr = NicUtil.getInetAddress(null, 0, + null, true); + try { + ZooHelper.ruok(localIpAddr, clientPort); + } catch (Throwable t) { + fail("Zookeeper not running:: " + localIpAddr + ":" + + clientPort, t); + } + } + +// // if necessary, start zookeeper (a server instance). +// ZookeeperProcessHelper.startZookeeper(config, listener); zookeeperAccessor = new ZooKeeperAccessor("localhost:" + clientPort, sessionTimeout); @@ -227,8 +247,8 @@ } catch (Throwable t) { - // don't leave around the dataDir if the setup fails. - recursiveDelete(dataDir); +// // don't leave around the dataDir if the setup fails. +// recursiveDelete(dataDir); throw new Exception(t); @@ -256,13 +276,13 @@ } - if (dataDir != null) { +// if (dataDir != null) { +// +// // clean out the zookeeper data dir. +// recursiveDelete(dataDir); +// +// } - // clean out the zookeeper data dir. - recursiveDelete(dataDir); - - } - } catch (Throwable t) { log.error(t, t); @@ -527,48 +547,48 @@ } - /** - * Recursively removes any files and subdirectories and then removes the - * file (or directory) itself. - * <p> - * Note: Files that are not recognized will be logged by the - * {@link ResourceFileFilter}. - * - * @param f - * A file or directory. - */ - private void recursiveDelete(final File f) { +// /** +// * Recursively removes any files and subdirectories and then removes the +// * file (or directory) itself. +// * <p> +// * Note: Files that are not recognized will be logged by the +// * {@link ResourceFileFilter}. +// * +// * @param f +// * A file or directory. +// */ +// private void recursiveDelete(final File f) { +// +// if (f.isDirectory()) { +// +// final File[] children = f.listFiles(); +// +// if (children == null) { +// +// // The directory does not exist. +// return; +// +// } +// +// for (int i = 0; i < children.length; i++) { +// +// recursiveDelete(children[i]); +// +// } +// +// } +// +// if(log.isInfoEnabled()) +// log.info("Removing: " + f); +// +// if (f.exists() && !f.delete()) { +// +// log.warn("Could not remove: " + f); +// +// } +// +// } - if (f.isDirectory()) { - - final File[] children = f.listFiles(); - - if (children == null) { - - // The directory does not exist. - return; - - } - - for (int i = 0; i < children.length; i++) { - - recursiveDelete(children[i]); - - } - - } - - if(log.isInfoEnabled()) - log.info("Removing: " + f); - - if (f.exists() && !f.delete()) { - - log.warn("Could not remove: " + f); - - } - - } - /** * Recursive delete of znodes. * Modified: branches/QUADS_QUERY_BRANCH/build.properties =================================================================== --- branches/QUADS_QUERY_BRANCH/build.properties 2011-01-18 15:30:00 UTC (rev 4121) +++ branches/QUADS_QUERY_BRANCH/build.properties 2011-01-18 17:36:58 UTC (rev 4122) @@ -377,6 +377,8 @@ # after the performance tests have run their course. perf.run.dir=/usr/bigdata/runs -# CI properties. +# CI properties. These must agree with the actual installation directory and zoo.cfg +# file for the zookeeper instance used to run CI. test.zookeeper.installDir=/Users/bryan/zookeeper-3.2.1 - +test.zookeeper.tickTime=2000 +test.zookeeper.clientPort=2888 Modified: branches/QUADS_QUERY_BRANCH/build.xml =================================================================== --- branches/QUADS_QUERY_BRANCH/build.xml 2011-01-18 15:30:00 UTC (rev 4121) +++ branches/QUADS_QUERY_BRANCH/build.xml 2011-01-18 17:36:58 UTC (rev 4122) @@ -1606,7 +1606,6 @@ <!-- be running on the localhost. --> <property name="test.zookeeper.tickTime" value="2000" /> <property name="test.zookeeper.clientPort" value="2888" /> - <property name="test.zookeeper.leaderPort" value="3888" /> <!-- The zookeeper install directory. --> <property name="test.zookeeper.installDir" value="${zookeeper.installDir}" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |