-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-37805][TESTS] Refactor TestUtils#configTestLog4j method to use log4j2 api
#35095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
cc @viirya |
|
FYI, @LuciferYang . It was intentionally ignored at that time after discussing with @williamhyun offline. |
What is the specific reason? I didn't find it in SPARK-37795 |
|
GA run failed,Let me check it first |
|
GA Passed |
| builder.add(appenderBuilder) | ||
| builder.add(builder.newRootLogger(s"$level").add(builder.newAppenderRef("console"))) | ||
| val configuration = builder.build() | ||
| LogManager.getContext(false).asInstanceOf[LoggerContext].reconfigure(configuration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rewriting looks okay. I just wonder the purpose of configTestLog4j and if it is necessary. These tests are not checking the log (as they are still passed with no-op configTestLog4j now). And seems it is not used to reduce verbose logging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can just remove configTestLog4j?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I traced back to the original pr (SPARK-3193), it seems that configTestLog4j is only added to help troubleshoot the failed UT on Jenkins about the Process exitcode != 0
I agree to remove this method directly,(EDIT) what do you think @dongjoon-hyun ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... It seems that the method of calling configTestLog4j in the current UTs is in the process of runSparkSubmit. If we directly remove this method, I can not find out where to see the relevant log of runSparkSubmit (not in target/unit-tests.log), which is really not conducive to troubleshooting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then it is okay to keep it, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok ~
| appenderBuilder.add(builder.newLayout("PatternLayout") | ||
| .addAttribute("pattern", "%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n")) | ||
| builder.add(appenderBuilder) | ||
| builder.add(builder.newRootLogger(s"$level").add(builder.newAppenderRef("console"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s"$level" -> level. level is already a string, no need to interpolate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc06076 fix this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viirya Any other need change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about #35095 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank @viirya , ping @dongjoon-hyun @williamhyun
srowen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK pending tests
|
8d0a078 merge with master |
GA passed |
|
Merged to master |
|
thanks all |
…se log4j2 api ### What changes were proposed in this pull request? SPARK-37795 add a scalastyle rule to ban `org.apache.log4j` imports, but there is still one place to retain the imports of `org.apache.log4j` in `o.a.spark.TestUtils`. This pr refactor `configTestLog4j` method in `o.a.spark.TestUtils` to use log4j2 api and let the log behavior using log4j2.x be the same as that using log4j1.x before. In fact, the `configTestLog4j` method behavior before this pr is invalid because `PropertyConfigurator.configure` method in `org.apache.logging.log4j:log4j-1.2-api` is an empty method as follows: https://github.com/apache/logging-log4j2/blob/491a0b3787975b6fc95b6a8cb3da76dc7517c65f/log4j-1.2-api/src/main/java/org/apache/log4j/PropertyConfigurator.java#L39-L47 Another change of this pr is rename the method name from `configTestLog4j` to `configTestLog4j2`. ### Why are the changes needed? Clean up the `org.apache.log4j` imports left in Spark internal and let `configTestLog4j` method behavior keep consistent between log4j1.x and log4j2.x. ### Does this PR introduce _any_ user-facing change? The `configTestLog4j` method in `TestUtils` rename to `configTestLog4j2` ### How was this patch tested? - Pass the Jenkins or GitHub Action - Manual test Run the test cases using `configTestLog4j` method in the following 3 scenarios: 1. without this pr to test log4j2.x 2. with this pr to test log4j2.x 3. run `git reset --hard 1922798` to test log4j1.x For example `WholeStageCodegenSparkSubmitSuite`, run ``` mvn clean install -DskipTests -pl sql/core -am mvn test -pl sql/core -Dtest=none -DwildcardSuites=org.apache.spark.sql.execution.WholeStageCodegenSparkSubmitSuite ``` Scenario 1 does not print any logs to the console, scenario 2 and scenario 3 will print similar logs to the console Closes apache#35095 from LuciferYang/refactor-configTestLog4j. Authored-by: yangjie01 <[email protected]> Signed-off-by: Sean Owen <[email protected]>
…se log4j2 api SPARK-37795 add a scalastyle rule to ban `org.apache.log4j` imports, but there is still one place to retain the imports of `org.apache.log4j` in `o.a.spark.TestUtils`. This pr refactor `configTestLog4j` method in `o.a.spark.TestUtils` to use log4j2 api and let the log behavior using log4j2.x be the same as that using log4j1.x before. In fact, the `configTestLog4j` method behavior before this pr is invalid because `PropertyConfigurator.configure` method in `org.apache.logging.log4j:log4j-1.2-api` is an empty method as follows: https://github.com/apache/logging-log4j2/blob/491a0b3787975b6fc95b6a8cb3da76dc7517c65f/log4j-1.2-api/src/main/java/org/apache/log4j/PropertyConfigurator.java#L39-L47 Another change of this pr is rename the method name from `configTestLog4j` to `configTestLog4j2`. Clean up the `org.apache.log4j` imports left in Spark internal and let `configTestLog4j` method behavior keep consistent between log4j1.x and log4j2.x. The `configTestLog4j` method in `TestUtils` rename to `configTestLog4j2` - Pass the Jenkins or GitHub Action - Manual test Run the test cases using `configTestLog4j` method in the following 3 scenarios: 1. without this pr to test log4j2.x 2. with this pr to test log4j2.x 3. run `git reset --hard 1922798` to test log4j1.x For example `WholeStageCodegenSparkSubmitSuite`, run ``` mvn clean install -DskipTests -pl sql/core -am mvn test -pl sql/core -Dtest=none -DwildcardSuites=org.apache.spark.sql.execution.WholeStageCodegenSparkSubmitSuite ``` Scenario 1 does not print any logs to the console, scenario 2 and scenario 3 will print similar logs to the console Closes apache#35095 from LuciferYang/refactor-configTestLog4j. Authored-by: yangjie01 <[email protected]> Signed-off-by: Sean Owen <[email protected]>
…se log4j2 api ### What changes were proposed in this pull request? SPARK-37795 add a scalastyle rule to ban `org.apache.log4j` imports, but there is still one place to retain the imports of `org.apache.log4j` in `o.a.spark.TestUtils`. This pr refactor `configTestLog4j` method in `o.a.spark.TestUtils` to use log4j2 api and let the log behavior using log4j2.x be the same as that using log4j1.x before. In fact, the `configTestLog4j` method behavior before this pr is invalid because `PropertyConfigurator.configure` method in `org.apache.logging.log4j:log4j-1.2-api` is an empty method as follows: https://github.com/apache/logging-log4j2/blob/491a0b3787975b6fc95b6a8cb3da76dc7517c65f/log4j-1.2-api/src/main/java/org/apache/log4j/PropertyConfigurator.java#L39-L47 Another change of this pr is rename the method name from `configTestLog4j` to `configTestLog4j2`. ### Why are the changes needed? Clean up the `org.apache.log4j` imports left in Spark internal and let `configTestLog4j` method behavior keep consistent between log4j1.x and log4j2.x. ### Does this PR introduce _any_ user-facing change? The `configTestLog4j` method in `TestUtils` rename to `configTestLog4j2` ### How was this patch tested? - Pass the Jenkins or GitHub Action - Manual test Run the test cases using `configTestLog4j` method in the following 3 scenarios: 1. without this pr to test log4j2.x 2. with this pr to test log4j2.x 3. run `git reset --hard 1922798` to test log4j1.x For example `WholeStageCodegenSparkSubmitSuite`, run ``` mvn clean install -DskipTests -pl sql/core -am mvn test -pl sql/core -Dtest=none -DwildcardSuites=org.apache.spark.sql.execution.WholeStageCodegenSparkSubmitSuite ``` Scenario 1 does not print any logs to the console, scenario 2 and scenario 3 will print similar logs to the console Closes apache#35095 from LuciferYang/refactor-configTestLog4j. Authored-by: yangjie01 <[email protected]> Signed-off-by: Sean Owen <[email protected]>
…se log4j2 api ### What changes were proposed in this pull request? SPARK-37795 add a scalastyle rule to ban `org.apache.log4j` imports, but there is still one place to retain the imports of `org.apache.log4j` in `o.a.spark.TestUtils`. This pr refactor `configTestLog4j` method in `o.a.spark.TestUtils` to use log4j2 api and let the log behavior using log4j2.x be the same as that using log4j1.x before. In fact, the `configTestLog4j` method behavior before this pr is invalid because `PropertyConfigurator.configure` method in `org.apache.logging.log4j:log4j-1.2-api` is an empty method as follows: https://github.com/apache/logging-log4j2/blob/491a0b3787975b6fc95b6a8cb3da76dc7517c65f/log4j-1.2-api/src/main/java/org/apache/log4j/PropertyConfigurator.java#L39-L47 Another change of this pr is rename the method name from `configTestLog4j` to `configTestLog4j2`. ### Why are the changes needed? Clean up the `org.apache.log4j` imports left in Spark internal and let `configTestLog4j` method behavior keep consistent between log4j1.x and log4j2.x. ### Does this PR introduce _any_ user-facing change? The `configTestLog4j` method in `TestUtils` rename to `configTestLog4j2` ### How was this patch tested? - Pass the Jenkins or GitHub Action - Manual test Run the test cases using `configTestLog4j` method in the following 3 scenarios: 1. without this pr to test log4j2.x 2. with this pr to test log4j2.x 3. run `git reset --hard 1922798` to test log4j1.x For example `WholeStageCodegenSparkSubmitSuite`, run ``` mvn clean install -DskipTests -pl sql/core -am mvn test -pl sql/core -Dtest=none -DwildcardSuites=org.apache.spark.sql.execution.WholeStageCodegenSparkSubmitSuite ``` Scenario 1 does not print any logs to the console, scenario 2 and scenario 3 will print similar logs to the console Closes apache#35095 from LuciferYang/refactor-configTestLog4j. Authored-by: yangjie01 <[email protected]> Signed-off-by: Sean Owen <[email protected]> (cherry picked from commit f3eedaf)
What changes were proposed in this pull request?
SPARK-37795 add a scalastyle rule to ban
org.apache.log4jimports, but there is still one place to retain the imports oforg.apache.log4jino.a.spark.TestUtils.This pr refactor
configTestLog4jmethod ino.a.spark.TestUtilsto use log4j2 api and let the log behavior using log4j2.x be the same as that using log4j1.x before. In fact, theconfigTestLog4jmethod behavior before this pr is invalid becausePropertyConfigurator.configuremethod inorg.apache.logging.log4j:log4j-1.2-apiis an empty method as follows:https://github.com/apache/logging-log4j2/blob/491a0b3787975b6fc95b6a8cb3da76dc7517c65f/log4j-1.2-api/src/main/java/org/apache/log4j/PropertyConfigurator.java#L39-L47
Another change of this pr is rename the method name from
configTestLog4jtoconfigTestLog4j2.Why are the changes needed?
Clean up the
org.apache.log4jimports left in Spark internal and letconfigTestLog4jmethod behavior keep consistent between log4j1.x and log4j2.x.Does this PR introduce any user-facing change?
The
configTestLog4jmethod inTestUtilsrename toconfigTestLog4j2How was this patch tested?
Run the test cases using
configTestLog4jmethod in the following 3 scenarios:git reset --hard 19227983e91a54b5f27ade6412dad1088dfcba9eto test log4j1.xFor example
WholeStageCodegenSparkSubmitSuite, runScenario 1 does not print any logs to the console, scenario 2 and scenario 3 will print similar logs to the console