You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2013/03/21 22:21:18 UTC

svn commit: r1459531 - in /accumulo/branches/1.5: ./ core/src/main/java/org/apache/accumulo/core/util/ core/src/main/java/org/apache/accumulo/core/util/shell/ core/src/main/java/org/apache/accumulo/core/util/shell/commands/ core/src/test/java/org/apach...

Author: ecn
Date: Thu Mar 21 21:21:17 2013
New Revision: 1459531

URL: http://svn.apache.org/r1459531
Log:
ACCUMULO-581 run a lot more shell commands using miniaccumulo cluster

Added:
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteShellIterCommand.java   (with props)
    accumulo/branches/1.5/test/src/test/java/org/apache/accumulo/test/shell/
    accumulo/branches/1.5/test/src/test/java/org/apache/accumulo/test/shell/ShellServerTest.java   (with props)
Removed:
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteShellterCommand.java
Modified:
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/LocalityGroupUtil.java
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/TableDiskUsage.java
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ClasspathCommand.java
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HistoryCommand.java
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MergeCommand.java
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/TraceCommand.java
    accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
    accumulo/branches/1.5/pom.xml
    accumulo/branches/1.5/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
    accumulo/branches/1.5/test/pom.xml
    accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/MiniAccumuloCluster.java
    accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/BulkPlusOne.java
    accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Setup.java
    accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Verify.java
    accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Write.java

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/LocalityGroupUtil.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/LocalityGroupUtil.java?rev=1459531&r1=1459530&r2=1459531&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/LocalityGroupUtil.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/LocalityGroupUtil.java Thu Mar 21 21:21:17 2013
@@ -23,6 +23,8 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
 
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
@@ -140,7 +142,7 @@ public class LocalityGroupUtil {
   }
   
   public static String encodeColumnFamilies(Set<Text> colFams) {
-    HashSet<String> ecfs = new HashSet<String>();
+    SortedSet<String> ecfs = new TreeSet<String>();
     
     StringBuilder sb = new StringBuilder();
     

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/TableDiskUsage.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/TableDiskUsage.java?rev=1459531&r1=1459530&r2=1459531&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/TableDiskUsage.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/TableDiskUsage.java Thu Mar 21 21:21:17 2013
@@ -112,9 +112,22 @@ public class TableDiskUsage {
     return externalUsage;
   }
   
+  public interface Printer {
+    void print(String line);
+  }
+  
   public static void printDiskUsage(AccumuloConfiguration acuConf, Collection<String> tables, FileSystem fs, Connector conn) throws TableNotFoundException,
-      IOException {
-    
+  IOException {
+    printDiskUsage(acuConf, tables, fs, conn, new Printer() {
+      @Override
+      public void print(String line) {
+        System.out.println(line);
+      }
+    });
+  }
+  public static void printDiskUsage(AccumuloConfiguration acuConf, Collection<String> tables, FileSystem fs, Connector conn, Printer printer) throws TableNotFoundException,
+  IOException {
+  
     TableDiskUsage tdu = new TableDiskUsage();
     
     HashSet<String> tableIds = new HashSet<String>();
@@ -204,7 +217,7 @@ public class TableDiskUsage {
     }
     
     for (Entry<TreeSet<String>,Long> entry : usage.entrySet())
-      System.out.printf("%,24d %s%n", entry.getValue(), entry.getKey());
+      printer.print(String.format("%,24d %s", entry.getValue(), entry.getKey()));
     
   }
   

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java?rev=1459531&r1=1459530&r2=1459531&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java Thu Mar 21 21:21:17 2013
@@ -84,7 +84,7 @@ import org.apache.accumulo.core.util.she
 import org.apache.accumulo.core.util.shell.commands.DeleteManyCommand;
 import org.apache.accumulo.core.util.shell.commands.DeleteRowsCommand;
 import org.apache.accumulo.core.util.shell.commands.DeleteScanIterCommand;
-import org.apache.accumulo.core.util.shell.commands.DeleteShellterCommand;
+import org.apache.accumulo.core.util.shell.commands.DeleteShellIterCommand;
 import org.apache.accumulo.core.util.shell.commands.DeleteTableCommand;
 import org.apache.accumulo.core.util.shell.commands.DeleteUserCommand;
 import org.apache.accumulo.core.util.shell.commands.DropTableCommand;
@@ -347,7 +347,7 @@ public class Shell extends ShellOptions 
     Command[] exitCommands = {new ByeCommand(), new ExitCommand(), new QuitCommand()};
     Command[] helpCommands = {new AboutCommand(), new HelpCommand(), new InfoCommand(), new QuestionCommand()};
     Command[] iteratorCommands = {new DeleteIterCommand(), new DeleteScanIterCommand(), new ListIterCommand(), new SetIterCommand(), new SetScanIterCommand(),
-        new SetShellIterCommand(), new ListShellIterCommand(), new DeleteShellterCommand()};
+        new SetShellIterCommand(), new ListShellIterCommand(), new DeleteShellIterCommand()};
     Command[] otherCommands = {new HiddenCommand()};
     Command[] permissionsCommands = {new GrantCommand(), new RevokeCommand(), new SystemPermissionsCommand(), new TablePermissionsCommand(),
         new UserPermissionsCommand()};
@@ -427,7 +427,10 @@ public class Shell extends ShellOptions 
     if (isVerbose())
       printInfo();
     
-    String configDir = System.getenv("HOME") + "/.accumulo";
+    String home = System.getProperty("HOME");
+    if (home == null)
+      home = System.getenv("HOME");
+    String configDir = home + "/.accumulo";
     String historyPath = configDir + "/shell_history.txt";
     File accumuloDir = new File(configDir);
     if (!accumuloDir.exists() && !accumuloDir.mkdirs())
@@ -962,6 +965,10 @@ public class Shell extends ShellOptions 
     this.exit = exit;
   }
   
+  public boolean getExit() {
+    return this.exit;
+  }
+  
   public boolean isVerbose() {
     return verbose;
   }

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ClasspathCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ClasspathCommand.java?rev=1459531&r1=1459530&r2=1459531&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ClasspathCommand.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ClasspathCommand.java Thu Mar 21 21:21:17 2013
@@ -16,15 +16,30 @@
  */
 package org.apache.accumulo.core.util.shell.commands;
 
