Package org.apache.hadoop.hbase.http.log
Class TestLogLevel
java.lang.Object
org.apache.hadoop.hbase.http.log.TestLogLevel
Test LogLevel.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enumprivate static interfaceprivate static interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HBaseClassTestRuleprivate static org.apache.hadoop.conf.Configurationprivate static final Stringprivate static final Patternprivate static Stringprivate static HBaseCommonTestingUtilprivate static org.apache.hadoop.minikdc.MiniKdcprivate static Stringprivate static final Stringprivate static Fileprivate static final Stringprivate static final org.apache.logging.log4j.Loggerprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static org.apache.hadoop.conf.Configurationprivate static org.apache.hadoop.conf.Configurationprivate static String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate org.apache.hadoop.hbase.http.HttpServercreateServer(String protocol, boolean isSpnego) Creates and starts a Jetty server binding at an ephemeral port to run LogLevel servlet.private static voidexceptionShouldContains(String substr, Throwable throwable) Assert that a throwable or one of its causes should contain the substr in its message.private StringextractEffectiveLevel(String response) Extract effective log level from server response.private StringRun LogLevel command line to start a client to get log level of this test class.private static org.apache.hadoop.conf.ConfigurationgetSslConfig(org.apache.hadoop.conf.Configuration conf) Get the SSL configuration.private voidRun LogLevel command line to start a client to set log level of this test class to debug.static voidsetUp()private static org.apache.hadoop.minikdc.MiniKdcSets upMiniKdcfor testing security.private static voidstatic voidtearDown()voidTest client command line options.voidvoidprivate voidtestGetLogLevel(TestLogLevel.Protocol protocol, boolean isSpnego, String loggerName, String expectedLevel) voidTest getting log level in readonly mode.voidServer runs HTTP, no SPNEGO.voidServer runs HTTPS, no SPNEGO.voidServer runs HTTPS + SPNEGO.voidServer runs HTTP + SPNEGO.voidTest setting log level to "Error".voidTest setting log level to "Info".private voidtestSetLogLevel(TestLogLevel.Protocol protocol, boolean isSpnego, String loggerName, String newLevel) voidTest setting log level in readonly mode.voidprivate booleanvalidateCommand(String[] args) Check to see if a command can be accepted.private voidwithLogLevelServer(TestLogLevel.Protocol protocol, boolean isSpnego, TestLogLevel.ThrowingConsumer consumer) Starts a LogLevel server and executes a client action against it.private void
-
Field Details
-
CLASS_RULE
-
keystoresDir
-
sslConfDir
-
serverConf
-
clientConf
-
sslConf
-
logName
-
protectedPrefix
- See Also:
-
protectedLogName
-
log
-
PRINCIPAL
- See Also:
-
KEYTAB
- See Also:
-
kdc
-
LOCALHOST
- See Also:
-
clientPrincipal
- See Also:
-
HTTP_PRINCIPAL
-
HTU
-
keyTabFile
-
EFFECTIVE_LEVEL
-
-
Constructor Details
-
TestLogLevel
public TestLogLevel()
-
-
Method Details
-
setUp
- Throws:
Exception
-
setupMiniKdc
Sets upMiniKdcfor testing security. Copied from HBaseTestingUtility#setupMiniKdc().- Throws:
Exception
-
setupSSL
- 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:
Configurationinstance with ssl configs loaded.
-
tearDown
-
testCommandOptions
Test client command line options. Does not validate server behavior.- Throws:
Exception- if commands return unexpected results.
-
validateCommand
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
-
testGetLogLevel
private void testGetLogLevel(TestLogLevel.Protocol protocol, boolean isSpnego, String loggerName, String expectedLevel) throws Exception - Throws:
Exception
-
testSetLogLevel
private void testSetLogLevel(TestLogLevel.Protocol protocol, boolean isSpnego, String loggerName, String newLevel) throws Exception - Throws:
Exception
-
withLogLevelServer
private void withLogLevelServer(TestLogLevel.Protocol protocol, boolean isSpnego, TestLogLevel.ThrowingConsumer consumer) throws Exception Starts a LogLevel server and executes a client action against it.- Parameters:
protocol- protocol configuration for client and serverisSpnego- whether SPNEGO authentication is enabledconsumer- client action executed with the server authority (host:port)- Throws:
Exception- if server setup or client execution fails
-
getLevel
Run LogLevel command line to start a client to get log level of this test class.- Parameters:
protocol- specify either http or httpsauthority- 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 httpsauthority- daemon's web UI address- Throws:
Exception- if unable to run or log level does not change as expected
-
extractEffectiveLevel
Extract effective log level from server response.- Parameters:
response- server body response string- Returns:
- the effective log level
-
testSettingProtectedLogLevel
- Throws:
Exception
-
testGetDebugLogLevel
- Throws:
Exception
-
testGetInfoLogLevel
- Throws:
Exception
-
testSetInfoLogLevel
Test setting log level to "Info".- Throws:
Exception- if client can't set log level to INFO.
-
testSetErrorLogLevel
Test setting log level to "Error".- Throws:
Exception- if client can't set log level to ERROR.
-
testLogLevelByHttp
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
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.
-
testGetLogLevelAllowedInReadonlyMode
Test getting log level in readonly mode.- Throws:
Exception- if a client can't get log level.
-
testSetLogLevelDisallowedInReadonlyMode
Test setting log level in readonly mode.- Throws:
Exception- if a client can set log level.
-
withMasterUIReadonly
- Throws:
Exception
-
exceptionShouldContains
Assert that a throwable or one of its causes should contain the substr in its message. Ideally we should useGenericTestUtils.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.
-