Package org.apache.hadoop.hbase.http.log
Class TestLogLevel
java.lang.Object
org.apache.hadoop.hbase.http.log.TestLogLevel
Test LogLevel.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final HBaseClassTestRule
private static org.apache.hadoop.conf.Configuration
private static final String
private static String
private static HBaseCommonTestingUtil
private static org.apache.hadoop.minikdc.MiniKdc
private static String
private static final String
private static File
private static final String
private static final org.apache.logging.log4j.Logger
private static final String
private static final String
private static final String
private static final String
private static org.apache.hadoop.conf.Configuration
private static org.apache.hadoop.conf.Configuration
private static String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate org.apache.hadoop.hbase.http.HttpServer
createServer
(String protocol, boolean isSpnego) Creates and starts a Jetty server binding at an ephemeral port to run LogLevel servlet.private static void
exceptionShouldContains
(String substr, Throwable throwable) Assert that a throwable or one of its causes should contain the substr in its message.private void
Run LogLevel command line to start a client to get log level of this test class.private static org.apache.hadoop.conf.Configuration
getSslConfig
(org.apache.hadoop.conf.Configuration conf) Get the SSL configuration.private void
Run LogLevel command line to start a client to set log level of this test class to debug.static void
setUp()
private static org.apache.hadoop.minikdc.MiniKdc
Sets upMiniKdc
for testing security.private static void
static void
tearDown()
void
Test client command line options.private void
testDynamicLogLevel
(String bindProtocol, String connectProtocol, boolean isSpnego) private void
testDynamicLogLevel
(String bindProtocol, String connectProtocol, boolean isSpnego, String newLevel) private void
testDynamicLogLevel
(String bindProtocol, String connectProtocol, boolean isSpnego, String loggerName, String newLevel) Run both client and server using the given protocol.void
Test setting log level to "Error".void
Test setting log level to "Info".void
Server runs HTTP, no SPNEGO.void
Server runs HTTPS, no SPNEGO.void
Server runs HTTPS + SPNEGO.void
Server runs HTTP + SPNEGO.void
private boolean
validateCommand
(String[] args) Check to see if a command can be accepted.
-
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
-
-
Constructor Details
-
TestLogLevel
public TestLogLevel()
-
-
Method Details
-
setUp
- Throws:
Exception
-
setupMiniKdc
Sets upMiniKdc
for 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:
Configuration
instance 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
-
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 serverconnectProtocol
- specify either http or https for clientisSpnego
- true if SPNEGO is enabled- Throws:
Exception
- if client can't accesss server.
-
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
-
testSettingProtectedLogLevel
- Throws:
Exception
-
testInfoLogLevel
Test setting log level to "Info".- Throws:
Exception
- if client can't set log level to INFO.
-
testErrorLogLevel
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.
-
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.
-