+import java.io.IOException;
+
+import jline.ConsoleReader;
+
 import org.apache.accumulo.core.util.shell.Shell;
 import org.apache.accumulo.core.util.shell.Shell.Command;
 import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
+import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader.Printer;
 import org.apache.commons.cli.CommandLine;
 
 public class ClasspathCommand extends Command {
   @Override
   public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) {
-    AccumuloVFSClassLoader.printClassPath();
+    final ConsoleReader reader = shellState.getReader();
+    AccumuloVFSClassLoader.printClassPath(new Printer() {
+      @Override
+      public void print(String s) {
+        try {
+          reader.printString(s + "\n");
+        } catch (IOException ex) {
+          throw new RuntimeException(ex);
+        }
+      }
+    });
     return 0;
   }
   

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java?rev=1459531&r1=1459530&r2=1459531&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java Thu Mar 21 21:21:17 2013
@@ -25,6 +25,7 @@ import org.apache.accumulo.core.client.T
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.ConfigurationCopy;
 import org.apache.accumulo.core.util.TableDiskUsage;
+import org.apache.accumulo.core.util.TableDiskUsage.Printer;
 import org.apache.accumulo.core.util.shell.Shell;
 import org.apache.accumulo.core.util.shell.Shell.Command;
 import org.apache.commons.cli.CommandLine;
