qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lqu...@apache.org
Subject svn commit: r1791260 - in /qpid/java/trunk: qpid-test-utils/src/main/java/org/apache/qpid/test/utils/ systests/protocol-tests-amqp-1-0/ systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/ systests/protocol-tests-amqp-1-0...
Date Thu, 13 Apr 2017 14:38:37 GMT
Author: lquack
Date: Thu Apr 13 14:38:37 2017
New Revision: 1791260

URL: http://svn.apache.org/viewvc?rev=1791260&view=rev
Log:
QPID-7665: [Java Broker] Make tests log into separate files

Modified:
    qpid/java/trunk/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/LogbackPropertyValueDiscriminator.java
    qpid/java/trunk/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
    qpid/java/trunk/systests/protocol-tests-amqp-1-0/pom.xml
    qpid/java/trunk/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/EmbeddedBrokerPerClassAdminImpl.java
    qpid/java/trunk/systests/protocol-tests-amqp-1-0/src/main/resources/config-protocol-tests.json
    qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
    qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java

Modified: qpid/java/trunk/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/LogbackPropertyValueDiscriminator.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/LogbackPropertyValueDiscriminator.java?rev=1791260&r1=1791259&r2=1791260&view=diff
==============================================================================
--- qpid/java/trunk/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/LogbackPropertyValueDiscriminator.java
(original)
+++ qpid/java/trunk/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/LogbackPropertyValueDiscriminator.java
Thu Apr 13 14:38:37 2017
@@ -26,6 +26,8 @@ import ch.qos.logback.core.sift.Abstract
 
 public class LogbackPropertyValueDiscriminator extends AbstractDiscriminator<ILoggingEvent>
 {
+    public static final String CLASS_QUALIFIED_TEST_NAME = "classQualifiedTestName";
+
     private String _key;
     private String _defaultValue;
 

Modified: qpid/java/trunk/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java?rev=1791260&r1=1791259&r2=1791260&view=diff
==============================================================================
--- qpid/java/trunk/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
(original)
+++ qpid/java/trunk/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
Thu Apr 13 14:38:37 2017
@@ -56,7 +56,6 @@ public class QpidTestCase extends TestCa
     public static final String TEST_PROFILES_DIR = QPID_HOME + File.separator + ".." + File.separator
+ "test-profiles" + File.separator;
     public static final String TEST_RESOURCES_DIR = TEST_PROFILES_DIR + "test_resources/";
     public static final String TMP_FOLDER = System.getProperty("java.io.tmpdir");
-    public static final String CLASS_QUALIFIED_TEST_NAME = "classQualifiedTestName";
 
     private static final Logger _logger = LoggerFactory.getLogger(QpidTestCase.class);
     private static QpidTestCase _currentInstance;
@@ -151,7 +150,7 @@ public class QpidTestCase extends TestCa
         try
         {
             _currentInstance = this;
-            loggerContext.putProperty(CLASS_QUALIFIED_TEST_NAME, getClassQualifiedTestName());
+            loggerContext.putProperty(LogbackPropertyValueDiscriminator.CLASS_QUALIFIED_TEST_NAME,
getClassQualifiedTestName());
 
             if (_exclusionList.contains(getClass().getPackage().getName() + ".*") ||
                 _exclusionList.contains(getClass().getName() + "#*") ||
@@ -170,7 +169,7 @@ public class QpidTestCase extends TestCa
         {
             _logger.info(ClassicConstants.FINALIZE_SESSION_MARKER, "Shutting down sub-appender");
             _currentInstance = null;
-            loggerContext.putProperty(CLASS_QUALIFIED_TEST_NAME, null);
+            loggerContext.putProperty(LogbackPropertyValueDiscriminator.CLASS_QUALIFIED_TEST_NAME,
null);
             revertTestSystemProperties();
         }
     }

Modified: qpid/java/trunk/systests/protocol-tests-amqp-1-0/pom.xml
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/protocol-tests-amqp-1-0/pom.xml?rev=1791260&r1=1791259&r2=1791260&view=diff
==============================================================================
--- qpid/java/trunk/systests/protocol-tests-amqp-1-0/pom.xml (original)
+++ qpid/java/trunk/systests/protocol-tests-amqp-1-0/pom.xml Thu Apr 13 14:38:37 2017
@@ -46,17 +46,49 @@
             <artifactId>qpid-broker-codegen</artifactId>
             <version>${project.version}</version>
         </dependency>
+
         <dependency>
             <groupId>org.apache.qpid</groupId>
-            <artifactId>qpid-broker-plugins-amqp-1-0-protocol-bdb-link-store</artifactId>
+            <artifactId>qpid-test-utils</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.qpid</groupId>
+            <artifactId>qpid-broker-plugins-logging-logback</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.qpid</groupId>
+            <artifactId>qpid-broker-plugins-derby-store</artifactId>
             <version>${project.version}</version>
             <optional>true</optional>
+            <scope>test</scope>
         </dependency>
+
         <dependency>
             <groupId>org.apache.qpid</groupId>
-            <artifactId>qpid-systests</artifactId>
+            <artifactId>qpid-broker-plugins-memory-store</artifactId>
             <version>${project.version}</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.qpid</groupId>
+            <artifactId>qpid-broker-plugins-amqp-1-0-protocol-jdbc-link-store</artifactId>
+            <version>${project.version}</version>
+            <optional>true</optional>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.qpid</groupId>
+            <artifactId>qpid-broker-plugins-amqp-1-0-protocol-bdb-link-store</artifactId>
+            <version>${project.version}</version>
+            <optional>true</optional>
+            <scope>test</scope>
+        </dependency>
+
         <dependency>
             <groupId>org.apache.qpid</groupId>
             <artifactId>qpid-bdbstore</artifactId>
@@ -68,7 +100,7 @@
         <dependency>
             <groupId>com.sleepycat</groupId>
             <artifactId>je</artifactId>
-            <scope>provided</scope>
+            <scope>test</scope>
             <optional>true</optional>
         </dependency>
 

Modified: qpid/java/trunk/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/EmbeddedBrokerPerClassAdminImpl.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/EmbeddedBrokerPerClassAdminImpl.java?rev=1791260&r1=1791259&r2=1791260&view=diff
==============================================================================
--- qpid/java/trunk/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/EmbeddedBrokerPerClassAdminImpl.java
(original)
+++ qpid/java/trunk/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/EmbeddedBrokerPerClassAdminImpl.java
Thu Apr 13 14:38:37 2017
@@ -34,6 +34,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import ch.qos.logback.classic.LoggerContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -54,6 +55,7 @@ import org.apache.qpid.server.store.Memo
 import org.apache.qpid.server.util.FileUtils;
 import org.apache.qpid.server.virtualhost.QueueManagingVirtualHost;
 import org.apache.qpid.server.virtualhostnode.JsonVirtualHostNode;
+import org.apache.qpid.test.utils.LogbackPropertyValueDiscriminator;
 
 @PluggableService
 public class EmbeddedBrokerPerClassAdminImpl implements BrokerAdmin
@@ -68,7 +70,8 @@ public class EmbeddedBrokerPerClassAdmin
     @Override
     public void beforeTestClass(final Class testClass)
     {
-        LOGGER.info("beforeTestClass " + testClass.getSimpleName());
+        setClassQualifiedTestName(testClass.getName());
+        LOGGER.info("========================= starting broker for test class : " + testClass.getSimpleName());
         try
         {
             String timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date(System.currentTimeMillis()));
@@ -107,7 +110,7 @@ public class EmbeddedBrokerPerClassAdmin
     @Override
     public void beforeTestMethod(final Class testClass, final Method method)
     {
-        LOGGER.info("beforeTestMethod " + testClass.getSimpleName() + "#" + method.getName());
+        LOGGER.info("========================= prepare test environment for test : " + testClass.getSimpleName()
+ "#" + method.getName());
 
         final String virtualHostNodeName = testClass.getSimpleName() + "_" + method.getName();
         final String storeType = System.getProperty("virtualhostnode.type");
@@ -136,12 +139,18 @@ public class EmbeddedBrokerPerClassAdmin
         }
 
         _currentVirtualHostNode = _broker.createChild(VirtualHostNode.class, attributes);
+
+        LOGGER.info("========================= executing test : " + testClass.getSimpleName()
+ "#" + method.getName());
+        setClassQualifiedTestName(testClass.getName() + "." + method.getName());
+        LOGGER.info("========================= start executing test : " + testClass.getSimpleName()
+ "#" + method.getName());
     }
 
     @Override
     public void afterTestMethod(final Class testClass, final Method method)
     {
-        LOGGER.info("afterTestMethod " + testClass.getSimpleName() + "#" + method.getName());
+        LOGGER.info("========================= stop executing test : " + testClass.getSimpleName()
+ "#" + method.getName());
+        setClassQualifiedTestName(testClass.getName());
+        LOGGER.info("========================= cleaning up test environment for test : "
+ testClass.getSimpleName() + "#" + method.getName());
         if (Boolean.getBoolean("broker.clean.between.tests"))
         {
             _currentVirtualHostNode.delete();
@@ -151,18 +160,22 @@ public class EmbeddedBrokerPerClassAdmin
             _currentVirtualHostNode.setAttributes(Collections.singletonMap(VirtualHostNode.DEFAULT_VIRTUAL_HOST_NODE,
                                                                            false));
         }
+        setClassQualifiedTestName(testClass.getName());
+        LOGGER.info("========================= cleaning done for test : " + testClass.getSimpleName()
+ "#" + method.getName());
     }
 
     @Override
     public void afterTestClass(final Class testClass)
     {
-        LOGGER.info("afterTestClass " + testClass.getSimpleName());
+        LOGGER.info("========================= stopping broker for test class: " + testClass.getSimpleName());
         _systemLauncher.shutdown();
         _ports.clear();
         if (Boolean.getBoolean("broker.clean.between.tests"))
         {
             FileUtils.delete(new File(_currentWorkDirectory), true);
         }
+        LOGGER.info("========================= stopping broker done for test class : " +
testClass.getSimpleName());
+        setClassQualifiedTestName(null);
     }
 
     @Override
@@ -305,6 +318,12 @@ public class EmbeddedBrokerPerClassAdmin
         throw new NotFoundException(String.format("Queue '%s' not found", queueName));
     }
 
+    private void setClassQualifiedTestName(final String name)
+    {
+        final LoggerContext loggerContext = ((ch.qos.logback.classic.Logger) LOGGER).getLoggerContext();
+        loggerContext.putProperty(LogbackPropertyValueDiscriminator.CLASS_QUALIFIED_TEST_NAME,
name);
+    }
+
     private class PortExtractingLauncherListener implements SystemLauncherListener
     {
         private SystemConfig<?> _systemConfig;

Modified: qpid/java/trunk/systests/protocol-tests-amqp-1-0/src/main/resources/config-protocol-tests.json
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/protocol-tests-amqp-1-0/src/main/resources/config-protocol-tests.json?rev=1791260&r1=1791259&r2=1791260&view=diff
==============================================================================
--- qpid/java/trunk/systests/protocol-tests-amqp-1-0/src/main/resources/config-protocol-tests.json
(original)
+++ qpid/java/trunk/systests/protocol-tests-amqp-1-0/src/main/resources/config-protocol-tests.json
Thu Apr 13 14:38:37 2017
@@ -37,28 +37,6 @@
       "password" : "guest"
     } ]
   } ],
