[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v0.9.18-21-g912a925

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Thu Feb 11 19:50:59 CET 2010


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  912a925ea5d92c45a8b6bafe7f2691fb9be155d7 (commit)
      from  aae40ddb853fa6535d0bf181d9b61435e8c1f984 (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=912a925ea5d92c45a8b6bafe7f2691fb9be155d7
http://github.com/ceki/logback/commit/912a925ea5d92c45a8b6bafe7f2691fb9be155d7

commit 912a925ea5d92c45a8b6bafe7f2691fb9be155d7
Author: Ceki Gulcu <ceki at gimmel.(none)>
Date:   Thu Feb 11 19:48:18 2010 +0100

    - have MultiThreadedRollingTest run consistently on a fast linux machine

diff --git a/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderIntegrationTest.java b/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderIntegrationTest.java
index 6c9b56e..f3f28b6 100644
--- a/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderIntegrationTest.java
+++ b/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderIntegrationTest.java
@@ -15,7 +15,6 @@ package ch.qos.logback.access.db;
 
 import static org.junit.Assert.assertEquals;
 
-import java.net.InetAddress;
 import java.util.Random;
 
 import org.junit.After;
@@ -37,7 +36,7 @@ import ch.qos.logback.core.util.StatusPrinter;
 
 public class DBAppenderIntegrationTest {
 
-  static String LOCAL_HOST_NAME;
+  static String LOCAL_HOST_NAME = Env.getLocalHostName();
   static String[] CONFORMING_HOST_LIST = new String[] { "Orion" };
 
   int diff = new Random(System.nanoTime()).nextInt(10000);
@@ -45,8 +44,6 @@ public class DBAppenderIntegrationTest {
   
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {
-    InetAddress localhostIA = InetAddress.getLocalHost();
-    LOCAL_HOST_NAME = localhostIA.getHostName();
   }
 
   @AfterClass
@@ -85,12 +82,7 @@ public class DBAppenderIntegrationTest {
     if(!Env.isJDK6OrHigher()) {
       return false;
     }
-    for (String conformingHost : CONFORMING_HOST_LIST) {
-      if (conformingHost.equalsIgnoreCase(LOCAL_HOST_NAME)) {
-        return true;
-      }
-    }
-    return false;
+    return Env.isLocalHostNameInList(CONFORMING_HOST_LIST);
   }
 
   @Test
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/MultiThreadedRollingTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/MultiThreadedRollingTest.java
index e6ecc44..bac049b 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/MultiThreadedRollingTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/MultiThreadedRollingTest.java
@@ -26,7 +26,6 @@ import java.io.OutputStream;
 
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import ch.qos.logback.core.Context;
@@ -36,6 +35,7 @@ import ch.qos.logback.core.contention.MultiThreadedHarness;
 import ch.qos.logback.core.contention.RunnableWithCounterAndDone;
 import ch.qos.logback.core.layout.EchoLayout;
 import ch.qos.logback.core.status.StatusChecker;
+import ch.qos.logback.core.testUtil.Env;
 import ch.qos.logback.core.testUtil.RandomUtil;
 import ch.qos.logback.core.util.CoreTestConstants;
 import ch.qos.logback.core.util.StatusPrinter;
@@ -50,13 +50,14 @@ public class MultiThreadedRollingTest {
   Context context = new ContextBase();
 
   static String VERIFY_SH = "verify.sh";
-  
+
   int diff = RandomUtil.getPositiveInt();
   String outputDirStr = CoreTestConstants.OUTPUT_DIR_PREFIX + "multi-" + diff
       + "/";
 
   RollingFileAppender<Object> rfa = new RollingFileAppender<Object>();
 
+  String pathToBash = Env.getPathToBash();
   OutputStream scriptOS;
 
   @Before
@@ -65,8 +66,8 @@ public class MultiThreadedRollingTest {
     File outputDir = new File(outputDirStr);
     outputDir.mkdirs();
 
-    System.out.println("Output dir ["+outputDirStr+"]");
-    
+    System.out.println("Output dir [" + outputDirStr + "]");
+
     scriptOS = openScript();
 
     rfa.setName("rolling");
@@ -113,7 +114,7 @@ public class MultiThreadedRollingTest {
     FixedWindowRollingPolicy fwrp = new FixedWindowRollingPolicy();
     fwrp.setContext(context);
     fwrp.setFileNamePattern(outputDirStr + "test-%i.log");
-    fwrp.setMaxIndex(10);
+    fwrp.setMaxIndex(20);
     fwrp.setMinIndex(0);
     fwrp.setParent(rfa);
     fwrp.start();
@@ -121,24 +122,24 @@ public class MultiThreadedRollingTest {
     rfa.start();
   }
 
-  RunnableWithCounterAndDone[] buildRunnableArray() {
+  RunnableWithCounterAndDone[] buildRunnableArray(boolean withDelay) {
     RunnableWithCounterAndDone[] runnableArray = new RunnableWithCounterAndDone[NUM_THREADS];
     for (int i = 0; i < NUM_THREADS; i++) {
-      runnableArray[i] = new RFARunnable(i, rfa);
+      runnableArray[i] = new RFARunnable(i, rfa, withDelay);
     }
     return runnableArray;
   }
 
   OutputStream openScript() throws IOException {
-    FileOutputStream fos = new FileOutputStream(outputDirStr +VERIFY_SH);
+    FileOutputStream fos = new FileOutputStream(outputDirStr + VERIFY_SH);
     return fos;
   }
-
+  
   @Test
   public void multiThreadedTimedBased() throws InterruptedException,
       IOException {
     setUpTimeBasedTriggeringPolicy(rfa);
-    executeHarness();
+    executeHarness(TOTAL_DURATION, false);
     printScriptForTimeBased();
     verify();
   }
@@ -147,30 +148,40 @@ public class MultiThreadedRollingTest {
     File outputDir = new File(outputDirStr);
     FilenameFilter filter = new FilenameFilter() {
       public boolean accept(File dir, String name) {
-        if(name.matches("test-\\d{1,2}.log")) {
+        if (name.matches("test-\\d{1,2}.log")) {
           return true;
-        } 
+        }
         return false;
       }
     };
     File[] files = outputDir.listFiles(filter);
     return files.length;
   }
-  
+
   void verify() throws IOException, InterruptedException {
     close(scriptOS);
+    // no point in this test if we don't have bash
+    if(pathToBash == null) {
+      return;
+    }
     ProcessBuilder pb = new ProcessBuilder();
-    pb.command(CoreTestConstants.BASH_PATH, VERIFY_SH);
+    pb.command(pathToBash, VERIFY_SH);
     pb.directory(new File(outputDirStr));
     Process process = pb.start();
     process.waitFor();
-    assertEquals(SUCCESSFUL_EXIT_CODE, process.exitValue());
+    int exitCode = process.exitValue();
+    
+    assertEquals(SUCCESSFUL_EXIT_CODE, exitCode);
+    System.out.println("External script based verification returned with exit code "+exitCode);
   }
 
   @Test
   public void multiThreadedSizeBased() throws InterruptedException, IOException {
     setUpSizeBasedTriggeringPolicy(rfa);
-    executeHarness();
+    // on a fast machine with a fast hard disk, if the tests runs for too
+    // long the MAX_WINDOW_SIZE is reached, resulting in data loss which
+    // we cannot test for.
+    executeHarness(TOTAL_DURATION, true);
     int numFiles = testFileCount();
     printScriptForSizeBased(numFiles);
     verify();
@@ -195,11 +206,11 @@ public class MultiThreadedRollingTest {
     out("  res=$?");
     out("  if [ $res != \"0\" ]; then");
     out("    echo \"FAILED for $t\"");
-    out("    exit "+FAILURE_EXIT_CODE);
+    out("    exit " + FAILURE_EXIT_CODE);
     out("  fi");
     out("done");
     out("");
-    out("exit "+SUCCESSFUL_EXIT_CODE);
+    out("exit " + SUCCESSFUL_EXIT_CODE);
   }
 
   private void printScriptForTimeBased() throws IOException {
@@ -222,7 +233,8 @@ public class MultiThreadedRollingTest {
     }
     out("");
     out("rm aggregated");
-    out("for i in $(seq " + numfiles+" -1 0); do cat test-$i.log >> aggregated; done");
+    out("for i in $(seq " + (numfiles - 1)
+        + " -1 0); do cat test-$i.log >> aggregated; done");
     out("cat output.log >> aggregated");
     out("");
     printCommonScriptCore();
@@ -233,10 +245,11 @@ public class MultiThreadedRollingTest {
     scriptOS.write("\n".getBytes());
   }
 
-  private void executeHarness() throws InterruptedException {
+  private void executeHarness(int duration, boolean withDelay)
+      throws InterruptedException {
     MultiThreadedHarness multiThreadedHarness = new MultiThreadedHarness(
-        TOTAL_DURATION);
-    this.runnableArray = buildRunnableArray();
+        duration);
+    this.runnableArray = buildRunnableArray(withDelay);
     multiThreadedHarness.execute(runnableArray);
 
     StatusChecker checker = new StatusChecker(context.getStatusManager());
@@ -253,16 +266,25 @@ public class MultiThreadedRollingTest {
   static class RFARunnable extends RunnableWithCounterAndDone {
     RollingFileAppender<Object> rfa;
     int id;
+    boolean withInducedDelay;
 
-    RFARunnable(int id, RollingFileAppender<Object> rfa) {
+    RFARunnable(int id, RollingFileAppender<Object> rfa,
+        boolean withInducedDelay) {
       this.id = id;
       this.rfa = rfa;
+      this.withInducedDelay = withInducedDelay;
     }
 
     public void run() {
       while (!isDone()) {
         counter++;
         rfa.doAppend(id + " " + counter);
+        if ((counter % 100 == 0) && withInducedDelay) {
+          try {
+            Thread.sleep(10);
+          } catch (InterruptedException e) {
+          }
+        }
       }
     }
 
diff --git a/logback-core/src/test/java/ch/qos/logback/core/testUtil/Env.java b/logback-core/src/test/java/ch/qos/logback/core/testUtil/Env.java
index bc7f55e..e645064 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/testUtil/Env.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/testUtil/Env.java
@@ -13,6 +13,11 @@
  */
 package ch.qos.logback.core.testUtil;
 
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import ch.qos.logback.core.util.CoreTestConstants;
+
 public class Env {
 
   static public boolean isWindows() {
@@ -22,7 +27,7 @@ public class Env {
   static public boolean isMac() {
     return System.getProperty("os.name").indexOf("Mac") != -1;
   }
-  
+
   static public boolean isLinux() {
     return System.getProperty("os.name").indexOf("Linux") != -1;
   }
@@ -39,4 +44,37 @@ public class Env {
     }
   }
 
+  static public String getLocalHostName() {
+    InetAddress localhostIA;
+    try {
+      localhostIA = InetAddress.getLocalHost();
+      return localhostIA.getHostName();
+    } catch (UnknownHostException e) {
+      return null;
+    }
+  }
+
+  static public boolean isLocalHostNameInList(String[] hostList) {
+    String localHostName = getLocalHostName();
+    if (localHostName == null) {
+      return false;
+    }
+    for (String host : hostList) {
+      if (host.equalsIgnoreCase(localHostName)) {
+        return true;
+      }
+    }
+    return false;
+  }
+  
+
+  public static String getPathToBash() {
+    if(Env.isLinux()) {
+      return CoreTestConstants.BASH_PATH_ON_LINUX;
+    }
+    if(Env.isLocalHostNameInList(new String[] {"hetz"})) {
+      return CoreTestConstants.BASH_PATH_ON_CYGWIN;
+    }
+    return null;
+  }
 }
diff --git a/logback-core/src/test/java/ch/qos/logback/core/util/CoreTestConstants.java b/logback-core/src/test/java/ch/qos/logback/core/util/CoreTestConstants.java
index 55f0761..29c180c 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/util/CoreTestConstants.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/util/CoreTestConstants.java
@@ -23,5 +23,6 @@ public class CoreTestConstants {
   public static final int SUCCESSFUL_EXIT_CODE = 8;
   public static final int FAILURE_EXIT_CODE = 1;
  
-  public static final String BASH_PATH = "c:/cygwin/bin/bash";
+  public static final String BASH_PATH_ON_CYGWIN = "c:/cygwin/bin/bash";
+  public static final String BASH_PATH_ON_LINUX = "bash";
 }

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

Summary of changes:
 .../access/db/DBAppenderIntegrationTest.java       |   12 +---
 .../core/rolling/MultiThreadedRollingTest.java     |   68 +++++++++++++-------
 .../java/ch/qos/logback/core/testUtil/Env.java     |   40 +++++++++++-
 .../qos/logback/core/util/CoreTestConstants.java   |    3 +-
 4 files changed, 88 insertions(+), 35 deletions(-)


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


More information about the logback-dev mailing list