Package org.apache.hadoop.hbase.http.log
Class TestLogLevel
java.lang.Object
org.apache.hadoop.hbase.http.log.TestLogLevel
Test LogLevel.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HBaseClassTestRuleprivate static org.apache.hadoop.conf.Configurationprivate static final Stringprivate static Stringprivate static HBaseCommonTestingUtilityprivate 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 voidRun 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.private voidtestDynamicLogLevel(String bindProtocol, String connectProtocol, boolean isSpnego) private voidtestDynamicLogLevel(String bindProtocol, String connectProtocol, boolean isSpnego, String newLevel) private voidtestDynamicLogLevel(String bindProtocol, String connectProtocol, boolean isSpnego, String loggerName, String newLevel) Run both client and server using the given protocol.voidTest setting log level to "Error".voidTest setting log level to "Info".voidServer runs HTTP, no SPNEGO.voidServer runs HTTPS, no SPNEGO.voidServer runs HTTPS + SPNEGO.voidServer runs HTTP + SPNEGO.voidprivate booleanvalidateCommand(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 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
-
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.
-