-  "brokerloggers" : [ {
-    "name" : "logfile",
-    "type" : "File",
-    "fileName" : "${qpid.work_dir}${file.separator}log${file.separator}qpid.log",
-    "brokerloginclusionrules" : [ {
-      "name" : "Operational",
-      "type" : "NameAndLevel",
-      "level" : "INFO",
-      "loggerName" : "qpid.message.*"
-    }, {
-      "name" : "Qpid",
-      "type" : "NameAndLevel",
-      "durable" : true,
-      "level" : "DEBUG",
-      "loggerName" : "org.apache.qpid.*"
-    }, {
-      "name" : "Root",
-      "type" : "NameAndLevel",
-      "level" : "WARN",
-      "loggerName" : "ROOT"
-    } ]
-  } ],
   "ports" : [ {
     "name" : "AMQP",
     "type" : "AMQP",
@@ -94,12 +72,6 @@
       "type" : "nameAlias",
       "durable" : true
     } ]
-  }, {
-    "name" : "HTTP",
-    "type" : "HTTP",
-    "authenticationProvider" : "anon",
-    "port" : "0",
-    "protocols" : [ "HTTP" ]
   } ],
   "virtualhostnodes" : []
 }

Modified: qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java?rev=1791260&r1=1791259&r2=1791260&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
(original)
+++ qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
Thu Apr 13 14:38:37 2017
@@ -29,8 +29,6 @@ import java.util.Map;
 import java.util.Properties;
 
 import javax.jms.*;
