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

    https://github.com/apache/spark/pull/14079#discussion_r92079769
  
    --- Diff: 
core/src/test/scala/org/apache/spark/scheduler/BlacklistTrackerSuite.scala ---
    @@ -17,10 +17,322 @@
     
     package org.apache.spark.scheduler
     
    -import org.apache.spark.{SparkConf, SparkFunSuite}
    +import org.mockito.Mockito.when
    +import org.scalatest.BeforeAndAfterEach
    +import org.scalatest.mock.MockitoSugar
    +
    +import org.apache.spark._
     import org.apache.spark.internal.config
    +import org.apache.spark.util.ManualClock
    +
    +class BlacklistTrackerSuite extends SparkFunSuite with BeforeAndAfterEach 
with MockitoSugar
    +    with LocalSparkContext {
    +
    +  private val clock = new ManualClock(0)
    +
    +  private var blacklist: BlacklistTracker = _
    +  private var scheduler: TaskSchedulerImpl = _
    +  private var conf: SparkConf = _
    +
    +  override def beforeEach(): Unit = {
    +    conf = new SparkConf().setAppName("test").setMaster("local")
    +      .set(config.BLACKLIST_ENABLED.key, "true")
    +    scheduler = mockTaskSchedWithConf(conf)
    +
    +    clock.setTime(0)
    +    blacklist = new BlacklistTracker(conf, clock)
    +  }
    +
    +  override def afterEach(): Unit = {
    +    if (blacklist != null) {
    +      blacklist = null
    +    }
    +    if (scheduler != null) {
    +      scheduler.stop()
    +      scheduler = null
    +    }
    +    super.afterEach()
    +  }
    +
    +  val allExecutorAndHostIds = (('A' to 'Z').map("host" + _) ++ (1 to 
100).map{_.toString}).toSet
    +
    +  /**
    +   * Its easier to write our tests as if we could directly look at the 
sets of nodes & executors in
    +   * the blacklist.  However the api doesn't expose a set, so this is a 
simple way to test
    +   * something similar, since we know the universe of values that might 
appear in these sets.
    +   */
    +  def assertEquivalentToSet(f: String => Boolean, expected: Set[String]): 
Unit = {
    +    allExecutorAndHostIds.foreach { id =>
    +      val actual = f(id)
    +      val exp = expected.contains(id)
    +      assert(actual === exp, raw"""for string "$id" """)
    +    }
    +  }
    +
    +  def mockTaskSchedWithConf(conf: SparkConf): TaskSchedulerImpl = {
    +    sc = new SparkContext(conf)
    +    val scheduler = mock[TaskSchedulerImpl]
    +    when(scheduler.sc).thenReturn(sc)
    +    
when(scheduler.mapOutputTracker).thenReturn(SparkEnv.get.mapOutputTracker)
    +    scheduler
    +  }
    +
    +  def createTaskSetBlacklist(stageId: Int = 0): TaskSetBlacklist = {
    +    new TaskSetBlacklist(conf, stageId, clock)
    +  }
    +
    +  test("executors can be blacklisted with only a few failures per stage") {
    +    // For 4 different stages, executor 1 fails a task, then executor 2 
succeeds the task,
    --- End diff --
    
    I don't think this is for 4 different stages? (looks like ~20?)


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