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

    https://github.com/apache/spark/pull/11118#discussion_r52465565
  
    --- Diff: 
core/src/test/scala/org/apache/spark/deploy/history/HistoryServerSuite.scala ---
    @@ -256,6 +269,215 @@ 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)
    +
    +    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()
    +    val port = server.boundPort
    +    val metrics = server.cacheMetrics
    +
    +    // assert that a metric has a value; if not dump the whole metrics 
instance
    +    def assertMetric(name: String, counter: Counter, expected: Long): Unit 
= {
    +      val actual = counter.getCount
    +      if (actual != expected) {
    +        // this is here because Scalatest loses stack depth
    +        fail(s"Wrong $name value - expected $expected but got $actual" +
    +            s" in metrics\n$metrics")
    +      }
    +    }
    +
    +    // build a URL for an app or app/attempt plus a page underneath
    +    def buildURL(appId: String, suffix: String): URL = {
    +      new URL(s"http://localhost:$port/history/$appId$suffix";)
    +    }
    +
    +    // build a rest URL for the application and suffix.
    +    def applications(appId: String, suffix: String): URL = {
    +      new URL(s"http://localhost:$port/api/v1/applications/$appId$suffix";)
    +    }
    +
    +    val historyServerRoot = new URL(s"http://localhost:$port/";)
    +    val historyServerIncompleted = new URL(historyServerRoot, 
"?page=1&showIncomplete=true")
    +
    +    // assert the body of a URL contains a string; return that body
    +    def assertUrlContains(url: URL, str: String): String = {
    +      val body = HistoryServerSuite.getUrl(url)
    +      assert(body.contains(str), s"did not find $str at $url : $body")
    +      body
    +    }
    +
    +    // start initial job
    +    val d = sc.parallelize(1 to 10)
    +    d.count()
    +    val stdInterval = interval(100 milliseconds)
    +    val appId = eventually(timeout(20 seconds), stdInterval) {
    +      val json = getContentAndCode("applications", port)._2.get
    +      val apps = parse(json).asInstanceOf[JArray].arr
    +      apps should have size 1
    +      (apps.head \ "id").extract[String]
    +    }
    +
    +    // which lists as incomplete
    +//    assertUrlContains(historyServerIncompleted, appId)
    --- End diff --
    
    and cut this line...we can't check the root HTML page any more


---
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