You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by my...@apache.org on 2009/09/15 01:08:48 UTC
svn commit: r814906 -
/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
Author: myrnavl
Date: Mon Sep 14 23:08:48 2009
New Revision: 814906
URL: http://svn.apache.org/viewvc?rev=814906&view=rev
Log:
DERBY-4347 - Provide a property to increase network server start timeout for JUnit tests
Introduces the optional property 'derby.tests.networkServerStartTimeout'.
backport of fix from trunk. merge command:
merge -c 814815 https://svn.apache.org/repos/asf/db/derby/code/trunk
Modified:
db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java?rev=814906&r1=814905&r2=814906&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java (original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java Mon Sep 14 23:08:48 2009
@@ -41,13 +41,17 @@
*/
final public class NetworkServerTestSetup extends BaseTestSetup {
- /** Setting maximum wait time to 40 seconds. On some platforms
+ /** Setting maximum wait time to 40 seconds by default. On some platforms
* it may take this long to start the server. Increasing the wait
* time should not adversely affect those
* systems with fast port turnaround as the actual code loops for
* SLEEP_TIME intervals, so should never see WAIT_TIME.
+ * For even slower systems (or for faster systems) the default value can
+ * be overwritten using the property derby.tests.networkServerStartTimeout
+ * (which is in seconds, rather than milliseconds)
*/
- private static final long WAIT_TIME = 40000;
+ private static final long DEFAULT_WAIT_TIME = 40000;
+ private static final long WAIT_TIME = getWaitTime();
/** Sleep for 500 ms before pinging the network server (again) */
private static final int SLEEP_TIME = 100;
@@ -629,4 +633,32 @@
{
return pingForServerUp(control, null, true);
}
+
+ /*
+ * set the period before network server times out on start up based on the
+ * value passed in with property derby.tests.networkServerStartTimeout
+ * in seconds, or use the default
+ * for example: with DEFAULT_WAIT_TIME set to 40000, i.e. 40 seconds,
+ * setting the property like so:
+ * -Dderby.tests.networkServerStartTimeout=60
+ * would extend the timeout to 1 minute.
+ * If an invalid value is passed in (eg. 'abc') the calling test will fail
+ */
+ public static long getWaitTime() {
+ long waitTime = DEFAULT_WAIT_TIME;
+ String waitString = BaseTestCase.getSystemProperty(
+ "derby.tests.networkServerStartTimeout");
+ if (waitString != null && waitString.length() != 0)
+ {
+ try {
+ waitTime = (Long.parseLong(waitString)*1000);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("trouble setting WAIT_TIME from passed in property " +
+ "derby.tests.networkServerStartTimeout");
+ }
+ }
+ return waitTime;
+ }
+
}