Class AssertTool

java.lang.Object
org.apache.solr.cli.ToolBase
org.apache.solr.cli.AssertTool
All Implemented Interfaces:
Tool

public class AssertTool extends ToolBase
Supports assert command in the bin/solr script. Asserts various conditions and exists with error code if there are failures, else continues with no output.
  • Constructor Details

  • Method Details

    • getName

      public String getName()
      Description copied from interface: Tool
      Defines the interface to a Solr tool that can be run from this command-line app.
    • getOptions

      public org.apache.commons.cli.Options getOptions()
      Description copied from interface: Tool
      Retrieve the Options supported by this tool.
      Specified by:
      getOptions in interface Tool
      Overrides:
      getOptions in class ToolBase
      Returns:
      The Options this tool supports.
    • runTool

      public int runTool(org.apache.commons.cli.CommandLine cli) throws Exception
      Returns 100 error code for a true "error", otherwise returns the number of tests that failed. Otherwise, very similar to the parent runTool method.
      Specified by:
      runTool in interface Tool
      Overrides:
      runTool in class ToolBase
      Parameters:
      cli - the command line object
      Returns:
      0 on success, or a number corresponding to number of tests that failed, or 100 for an Error
      Throws:
      Exception - if a tool failed, e.g. authentication failure
    • runImpl

      public void runImpl(org.apache.commons.cli.CommandLine cli) throws Exception
      Specified by:
      runImpl in class ToolBase
      Throws:
      Exception
    • runAssert

      protected int runAssert(org.apache.commons.cli.CommandLine cli) throws Exception
      Custom run method which may return exit code
      Parameters:
      cli - the command line object
      Returns:
      0 on success, or a number corresponding to number of tests that failed
      Throws:
      Exception - if a tool failed, e.g. authentication failure
    • assertSolrRunning

      public int assertSolrRunning(String url, String credentials) throws Exception
      Throws:
      Exception
    • assertSolrNotRunning

      public int assertSolrNotRunning(String url, String credentials) throws Exception
      Throws:
      Exception
    • assertSolrRunningInCloudMode

      public int assertSolrRunningInCloudMode(String url, String credentials) throws Exception
      Throws:
      Exception
    • assertSolrNotRunningInCloudMode

      public int assertSolrNotRunningInCloudMode(String url, String credentials) throws Exception
      Throws:
      Exception
    • sameUser

      public static int sameUser(String directory) throws Exception
      Throws:
      Exception
    • assertFileExists

      public static int assertFileExists(String directory) throws Exception
      Throws:
      Exception
    • assertFileNotExists

      public static int assertFileNotExists(String directory) throws Exception
      Throws:
      Exception
    • assertRootUser

      public static int assertRootUser() throws Exception
      Throws:
      Exception
    • assertNotRootUser

      public static int assertNotRootUser() throws Exception
      Throws:
      Exception
    • currentUser

      public static String currentUser()
    • userForDir

      public static String userForDir(Path pathToDir)