You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by jx...@apache.org on 2023/05/02 16:31:39 UTC
[helix] branch master updated: Enabling INFO level for helix logs for TestClusterStatusMonitorLifecycle integration test. (#2462)
This is an automated email from the ASF dual-hosted git repository.
jxue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
The following commit(s) were added to refs/heads/master by this push:
new 3e563279c Enabling INFO level for helix logs for TestClusterStatusMonitorLifecycle integration test. (#2462)
3e563279c is described below
commit 3e563279cb2a72282372ab32baed66bd6c27b43a
Author: Naman Parakh <pa...@gmail.com>
AuthorDate: Tue May 2 09:31:34 2023 -0700
Enabling INFO level for helix logs for TestClusterStatusMonitorLifecycle integration test. (#2462)
* Enabling INFO level for helix logs for TestClusterStatusMonitorLifecycle integration test.
---
.../TestClusterStatusMonitorLifecycle.java | 26 ++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/helix-core/src/test/java/org/apache/helix/monitoring/TestClusterStatusMonitorLifecycle.java b/helix-core/src/test/java/org/apache/helix/monitoring/TestClusterStatusMonitorLifecycle.java
index 6a5526492..8ef0bebd0 100644
--- a/helix-core/src/test/java/org/apache/helix/monitoring/TestClusterStatusMonitorLifecycle.java
+++ b/helix-core/src/test/java/org/apache/helix/monitoring/TestClusterStatusMonitorLifecycle.java
@@ -37,12 +37,20 @@ import org.apache.helix.model.IdealState;
import org.apache.helix.tools.ClusterSetup;
import org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier;
import org.apache.helix.tools.ClusterVerifiers.ZkHelixClusterVerifier;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.LoggerConfig;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import static org.apache.logging.log4j.Level.ERROR;
+import static org.apache.logging.log4j.Level.INFO;
+
public class TestClusterStatusMonitorLifecycle extends ZkTestBase {
+ public static final String HELIX_LOGGER_NAME = "org.apache.helix";
MockParticipantManager[] _participants;
ClusterDistributedController[] _controllers;
String _controllerClusterName;
@@ -55,6 +63,8 @@ public class TestClusterStatusMonitorLifecycle extends ZkTestBase {
@BeforeClass
public void beforeClass() throws Exception {
+ // enabling info level for helix logs to help with debugging
+ updateLog4jLevel(INFO, HELIX_LOGGER_NAME);
String className = TestHelper.getTestClassName();
_clusterNamePrefix = className;
@@ -172,6 +182,8 @@ public class TestClusterStatusMonitorLifecycle extends ZkTestBase {
}
System.out.println("END " + _clusterNamePrefix + " at " + new Date(System.currentTimeMillis()));
+ // restoring error level for helix logs
+ updateLog4jLevel(ERROR, HELIX_LOGGER_NAME);
}
private void cleanupControllers() {
@@ -180,6 +192,20 @@ public class TestClusterStatusMonitorLifecycle extends ZkTestBase {
}
}
+ /**
+ * Updates the log level for the specified logger.
+ * @param level Log level to update.
+ * @param loggerName Name of the logger for which the level will be updated.
+ */
+ private void updateLog4jLevel(org.apache.logging.log4j.Level level, String loggerName) {
+ LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+ Configuration config = ctx.getConfiguration();
+ LoggerConfig loggerConfig =
+ config.getLoggerConfig(String.valueOf(LogManager.getLogger(loggerName)));
+ loggerConfig.setLevel(level);
+ ctx.updateLoggers();
+ }
+
@Test
public void testClusterStatusMonitorLifecycle() throws Exception {
// Filter other unrelated clusters' metrics