jinhyukify commented on code in PR #7540:
URL: https://github.com/apache/hbase/pull/7540#discussion_r2648884181
##########
hbase-http/src/test/java/org/apache/hadoop/hbase/http/log/TestLogLevel.java:
##########
@@ -448,15 +512,56 @@ public void testLogLevelByHttps() throws Exception {
*/
@Test
public void testLogLevelByHttpsWithSpnego() throws Exception {
- testDynamicLogLevel(LogLevel.PROTOCOL_HTTPS, LogLevel.PROTOCOL_HTTPS,
true);
+ Log4jUtils.setLogLevel(logName, "DEBUG");
+ testGetLogLevel(Protocol.C_HTTPS_S_HTTPS, true, logName, "DEBUG");
try {
- testDynamicLogLevel(LogLevel.PROTOCOL_HTTPS, LogLevel.PROTOCOL_HTTP,
true);
- fail("An HTTP Client should not have succeeded in connecting to a " +
"HTTPS server");
+ testGetLogLevel(Protocol.C_HTTP_S_HTTPS, true, logName, "DEBUG");
+ fail("An HTTP Client should not have succeeded in connecting to a HTTPS
server");
} catch (SocketException e) {
exceptionShouldContains("Unexpected end of file from server", e);
}
}
+ /**
+ * Test getting log level in readonly mode.
+ * @throws Exception if a client can't get log level.
+ */
+ @Test
+ public void testGetLogLevelAllowedInReadonlyMode() throws Exception {
+ withMasterUIReadonly(() -> {
+ Log4jUtils.setLogLevel(logName, "DEBUG");
+ testGetLogLevel(Protocol.C_HTTP_S_HTTP, true, logName, "DEBUG");
Review Comment:
This verifies log level reads in read-only mode.
##########
hbase-http/src/test/java/org/apache/hadoop/hbase/http/log/TestLogLevel.java:
##########
@@ -448,15 +512,56 @@ public void testLogLevelByHttps() throws Exception {
*/
@Test
public void testLogLevelByHttpsWithSpnego() throws Exception {
- testDynamicLogLevel(LogLevel.PROTOCOL_HTTPS, LogLevel.PROTOCOL_HTTPS,
true);
+ Log4jUtils.setLogLevel(logName, "DEBUG");
+ testGetLogLevel(Protocol.C_HTTPS_S_HTTPS, true, logName, "DEBUG");
try {
- testDynamicLogLevel(LogLevel.PROTOCOL_HTTPS, LogLevel.PROTOCOL_HTTP,
true);
- fail("An HTTP Client should not have succeeded in connecting to a " +
"HTTPS server");
+ testGetLogLevel(Protocol.C_HTTP_S_HTTPS, true, logName, "DEBUG");
+ fail("An HTTP Client should not have succeeded in connecting to a HTTPS
server");
} catch (SocketException e) {
exceptionShouldContains("Unexpected end of file from server", e);
}
}
+ /**
+ * Test getting log level in readonly mode.
+ * @throws Exception if a client can't get log level.
+ */
+ @Test
+ public void testGetLogLevelAllowedInReadonlyMode() throws Exception {
+ withMasterUIReadonly(() -> {
+ Log4jUtils.setLogLevel(logName, "DEBUG");
+ testGetLogLevel(Protocol.C_HTTP_S_HTTP, true, logName, "DEBUG");
+ });
+ }
+
+ /**
+ * Test setting log level in readonly mode.
+ * @throws Exception if a client can set log level.
+ */
+ @Test
+ public void testSetLogLevelDisallowedInReadonlyMode() throws Exception {
+ withMasterUIReadonly(() -> {
+ Log4jUtils.setLogLevel(logName, "DEBUG");
+ try {
+ testSetLogLevel(Protocol.C_HTTP_S_HTTP, true, logName, "INFO");
+ fail("Setting log level should be disallowed in readonly mode.");
Review Comment:
This verifies log level updates in read-only mode.
##########
hbase-http/src/main/java/org/apache/hadoop/hbase/http/log/LogLevel.java:
##########
@@ -213,7 +215,11 @@ private int parseProtocolArgs(String[] args, int index)
throws HadoopIllegalArgu
* @throws Exception if unable to connect
*/
private void doGetLevel() throws Exception {
- process(protocol + "://" + hostName + "/logLevel?log=" + className);
+ System.out.println(fetchGetLevelResponse());
+ }
+
+ String fetchGetLevelResponse() throws Exception {
+ return fetchResponse(protocol + "://" + hostName + "/logLevel?log=" +
className);
Review Comment:
The previous implementation printed results only to standard output, making
it hard to write tests. I refactored the code slightly to separate the logic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]