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

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Fri Feb 12 17:58:24 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  3511d5fac561b6e34b8b3e615a87567e7ee1f51b (commit)
      from  183395777e6e189e69198f24567d7d214d163f4e (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=3511d5fac561b6e34b8b3e615a87567e7ee1f51b
http://github.com/ceki/logback/commit/3511d5fac561b6e34b8b3e615a87567e7ee1f51b

commit 3511d5fac561b6e34b8b3e615a87567e7ee1f51b
Author: Ceki Gulcu <ceki at gimmel.(none)>
Date:   Fri Feb 12 17:51:43 2010 +0100

    - Preparing test bed for LBCORE-109. Unfortunately, due to the
    tight dependence on the OS, this test runs only on
    Linux. Moreover, root priviledges are required...
    
    If anyone knows how to simulate a file system space overflow is
    encouraged to share their knowledge.

diff --git a/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java b/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java
new file mode 100644
index 0000000..ddf695c
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java
@@ -0,0 +1,141 @@
+package ch.qos.logback.core;
+
+import static org.junit.Assert.*;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import ch.qos.logback.core.layout.EchoLayout;
+import ch.qos.logback.core.testUtil.RandomUtil;
+import ch.qos.logback.core.util.StatusPrinter;
+
+public class FileAppenderResilienceTest {
+
+  static String MOUNT_POINT = "/mnt/loop/";
+
+  static String LONG_STR = " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+
+  enum LoopFSCommand {
+    setup, shake, teardown;
+  }
+
+  Context context = new ContextBase();
+  int diff = RandomUtil.getPositiveInt();
+  String outputDirStr = MOUNT_POINT + "resilience-" + diff + "/";
+  String logfileStr = outputDirStr + "output.log";
+  
+  FileAppender<Object> fa = new FileAppender<Object>();
+
+  @Before
+  public void setUp() throws IOException, InterruptedException {
+    Process p = runLoopFSScript(LoopFSCommand.setup);
+    p.waitFor();
+
+    dump("/tmp/loopfs.log");
+
+    fa.setContext(context);
+    File outputDir = new File(outputDirStr);
+    outputDir.mkdirs();
+    System.out.println("FileAppenderResilienceTest output dir [" + outputDirStr
+        + "]");
+
+    fa.setName("FILE");
+    fa.setLayout(new EchoLayout<Object>());
+    fa.setFile(logfileStr);
+    fa.start();
+  }
+
+  void dump(String file) throws IOException {
+    FileInputStream fis = null;
+    try {
+      fis = new FileInputStream(file);
+      int r;
+      while ((r = fis.read()) != -1) {
+        char c = (char) r;
+        System.out.print(c);
+      }
+    } finally {
+      if (fis != null) {
+        fis.close();
+      }
+    }
+  }
+
+  
+  @After
+  public void tearDown() throws IOException, InterruptedException {
+    StatusPrinter.print(context);
+    fa.stop();
+    Process p = runLoopFSScript(LoopFSCommand.teardown);
+    p.waitFor();
+    System.out.println("Tearing down");
+  }
+
+  static int TOTAL_DURATION = 5000;
+  static int NUM_STEPS = 500;
+  static int DELAY = TOTAL_DURATION / NUM_STEPS;
+
+  @Test
+  public void go() throws IOException, InterruptedException {
+    Process p = runLoopFSScript(LoopFSCommand.shake);
+    for (int i = 0; i < NUM_STEPS; i++) {
+      fa.append(String.valueOf(i) + LONG_STR);
+      Thread.sleep(DELAY);
+    }
+    p.waitFor();
+    verify(logfileStr);
+    System.out.println("Done go");
+  }
+
+  Process runLoopFSScript(LoopFSCommand cmd) throws IOException,
+      InterruptedException {
+    ProcessBuilder pb = new ProcessBuilder();
+    pb.command("/usr/bin/sudo", "/home/ceki/loopfs.sh", cmd.toString());
+    Process process = pb.start();
+    return process;
+  }
+
+  void verify(String logfile) throws NumberFormatException, IOException {
+    FileReader fr = new FileReader(logfile);
+    BufferedReader br = new BufferedReader(fr);
+    String regExp = "^(\\d{1,3}) x*$";
+    Pattern p = Pattern.compile(regExp);
+    String line;
+    
+    int totalLines = 0;
+    int oldNum = -1;
+    int gaps = 0;
+    while ((line = br.readLine()) != null) {
+      Matcher m = p.matcher(line);
+      if (m.matches()) {
+        totalLines++;
+        String g = m.group(1);
+        int num = Integer.parseInt(g);
+        if(num != oldNum+1) {
+          gaps++;
+        }
+        oldNum = num;
+      }
+    }
+    fr.close();
+    br.close();
+
+    // at least 40% of the logs should have been written
+    int lowerLimit = (int) (NUM_STEPS*0.4);
+    assertTrue("totalLines="+totalLines+" less than "+lowerLimit, totalLines > lowerLimit);
+    
+    // we want some gaps which indicate recuperation
+    assertTrue("gaps="+gaps+" less than 3", gaps > 3);
+    
+  }
+
+}
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 4e33647..b41294d 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
@@ -66,7 +66,7 @@ public class MultiThreadedRollingTest {
     File outputDir = new File(outputDirStr);
     outputDir.mkdirs();
 
-    System.out.println("Output dir [" + outputDirStr + "]");
+    System.out.println("MultiThreadedRollingTest output dir [" + outputDirStr + "]");
 
     scriptOS = openScript();
 

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

Summary of changes:
 .../logback/core/FileAppenderResilienceTest.java   |  141 ++++++++++++++++++++
 .../core/rolling/MultiThreadedRollingTest.java     |    2 +-
 2 files changed, 142 insertions(+), 1 deletions(-)
 create mode 100644 logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java


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


More information about the logback-dev mailing list