public class TestLogLevel extends Object
Modifier and Type | Field and Description |
---|---|
static HBaseClassTestRule |
CLASS_RULE |
private static org.apache.hadoop.conf.Configuration |
clientConf |
private static String |
clientPrincipal |
private static String |
HTTP_PRINCIPAL |
private static HBaseCommonTestingUtility |
HTU |
private static org.apache.hadoop.minikdc.MiniKdc |
kdc |
private static String |
keystoresDir |
private static String |
KEYTAB |
private static File |
keyTabFile |
private static String |
LOCALHOST |
private static org.apache.logging.log4j.Logger |
log |
private static String |
logName |
private static String |
PRINCIPAL |
private static String |
protectedLogName |
private static String |
protectedPrefix |
private static org.apache.hadoop.conf.Configuration |
serverConf |
private static org.apache.hadoop.conf.Configuration |
sslConf |
private static String |
sslConfDir |
Constructor and Description |
---|
TestLogLevel() |
Modifier and Type | Method and Description |
---|---|
private 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 |
getLevel(String protocol,
String authority,
String logName)
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 |
setLevel(String protocol,
String authority,
String logName,
String newLevel)
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 |
setupMiniKdc()
Sets up
MiniKdc for testing security. |
private static void |
setupSSL(File base) |
static void |
tearDown() |
void |
testCommandOptions()
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 |
testErrorLogLevel()
Test setting log level to "Error".
|
void |
testInfoLogLevel()
Test setting log level to "Info".
|
void |
testLogLevelByHttp()
Server runs HTTP, no SPNEGO.
|
void |
testLogLevelByHttps()
Server runs HTTPS, no SPNEGO.
|
void |
testLogLevelByHttpsWithSpnego()
Server runs HTTPS + SPNEGO.
|
void |
testLogLevelByHttpWithSpnego()
Server runs HTTP + SPNEGO.
|
void |
testSettingProtectedLogLevel() |
private boolean |
validateCommand(String[] args)
Check to see if a command can be accepted.
|
public static final HBaseClassTestRule CLASS_RULE
private static String keystoresDir
private static String sslConfDir
private static org.apache.hadoop.conf.Configuration serverConf
private static org.apache.hadoop.conf.Configuration clientConf
private static org.apache.hadoop.conf.Configuration sslConf
private static final String protectedPrefix
private static final String protectedLogName
private static final org.apache.logging.log4j.Logger log
private static final String PRINCIPAL
private static final String KEYTAB
private static org.apache.hadoop.minikdc.MiniKdc kdc
private static final String LOCALHOST
private static final String clientPrincipal
private static String HTTP_PRINCIPAL
private static HBaseCommonTestingUtility HTU
private static File keyTabFile
public TestLogLevel()
private static org.apache.hadoop.minikdc.MiniKdc setupMiniKdc() throws Exception
MiniKdc
for testing security. Copied from HBaseTestingUtility#setupMiniKdc().Exception
private static org.apache.hadoop.conf.Configuration getSslConfig(org.apache.hadoop.conf.Configuration conf)
conf
- to pull client/server SSL settings filename fromConfiguration
instance with ssl configs loaded.public static void tearDown()
public void testCommandOptions() throws Exception
Exception
- if commands return unexpected results.private boolean validateCommand(String[] args)
args
- a String array of argumentsprivate org.apache.hadoop.hbase.http.HttpServer createServer(String protocol, boolean isSpnego) throws Exception
protocol
- "http" or "https"isSpnego
- true if SPNEGO is enabledException
- if unable to create or start a Jetty serverprivate void testDynamicLogLevel(String bindProtocol, String connectProtocol, boolean isSpnego) throws Exception
Exception
private void testDynamicLogLevel(String bindProtocol, String connectProtocol, boolean isSpnego, String newLevel) throws Exception
Exception
private void testDynamicLogLevel(String bindProtocol, String connectProtocol, boolean isSpnego, String loggerName, String newLevel) throws Exception
bindProtocol
- specify either http or https for serverconnectProtocol
- specify either http or https for clientisSpnego
- true if SPNEGO is enabledException
- if client can't accesss server.private void getLevel(String protocol, String authority, String logName) throws Exception
protocol
- specify either http or httpsauthority
- daemon's web UI addressException
- if unable to connectprivate void setLevel(String protocol, String authority, String logName, String newLevel) throws Exception
protocol
- specify either http or httpsauthority
- daemon's web UI addressException
- if unable to run or log level does not change as expectedpublic void testSettingProtectedLogLevel() throws Exception
Exception
public void testInfoLogLevel() throws Exception
Exception
- if client can't set log level to INFO.public void testErrorLogLevel() throws Exception
Exception
- if client can't set log level to ERROR.public void testLogLevelByHttp() throws Exception
Exception
- if http client can't access http server, or http client can access https
server.public void testLogLevelByHttpWithSpnego() throws Exception
Exception
- if http client can't access http server, or http client can access https
server.public void testLogLevelByHttps() throws Exception
Exception
- if https client can't access https server, or https client can access http
server.public void testLogLevelByHttpsWithSpnego() throws Exception
Exception
- if https client can't access https server, or https client can access http
server.private static void exceptionShouldContains(String substr, Throwable throwable)
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.Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.