squito commented on a change in pull request #23767: [SPARK-26329][CORE] Faster 
polling of executor memory metrics.
URL: https://github.com/apache/spark/pull/23767#discussion_r304123384
 
 

 ##########
 File path: core/src/test/scala/org/apache/spark/executor/ExecutorSuite.scala
 ##########
 @@ -342,6 +320,87 @@ class ExecutorSuite extends SparkFunSuite
     }
   }
 
+  test("Send task executor metrics in DirectTaskResult") {
+    // Run a successful, trivial result task
+    // We need to ensure, however, that executor metrics are polled after the 
task is started
+    // so this requires some coordination using ExecutorSuiteHelper.
+    val conf = new SparkConf().setMaster("local").setAppName("executor suite 
test")
+    sc = new SparkContext(conf)
+    val serializer = SparkEnv.get.closureSerializer.newInstance()
+    ExecutorSuiteHelper.latches = new ExecutorSuiteHelper
+    val resultFunc =
+      (context: TaskContext, itr: Iterator[Int]) => {
+        ExecutorSuiteHelper.latches.latch1.await(300, TimeUnit.MILLISECONDS)
+        ExecutorSuiteHelper.latches.latch2.countDown()
+        ExecutorSuiteHelper.latches.latch3.await(500, TimeUnit.MILLISECONDS)
+        itr.size
+      }
+    val rdd = new RDD[Int](sc, Nil) {
+      override def compute(split: Partition, context: TaskContext): 
Iterator[Int] = {
+        val l = List(1)
+        l.iterator
+      }
+      override protected def getPartitions: Array[Partition] = {
+        Array(new SimplePartition)
+      }
+    }
+    val taskDescription = createResultTaskDescription(serializer, resultFunc, 
rdd, 0)
+
+    val mockBackend = mock[ExecutorBackend]
+    when(mockBackend.statusUpdate(any(), meq(TaskState.RUNNING), any()))
+      .thenAnswer(new Answer[Unit] {
+        override def answer(invocationOnMock: InvocationOnMock): Unit = {
+          ExecutorSuiteHelper.latches.latch1.countDown()
+        }
+      })
 
 Review comment:
   as I mentioned above, i don't see any point to having the call to 
`statusUpdate` set a latch.  the statusUpdate occurs in the same thread as the 
taskRunner, so you know its completed by the time `resultFunc` is called.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to