[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_0.9.30-46-gdea82f9

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Tue Oct 25 22:29:36 CEST 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".

The branch, master has been updated
       via  dea82f92852be5f4c191ebb06ff5c8254485428b (commit)
      from  3634bf15c5c1eaf35699770b858ab0b29fc4fc97 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=dea82f92852be5f4c191ebb06ff5c8254485428b
http://github.com/ceki/logback/commit/dea82f92852be5f4c191ebb06ff5c8254485428b

commit dea82f92852be5f4c191ebb06ff5c8254485428b
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Tue Oct 25 22:07:13 2011 +0200

    make ReconfigureOnChangeTest more robust

diff --git a/logback-classic/src/test/input/joran/scan1.xml b/logback-classic/src/test/input/joran/scan1.xml
index 68c4af3..7be1d6c 100644
--- a/logback-classic/src/test/input/joran/scan1.xml
+++ b/logback-classic/src/test/input/joran/scan1.xml
@@ -1,16 +1,9 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE configuration>
-
 <configuration scan="true" scanPeriod="1 millisecond">
 
-  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
-    <encoder>
-      <Pattern>yx %d - %m%n"</Pattern>  
-    </encoder>
-  </appender>
+  <appender name="LIST" class="ch.qos.logback.core.read.ListAppender"/>
     
   <root level="TRACE">  
-    <appender-ref ref="CONSOLE" />
+    <appender-ref ref="LIST" />
   </root>
   
 </configuration> 
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderIntegrationTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderIntegrationTest.java
index aa72ae5..245ae90 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderIntegrationTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderIntegrationTest.java
@@ -48,8 +48,8 @@ public class DBAppenderIntegrationTest {
   static String LOCAL_HOST_NAME;
   static String[] CONFORMING_HOST_LIST = new String[] { "Orion" };
   static String[] POSTGRES_CONFORMING_HOST_LIST = new String[] { "haro" };
-  static String[] MYSQL_CONFORMING_HOST_LIST = new String[] { "hetz", "haro" };
-  static String[] ORACLE_CONFORMING_HOST_LIST = new String[] { "haro" };
+  static String[] MYSQL_CONFORMING_HOST_LIST = new String[] { "hetz", "xharo" };
+  static String[] ORACLE_CONFORMING_HOST_LIST = new String[] { "xharo" };
 
   int diff = RandomUtil.getPositiveInt();
   LoggerContext lc = new LoggerContext();
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
index 3f8f5a2..188b222 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
@@ -287,7 +287,7 @@ public class JoranConfiguratorTest {
 
   // Tests whether ConfigurationAction is installing ReconfigureOnChangeFilter
   @Test
-  public void scan1() throws JoranException, IOException, InterruptedException {
+  public void autoscanShouldReconfigureOnFileChange() throws Exception {
 
     String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX
             + "scan1.xml";
@@ -296,7 +296,7 @@ public class JoranConfiguratorTest {
     File file = new File(configFileAsStr);
     file.setLastModified(System.currentTimeMillis());
 
-    Thread.sleep(100);
+    Thread.sleep(10);
     // scanning requires 16 logs
     for (int i = 0; i < 16; i++) {
       logger.debug("after " + i);
@@ -305,7 +305,7 @@ public class JoranConfiguratorTest {
     loggerContext.getExecutorService().shutdown();
     loggerContext.getExecutorService().awaitTermination(1000, TimeUnit.MILLISECONDS);
 
-    StatusPrinter.print(loggerContext);
+    //StatusPrinter.print(loggerContext);
     StatusChecker checker = new StatusChecker(loggerContext);
     assertTrue(checker.isErrorFree(0));
     assertTrue(checker.containsMatch("Will reset and reconfigure context"));
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_SubethaSMTPTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_SubethaSMTPTest.java
index 446fafb..c59d364 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_SubethaSMTPTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_SubethaSMTPTest.java
@@ -122,8 +122,9 @@ public class SMTPAppender_SubethaSMTPTest {
   }
 
   void waitUntilEmailIsSent() throws Exception {
+    System.out.println("About to wait for sending thread to finish");
     loggerContext.getExecutorService().shutdown();
-    loggerContext.getExecutorService().awaitTermination(1000, TimeUnit.MILLISECONDS);
+    loggerContext.getExecutorService().awaitTermination(3000, TimeUnit.MILLISECONDS);
   }
 
   private static String getBody(Part msg) {
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java
index fd3247f..b63a079 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java
@@ -19,14 +19,18 @@ import static org.junit.Assert.assertTrue;
 
 import java.io.*;
 import java.net.MalformedURLException;
-import java.util.Random;
+import java.util.concurrent.ThreadPoolExecutor;
 
 import ch.qos.logback.classic.gaffer.GafferConfigurator;
+import ch.qos.logback.core.contention.AbstractMultiThreadedHarness;
+import ch.qos.logback.core.contention.MultiThreadedHarness;
+import ch.qos.logback.core.contention.WaitOnExecutionMultiThreadedHarness;
 import ch.qos.logback.core.joran.util.ConfigurationWatchListUtil;
 import ch.qos.logback.core.testUtil.RandomUtil;
 import ch.qos.logback.core.util.CoreTestConstants;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.helpers.BogoPerf;
 
@@ -37,7 +41,6 @@ import ch.qos.logback.classic.LoggerContext;
 import ch.qos.logback.classic.issue.lbclassic135.LoggingRunnable;
 import ch.qos.logback.classic.joran.JoranConfigurator;
 import ch.qos.logback.core.CoreConstants;
-import ch.qos.logback.core.contention.MultiThreadedHarness;
 import ch.qos.logback.core.contention.RunnableWithCounterAndDone;
 import ch.qos.logback.core.joran.spi.JoranException;
 import ch.qos.logback.core.status.InfoStatus;
@@ -52,6 +55,9 @@ public class ReconfigureOnChangeTest {
   static final boolean MUST_BE_ERROR_FREE = true;
   static final boolean ERRORS_EXPECTED = false;
 
+  static final boolean REGULAR_RECONFIGURATION = false;
+  static final boolean FORCED_RECONFIGURATION_SKIP = true;
+
 
   int diff = RandomUtil.getPositiveInt();
 
@@ -87,32 +93,27 @@ public class ReconfigureOnChangeTest {
   // it actually takes time for Windows to propagate file modification changes
   // values below 100 milliseconds can be problematic the same propagation
   // latency occurs in Linux but is even larger (>600 ms)
-  final static int DEFAULT_SLEEP_BETWEEN_UPDATES = 210;
+  final static int DEFAULT_SLEEP_BETWEEN_UPDATES = 60;
 
-  int sleepBetweenUpdates = DEFAULT_SLEEP_BETWEEN_UPDATES;
+  int sleepBetweenUpdates = 100;//DEFAULT_SLEEP_BETWEEN_UPDATES;
 
-  static int totalTestDuration;
+//  static int totalTestDuration;
 
   LoggerContext loggerContext = new LoggerContext();
   Logger logger = loggerContext.getLogger(this.getClass());
-  MultiThreadedHarness harness;
+  AbstractMultiThreadedHarness harness;
+
+  ThreadPoolExecutor executor = (ThreadPoolExecutor) loggerContext.getExecutorService();
+
+  int expectedResets = 2;
 
   @Before
   public void setUp() {
-    System.out.println("======== TEST START, time" + System.currentTimeMillis());
-    // take into account propagation latency occurs on Linux or Mac
-    if (Env.isLinux() || Env.isMac()) {
-      sleepBetweenUpdates = 950;
-      totalTestDuration = sleepBetweenUpdates * 5;
-    } else {
-      totalTestDuration = sleepBetweenUpdates * 10;
-    }
-    harness = new MultiThreadedHarness(totalTestDuration);
+    harness = new WaitOnExecutionMultiThreadedHarness(executor, expectedResets);
   }
 
   @After
   public void tearDown() {
-    System.out.println("======= TEST STOP");
   }
 
   void configure(File file) throws JoranException {
@@ -143,7 +144,7 @@ public class ReconfigureOnChangeTest {
 
 
   void doScanTest(File fileToTouch) throws JoranException, IOException, InterruptedException {
-    doScanTest(fileToTouch, UpdateType.TOUCH, false, MUST_BE_ERROR_FREE);
+    doScanTest(fileToTouch, UpdateType.TOUCH, REGULAR_RECONFIGURATION, MUST_BE_ERROR_FREE);
   }
 
   void doScanTest(File fileToTouch, UpdateType updateType, boolean forcedReconfigurationSkip, boolean mustBeErrorFree) throws JoranException, IOException, InterruptedException {
@@ -153,22 +154,22 @@ public class ReconfigureOnChangeTest {
     loggerContext.getStatusManager().add(
             new InfoStatus("end of execution ", this));
 
-    long expectedReconfigurations = runnableArray[0].getCounter();
+    int expected = expectedResets;
     if (forcedReconfigurationSkip)
-      expectedReconfigurations = 0;
+      expected = 0;
 
-    verify(expectedReconfigurations, mustBeErrorFree);
+    verify(expected, mustBeErrorFree);
   }
 
   // Tests whether ConfigurationAction is installing ReconfigureOnChangeFilter
-  @Test
+  @Test(timeout = 4000L)
   public void scan1() throws JoranException, IOException, InterruptedException {
     File file = new File(SCAN1_FILE_AS_STR);
     configure(file);
     doScanTest(file);
   }
 
-  @Test
+  @Test(timeout = 4000L)
   public void scanWithFileInclusion() throws JoranException, IOException, InterruptedException {
     File topLevelFile = new File(INCLUSION_SCAN_TOPLEVEL0_AS_STR);
     File innerFile = new File(INCLUSION_SCAN_INNER0_AS_STR);
@@ -176,7 +177,7 @@ public class ReconfigureOnChangeTest {
     doScanTest(innerFile);
   }
 
-  @Test
+  @Test(timeout = 4000L)
   public void scanWithResourceInclusion() throws JoranException, IOException, InterruptedException {
     File topLevelFile = new File(INCLUSION_SCAN_TOP_BY_RESOURCE_AS_STR);
     File innerFile = new File(INCLUSION_SCAN_INNER1_AS_STR);
@@ -185,24 +186,25 @@ public class ReconfigureOnChangeTest {
   }
 
   // See also http://jira.qos.ch/browse/LBCLASSIC-247
-  @Test
+  @Test(timeout = 4000L)
   public void includeScanViaInputStreamSuppliedConfigFile() throws IOException, JoranException, InterruptedException {
+    harness = new MultiThreadedHarness(1000);
     String configurationStr = "<configuration scan=\"true\" scanPeriod=\"50 millisecond\"><include resource=\"asResource/inner1.xml\"/></configuration>";
     configure(new ByteArrayInputStream(configurationStr.getBytes("UTF-8")));
     File innerFile = new File(INCLUSION_SCAN_INNER1_AS_STR);
-    doScanTest(innerFile, UpdateType.TOUCH, true, MUST_BE_ERROR_FREE);
+    doScanTest(innerFile, UpdateType.TOUCH, FORCED_RECONFIGURATION_SKIP, MUST_BE_ERROR_FREE);
   }
 
-  @Test
+  @Test(timeout = 4000L)
   public void fallbackToSafe() throws IOException, JoranException, InterruptedException {
     String path = CoreTestConstants.OUTPUT_DIR_PREFIX + "reconfigureOnChangeConfig_fallbackToSafe-" + diff + ".xml";
     File file = new File(path);
     writeToFile(file, "<configuration scan=\"true\" scanPeriod=\"50 millisecond\"><root level=\"ERROR\"/></configuration> ");
     configure(file);
-    doScanTest(file, UpdateType.MALFORMED, false, ERRORS_EXPECTED);
+    doScanTest(file, UpdateType.MALFORMED, REGULAR_RECONFIGURATION, ERRORS_EXPECTED);
   }
 
-  @Test
+  @Test(timeout = 4000L)
   public void fallbackToSafeWithIncludedFile() throws IOException, JoranException, InterruptedException {
     String topLevelFileAsStr = CoreTestConstants.OUTPUT_DIR_PREFIX + "reconfigureOnChangeConfig_top-" + diff + ".xml";
     String innerFileAsStr = CoreTestConstants.OUTPUT_DIR_PREFIX + "reconfigureOnChangeConfig_inner-" + diff + ".xml";
@@ -212,11 +214,11 @@ public class ReconfigureOnChangeTest {
     File innerFile = new File(innerFileAsStr);
     writeToFile(innerFile, "<included><root level=\"ERROR\"/></included> ");
     configure(topLevelFile);
-    doScanTest(innerFile, UpdateType.MALFORMED_INNER, false, ERRORS_EXPECTED);
+    doScanTest(innerFile, UpdateType.MALFORMED_INNER, REGULAR_RECONFIGURATION, ERRORS_EXPECTED);
   }
 
 
-  @Test
+  @Test(timeout = 4000L)
   public void gscan1() throws JoranException, IOException, InterruptedException {
     File file = new File(G_SCAN1_FILE_AS_STR);
     gConfigure(file);
@@ -226,13 +228,11 @@ public class ReconfigureOnChangeTest {
     loggerContext.getStatusManager().add(
             new InfoStatus("end of execution ", this));
 
-    long expectedRreconfigurations = runnableArray[0].getCounter();
-    verify(expectedRreconfigurations, MUST_BE_ERROR_FREE);
+    verify(expectedResets, MUST_BE_ERROR_FREE);
   }
 
   // check for deadlocks
-  //Attr_Test(timeout = 20000)
-  @Test
+  @Test(timeout = 4000L)
   public void scan_lbclassic154() throws JoranException, IOException,
           InterruptedException {
     File file = new File(SCAN_LBCLASSIC_154_FILE_AS_STR);
@@ -243,12 +243,11 @@ public class ReconfigureOnChangeTest {
     loggerContext.getStatusManager().add(
             new InfoStatus("end of execution ", this));
 
-    long expectedReconfigurations = runnableArray[0].getCounter();
-    verify(expectedReconfigurations, MUST_BE_ERROR_FREE);
+    verify(expectedResets, MUST_BE_ERROR_FREE);
   }
 
 
-  void verify(long expectedReconfigurations, boolean errorFreeness) {
+  void verify(int expected, boolean errorFreeness) {
     StatusChecker checker = new StatusChecker(loggerContext);
     StatusPrinter.print(loggerContext);
     if (errorFreeness == MUST_BE_ERROR_FREE) {
@@ -256,23 +255,14 @@ public class ReconfigureOnChangeTest {
     } else {
       assertFalse(checker.isErrorFree(0));
     }
+
     int effectiveResets = checker
             .matchCount("Will reset and reconfigure context");
-    // the number of effective resets must be equal or less than
-    // expectedReconfigurations
-    System.out.println("effectiveResets=" + effectiveResets);
-
-    System.out.println("expectedReconfigurations=" + expectedReconfigurations);
-    assertTrue(effectiveResets <= expectedReconfigurations);
 
-    // however, there should be some effective resets
     String failMsg = "effective=" + effectiveResets + ", expected="
-            + expectedReconfigurations;
-    // we can't have the test succeed under JDK 1.5, punt and require 1.6+
-    if (Env.isJDK6OrHigher()) {
-      assertTrue(failMsg,
-              (effectiveResets * 1.5) >= (expectedReconfigurations * 1.0));
-    }
+            + expected;
+    assertEquals(failMsg, expected, effectiveResets);
+
   }
 
   ReconfigureOnChangeFilter initROCF() throws MalformedURLException {
diff --git a/logback-core/src/test/java/ch/qos/logback/core/contention/AbstractMultiThreadedHarness.java b/logback-core/src/test/java/ch/qos/logback/core/contention/AbstractMultiThreadedHarness.java
new file mode 100644
index 0000000..aa4d4fd
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/contention/AbstractMultiThreadedHarness.java
@@ -0,0 +1,29 @@
+package ch.qos.logback.core.contention;
+
+abstract public class AbstractMultiThreadedHarness {
+
+  RunnableWithCounterAndDone[] runnableArray;
+
+  abstract void waitUntilEndCondition() throws InterruptedException;
+
+  public void execute(RunnableWithCounterAndDone[] runnableArray)
+      throws InterruptedException {
+    this.runnableArray = runnableArray;
+    Thread[] threadArray = new Thread[runnableArray.length];
+
+    for (int i = 0; i < runnableArray.length; i++) {
+      threadArray[i] = new Thread(runnableArray[i], "Harness["+i+"]");
+    }
+    for (Thread t : threadArray) {
+      t.start();
+    }
+
+    waitUntilEndCondition();
+    for (RunnableWithCounterAndDone r : runnableArray) {
+      r.setDone(true);
+    }
+    for (Thread t : threadArray) {
+      t.join();
+    }
+  }
+}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/contention/MultiThreadedHarness.java b/logback-core/src/test/java/ch/qos/logback/core/contention/MultiThreadedHarness.java
index 093f889..8b9f744 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/contention/MultiThreadedHarness.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/contention/MultiThreadedHarness.java
@@ -21,10 +21,8 @@ package ch.qos.logback.core.contention;
  * @author Ralph Goers
  * @author Ceki Gulcu
  */
-public class MultiThreadedHarness {
+public class MultiThreadedHarness extends AbstractMultiThreadedHarness {
 
-  RunnableWithCounterAndDone[] runnableArray;
-  Thread[] threadArray;
   final long overallDurationInMillis;
 
   public MultiThreadedHarness(long overallDurationInMillis) {
@@ -45,25 +43,7 @@ public class MultiThreadedHarness {
         + System.getProperty("os.version"));
   }
 
-  public void execute(RunnableWithCounterAndDone[] runnableArray)
-      throws InterruptedException {
-    this.runnableArray = runnableArray;
-    Thread[] threadArray = new Thread[runnableArray.length];
-
-    for (int i = 0; i < runnableArray.length; i++) {
-      threadArray[i] = new Thread(runnableArray[i], "Harness["+i+"]");
-    }
-    for (Thread t : threadArray) {
-      t.start();
-    }
-    // let the threads run for a while
+  void waitUntilEndCondition() throws InterruptedException {
     Thread.sleep(overallDurationInMillis);
-
-    for (RunnableWithCounterAndDone r : runnableArray) {
-      r.setDone(true);
-    }
-    for (Thread t : threadArray) {
-      t.join();
-    }
   }
 }
diff --git a/logback-core/src/test/java/ch/qos/logback/core/contention/WaitOnExecutionMultiThreadedHarness.java b/logback-core/src/test/java/ch/qos/logback/core/contention/WaitOnExecutionMultiThreadedHarness.java
new file mode 100644
index 0000000..0854e7a
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/contention/WaitOnExecutionMultiThreadedHarness.java
@@ -0,0 +1,20 @@
+package ch.qos.logback.core.contention;
+
+import java.util.concurrent.ThreadPoolExecutor;
+
+public class WaitOnExecutionMultiThreadedHarness extends AbstractMultiThreadedHarness {
+    ThreadPoolExecutor threadPoolExecutor;
+    int count;
+
+    public WaitOnExecutionMultiThreadedHarness(ThreadPoolExecutor threadPoolExecutor, int count) {
+        this.threadPoolExecutor = threadPoolExecutor;
+        this.count =count;
+
+    }
+    @Override
+    void waitUntilEndCondition() throws InterruptedException {
+      while(threadPoolExecutor.getCompletedTaskCount() != count) {
+        Thread.sleep(100);
+      }
+    }
+}

-----------------------------------------------------------------------

Summary of changes:
 logback-classic/src/test/input/joran/scan1.xml     |   11 +--
 .../classic/db/DBAppenderIntegrationTest.java      |    4 +-
 .../classic/joran/JoranConfiguratorTest.java       |    6 +-
 .../classic/net/SMTPAppender_SubethaSMTPTest.java  |    3 +-
 .../classic/turbo/ReconfigureOnChangeTest.java     |   90 +++++++++-----------
 .../contention/AbstractMultiThreadedHarness.java   |   29 ++++++
 .../core/contention/MultiThreadedHarness.java      |   24 +-----
 .../WaitOnExecutionMultiThreadedHarness.java       |   20 +++++
 8 files changed, 100 insertions(+), 87 deletions(-)
 create mode 100644 logback-core/src/test/java/ch/qos/logback/core/contention/AbstractMultiThreadedHarness.java
 create mode 100644 logback-core/src/test/java/ch/qos/logback/core/contention/WaitOnExecutionMultiThreadedHarness.java


hooks/post-receive
-- 
Logback: the generic, reliable, fast and flexible logging framework.


More information about the logback-dev mailing list