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

    https://github.com/apache/spark/pull/6935#discussion_r47023063
  
    --- Diff: 
core/src/test/scala/org/apache/spark/deploy/history/HistoryServerSuite.scala ---
    @@ -281,6 +296,202 @@ 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 {
    +      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
    +          throw new scala.Exception(s"Wrong $name value - expected 
$expected but got $actual" +
    --- End diff --
    
    Exception was the IDE being clever. I'l just throw a fail.
    
    The comment about stack depth is that the scalatest reporter cuts logging 
of a lot of the stack trace on an assert failure; on a normal exception it 
lists more. That's the reporter & not the test runner: somethings it does 
better than surefire (coloured output to the terminal), other things it 
doesn't. At least scalatest does let you plug in a new reporter, which surefire 
doesn't -so that at some point in the future, in a project of my own choosing, 
I can write my own.


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