zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r1156497 - in /zookeeper/trunk: ./ src/java/main/org/apache/zookeeper/server/ src/java/test/org/apache/zookeeper/test/
Date Thu, 11 Aug 2011 06:00:21 GMT
Author: mahadev
Date: Thu Aug 11 06:00:21 2011
New Revision: 1156497

URL: http://svn.apache.org/viewvc?rev=1156497&view=rev
Log:
ZOOKEEPER-1142. incorrect stat output (phunt via mahadev)

Modified:
    zookeeper/trunk/CHANGES.txt
    zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java
    zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NettyServerCnxn.java
    zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerCnxn.java
    zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FourLetterWordsTest.java

Modified: zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1156497&r1=1156496&r2=1156497&view=diff
==============================================================================
--- zookeeper/trunk/CHANGES.txt (original)
+++ zookeeper/trunk/CHANGES.txt Thu Aug 11 06:00:21 2011
@@ -272,6 +272,8 @@ BUGFIXES: 
 
   ZOOKEEPER-1139. jenkins is reporting two warnings, fix these (phunt via mahadev)
 
+  ZOOKEEPER-1142. incorrect stat output (phunt via mahadev)
+
 IMPROVEMENTS:
   ZOOKEEPER-724. Improve junit test integration - log harness information 
   (phunt via mahadev)

Modified: zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java?rev=1156497&r1=1156496&r2=1156497&view=diff
==============================================================================
--- zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java (original)
+++ zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java Thu Aug 11
06:00:21 2011
@@ -660,6 +660,7 @@ public class NIOServerCnxn extends Serve
                     }
                     for(NIOServerCnxn c : cnxnset){
                         c.dumpConnectionInfo(pw, true);
+                        pw.println();
                     }
                     pw.println();
                 }
@@ -690,6 +691,7 @@ public class NIOServerCnxn extends Serve
                 }
                 for (NIOServerCnxn c : cnxns) {
                     c.dumpConnectionInfo(pw, false);
+                    pw.println();
                 }
                 pw.println();
             }

Modified: zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NettyServerCnxn.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NettyServerCnxn.java?rev=1156497&r1=1156496&r2=1156497&view=diff
==============================================================================
--- zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NettyServerCnxn.java (original)
+++ zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NettyServerCnxn.java Thu Aug
11 06:00:21 2011
@@ -472,6 +472,7 @@ public class NettyServerCnxn extends Ser
                     }
                     for(ServerCnxn c : cnxns){
                         c.dumpConnectionInfo(pw, true);
+                        pw.println();
                     }
                     pw.println();
                 }
@@ -501,6 +502,7 @@ public class NettyServerCnxn extends Ser
                 }
                 for (ServerCnxn c : cnxns) {
                     c.dumpConnectionInfo(pw, false);
+                    pw.println();
                 }
                 pw.println();
             }

Modified: zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerCnxn.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerCnxn.java?rev=1156497&r1=1156496&r2=1156497&view=diff
==============================================================================
--- zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerCnxn.java (original)
+++ zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerCnxn.java Thu Aug 11 06:00:21
2011
@@ -442,6 +442,7 @@ public abstract class ServerCnxn impleme
                 pwriter.print(getMaxLatency());
             }
         }
+        pwriter.print(")");
     }
 
 }

Modified: zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FourLetterWordsTest.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FourLetterWordsTest.java?rev=1156497&r1=1156496&r2=1156497&view=diff
==============================================================================
--- zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FourLetterWordsTest.java (original)
+++ zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FourLetterWordsTest.java Thu Aug
11 06:00:21 2011
@@ -18,13 +18,17 @@
 
 package org.apache.zookeeper.test;
 
+import java.io.BufferedReader;
 import java.io.IOException;
+import java.io.StringReader;
+import java.util.regex.Pattern;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.zookeeper.TestableZooKeeper;
+import org.apache.zookeeper.ZooKeeper;
 import org.junit.Assert;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class FourLetterWordsTest extends ClientBase {
     protected static final Logger LOG =
@@ -91,10 +95,76 @@ public class FourLetterWordsTest extends
         verify("mntr", "zk_server_state\tstandalone");
     }
 
+    private String sendRequest(String cmd) throws IOException {
+      HostPort hpobj = ClientBase.parseHostPortList(hostPort).get(0);
+      return ClientBase.send4LetterWord(hpobj.host, hpobj.port, cmd);
+    }
+
     private void verify(String cmd, String expected) throws IOException {
-        HostPort hpobj = parseHostPortList(hostPort).get(0);
-        String resp = send4LetterWord(hpobj.host, hpobj.port, cmd);
+        String resp = sendRequest(cmd);
         LOG.info("cmd " + cmd + " expected " + expected + " got " + resp);
         Assert.assertTrue(resp.contains(expected));
     }
+    
+    @Test
+    public void validateStatOutput() throws Exception {
+        ZooKeeper zk1 = createClient();
+        ZooKeeper zk2 = createClient();
+        
+        String resp = sendRequest("stat");
+        BufferedReader in = new BufferedReader(new StringReader(resp));
+
+        String line;
+        // first line should be version info
+        line = in.readLine();
+        Assert.assertTrue(Pattern.matches("^.*\\s\\d+\\.\\d+\\.\\d+-.*$", line));
+        Assert.assertTrue(Pattern.matches("^Clients:$", in.readLine()));
+
+        int count = 0;
+        while ((line = in.readLine()).length() > 0) {
+            count++;
+            Assert.assertTrue(Pattern.matches("^ /.*:\\d+\\[\\d+\\]\\(queued=\\d+,recved=\\d+,sent=\\d+\\)$",
line));
+        }
+        // ensure at least the two clients we created are accounted for
+        Assert.assertTrue(count >= 2);
+
+        line = in.readLine();
+        Assert.assertTrue(Pattern.matches("^Latency min/avg/max: \\d+/\\d+/\\d+$", line));
+        line = in.readLine();
+        Assert.assertTrue(Pattern.matches("^Received: \\d+$", line));
+        line = in.readLine();
+        Assert.assertTrue(Pattern.matches("^Sent: \\d+$", line));
+        line = in.readLine();
+        Assert.assertTrue(Pattern.matches("^Outstanding: \\d+$", line));
+        line = in.readLine();
+        Assert.assertTrue(Pattern.matches("^Zxid: 0x[\\da-fA-F]+$", line));
+        line = in.readLine();
+        Assert.assertTrue(Pattern.matches("^Mode: .*$", line));
+        line = in.readLine();
+        Assert.assertTrue(Pattern.matches("^Node count: \\d+$", line));
+
+        zk1.close();
+        zk2.close();
+    }
+
+    @Test
+    public void validateConsOutput() throws Exception {
+        ZooKeeper zk1 = createClient();
+        ZooKeeper zk2 = createClient();
+        
+        String resp = sendRequest("cons");
+        BufferedReader in = new BufferedReader(new StringReader(resp));
+
+        String line;
+        int count = 0;
+        while ((line = in.readLine()) != null && line.length() > 0) {
+            count++;
+            Assert.assertTrue(line, Pattern.matches("^ /.*:\\d+\\[\\d+\\]\\(queued=\\d+,recved=\\d+,sent=\\d+.*\\)$",
line));
+        }
+        // ensure at least the two clients we created are accounted for
+        Assert.assertTrue(count >= 2);
+
+        zk1.close();
+        zk2.close();
+    }
 }



Mime
View raw message