Class TestLogLevel

java.lang.Object
org.apache.hadoop.hbase.http.log.TestLogLevel

public class TestLogLevel extends Object
Test LogLevel.
  • Field Details

  • Constructor Details

  • Method Details

    • setUp

      public static void setUp() throws Exception
      Throws:
      Exception
    • setupMiniKdc

      private static org.apache.hadoop.minikdc.MiniKdc setupMiniKdc() throws Exception
      Sets up MiniKdc for testing security. Copied from HBaseTestingUtility#setupMiniKdc().
      Throws:
      Exception
    • setupSSL

      private static void setupSSL(File base) throws Exception
      Throws:
      Exception
    • getSslConfig

      private static org.apache.hadoop.conf.Configuration getSslConfig(org.apache.hadoop.conf.Configuration conf)
      Get the SSL configuration. This method is copied from KeyStoreTestUtil#getSslConfig() in Hadoop.
      Parameters:
      conf - to pull client/server SSL settings filename from
      Returns:
      Configuration instance with ssl configs loaded.
    • tearDown

      public static void tearDown()
    • testCommandOptions

      public void testCommandOptions() throws Exception
      Test client command line options. Does not validate server behavior.
      Throws:
      Exception - if commands return unexpected results.
    • validateCommand

      private boolean validateCommand(String[] args)
      Check to see if a command can be accepted.
      Parameters:
      args - a String array of arguments
      Returns:
      true if the command can be accepted, false if not.
    • createServer

      private org.apache.hadoop.hbase.http.HttpServer createServer(String protocol, boolean isSpnego) throws Exception
      Creates and starts a Jetty server binding at an ephemeral port to run LogLevel servlet.
      Parameters:
      protocol - "http" or "https"
      isSpnego - true if SPNEGO is enabled
      Returns:
      a created HttpServer object
      Throws:
      Exception - if unable to create or start a Jetty server
    • testDynamicLogLevel

      private void testDynamicLogLevel(String bindProtocol, String connectProtocol, boolean isSpnego) throws Exception
      Throws:
      Exception
    • testDynamicLogLevel

      private void testDynamicLogLevel(String bindProtocol, String connectProtocol, boolean isSpnego, String newLevel) throws Exception
      Throws:
      Exception
    • testDynamicLogLevel

      private void testDynamicLogLevel(String bindProtocol, String connectProtocol, boolean isSpnego, String loggerName, String newLevel) throws Exception
      Run both client and server using the given protocol.
      Parameters:
      bindProtocol - specify either http or https for server
      connectProtocol - specify either http or https for client
      isSpnego - true if SPNEGO is enabled
      Throws:
      Exception - if client can't accesss server.
    • getLevel

      private void getLevel(String protocol, String authority, String logName) throws Exception
      Run LogLevel command line to start a client to get log level of this test class.
      Parameters:
      protocol - specify either http or https
      authority - daemon's web UI address
      Throws:
      Exception - if unable to connect
    • setLevel

      private void setLevel(String protocol, String authority, String logName, String newLevel) throws Exception
      Run LogLevel command line to start a client to set log level of this test class to debug.
      Parameters:
      protocol - specify either http or https
      authority - daemon's web UI address
      Throws:
      Exception - if unable to run or log level does not change as expected
    • testSettingProtectedLogLevel

      Throws:
      Exception
    • testInfoLogLevel

      public void testInfoLogLevel() throws Exception
      Test setting log level to "Info".
      Throws:
      Exception - if client can't set log level to INFO.
    • testErrorLogLevel

      public void testErrorLogLevel() throws Exception
      Test setting log level to "Error".
      Throws:
      Exception - if client can't set log level to ERROR.
    • testLogLevelByHttp

      public void testLogLevelByHttp() throws Exception
      Server runs HTTP, no SPNEGO.
      Throws:
      Exception - if http client can't access http server, or http client can access https server.
    • testLogLevelByHttpWithSpnego

      Server runs HTTP + SPNEGO.
      Throws:
      Exception - if http client can't access http server, or http client can access https server.
    • testLogLevelByHttps

      public void testLogLevelByHttps() throws Exception
      Server runs HTTPS, no SPNEGO.
      Throws:
      Exception - if https client can't access https server, or https client can access http server.
    • testLogLevelByHttpsWithSpnego

      Server runs HTTPS + SPNEGO.
      Throws:
      Exception - if https client can't access https server, or https client can access http server.
    • exceptionShouldContains

      private static void exceptionShouldContains(String substr, Throwable throwable)
      Assert that a throwable or one of its causes should contain the substr in its message. Ideally we should use GenericTestUtils.assertExceptionContains(String, Throwable) util method which asserts t.toString() contains the substr. As the original throwable may have been wrapped in Hadoop3 because of HADOOP-12897, it's required to check all the wrapped causes. After stop supporting Hadoop2, this method can be removed and assertion in tests can use t.getCause() directly, similar to HADOOP-15280.