summaryrefslogtreecommitdiff
path: root/qpid/java/systests
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2010-08-09 20:28:57 +0000
committerRobert Gemmell <robbie@apache.org>2010-08-09 20:28:57 +0000
commit74a19608af74614575d1185b9dacc71bf1f00c41 (patch)
treec77e81a29520dd817fb2c33407c3706a68d4d10f /qpid/java/systests
parent02a8c58fbed023e020f7cbababe31c3f69ef845d (diff)
downloadqpid-python-74a19608af74614575d1185b9dacc71bf1f00c41.tar.gz
QPID-2775: use the JMX interface to reload the configuration synchronously, helping to avoid situations where the timeout is insufficient for the SIGHUP process to complete
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@983805 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/systests')
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java9
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java53
2 files changed, 27 insertions, 35 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java
index 35dd757330..f40e95885d 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java
@@ -205,7 +205,7 @@ public class FirewallConfigTest extends QpidBrokerTestCase
{
try
{
- reloadBroker();
+ reloadBrokerSecurityConfig();
} catch (Exception e)
{
fail(e.getMessage());
@@ -222,7 +222,7 @@ public class FirewallConfigTest extends QpidBrokerTestCase
{
try
{
- reloadBroker();
+ reloadBrokerSecurityConfig();
} catch (Exception e)
{
fail(e.getMessage());
@@ -240,7 +240,7 @@ public class FirewallConfigTest extends QpidBrokerTestCase
{
try
{
- reloadBroker();
+ reloadBrokerSecurityConfig();
} catch (Exception e)
{
fail(e.getMessage());
@@ -283,7 +283,8 @@ public class FirewallConfigTest extends QpidBrokerTestCase
return;
}
- writeFirewallFile(initial, inVhost);
+ writeFirewallFile(initial, inVhost);
+ setConfigurationProperty("management.enabled", String.valueOf(true));
super.setUp();
assertEquals("Initial connection check failed", initial, checkConnection());
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
index 41c24a453d..ae38a75e7a 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
@@ -17,10 +17,8 @@
*/
package org.apache.qpid.test.utils;
-import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
-import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -34,30 +32,27 @@ import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import javax.jms.BytesMessage;
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException;
+import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
import javax.jms.Queue;
import javax.jms.Session;
-import javax.jms.BytesMessage;
-import javax.jms.MapMessage;
-import javax.jms.TextMessage;
-import javax.jms.ObjectMessage;
import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import junit.framework.TestCase;
-import junit.framework.TestResult;
-
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
import org.apache.qpid.AMQException;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQConnectionFactory;
@@ -66,6 +61,7 @@ import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.jms.BrokerDetails;
import org.apache.qpid.jms.ConnectionURL;
+import org.apache.qpid.management.common.mbeans.ConfigurationManagement;
import org.apache.qpid.server.configuration.ServerConfiguration;
import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
@@ -1305,37 +1301,32 @@ public class QpidBrokerTestCase extends QpidTestCase
return null;
}
- public void reloadBroker() throws ConfigurationException, IOException
- {
- reloadBroker(0);
- }
-
- public void reloadBroker(int port) throws ConfigurationException, IOException
+ /**
+ * Reloads the broker security configuration using the ApplicationRegistry (InVM brokers) or the
+ * ConfigurationManagementMBean via the JMX interface (Standalone brokers, management must be
+ * enabled before calling the method).
+ */
+ public void reloadBrokerSecurityConfig() throws Exception
{
if (_broker.equals(VM))
{
ApplicationRegistry.getInstance().getConfiguration().reparseConfigFileSecuritySections();
}
- else // FIXME: should really use the JMX interface to do this
+ else
{
- /*
- * Sigh, this is going to get messy. grep for BRKR and the port number
- */
- String osName = System.getProperty("os.name");
- boolean osx = osName.equals("Mac OS X");
+ JMXTestUtils jmxu = new JMXTestUtils(this, "admin" , "admin");
+ jmxu.open();
- String cmd = osx ? "/usr/sbin/lsof -i TCP:%d -Fp" : "/usr/bin/pgrep -f %d";
- Process p = Runtime.getRuntime().exec(String.format(cmd, getPort(port)));
- BufferedReader reader = new BufferedReader (new InputStreamReader(p.getInputStream()));
- String pid = reader.readLine();
- while (reader.ready())
+ try
{
- pid = reader.readLine();
+ ConfigurationManagement configMBean = jmxu.getConfigurationManagement();
+ configMBean.reloadSecurityConfiguration();
+ }
+ finally
+ {
+ jmxu.close();
}
- cmd = "/bin/kill -SIGHUP " + (osx ? pid.substring(1) : pid);
- p = Runtime.getRuntime().exec(cmd);
-
LogMonitor _monitor = new LogMonitor(_outputFile);
assertTrue("The expected server security configuration reload did not occur",
_monitor.waitForMessage(ServerConfiguration.SECURITY_CONFIG_RELOADED, LOGMONITOR_TIMEOUT));