-import javax.naming.Context;
-import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
 import ch.qos.logback.classic.sift.SiftingAppender;
@@ -39,7 +37,6 @@ import ch.qos.logback.core.Appender;
 import ch.qos.logback.core.FileAppender;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
 
 import org.apache.qpid.server.model.Protocol;
 import org.apache.qpid.server.store.MemoryConfigurationStore;
@@ -779,7 +776,7 @@ public class QpidBrokerTestCase extends
 
     private File getFileFromSiftingAppender(final ch.qos.logback.classic.Logger logger)
     {
-        String key = logger.getLoggerContext().getProperty(QpidTestCase.CLASS_QUALIFIED_TEST_NAME);
+        String key = logger.getLoggerContext().getProperty(LogbackPropertyValueDiscriminator.CLASS_QUALIFIED_TEST_NAME);
 
         for (Iterator<Appender<ILoggingEvent>> index = logger.iteratorForAppenders();
index.hasNext(); /* do nothing */)
         {

Modified: qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java?rev=1791260&r1=1791259&r2=1791260&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java
(original)
+++ qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java
Thu Apr 13 14:38:37 2017
@@ -480,7 +480,7 @@ public class SpawnedBrokerHolder extends
         mdc.put("origin", getLogPrefix());
 
         Map<String, String> contextProperties = new HashMap<>();
-        contextProperties.put(QpidBrokerTestCase.CLASS_QUALIFIED_TEST_NAME, getClassQualifiedTestName());
+        contextProperties.put(LogbackPropertyValueDiscriminator.CLASS_QUALIFIED_TEST_NAME,
getClassQualifiedTestName());
 
         Map<String, Object> loggerAttrs = new HashMap<>();
         loggerAttrs.put(BrokerLogger.TYPE, BrokerLogbackSocketLogger.TYPE);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message