Github user reggert commented on a diff in the pull request:
https://github.com/apache/spark/pull/9264#discussion_r46909976
--- Diff:
core/src/test/scala/org/apache/spark/rdd/AsyncRDDActionsSuite.scala ---
@@ -197,4 +197,34 @@ class AsyncRDDActionsSuite extends SparkFunSuite with
BeforeAndAfterAll with Tim
Await.result(f, Duration(20, "milliseconds"))
}
}
+
+ private def testAsyncAction[R](action: RDD[Int] => FutureAction[R]):
Unit = {
+ val executionContextInvoked = Promise[Unit]
+ val fakeExecutionContext = new ExecutionContext {
+ override def execute(runnable: Runnable): Unit = {
+ executionContextInvoked.success(())
+ }
+ override def reportFailure(t: Throwable): Unit = ()
+ }
+ val starter = Smuggle(new Semaphore(0))
+ starter.drainPermits()
+ val rdd = sc.parallelize(1 to 100, 4).mapPartitions {itr =>
starter.acquire(1); itr}
+ val f = action(rdd)
+ f.onComplete(_ => ())(fakeExecutionContext)
+ // Here we verify that registering the callback didn't cause a thread
to be consumed.
+ assert(!executionContextInvoked.isCompleted)
+ // Now allow the executors to proceed with task processing.
+ starter.release(rdd.partitions.length)
+ // Waiting for the result verifies that the tasks were successfully
processed.
+ // This mainly exists to verify that we didn't break task
deserialization.
--- End diff --
Unless I'm mistaken, the `Await.result` call will throw an exception if the
job fails.
---
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]