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

    https://github.com/apache/spark/pull/8760#discussion_r42043964
  
    --- Diff: 
core/src/test/scala/org/apache/spark/scheduler/BlacklistTrackerSuite.scala ---
    @@ -0,0 +1,162 @@
    +package org.apache.spark.scheduler
    +
    +import org.apache.spark.SparkFunSuite
    +import org.scalatest.BeforeAndAfter
    +import org.apache.spark.SparkConf
    +import org.apache.spark.TaskEndReason
    +import org.apache.spark.Success
    +import org.apache.spark.ExceptionFailure
    +import org.apache.spark.LocalSparkContext
    +import org.apache.spark.SparkContext
    +
    +import org.mockito.Mockito.{when,spy}
    +
    +class BlacklistTrackerSuite extends SparkFunSuite with BeforeAndAfter with 
LocalSparkContext {
    +
    +  val FAILURE: TaskEndReason = new ExceptionFailure(
    +      "Fake",
    +      "fake failure",
    +      Array.empty[StackTraceElement],
    +      "fake stack trace",
    +      None,
    +      None)
    +
    +  // Variable name can indicate basic information of taskInfo
    +  // The format is "taskInfo_executorId_taskId_hostName"
    +  val taskInfo_1_1_hostA = new TaskInfo(1L,1,1,0L,"1","hostA", 
TaskLocality.ANY, false)
    +  val taskInfo_1_2_hostA = new TaskInfo(2L,1,1,0L,"1","hostA", 
TaskLocality.ANY, false)
    +  val taskInfo_2_1_hostA = new TaskInfo(1L,1,1,0L,"2","hostA", 
TaskLocality.ANY, false)
    +  val taskInfo_2_2_hostA = new TaskInfo(2L,1,1,0L,"2","hostA", 
TaskLocality.ANY, false)
    +  val taskInfo_3_3_hostB = new TaskInfo(3L,1,1,0L,"3","hostB", 
TaskLocality.ANY, false)
    +
    +  test ("expireExecutorsInBlacklist works ") {
    +    val conf = new SparkConf().setAppName("test").setMaster("local")
    +      .set("spark.ui.enabled","false")
    +      .set("spark.scheduler.blacklist.recoverPeriod", "2")
    +    sc = new SparkContext(conf)
    +    val scheduler = new TaskSchedulerImpl(sc, 1)
    +
    +    val tracker = new BlacklistTracker(conf)
    +    tracker.start()
    +    Thread.sleep(100)
    --- End diff --
    
    We should avoid `Thread.sleep` for slow tests / flakiness by
    (1) changing BlacklistTracker constructor to take an optional second arg, 
the `Clock`
    (2) factor out the scheduled blacklist expiration into a method:
    ```scala
    @VisibleForTesting
    private[scheduler] def expireBlacklist(): Unit = 
expireExecutorsInBlackList(executorIdToFailureStatus)
    ```
    (3) in the tests, use a `ManualClock` which you update directly and also 
call `expireBlacklist` directly.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to