@@ -37,7 +38,7 @@ public class DUCommand extends Command {
   
   private Option optTablePattern;
   
-  public int execute(final String fullCommand, final CommandLine cl, Shell shellState) throws IOException, TableNotFoundException {
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException, TableNotFoundException {
     
     final SortedSet<String> tablesToFlush = new TreeSet<String>(Arrays.asList(cl.getArgs()));
     if (cl.hasOption(optTablePattern.getOpt())) {
@@ -49,7 +50,17 @@ public class DUCommand extends Command {
     }
     try {
       final AccumuloConfiguration acuConf = new ConfigurationCopy(shellState.getConnector().instanceOperations().getSystemConfiguration());
-      TableDiskUsage.printDiskUsage(acuConf, tablesToFlush, FileSystem.get(new Configuration()), shellState.getConnector());
+      TableDiskUsage.printDiskUsage(acuConf, tablesToFlush, FileSystem.get(new Configuration()), shellState.getConnector(), new Printer() {
+        @Override
+        public void print(String line) {
+          try {
+            shellState.getReader().printString(line + "\n");
+          } catch (IOException ex) {
+            throw new RuntimeException(ex);
+          }
+        }
+        
+      });
     } catch (Exception ex) {
       throw new RuntimeException(ex);
     }

Added: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteShellIterCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteShellIterCommand.java?rev=1459531&view=auto
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteShellIterCommand.java (added)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteShellIterCommand.java Thu Mar 21 21:21:17 2013
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.core.util.shell.commands;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.util.shell.Shell;
+import org.apache.accumulo.core.util.shell.Shell.Command;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
+
+public class DeleteShellIterCommand extends Command {
+  private Option nameOpt, allOpt, profileOpt;
+  
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+
+    String profile = cl.getOptionValue(profileOpt.getOpt());
+    if (shellState.iteratorProfiles.containsKey(profile)) {
+      if (cl.hasOption(allOpt.getOpt())) {
+        shellState.iteratorProfiles.remove(profile);
+        Shell.log.info("Removed profile " + profile);
+      } else {
+        List<IteratorSetting> iterSettings = shellState.iteratorProfiles.get(profile);
+        String name = cl.getOptionValue(nameOpt.getOpt());
+        boolean found = false;
+        for (Iterator<IteratorSetting> iter = iterSettings.iterator(); iter.hasNext();) {
+          if (iter.next().getName().equals(name)) {
+            iter.remove();
+            found = true;
+            break;
+          }
+        }
+        if (!found) {
+          Shell.log.info("No iterator named " + name + " found");
+        } else {
+          Shell.log.info("Removed iterator " + name + " from profile " + profile + " (" + iterSettings.size() + " left)");
+        }
+      }
+      
+    } else {
+      Shell.log.info("No profile named " + profile);
+    }
+    
+    return 0;
+  }
+  
+  @Override
+  public String description() {
+    return "deletes iterators profiles configured in this shell session";
+  }
+  
+  @Override
+  public Options getOptions() {
+    final Options o = new Options();
+    
+    OptionGroup nameGroup = new OptionGroup();
+    
+    nameOpt = new Option("n", "name", true, "iterator to delete");
+    nameOpt.setArgName("itername");
+    
+    allOpt = new Option("a", "all", false, "delete all scan iterators");
+    allOpt.setArgName("all");
+    
+    nameGroup.addOption(nameOpt);
+    nameGroup.addOption(allOpt);
+    nameGroup.setRequired(true);
+    o.addOptionGroup(nameGroup);
+    
+    profileOpt = new Option("pn", "profile", true, "iterator profile name");
+    profileOpt.setRequired(true);
+    profileOpt.setArgName("profile");
+    o.addOption(profileOpt);
+
+    return o;
+  }
+  
+  @Override
+  public int numArgs() {
+    return 0;
+  }
+}

Propchange: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteShellIterCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HistoryCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HistoryCommand.java?rev=1459531&r1=1459530&r2=1459531&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HistoryCommand.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HistoryCommand.java Thu Mar 21 21:21:17 2013
@@ -36,7 +36,10 @@ public class HistoryCommand extends Comm
   @Override
   public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
     
-    final String histDir = System.getenv("HOME") + "/.accumulo";
+    String home = System.getProperty("HOME");
+    if (home == null)
+      home = System.getenv("HOME");
+    final String histDir = home + "/.accumulo";
     int counter = 0;
     
     if (cl.hasOption(clearHist.getOpt())) {
@@ -60,8 +63,7 @@ public class HistoryCommand extends Comm
         try {
           Line = in.readLine();
           while (Line != null) {
-            shellState.getReader().printString(counter + " " + Line);
-            shellState.getReader().printNewline();
+            shellState.getReader().printString(counter + " " + Line + "\n");
             counter++;
             Line = in.readLine();
           }

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MergeCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MergeCommand.java?rev=1459531&r1=1459530&r2=1459531&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MergeCommand.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MergeCommand.java Thu Mar 21 21:21:17 2013
@@ -28,12 +28,13 @@ import org.apache.commons.cli.Options;
 import org.apache.hadoop.io.Text;
 
 public class MergeCommand extends Command {
-  private Option verboseOpt, forceOpt, sizeOpt;
+  private Option verboseOpt, forceOpt, sizeOpt, allOpt;
   
   @Override
   public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
     boolean verbose = shellState.isVerbose();
     boolean force = false;
+    boolean all = false;
     long size = -1;
     final String tableName = OptUtil.getTableOpt(cl, shellState);
     final Text startRow = OptUtil.getStartRow(cl);
@@ -44,10 +45,13 @@ public class MergeCommand extends Comman
     if (cl.hasOption(forceOpt.getOpt())) {
       force = true;
     }
+    if (cl.hasOption(allOpt.getOpt())) {
+      force = true;
+    }
     if (cl.hasOption(sizeOpt.getOpt())) {
       size = AccumuloConfiguration.getMemoryInBytes(cl.getOptionValue(sizeOpt.getOpt()));
     }
-    if (startRow == null && endRow == null && size < 0) {
+    if (startRow == null && endRow == null && size < 0 && all) {
       shellState.getReader().flushConsole();
       String line = shellState.getReader().readLine("Merge the entire table { " + tableName + " } into one tablet (yes|no)? ");
       if (line == null)
@@ -92,6 +96,7 @@ public class MergeCommand extends Comman
     verboseOpt = new Option("v", "verbose", false, "verbose output during merge");
     sizeOpt = new Option("s", "size", true, "merge tablets to the given size over the entire table");
     forceOpt = new Option("f", "force", false, "merge small tablets to large tablets, even if it goes over the given size");
+    allOpt = new Option("", "all", false, "allow an entire table to be merged into one tablet without prompting the user for confirmation");
     Option startRowOpt = OptUtil.startRowOpt();
     startRowOpt.setDescription("begin row (NOT inclusive)");
     o.addOption(startRowOpt);
@@ -100,6 +105,7 @@ public class MergeCommand extends Comman
     o.addOption(verboseOpt);
     o.addOption(sizeOpt);
     o.addOption(forceOpt);
+    o.addOption(allOpt);
     return o;
   }
   

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/TraceCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/TraceCommand.java?rev=1459531&r1=1459530&r2=1459531&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/TraceCommand.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/TraceCommand.java Thu Mar 21 21:21:17 2013
@@ -42,7 +42,7 @@ public class TraceCommand extends DebugC
         if (Trace.isTracing()) {
           final long trace = Trace.currentTrace().traceId();
           Trace.off();
-          for (int i = 0; i < 10; i++) {
+          for (int i = 0; i < 30; i++) {
             try {
               final Map<String,String> properties = shellState.getConnector().instanceOperations().getSystemConfiguration();
               final String table = properties.get(Property.TRACE_TABLE.getKey());

Modified: accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java?rev=1459531&r1=1459530&r2=1459531&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java (original)
+++ accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java Thu Mar 21 21:21:17 2013
@@ -32,7 +32,7 @@ import org.junit.Before;
 import org.junit.Test;
 
 public class ShellTest {
-  static class TestOutputStream extends OutputStream {
+  public static class TestOutputStream extends OutputStream {
     StringBuilder sb = new StringBuilder();
     
     @Override
@@ -164,4 +164,5 @@ public class ShellTest {
     Shell.log.debug("Starting user test --------------------------");
     //exec("createuser root", false, "user exists");
   }
+  
 }

Modified: accumulo/branches/1.5/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/pom.xml?rev=1459531&r1=1459530&r2=1459531&view=diff
==============================================================================
--- accumulo/branches/1.5/pom.xml (original)
+++ accumulo/branches/1.5/pom.xml Thu Mar 21 21:21:17 2013
@@ -197,7 +197,7 @@
       <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
-          <redirectTestOutputToFile>true</redirectTestOutputToFile>
+          <redirectTestOutputToFile>false</redirectTestOutputToFile>
         </configuration>
       </plugin>
     </plugins>
@@ -520,6 +520,12 @@
             <version>${hadoop.version}</version>
             <scope>provided</scope>
           </dependency>
+          <dependency>
+            <groupId>org.apache.hadoop</groupId>
+            <artifactId>hadoop-tools</artifactId>
+            <version>${hadoop.version}</version>
+            <scope>test</scope>
+          </dependency>
         </dependencies>
       </dependencyManagement>
     </profile>
@@ -548,6 +554,12 @@
             <scope>provided</scope>
           </dependency>
           <dependency>
+            <groupId>org.apache.hadoop</groupId>
+            <artifactId>hadoop-distcp</artifactId>
+            <version>${hadoop.version}</version>
+            <scope>test</scope>
+          </dependency>
+          <dependency>
             <groupId>org.apache.avro</groupId>
             <artifactId>avro</artifactId>
             <version>${avro.version}</version>

Modified: accumulo/branches/1.5/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java?rev=1459531&r1=1459530&r2=1459531&view=diff
==============================================================================
--- accumulo/branches/1.5/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java (original)
+++ accumulo/branches/1.5/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java Thu Mar 21 21:21:17 2013
@@ -261,8 +261,19 @@ public class AccumuloVFSClassLoader {
 
     return localLoader.getClassLoader();
   }
+  public interface Printer {
+    void print(String s);
+  }
   
   public static void printClassPath() {
+    printClassPath(new Printer() {
+      @Override
+      public void print(String s) { 
+        System.out.println(s);
+      }
+    });
+  }
+  public static void printClassPath(Printer out) {
     try {
       ClassLoader cl = getClassLoader();
       ArrayList<ClassLoader> classloaders = new ArrayList<ClassLoader>();
@@ -278,27 +289,26 @@ public class AccumuloVFSClassLoader {
       
       for (ClassLoader classLoader : classloaders) {
         if (level > 0)
-          System.out.println();
-        System.out.print("Level " + level + " ");
+          out.print("");
         level++;
         
         if (classLoader instanceof URLClassLoader) {
           // If VFS class loader enabled, but no contexts defined.
           URLClassLoader ucl = (URLClassLoader) classLoader;
-          System.out.println("URL classpath items are:");
+          out.print("Level " + level + " URL classpath items are:");
 
             for (URL u : ucl.getURLs()) {
-              System.out.println("\t" + u.toExternalForm());
+              out.print("\t" + u.toExternalForm());
             }
 
         } else if (classLoader instanceof VFSClassLoader) {
-          System.out.println("VFS classpaths items are:");
+          out.print("Level " + level + " VFS classpaths items are:");
           VFSClassLoader vcl = (VFSClassLoader) classLoader;
           for (FileObject f : vcl.getFileObjects()) {
-            System.out.println("\t" + f.getURL().toExternalForm());
+            out.print("\t" + f.getURL().toExternalForm());
           }
         } else {
-          System.out.println("Unknown classloader configuration " + classLoader.getClass());
+          out.print("Unknown classloader configuration " + classLoader.getClass());
         }
       }
       

Modified: accumulo/branches/1.5/test/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/pom.xml?rev=1459531&r1=1459530&r2=1459531&view=diff
==============================================================================
--- accumulo/branches/1.5/test/pom.xml (original)
+++ accumulo/branches/1.5/test/pom.xml Thu Mar 21 21:21:17 2013
@@ -111,6 +111,10 @@
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-math</artifactId>
     </dependency>
+    <dependency>
+    	<groupId>org.apache.hadoop</groupId>
+    	<artifactId>hadoop-tools</artifactId>
+    </dependency>
   </dependencies>
 
 </project>

Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/MiniAccumuloCluster.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/MiniAccumuloCluster.java?rev=1459531&r1=1459530&r2=1459531&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/MiniAccumuloCluster.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/MiniAccumuloCluster.java Thu Mar 21 21:21:17 2013
@@ -148,7 +148,7 @@ public class MiniAccumuloCluster {
     throw new RuntimeException("Unable to find port");
   }
   
-  private Process exec(Class<? extends Object> clazz, String... args) throws IOException {
+  public Process exec(Class<? extends Object> clazz, String... args) throws IOException {
     String javaHome = System.getProperty("java.home");
     String javaBin = javaHome + File.separator + "bin" + File.separator + "java";
     String classpath = System.getProperty("java.class.path");
@@ -263,6 +263,8 @@ public class MiniAccumuloCluster {
     appendProp(fileWriter, Property.TSERV_MAXMEM, "50M", siteConfig);
     appendProp(fileWriter, Property.TSERV_WALOG_MAX_SIZE, "100M", siteConfig);
     appendProp(fileWriter, Property.TSERV_NATIVEMAP_ENABLED, "false", siteConfig);
+    appendProp(fileWriter, Property.TRACE_LOGIN_PROPERTIES  + ".password", config.getRootPassword(), siteConfig);
+    appendProp(fileWriter, Property.TRACE_PORT, "" + getRandomFreePort(), siteConfig);
     // since there is a small amount of memory, check more frequently for majc... setting may not be needed in 1.5
     appendProp(fileWriter, Property.TSERV_MAJC_DELAY, "3", siteConfig);
     String cp = System.getenv("ACCUMULO_HOME")+"/lib/.*.jar,"+

Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/BulkPlusOne.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/BulkPlusOne.java?rev=1459531&r1=1459530&r2=1459531&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/BulkPlusOne.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/BulkPlusOne.java Thu Mar 21 21:21:17 2013
@@ -100,6 +100,7 @@ public class BulkPlusOne extends BulkTes
     fs.delete(dir, true);
     FileStatus[] failures = fs.listStatus(fail);
     if (failures != null && failures.length > 0) {
+      state.set("bulkImportSuccess", "false");
       throw new Exception(failures.length + " failure files found importing files from " + dir);
     }
     fs.delete(fail, true);

Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Setup.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Setup.java?rev=1459531&r1=1459530&r2=1459531&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Setup.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Setup.java Thu Mar 21 21:21:17 2013
@@ -59,6 +59,7 @@ public class Setup extends Test {
     }
     state.set("rand", rand);
     state.set("fs", FileSystem.get(CachedConfiguration.getInstance()));
+    state.set("bulkImportSuccess", "true");
     BulkPlusOne.counter.set(0l);
     
     ThreadPoolExecutor e = new SimpleThreadPool(MAX_POOL_SIZE, "bulkImportPool");

Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Verify.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Verify.java?rev=1459531&r1=1459530&r2=1459531&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Verify.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Verify.java Thu Mar 21 21:21:17 2013
@@ -50,6 +50,10 @@ public class Verify extends Test {
       lastSize = size;
       threadPool.awaitTermination(10, TimeUnit.SECONDS);
     }
+    if (!"true".equals(state.get("bulkImportSuccess"))) {
+      log.info("Not verifying bulk import test due to import failures");
+      return;
+    }
     
     String user = state.getConnector().whoami();
     Authorizations auths = state.getConnector().securityOperations().getUserAuthorizations(user);

Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Write.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Write.java?rev=1459531&r1=1459530&r2=1459531&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Write.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Write.java Thu Mar 21 21:21:17 2013
@@ -24,6 +24,7 @@ import java.util.UUID;
 
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.client.TableOfflineException;
 import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.test.randomwalk.State;
@@ -37,7 +38,7 @@ public class Write extends Test {
     
     @SuppressWarnings("unchecked")
     ArrayList<String> tables = (ArrayList<String>) state.get("tableList");
-    
+
     if (tables.isEmpty()) {
       log.debug("No tables to ingest into");
       return;
@@ -49,6 +50,9 @@ public class Write extends Test {
     BatchWriter bw = null;
     try {
       bw = state.getMultiTableBatchWriter().getBatchWriter(tableName);
+    } catch (TableOfflineException e) {
+      log.error("Table " + tableName + " is offline!");
+      return;
     } catch (TableNotFoundException e) {
       log.error("Table " + tableName + " not found!");
       return;

Added: accumulo/branches/1.5/test/src/test/java/org/apache/accumulo/test/shell/ShellServerTest.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/test/java/org/apache/accumulo/test/shell/ShellServerTest.java?rev=1459531&view=auto
==============================================================================
--- accumulo/branches/1.5/test/src/test/java/org/apache/accumulo/test/shell/ShellServerTest.java (added)
+++ accumulo/branches/1.5/test/src/test/java/org/apache/accumulo/test/shell/ShellServerTest.java Thu Mar 21 21:21:17 2013
@@ -0,0 +1,642 @@
+package org.apache.accumulo.test.shell;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.Map.Entry;
+
+import jline.ConsoleReader;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.client.ZooKeeperInstance;
+import org.apache.accumulo.core.client.security.tokens.PasswordToken;
+import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.file.FileOperations;
+import org.apache.accumulo.core.file.FileSKVWriter;
+import org.apache.accumulo.core.util.UtilWaitThread;
+import org.apache.accumulo.core.util.shell.Shell;
+import org.apache.accumulo.server.trace.TraceServer;
+import org.apache.accumulo.test.MiniAccumuloCluster;
+import org.apache.accumulo.test.MiniAccumuloConfig;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.tools.DistCp;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+public class ShellServerTest {
+  public static class TestOutputStream extends OutputStream {
+    StringBuilder sb = new StringBuilder();
+    
+    @Override
+    public void write(int b) throws IOException {
+      sb.append((char) (0xff & b));
+    }
+    
+    public String get() {
+      return sb.toString();
+    }
+    
+    public void clear() {
+      sb.setLength(0);
+    }
+  }
+  
+  private static String secret = "superSecret";
+  public static TemporaryFolder folder = new TemporaryFolder();
+  public static MiniAccumuloCluster cluster;
+  public static TestOutputStream output;
+  public static Shell shell;
+  private static Process traceProcess;
+  
+  static String exec(String cmd) throws IOException {
+    output.clear();
+    shell.execCommand(cmd, true, true);
+    return output.get();
+  }
+  
+  static String exec(String cmd, boolean expectGoodExit) throws IOException {
+    String result = exec(cmd);
+    if (expectGoodExit)
+      assertGoodExit("", true);
+    else
+      assertBadExit("", true);
+    return result;
+  }
+  
+  static String exec(String cmd, boolean expectGoodExit, String expectString) throws IOException {
+    return exec(cmd, expectGoodExit, expectString, true);
+  }
+  
+  static String exec(String cmd, boolean expectGoodExit, String expectString, boolean stringPresent) throws IOException {
+    String result = exec(cmd);
+    if (expectGoodExit)
+      assertGoodExit(expectString, stringPresent);
+    else
+      assertBadExit(expectString, stringPresent);
+    return result;
+  }
+  
+  static void assertGoodExit(String s, boolean stringPresent) {
+    Shell.log.debug(output.get());
+    assertEquals(shell.getExitCode(), 0);
+    if (s.length() > 0)
+      assertEquals(s + " present in " + output.get() + " was not " + stringPresent, stringPresent, output.get().contains(s));
+  }
+  
+  static void assertBadExit(String s, boolean stringPresent) {
+    Shell.log.debug(output.get());
+    assertTrue(shell.getExitCode() > 0);
+    if (s.length() > 0)
+      assertEquals(s + " present in " + output.get() + " was not " + stringPresent, stringPresent, output.get().contains(s));
+    shell.resetExitCode();
+  }
+  
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {
+    folder.create();
+    MiniAccumuloConfig cfg = new MiniAccumuloConfig(folder.getRoot(), secret);
+    cluster = new MiniAccumuloCluster(cfg);
+    cluster.start();
+    
+    System.setProperty("HOME", folder.getRoot().getAbsolutePath());
+    
+    // start the shell
+    output = new TestOutputStream();
+    shell = new Shell(new ConsoleReader(new FileInputStream(FileDescriptor.in), new OutputStreamWriter(output)));
+    shell.setLogErrorsToConsole();
+    shell.config("-u", "root", "-p", secret, "-z", cluster.getInstanceName(), cluster.getZooKeepers());
+    exec("quit", true);
+    shell.start();
+    shell.setExit(false);
+    traceProcess = cluster.exec(TraceServer.class);
+  }
+  
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception {
+    cluster.stop();
+    traceProcess.destroy();
+    //folder.delete();
+  }
+  
+  @Test(timeout = 30000)
+  public void exporttableImporttable() throws Exception {
+    // exporttable / importtable
+    exec("createtable t -evc", true);
+    make10();
+    exec("addsplits row5", true);
+    exec("config -t t -s table.split.threshold=345M", true);
+    exec("offline t", true);
+    String export = folder.newFolder().getName();
+    exec("exporttable -t t " + export, true);
+    DistCp cp = new DistCp(new Configuration());
+    String import_ = "/tmp/import";
+    cp.run(new String[] {"-f", export + "/distcp.txt", import_});
+    exec("importtable t2 " + import_, true);
+    exec("config -t t2 -np", true, "345M", true);
+    exec("getsplits -t t2", true, "row5", true);
+    exec("constraint --list -t t2", true, "VisibilityConstraint=1", true);
+    exec("onlinetable t", true);
+    exec("deletetable -f t", true);
+    exec("deletetable -f t2", true);
+  }
+  
+  @Test(timeout = 30000)
+  public void setscaniterDeletescaniter() throws Exception {
+    // setscaniter, deletescaniter
+    exec("createtable t");
+    exec("insert a cf cq 1");
+    exec("insert a cf cq 1");
+    exec("insert a cf cq 1");
+    shell.getReader().setInput(new ByteArrayInputStream("true\n\n\nSTRING\n".getBytes()));
+    exec("setscaniter -class org.apache.accumulo.core.iterators.user.SummingCombiner -p 10 -n name", true);
+    exec("scan", true, "3", true);
+    exec("deletescaniter -n name", true);
+    exec("scan", true, "1", true);
+    exec("deletetable -f t");
+    
+  }
+  
+  @Test(timeout = 30000)
+  public void execfile() throws Exception {
+    // execfile
+    File file = folder.newFile();
+    PrintWriter writer = new PrintWriter(file.getAbsolutePath());
+    writer.println("about");
+    writer.close();
+    exec("execfile " + file.getAbsolutePath(), true, Constants.VERSION, true);
+    
+  }
+  
+  @Test(timeout = 30000)
+  public void egrep() throws Exception {
+    // egrep
+    exec("createtable t");
+    make10();
+    String lines = exec("egrep row[123]", true);
+    assertTrue(lines.split("\n").length - 1 == 3);
+    exec("deletetable -f t");
+  }
+  
+  @Test(timeout = 30000)
+  public void du() throws Exception {
+    // du
+    exec("createtable t");
+    make10();
+    exec("flush -t t -w");
+    exec("du t", true, " [t]", true);
+    exec("deletetable -f t");
+  }
+  
+  @Test(timeout = 30000)
+  public void user() throws Exception {
+    // createuser, deleteuser, user, users, droptable
+    shell.getReader().setInput(new ByteArrayInputStream("secret\nsecret\n".getBytes()));
+    exec("createuser xyzzy", true);
+    exec("users", true, "xyzzy", true);
+    exec("grant -u xyzzy -s System.CREATE_TABLE", true);
+    shell.getReader().setInput(new ByteArrayInputStream("secret\nsecret\n".getBytes()));
+    exec("user xyzzy", true);
+    exec("createtable t", true, "xyzzy@", true);
+    exec("insert row1 cf cq 1", true);
+    exec("scan", true, "row1", true);
+    exec("droptable -f t", true);
+    exec("deleteuser xyzzy", false, "delete yourself", true);
+    shell.getReader().setInput(new ByteArrayInputStream((secret + "\n" + secret + "\n").getBytes()));
+    exec("user root", true);
+    exec("deleteuser xyzzy", true);
+    exec("users", true, "xyzzy", false);
+  }
+  
+  @Test(timeout = 30000)
+  public void iter() throws Exception {
+    // setshelliter, listshelliter, deleteshelliter
+    exec("createtable t");
+    exec("insert a cf cq 1");
+    exec("insert a cf cq 1");
+    exec("insert a cf cq 1");
+    shell.getReader().setInput(new ByteArrayInputStream("true\n\n\nSTRING\n".getBytes()));
+    exec("setshelliter -class org.apache.accumulo.core.iterators.user.SummingCombiner -p 10 -pn sum -n name", true);
+    shell.getReader().setInput(new ByteArrayInputStream("true\n\n\nSTRING\n".getBytes()));
+    exec("setshelliter -class org.apache.accumulo.core.iterators.user.SummingCombiner -p 11 -pn sum -n xyzzy", true);
+    exec("scan -pn sum", true, "3", true);
+    exec("listshelliter", true, "Iterator name", true);
+    exec("listshelliter", true, "Iterator xyzzy", true);
+    exec("listshelliter", true, "Profile : sum", true);
+    exec("deleteshelliter -pn sum -n name", true);
+    exec("listshelliter", true, "Iterator name", false);
+    exec("listshelliter", true, "Iterator xyzzy", true);
+    exec("deleteshelliter -pn sum -a", true);
+    exec("listshelliter", true, "Iterator xyzzy", false);
+    exec("listshelliter", true, "Profile : sum", false);
+    exec("deletetable -f t");
+    // list iter
+    exec("createtable t");
+    exec("insert a cf cq 1");
+    exec("insert a cf cq 1");
+    exec("insert a cf cq 1");
+    shell.getReader().setInput(new ByteArrayInputStream("true\n\n\nSTRING\n".getBytes()));
+    exec("setiter -scan -class org.apache.accumulo.core.iterators.user.SummingCombiner -p 10 -n name", true);
+    shell.getReader().setInput(new ByteArrayInputStream("true\n\n\nSTRING\n".getBytes()));
+    exec("setiter -scan -class org.apache.accumulo.core.iterators.user.SummingCombiner -p 11 -n xyzzy", true);
+    exec("scan", true, "3", true);
+    exec("listiter -scan", true, "Iterator name", true);
+    exec("listiter -scan", true, "Iterator xyzzy", true);
+    exec("listiter -minc", true, "Iterator name", false);
+    exec("listiter -minc", true, "Iterator xyzzy", false);
+    exec("deleteiter -scan -n name", true);
+    exec("listiter -scan", true, "Iterator name", false);
+    exec("listiter -scan", true, "Iterator xyzzy", true);
+    exec("deletetable -f t");
+    
+  }
+  
+  @Test(timeout = 30000)
+  public void notable() throws Exception {
+    // notable
+    exec("createtable xyzzy", true);
+    exec("scan", true, " xyzzy>", true);
+    assert (output.get().contains(" xyzzy>"));
+    exec("notable", true);
+    exec("scan", false, "Not in a table context.", true);
+    assert (output.get().contains(" xyzzy>"));
+    exec("deletetable -f xyzzy");
+  }
+  
+  @Test(timeout = 30000)
+  public void sleep() throws Exception {
+    // sleep
+    long now = System.currentTimeMillis();
+    exec("sleep 0.2", true);
+    long diff = System.currentTimeMillis() - now;
+    assertTrue(diff >= 200);
+    assertTrue(diff < 400);
+  }
+  
+  @Test(timeout = 30000)
+  public void addauths() throws Exception {
+    // addauths
+    exec("createtable xyzzy -evc");
+    exec("insert a b c d -l foo", true, "does not have authorization", true);
+    exec("addauths -s foo,bar", true);
+    exec("getauths", true, "foo,bar", true);
+    exec("insert a b c d -l foo");
+    exec("scan", true, "[foo]");
+    exec("scan -s bar", true, "[foo]", false);
+    exec("deletetable -f xyzzy");
+  }
+  
+  @Test(timeout = 30000)
+  public void byeQuitExit() throws Exception {
+    // bye, quit, exit
+    for (String cmd : "bye quit exit".split(" ")) {
+      assertFalse(shell.getExit());
+      exec(cmd);
+      assertTrue(shell.getExit());
+      shell.setExit(false);
+    }
+  }
+  
+  @Test(timeout = 30000)
+  public void classpath() throws Exception {
+    // classpath
+    exec("classpath", true, "Level 2 URL classpath items are", true);
+  }
+  
+  @Test(timeout = 30000)
+  public void clearCls() throws Exception {
+    // clear/cls
+    exec("cls", true, "[1;1H");
+    exec("clear", true, "[2J");
+  }
+  
+  @Test(timeout = 30000)
+  public void clonetable() throws Exception {
+    // clonetable
+    exec("createtable orig -evc");
+    exec("config -t orig -s table.split.threshold=123M");
+    exec("addsplit -t orig a b c");
+    exec("insert a b c value");
+    exec("scan", true, "value", true);
+    exec("clonetable orig clone");
+    // verify constraint, config, and splits were cloned
+    exec("constraint --list -t clone", true, "VisibilityConstraint=1", true);
+    exec("config -t clone -np", true, "123M", true);
+    String out = exec("getsplits -t clone"); // , true, "a\nb\nc\n");
+    // compact
+    exec("createtable c");
+    // make two files
+    exec("insert a b c d");
+    exec("flush -w");
+    exec("insert x y z v");
+    exec("flush -w");
+    int oldCount = countFiles();
+    // merge two files into one
+    exec("compact -t c -w");
+    assertTrue(countFiles() < oldCount);
+    exec("addsplits -t c f");
+    // make two more files:
+    exec("insert m 1 2 3");
+    exec("flush -w");
+    exec("insert n 1 2 3");
+    exec("flush -w");
+    oldCount = countFiles();
+    // at this point there are 3 files in the default tablet
+    // compact some data:
+    exec("compact -b g -e z -w");
+    assertTrue(countFiles() == oldCount - 2);
+    exec("compact -w");
+    assertTrue(countFiles() == oldCount - 2);
+    exec("merge --all -t c");
+    exec("compact -w");
+    assertTrue(countFiles() == oldCount - 3);
+    exec("deletetable orig");
+    exec("deletetable clone");
+    exec("deletetable c");
+  }
+  
+  @Test(timeout = 30000)
+  public void constraint() throws Exception {
+    // constraint
+    exec("constraint -l -t !METADATA", true, "MetadataConstraints=1", true);
+    exec("createtable c -evc");
+    exec("constraint -l -t c", true, "VisibilityConstraint=1", true);
+    exec("constraint -t c -d 1", true, "Removed constraint 1 from table c");
+    exec("constraint -l -t c", true, "VisibilityConstraint=1", false);
+    exec("deletetable -f c");
+  }
+  
+  @Test(timeout = 30000)
+  public void deletemany() throws Exception {
+    // deletemany
+    exec("createtable t");
+    make10();
+    assertEquals(10, countkeys("t"));
+    exec("deletemany -f -b row8");
+    assertEquals(8, countkeys("t"));
+    exec("scan -t t -np", true, "row8", false);
+    make10();
+    exec("deletemany -f -b row4 -e row5");
+    assertEquals(8, countkeys("t"));
+    make10();
+    exec("deletemany -f -c cf:col4,cf:col5");
+    assertEquals(8, countkeys("t"));
+    make10();
+    exec("deletemany -f -r row3");
+    assertEquals(9, countkeys("t"));
+    make10();
+    exec("deletemany -f -r row3");
+    assertEquals(9, countkeys("t"));
+    make10();
+    exec("deletemany -f -b row3 -be -e row5 -ee");
+    assertEquals(9, countkeys("t"));
+    exec("deletetable -f t");
+  }
+  
+  @Test(timeout = 30000)
+  public void deleterows() throws Exception {
+    // deleterows
+    int base = countFiles();
+    exec("createtable t");
+    exec("addsplits row5 row7");
+    make10();
+    exec("flush -w -t t");
+    assertTrue(base + 3 == countFiles());
+    exec("deleterows -t t -b row5 -e row7", true);
+    assertTrue(base + 2 == countFiles());
+    exec("deletetable -f t");
+  }
+  
+  @Test(timeout = 30000)
+  public void groups() throws Exception {
+    exec("createtable t");
+    exec("setgroups -t t alpha=a,b,c num=3,2,1");
+    exec("getgroups -t t", true, "alpha=a,b,c", true);
+    exec("getgroups -t t", true, "num=1,2,3", true);
+    exec("deletetable -f t");
+  }
+  
+  @Test(timeout = 30000)
+  public void grep() throws Exception {
+    exec("createtable t", true);
+    make10();
+    exec("grep row[123]", true, "row1", false);
+    exec("grep row5", true, "row5", true);
+    exec("deletetable -f t", true);
+  }
+  
+  @Test(timeout = 30000)
+  public void help() throws Exception {
+    exec("help -np", true, "Help Commands", true);
+  }
+  
+  // @Test(timeout = 30000)
+  public void history() throws Exception {
+    exec("history -c", true);
+    exec("createtable unusualstring");
+    exec("deletetable -f unusualstring");
+    exec("history", true, "unusualstring", true);
+    exec("history", true, "history", true);
+  }
+  
+  @Test(timeout = 30000)
+  public void importDirectory() throws Exception {
+    Configuration conf = new Configuration();
+    FileSystem fs = FileSystem.get(conf);
+    fs.delete(new Path("/tmp/import"), true);
+    fs.delete(new Path("/tmp/errors"), true);
+    String even = "/tmp/import/even.rf";
+    String odd = "/tmp/import/odd.rf";
+    fs.mkdirs(new Path("/tmp/errors"));
+    AccumuloConfiguration aconf = AccumuloConfiguration.getDefaultConfiguration();
+    FileSKVWriter evenWriter = FileOperations.getInstance().openWriter(even, fs, conf, aconf);
+    evenWriter.startDefaultLocalityGroup();
+    FileSKVWriter oddWriter = FileOperations.getInstance().openWriter(odd, fs, conf, aconf);
+    oddWriter.startDefaultLocalityGroup();
+    long ts = System.currentTimeMillis();
+    Text cf = new Text("cf");
+    Text cq = new Text("cq");
+    Value value = new Value("value".getBytes());
+    for (int i = 0; i < 100; i += 2) {
+      Key key = new Key(new Text(String.format("%8d", i)), cf, cq, ts);
+      evenWriter.append(key, value);
+      key = new Key(new Text(String.format("%8d", i + 1)), cf, cq, ts);
+      oddWriter.append(key, value);
+    }
+    evenWriter.close();
+    oddWriter.close();
+    exec("createtable t", true);
+    exec("importdirectory /tmp/import /tmp/errors true", true);
+    exec("scan -r 00000000", true, "00000000", true);
+    exec("scan -r 00000099", true, "00000099", true);
+    exec("deletetable -f t");
+  }
+  
+  @Test(timeout = 30000)
+  public void info() throws Exception {
+    exec("info", true, Constants.VERSION, true);
+  }
+  
+  @Test(timeout = 30000)
+  public void interpreter() throws Exception {
+    exec("createtable t", true);
+    exec("interpreter -l", true, "HexScan", false);
+    exec("insert \\x02 cf cq value", true);
+    exec("scan -b 02", true, "value", false);
+    exec("interpreter -i org.apache.accumulo.core.util.interpret.HexScanInterpreter", true);
+    exec("interpreter -l", true, "HexScan", true);
+    exec("scan -b 02", true, "value", true);
+    exec("deletetable -f t", true);
+  }
+  
+  @Test(timeout = 30000)
+  public void listcompactions() throws Exception {
+    exec("createtable t", true);
+    exec("config -t t -s table.iterator.minc.slow=30,org.apache.accumulo.test.functional.SlowIterator", true);
+    exec("config -t t -s table.iterator.minc.slow.opt.sleepTime=100", true);
+    exec("insert a cf cq value", true);
+    exec("insert b cf cq value", true);
+    exec("insert c cf cq value", true);
+    exec("insert d cf cq value", true);
+    exec("flush -t t", true);
+    exec("sleep 0.2", true);
+    exec("listcompactions", true, "default_tablet");
+    String[] lines = output.get().split("\n");
+    String last = lines[lines.length - 1];
+    String[] parts = last.split("\\|");
+    assertEquals(12, parts.length);
+    exec("deletetable -f t", true);
+  }
+  
+  @Test(timeout = 30000)
+  public void maxrow() throws Exception {
+    exec("createtable t", true);
+    exec("insert a cf cq value", true);
+    exec("insert b cf cq value", true);
+    exec("insert ccc cf cq value", true);
+    exec("insert zzz cf cq value", true);
+    exec("maxrow", true, "zzz", true);
+    exec("delete zzz cf cq", true);
+    exec("maxrow", true, "ccc", true);
+    exec("deletetable -f t", true);
+  }
+  
+  @Test(timeout = 30000)
+  public void merge() throws Exception {
+    exec("createtable t");
+    exec("addsplits a m z");
+    exec("getsplits", true, "z", true);
+    exec("merge -f", true);
+    exec("getsplits", true, "z", false);
+    exec("deletetable -f t");
+    exec("getsplits -t !METADATA", true);
+    assertEquals(3, output.get().split("\n").length);
+    exec("merge -f -t !METADATA");
+    exec("getsplits -t !METADATA", true);
+    assertEquals(2, output.get().split("\n").length);
+  }
+  
+  @Test(timeout = 30000)
+  public void ping() throws Exception {
+    exec("ping", true, "OK", true);
+    assertEquals(2, output.get().split("\n").length);
+  }
+  
+  @Test(timeout = 30000)
+  public void renametable() throws Exception {
+    exec("createtable aaaa");
+    exec("insert this is a value");
+    exec("renametable aaaa xyzzy");
+    exec("tables", true, "xyzzy", true);
+    exec("tables", true, "aaaa", false);
+    exec("scan -t xyzzy", true, "value", true);
+    exec("deletetable xyzzy", true);
+  }
+  
+  @Test(timeout = 30000)
+  public void systempermission() throws Exception {
+    exec("systempermissions");
+    assertEquals(8, output.get().split("\n").length - 1);
+  }
+  
+  @Test(timeout = 30000)
+  public void listscans() throws Exception {
+    exec("createtable t", true);
+    exec("config -t t -s table.iterator.scan.slow=30,org.apache.accumulo.test.functional.SlowIterator", true);
+    exec("config -t t -s table.iterator.scan.slow.opt.sleepTime=100", true);
+    exec("insert a cf cq value", true);
+    exec("insert b cf cq value", true);
+    exec("insert c cf cq value", true);
+    exec("insert d cf cq value", true);
+    Thread thread = new Thread() {
+      public void run() {
+        try {
+          ZooKeeperInstance instance = new ZooKeeperInstance(cluster.getInstanceName(), cluster.getZooKeepers());
+          Connector connector = instance.getConnector("root", new PasswordToken(secret));
+          Scanner s = connector.createScanner("t", Constants.NO_AUTHS);
+          for (@SuppressWarnings("unused") Entry<Key,Value> kv : s)
+            ;
+        } catch (Exception ex) {
+          throw new RuntimeException(ex);
+        }
+      }
+    };
+    thread.start();
+    exec("sleep 0.1", true);
+    System.out.println(exec("listscans", true));
+    String lines[] = output.get().split("\n");
+    String last = lines[lines.length - 1];
+    assertTrue(last.contains("RUNNING"));
+    String parts[] = last.split("\\|");
+    assertEquals(13, parts.length);
+    thread.join();
+  }
+  
+  //@Test(timeout = 60000)
+  public void trace() throws Exception {
+    exec("sleep 1", true);
+    exec("trace on", true);
+    exec("createtable t", true);
+    System.out.println(exec("trace off"));
+    exec("table trace");
+    System.out.println(exec("scan -np"));
+    exec("sleep 10");
+    System.out.println(exec("scan -np"));
+    UtilWaitThread.sleep(60*1000);
+  }
+  
+  private int countkeys(String table) throws IOException {
+    exec("scan -np -t " + table);
+    return output.get().split("\n").length - 1;
+  }
+  
+  private void make10() throws IOException {
+    for (int i = 0; i < 10; i++) {
+      exec(String.format("insert row%d cf col%d value", i, i));
+    }
+  }
+  
+  private int countFiles() throws IOException {
+    exec("scan -t !METADATA -np -c file");
+    // System.out.println(output.get());
+    return output.get().split("\n").length - 1;
+  }
+  
+}

Propchange: accumulo/branches/1.5/test/src/test/java/org/apache/accumulo/test/shell/ShellServerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native