mynameborat commented on a change in pull request #1378:
URL: https://github.com/apache/samza/pull/1378#discussion_r437003992



##########
File path: 
samza-core/src/test/java/org/apache/samza/clustermanager/TestContainerPlacementActions.java
##########
@@ -1011,4 +1026,13 @@ private void assertBadRequests(String processorId, 
String destinationHost, Conta
     // Request shall be deleted as soon as it is acted upon
     
assertFalse(containerPlacementMetadataStore.readContainerPlacementRequestMessage(requestMessage.getUuid()).isPresent());
   }
+
+  private void 
cleanUpRequestAllocatorThread(ContainerPlacementRequestAllocator 
requestAllocator, Thread containerPlacementRequestAllocatorThread) {
+    requestAllocator.stop();
+    try {
+      containerPlacementRequestAllocatorThread.join();
+    } catch (InterruptedException ie) {
+      Thread.currentThread().interrupt();
+    }
+  }

Review comment:
       Can this be part of `AfterMethod` tearDown provided you extract the 
request allocator to class level? It still gets cleaned up for tests that 
forget to invoke this explicitly.

##########
File path: 
samza-core/src/test/java/org/apache/samza/clustermanager/TestContainerPlacementActions.java
##########
@@ -266,9 +274,10 @@ public Void answer(InvocationOnMock invocation) {
   @Test(timeout = 30000)
   public void testActionQueuingForConsecutivePlacementActions() throws 
Exception {
     // Spawn a Request Allocator Thread
-    Thread requestAllocatorThread = new Thread(
-        new 
ContainerPlacementRequestAllocator(containerPlacementMetadataStore, cpm, new 
ApplicationConfig(config)),
-        "ContainerPlacement Request Allocator Thread");
+    ContainerPlacementRequestAllocator requestAllocator =
+        new 
ContainerPlacementRequestAllocator(containerPlacementMetadataStore, cpm, new 
ApplicationConfig(config));
+    Thread requestAllocatorThread = new Thread(requestAllocator, 
"ContainerPlacement Request Allocator Thread");
+

Review comment:
       Can this be extracted at the class level and initialize before every 
tests?




----------------------------------------------------------------
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:
[email protected]


Reply via email to