Skip to content

Commit 6cff13a

Browse files
author
Marcelo Vanzin
committed
[SPARK-3444] [core] Restore INFO level after log4j test.
Otherwise other tests don't log anything useful...
1 parent a48e619 commit 6cff13a

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+
try {
490+
Utils.setLogLevel(org.apache.log4j.Level.ALL)
491+
assert(log.isInfoEnabled())
492+
Utils.setLogLevel(org.apache.log4j.Level.ERROR)
493+
assert(!log.isInfoEnabled())
494+
assert(log.isErrorEnabled())
495+
} finally {
496+
// Best effort at undoing changes this test made. Level should be synchronized with the
497+
// log4j.properties file used for testing.
498+
Utils.setLogLevel(org.apache.log4j.Level.INFO)
499+
}
494500
}
495501

496502
test("deleteRecursively") {

0 commit comments

Comments
 (0)