You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ra...@apache.org on 2010/05/06 23:17:22 UTC
svn commit: r941934 - in /qpid/trunk/qpid/java:
systests/src/main/java/org/apache/qpid/test/unit/client/
systests/src/main/java/org/apache/qpid/test/utils/ test-profiles/
Author: rajith
Date: Thu May 6 21:17:21 2010
New Revision: 941934
URL: http://svn.apache.org/viewvc?rev=941934&view=rev
Log:
Modified the testHeartbeat method to use an external script to start & stop the broker.
Added:
qpid/trunk/qpid/java/test-profiles/start-broker (with props)
Modified:
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
qpid/trunk/qpid/java/test-profiles/default.testprofile
qpid/trunk/qpid/java/test-profiles/kill-broker
Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java?rev=941934&r1=941933&r2=941934&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java Thu May 6 21:17:21 2010
@@ -26,6 +26,7 @@ import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
+import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.jms.Connection;
@@ -294,11 +295,33 @@ public class AMQConnectionTest extends Q
Process process = null;
int port = getPort(0);
+ String pid = null;
try
{
+ // close the connection and shutdown the broker started by QpidTest
_connection.close();
- System.setProperty("qpid.heartbeat", "1");
- Connection con = getConnection();
+ stopBroker(port);
+
+ System.setProperty("qpid.heartbeat", "1");
+
+ // in case this broker gets stuck, atleast the rest of the tests will not fail.
+ port = port + 200;
+ String startCmd = getBrokerCommand(port);
+
+ // start a broker using a script
+ ProcessBuilder pb = new ProcessBuilder(System.getProperty("broker.start"));
+ pb.redirectErrorStream(true);
+
+ Map<String, String> env = pb.environment();
+ env.put("BROKER_CMD",startCmd);
+ env.put("BROKER_READY",System.getProperty(BROKER_READY));
+
+ Process startScript = pb.start();
+ startScript.waitFor();
+ startScript.destroy();
+
+ Connection con =
+ new AMQConnection("amqp://guest:guest@clientid/testpath?brokerlist='tcp://localhost:" + port + "'");
final AtomicBoolean lock = new AtomicBoolean(false);
String cmd = "/usr/bin/pgrep -f " + port;
@@ -306,7 +329,7 @@ public class AMQConnectionTest extends Q
LineNumberReader reader = new LineNumberReader(new InputStreamReader(process.getInputStream()));
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(process.getOutputStream())), true);
out.println(cmd);
- String pid = reader.readLine();
+ pid = reader.readLine();
try
{
Integer.parseInt(pid);
@@ -351,18 +374,15 @@ public class AMQConnectionTest extends Q
finally
{
System.setProperty("qpid.heartbeat", "");
+
if (process != null)
{
process.destroy();
}
- Runtime.getRuntime().exec(System.getProperty("broker.kill"));
-
- Process brokerProcess = _brokers.remove(port);
- if (process != null)
- {
- brokerProcess.destroy();
- }
+ Process killScript = Runtime.getRuntime().exec(System.getProperty("broker.kill") + " " + pid);
+ killScript.waitFor();
+ killScript.destroy();
cleanBroker();
}
}
Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java?rev=941934&r1=941933&r2=941934&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java Thu May 6 21:17:21 2010
@@ -469,7 +469,7 @@ public class QpidTestCase extends TestCa
}
}
- private String getBrokerCommand(int port) throws MalformedURLException
+ protected String getBrokerCommand(int port) throws MalformedURLException
{
return _broker
.replace("@PORT", "" + port)
Modified: qpid/trunk/qpid/java/test-profiles/default.testprofile
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/test-profiles/default.testprofile?rev=941934&r1=941933&r2=941934&view=diff
==============================================================================
--- qpid/trunk/qpid/java/test-profiles/default.testprofile (original)
+++ qpid/trunk/qpid/java/test-profiles/default.testprofile Thu May 6 21:17:21 2010
@@ -6,6 +6,8 @@ broker=vm
broker.clean=${test.profiles}/clean-dir ${build.data} ${project.root}/build/work/derbyDB
broker.ready=Listening on TCP port
broker.config=${project.root}/build/etc/config-systests.xml
+broker.start=${test.profiles}/start-broker
+broker.kill=${test.profiles}/kill-broker
max_prefetch=1000
qpid.dest_syntax=BURL
Modified: qpid/trunk/qpid/java/test-profiles/kill-broker
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/test-profiles/kill-broker?rev=941934&r1=941933&r2=941934&view=diff
==============================================================================
--- qpid/trunk/qpid/java/test-profiles/kill-broker (original)
+++ qpid/trunk/qpid/java/test-profiles/kill-broker Thu May 6 21:17:21 2010
@@ -21,5 +21,6 @@
#
#
-
+kill -CONT $1
kill -9 $1
+rm /tmp/broker.log
Added: qpid/trunk/qpid/java/test-profiles/start-broker
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/test-profiles/start-broker?rev=941934&view=auto
==============================================================================
--- qpid/trunk/qpid/java/test-profiles/start-broker (added)
+++ qpid/trunk/qpid/java/test-profiles/start-broker Thu May 6 21:17:21 2010
@@ -0,0 +1,30 @@
+
+#!/bin/bash
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+
+# The entire broker command is passed as an argument.
+
+waitfor() { until grep -a -l "$2" $1 >/dev/null 2>&1 ; do sleep 1 ; done ; }
+
+sh $BROKER_CMD --log-to-file /tmp/broker.log &
+waitfor /tmp/broker.log $BROKER_READY
+
Propchange: qpid/trunk/qpid/java/test-profiles/start-broker
------------------------------------------------------------------------------
svn:executable = *
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org