ayushtkn commented on code in PR #504:
URL: https://github.com/apache/tez/pull/504#discussion_r3371125583


##########
tez-mapreduce/src/test/java/org/apache/tez/mapreduce/processor/map/TestMapProcessor.java:
##########
@@ -237,21 +270,20 @@ public void testMapProcessorProgress() throws Exception {
             Collections.singletonList(mapOutputSpec), sharedExecutor);
 
     ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
-    Thread monitorProgress = new Thread(new Runnable() {
-      @Override
-      public void run() {
-        float prog = task.getProgress();
-        if(prog > 0.0f && prog < 1.0f)
-          progressUpdate = prog;
+    scheduler.scheduleAtFixedRate(() -> {
+      float prog = task.getProgress();
+      if (prog > 0.0f && prog < 1.0f) {
+        progressLatch.countDown();
       }
-    });
+    }, 0, 1, TimeUnit.MILLISECONDS);
 
     task.initialize();
-    scheduler.scheduleAtFixedRate(monitorProgress, 0, 1,
-        TimeUnit.MILLISECONDS);
     task.run();
-    Assert.assertTrue("Progress Updates should be captured!",
-        progressUpdate > 0.0f && progressUpdate < 1.0f);
+
+    GenericTestUtils.waitFor(() -> progressLatch.getCount() == 0, 10, 5000,
+        "Progress update between 0.0 and 1.0 was never captured");
+
+    scheduler.shutdownNow();
     task.close();
     sharedExecutor.shutdownNow();

Review Comment:
   maybe this could be in finally block, if the above assertion fails, 
resources would get leaked



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to