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

    https://github.com/apache/spark/pull/6935#discussion_r47555335
  
    --- Diff: 
core/src/test/scala/org/apache/spark/deploy/history/HistoryServerSuite.scala ---
    @@ -281,6 +296,191 @@ class HistoryServerSuite extends SparkFunSuite with 
BeforeAndAfter with Matchers
         all (siteRelativeLinks) should startWith (uiRoot)
       }
     
    +  test("incomplete apps get refreshed") {
    +
    +    implicit val webDriver: WebDriver = new HtmlUnitDriver
    +    implicit val formats = org.json4s.DefaultFormats
    +
    +    // this test dir is explictly deleted on successful runs; retained for 
diagnostics when
    +    // not
    +    val logDir = 
Utils.createDirectory(System.getProperty("java.io.tmpdir", "logs"))
    +
    +    // a new conf is used with the background thread set and running at 
its fastest
    +    // alllowed refresh rate (1Hz)
    +    val myConf = new SparkConf()
    +      .set("spark.history.fs.logDirectory", logDir.getAbsolutePath)
    +      .set("spark.eventLog.dir", logDir.getAbsolutePath)
    +      .set("spark.history.fs.update.interval", "1s")
    +      .set("spark.eventLog.enabled", "true")
    +      .set("spark.history.cache.window", "250ms")
    +      .remove("spark.testing")
    +    val provider = new FsHistoryProvider(myConf)
    +    val securityManager = new SecurityManager(myConf)
    +
    +    val sc = new SparkContext("local", "test", myConf)
    +    val logDirUri = logDir.toURI
    +    val logDirPath = new Path(logDirUri)
    +    val fs = FileSystem.get(logDirUri, sc.hadoopConfiguration)
    +
    +    def listDir(dir: Path): Seq[FileStatus] = {
    +      val statuses = fs.listStatus(dir)
    +      statuses.flatMap(
    +        stat => if (stat.isDirectory) listDir(stat.getPath) else Seq(stat))
    +    }
    +
    +    def dumpLogDir(msg: String = ""): Unit = {
    +      if (log.isDebugEnabled) {
    +        logDebug(msg)
    +        listDir(logDirPath).foreach { status =>
    +          val s = status.toString
    +          logDebug(s)
    +        }
    +      }
    +    }
    +
    +    // stop the server with the old config, and start the new one
    +    server.stop()
    +    server = new HistoryServer(myConf, provider, securityManager, 18080)
    +    server.initialize()
    +    server.bind()
    +    try {
    --- End diff --
    
    there is room here for something to go wrong before you enter the try, and 
so you'd never clean up the spark context.  That could screw up other tests. I 
think the easiest way to handle this is to just use `LocalSparkContext`, which 
will automatically clean up its `sc` after each test.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to