@@ -26,6 +26,8 @@ import scala.concurrent.{Await, Promise}
26
26
import scala .sys .process .{Process , ProcessLogger }
27
27
import scala .util .{Random , Try }
28
28
29
+ import com .google .common .base .Charsets .UTF_8
30
+ import com .google .common .io .Files
29
31
import org .apache .hadoop .hive .conf .HiveConf .ConfVars
30
32
import org .apache .hive .jdbc .HiveDriver
31
33
import org .apache .hive .service .auth .PlainSaslHelper
@@ -286,6 +288,24 @@ abstract class HiveThriftServer2Test extends SparkFunSuite with BeforeAndAfterAl
286
288
ConfVars .HIVE_SERVER2_THRIFT_HTTP_PORT
287
289
}
288
290
291
+ val driverClassPath = {
292
+ // Writes a temporary log4j.properties and prepend it to driver classpath, so that it
293
+ // overrides all other potential log4j configurations contained in other dependency jar files.
294
+ val tempLog4jConf = Utils .createTempDir().getCanonicalPath
295
+
296
+ Files .write(
297
+ """ log4j.rootCategory=INFO, console
298
+ |log4j.appender.console=org.apache.log4j.ConsoleAppender
299
+ |log4j.appender.console.target=System.err
300
+ |log4j.appender.console.layout=org.apache.log4j.PatternLayout
301
+ |log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n
302
+ """ .stripMargin,
303
+ new File (s " $tempLog4jConf/log4j.properties " ),
304
+ UTF_8 )
305
+
306
+ tempLog4jConf + File .pathSeparator + sys.props(" java.class.path" )
307
+ }
308
+
289
309
s """ $startScript
290
310
| --master local
291
311
| --hiveconf hive.root.logger=INFO,console
@@ -295,6 +315,8 @@ abstract class HiveThriftServer2Test extends SparkFunSuite with BeforeAndAfterAl
295
315
| --hiveconf ${ConfVars .HIVE_SERVER2_TRANSPORT_MODE }= $mode
296
316
| --hiveconf $portConf= $port
297
317
| --driver-class-path ${sys.props(" java.class.path" )}
318
+ | --driver-class-path $driverClassPath
319
+ | --driver-java-options -Dlog4j.debug
298
320
| --conf spark.ui.enabled=false
299
321
""" .stripMargin.split(" \\ s+" ).toSeq
300
322
}
0 commit comments