Skip to content
This repository has been archived by the owner on Oct 31, 2018. It is now read-only.

Commit

Permalink
tests: Fix race condition in ComputeSchedulerSuite
Browse files Browse the repository at this point in the history
  • Loading branch information
kayousterhout committed May 25, 2017
1 parent be52393 commit eed528e
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ package org.apache.spark.monotasks.compute

import java.nio.ByteBuffer

import scala.concurrent.duration._
import scala.language.postfixOps

import org.mockito.Mockito.{mock, never, timeout, verify, when}

import org.scalatest.FunSuite
import org.scalatest.concurrent.Eventually.{eventually, interval => scalatestInterval,
timeout => scalatestTimeout}

import org.apache.spark.TaskContextImpl
import org.apache.spark.storage.{BlockManager, MemoryStore, TestBlockId}
Expand Down Expand Up @@ -96,8 +101,11 @@ class ComputeSchedulerSuite extends FunSuite {
computeScheduler.submitTask(computeMonotask2)
computeScheduler.submitTask(computeMonotask3)

assert(computeMonotask1.isStarted)
assert(computeMonotask2.isStarted)
// Wrap this in an eventually loop, since the compute threads pull tasks asynchronously.
eventually(scalatestTimeout(3 seconds), scalatestInterval(10 milliseconds)) {
assert(computeMonotask1.isStarted)
assert(computeMonotask2.isStarted)
}
assert(!computeMonotask3.isStarted)

// Now submit a prepare monotask, and finish one of the other compute monotasks. The prepare
Expand Down

0 comments on commit eed528e

Please sign in to comment.