Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22504#discussion_r226468219
  
    --- Diff: 
core/src/test/scala/org/apache/spark/util/logging/DriverLoggerSuite.scala ---
    @@ -0,0 +1,83 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.util.logging
    +
    +import java.io.{BufferedInputStream, File, FileInputStream}
    +
    +import org.apache.commons.io.FileUtils
    +
    +import org.apache.spark._
    +import org.apache.spark.{SparkContext, SparkFunSuite}
    +import org.apache.spark.internal.config._
    +import org.apache.spark.launcher.SparkLauncher
    +import org.apache.spark.network.util.JavaUtils
    +import org.apache.spark.util.Utils
    +
    +class DriverLoggerSuite extends SparkFunSuite with LocalSparkContext {
    +
    +  private var rootHdfsDir : File = _
    +
    +  override def beforeAll(): Unit = {
    +    rootHdfsDir = Utils.createTempDir(namePrefix = "hdfs_logs")
    +  }
    +
    +  override def afterAll(): Unit = {
    +    JavaUtils.deleteRecursively(rootHdfsDir)
    +  }
    +
    +  test("driver logs are persisted locally and synced to hdfs") {
    +    val sc = getSparkContext()
    +
    +    val app_id = sc.applicationId
    +    // Run a simple spark application
    +    sc.parallelize(1 to 1000).count()
    +
    +    // Assert driver log file exists
    +    val rootDir = Utils.getLocalDir(sc.getConf)
    +    val driverLogsDir = FileUtils.getFile(rootDir, "driver_logs")
    +    assert(driverLogsDir.exists())
    +    val files = driverLogsDir.listFiles()
    +    assert(files.length === 1)
    +    assert(files(0).getName.equals("driver.log"))
    +
    +    sc.stop()
    +    // File is continuously synced to Hdfs (which is a local dir for this 
test)
    --- End diff --
    
    Comment is unrelated to any of the code around it.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to