This is an automated email from the ASF dual-hosted git repository.

chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new 3a1da69  [KYUUBI #1145] Suppress 
MiniDFSCluster/MiniYARNCluster/Kerberos output in tests
3a1da69 is described below

commit 3a1da695e63c7996986d3568759242b0d5886994
Author: zhouyifan279 <[email protected]>
AuthorDate: Sat Sep 25 13:42:53 2021 +0800

    [KYUUBI #1145] Suppress MiniDFSCluster/MiniYARNCluster/Kerberos output in 
tests
    
    ### _Why are the changes needed?_
    
    - Kerberos login module outputs lots of debug level log records to stdout, 
which is annoying at most of the time.
    - MiniYARNCluster already outputs most of the log records to 
unit-tests.log. But some referred classes, such as 
`GuiceComponentProviderFactory` use java.util.logging.Logging and output log 
records to stdout.
    
    In this PR, we turn off kerberos logging by default and allow users to turn 
on it by setting java system property `sun.security.krb5.debug`. 
java.util.logging.Logging is redirected to slf4j using `SLF4JBridgeHandler`.
    
    **Note:** MiniDFSCluster outputs a few log records using 
`System.stdout`/`System.stderr`.
    ```
    Formatting using clusterid: testClusterID
    isSaslEnabled:false
    Opened streaming server at /0.0.0.0:1025
    Successfully obtained privileged resources (streaming port = 
ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=1025] ) (http listener port = 9864)
    Opened info server at /0.0.0.0:9864
    ```
    It should be acceptable.
    
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including 
negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [x] [Run 
test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests)
 locally before make a pull request
    
    Closes #1150 from zhouyifan279/KYUUBI#1145.
    
    Closes #1145
    
    5c91816d [zhouyifan279] [KYUUBI #1145] Suppress 
MiniDFSCluster/MiniYARNCluster/Kerberos output in tests
    1a9f6345 [zhouyifan279] [KYUUBI #1145] Suppress MiniDFS/YARNCluster/ 
Kerberos output in tests
    9877085a [zhouyifan279] [KYUUBI #1145] Suppress MiniDFS/YARNCluster/ 
Kerberos output in tests
    8b05cb02 [zhouyifan279] [KYUUBI #1145] Suppress MiniDFS/YARNCluster/ 
Kerberos output in tests
    435a4715 [zhouyifan279] [KYUUBI #1145] Suppress MiniDFS/YARNCluster/ 
Kerberos output in tests
    
    Authored-by: zhouyifan279 <[email protected]>
    Signed-off-by: Cheng Pan <[email protected]>
---
 .../test/scala/org/apache/kyuubi/KerberizedTestHelper.scala  |  5 ++++-
 .../src/test/scala/org/apache/kyuubi/KyuubiFunSuite.scala    |  6 ++++++
 pom.xml                                                      | 12 ++++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git 
a/kyuubi-common/src/test/scala/org/apache/kyuubi/KerberizedTestHelper.scala 
b/kyuubi-common/src/test/scala/org/apache/kyuubi/KerberizedTestHelper.scala
index 78ac972..d5ba4a0 100644
--- a/kyuubi-common/src/test/scala/org/apache/kyuubi/KerberizedTestHelper.scala
+++ b/kyuubi-common/src/test/scala/org/apache/kyuubi/KerberizedTestHelper.scala
@@ -42,7 +42,10 @@ trait KerberizedTestHelper extends KyuubiFunSuite {
   kdcConf.setProperty(MiniKdc.ORG_DOMAIN, "COM")
   kdcConf.setProperty(MiniKdc.KDC_BIND_ADDRESS, hostName)
   kdcConf.setProperty(MiniKdc.KDC_PORT, "0")
-  kdcConf.setProperty(MiniKdc.DEBUG, "true")
+  // MiniKdc.DEBUG in kdcConf is set to false by default and will override JVM 
system property.
+  // Remove it so we can turn on/off kerberos debug message by setting system 
property
+  // `sun.security.krb5.debug`.
+  kdcConf.remove(MiniKdc.DEBUG)
 
   private var kdc: MiniKdc = _
   private var krb5ConfPath: String = _
diff --git 
a/kyuubi-common/src/test/scala/org/apache/kyuubi/KyuubiFunSuite.scala 
b/kyuubi-common/src/test/scala/org/apache/kyuubi/KyuubiFunSuite.scala
index 640d7ea..35d328e 100644
--- a/kyuubi-common/src/test/scala/org/apache/kyuubi/KyuubiFunSuite.scala
+++ b/kyuubi-common/src/test/scala/org/apache/kyuubi/KyuubiFunSuite.scala
@@ -25,6 +25,7 @@ import org.apache.log4j.spi.LoggingEvent
 import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach, Outcome}
 import org.scalatest.concurrent.Eventually
 import org.scalatest.funsuite.AnyFunSuite
+import org.slf4j.bridge.SLF4JBridgeHandler
 
 import org.apache.kyuubi.config.internal.Tests.IS_TESTING
 
@@ -34,6 +35,11 @@ trait KyuubiFunSuite extends AnyFunSuite
   with Eventually
   with ThreadAudit
   with Logging {
+
+  // Redirect jul to sl4j
+  SLF4JBridgeHandler.removeHandlersForRootLogger()
+  SLF4JBridgeHandler.install()
+
   // scalastyle:on
   override def beforeAll(): Unit = {
     System.setProperty(IS_TESTING.key, "true")
diff --git a/pom.xml b/pom.xml
index 28b5089..69933e1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -977,6 +977,12 @@
             </dependency>
 
             <dependency>
+                <groupId>org.slf4j</groupId>
+                <artifactId>jul-to-slf4j</artifactId>
+                <version>${slf4j.version}</version>
+            </dependency>
+
+            <dependency>
                 <groupId>io.dropwizard.metrics</groupId>
                 <artifactId>metrics-core</artifactId>
                 <version>${codahale.metrics.version}</version>
@@ -1331,6 +1337,11 @@
             <artifactId>scalatest_${scala.binary.version}</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jul-to-slf4j</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
@@ -1511,6 +1522,7 @@
                             <spark.driver.memory>2g</spark.driver.memory>
                             
<kyuubi.metrics.json.location>${project.build.directory}/metrics</kyuubi.metrics.json.location>
                             
<kyuubi.frontend.bind.host>localhost</kyuubi.frontend.bind.host>
+                            
<sun.security.krb5.debug>false</sun.security.krb5.debug>
                         </systemProperties>
                         
<tagsToExclude>${maven.plugin.scalatest.exclude.tags}</tagsToExclude>
                         
<tagsToInclude>${maven.plugin.scalatest.include.tags}</tagsToInclude>

Reply via email to