Skip to content

Commit 228aabe

Browse files
Marcelo Vanzinsrowen
authored andcommitted
[SPARK-3444] [CORE] Restore INFO level after log4j test.
Otherwise other tests don't log anything useful... Author: Marcelo Vanzin <vanzin@cloudera.com> Closes #7140 from vanzin/SPARK-3444 and squashes the following commits: de14836 [Marcelo Vanzin] Better fix. 6cff13a [Marcelo Vanzin] [SPARK-3444] [core] Restore INFO level after log4j test. (cherry picked from commit 1ce6428) Signed-off-by: Sean Owen <sowen@cloudera.com>
1 parent bcfb37b commit 228aabe

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

core/src/test/scala/org/apache/spark/util/UtilsSuite.scala

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,17 @@ class UtilsSuite extends SparkFunSuite with ResetSystemProperties with Logging {
486486

487487
// Test for using the util function to change our log levels.
488488
test("log4j log level change") {
489-
Utils.setLogLevel(org.apache.log4j.Level.ALL)
490-
assert(log.isInfoEnabled())
491-
Utils.setLogLevel(org.apache.log4j.Level.ERROR)
492-
assert(!log.isInfoEnabled())
493-
assert(log.isErrorEnabled())
489+
val current = org.apache.log4j.Logger.getRootLogger().getLevel()
490+
try {
491+
Utils.setLogLevel(org.apache.log4j.Level.ALL)
492+
assert(log.isInfoEnabled())
493+
Utils.setLogLevel(org.apache.log4j.Level.ERROR)
494+
assert(!log.isInfoEnabled())
495+
assert(log.isErrorEnabled())
496+
} finally {
497+
// Best effort at undoing changes this test made.
498+
Utils.setLogLevel(current)
499+
}
494500
}
495501

496502
test("deleteRecursively") {

0 commit comments

Comments
 (0)