diff options
| author | Martin Ritchie <ritchiem@apache.org> | 2009-08-09 23:27:09 +0000 |
|---|---|---|
| committer | Martin Ritchie <ritchiem@apache.org> | 2009-08-09 23:27:09 +0000 |
| commit | 22b938c17b8dfb181e84784e6467f936422119e1 (patch) | |
| tree | 9295791b5148a155a622575ff29d088dbe68aff9 | |
| parent | 0c73c218cf7428d87e0df8c2552b3a1f1738f071 (diff) | |
| download | qpid-python-22b938c17b8dfb181e84784e6467f936422119e1.tar.gz | |
QPID-2002 : Add VirtualHost logging and testing, again shutdown testing must be excluded due to the way we stop test brokers.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@802627 13f79535-47bb-0310-9956-ffa450edef68
3 files changed, 173 insertions, 0 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java index ad1e8a580e..fa6b2285eb 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java @@ -29,6 +29,9 @@ import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.FieldTable; import org.apache.qpid.framing.abstraction.ContentChunk; import org.apache.qpid.server.AMQBrokerManagerMBean; +import org.apache.qpid.server.logging.actors.CurrentActor; +import org.apache.qpid.server.logging.LogSubject; +import org.apache.qpid.server.logging.messages.VirtualHostMessages; import org.apache.qpid.server.configuration.ExchangeConfiguration; import org.apache.qpid.server.configuration.QueueConfiguration; import org.apache.qpid.server.configuration.VirtualHostConfiguration; @@ -155,6 +158,8 @@ public class VirtualHost implements Accessable _configuration = hostConfig; _name = hostConfig.getName(); + CurrentActor.get().message(VirtualHostMessages.VHT_1001(_name)); + if (_name == null || _name.length() == 0) { throw new IllegalArgumentException("Illegal name (" + _name + ") for virtualhost."); @@ -427,6 +432,8 @@ public class VirtualHost implements Accessable { _messageStore.close(); } + + CurrentActor.get().message(VirtualHostMessages.VHT_1002()); } public ManagedObject getBrokerMBean() diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java new file mode 100644 index 0000000000..1c0783227b --- /dev/null +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java @@ -0,0 +1,165 @@ +/* + * 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. + * + * + */ + +package org.apache.qpid.server.logging; + +import junit.framework.AssertionFailedError; +import org.apache.commons.configuration.Configuration; +import org.apache.qpid.server.configuration.ServerConfiguration; +import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject; + +import java.util.List; + +/** + * Virtualhost Test Cases + * The virtualhost test suite validates that the follow log messages as specified in the Functional Specification. + * <p/> + * This suite of tests validate that the management console messages occur correctly and according to the following format: + * <p/> + * VHT-1001 : Created : <name> + * VHT-1002 : Work directory : <path> + * VHT-1003 : Closed + */ +public class VirtualHostLoggingTest extends AbstractTestLogging +{ + private static final String VHT_PREFIX = "VHT-"; + + /** + * Description: + * Testing can be performed using the default configuration. The goal is to validate that for each virtualhost defined in the configuration file a VHT-1001 Created message is provided. + * Input: + * The default configuration file + * Output: + * <p/> + * <date> VHT-1001 : Created : <name> + * Validation Steps: + * <p/> + * The VHT ID is correct + * A VHT-1001 is printed for each virtualhost defined in the configuration file. + * This must be the first message for the specified virtualhost. + * + * @throws Exception caused by broker startup + */ + public void testVirtualhostCreation() throws Exception + { + // This logging startup code only occurs when you run a Java broker, + // that broker must be started via Main so not an InVM broker. +// if (isJavaBroker() && isExternalBroker()) + { +// startBroker(); + + // Now we can create the monitor as _outputFile will now be defined +// _monitor = new LogMonitor(_outputFile); + + + String configFilePath = _configFile.toString(); + + List<String> results = _monitor.findMatches(VHT_PREFIX); + try + { + // Validation + Configuration configuration = ServerConfiguration.flatConfig(_configFile); + List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name"); + + //Validate each vhost logs a creation + results = _monitor.findMatches("VHT-1001"); + + assertEquals("Each vhost did not create a store.", vhosts.size(), results.size()); + + for (int index = 0; index < results.size(); index++) + { + String result = getLog(results.get(index)); + + // Retrieve the vhostname from the log entry message 'Created : <vhostname>' + String vhostName = getMessageString(fromMessage(result)).split(" ")[2] ; + + assertTrue("Virualhost named in log not found in config file:"+ vhostName+":"+vhosts, vhosts.contains(vhostName)); + } + } + catch (AssertionFailedError afe) + { + System.err.println("Log Dump:"); + for (String log : results) + { + System.err.println(log); + } + throw afe; + } + } + } + + /** + * Description: + * Testing can be performed using the default configuration. During broker shutdown a VHT-1002 Closed message will be printed for each of the configured virtualhosts. For every virtualhost that was started a close must be logged. After the close message has been printed no further logging will be performed by this virtualhost. + * Input: + * The default configuration file + * Output: + * <p/> + * <date> VHT-1002 : Closed + * Validation Steps: + * <p/> + * The VHT ID is correct + * This is the last VHT message for the given virtualhost. + * + * @throws Exception caused by broker startup + */ + public void testVirtualhostClosure() throws Exception + { + // This logging startup code only occurs when you run a Java broker, + // that broker must be started via Main so not an InVM broker. +// if (isJavaBroker() && isExternalBroker()) + { +// startBroker(); + + // Now we can create the monitor as _outputFile will now be defined +// _monitor = new LogMonitor(_outputFile); + + stopBroker(); + + String configFilePath = _configFile.toString(); + + List<String> results = _monitor.findMatches(VHT_PREFIX); + try + { + // Validation + + Configuration configuration = ServerConfiguration.flatConfig(_configFile); + List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name"); + + //Validate each vhost logs a creation + results = _monitor.findMatches("VHT-1002"); + + assertEquals("Each vhost did not create a store.", vhosts.size(), results.size()); + } + catch (AssertionFailedError afe) + { + System.err.println("Log Dump:"); + for (String log : results) + { + System.err.println(log); + } + throw afe; + } + } + } + + +} diff --git a/qpid/java/test-profiles/Excludes b/qpid/java/test-profiles/Excludes index b4b3fb7cb9..7ef2a15e51 100644 --- a/qpid/java/test-profiles/Excludes +++ b/qpid/java/test-profiles/Excludes @@ -11,6 +11,7 @@ org.apache.qpid.server.queue.QueueCreateTest#testCreateFlowToDiskInvalidSize org.apache.qpid.server.logging.BrokerLoggingTest#testBrokerShutdownListeningTCPDefault org.apache.qpid.server.logging.BrokerLoggingTest#testBrokerShutdownListeningTCPSSL org.apache.qpid.server.logging.BrokerLoggingTest#testBrokerShutdownStopped +org.apache.qpid.server.logging.VirtualHostLoggingTest#testVirtualhostClosure org.apache.qpid.server.logging.MemoryMessageStoreLoggingTest#testMessageStoreClose org.apache.qpid.server.logging.DerbyMessageStoreLoggingTest#testMessageStoreClose |
