HuangZhenQiu commented on a change in pull request #8952:
URL: https://github.com/apache/flink/pull/8952#discussion_r547855489



##########
File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/active/ActiveResourceManagerTest.java
##########
@@ -378,15 +382,69 @@ public void testOnError() throws Exception {
                }};
        }
 
-       private static class Context {
+       @Test
+       public void testWorkerCreationInterval() throws Exception {
+               Configuration configuration = new Configuration();
+               
configuration.setDouble(ResourceManagerOptions.MAXIMUM_WORKERS_FAILURE_RATE, 1);
+               
configuration.setLong(ResourceManagerOptions.WORKER_CREATION_RETRY_INTERVAL,
+                       WORKER_CREATION_INTERVAL.toMilliseconds());
+               new Context(configuration) {{

Review comment:
       Sorry, what I mean is the initialization of the resource manager is 
before the testMethod.run(). We can't override the config in 
RunnableWithException to change the behavior of rm.

##########
File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/active/ActiveResourceManagerTest.java
##########
@@ -378,15 +382,69 @@ public void testOnError() throws Exception {
                }};
        }
 
-       private static class Context {
+       @Test
+       public void testWorkerCreationInterval() throws Exception {
+               Configuration configuration = new Configuration();
+               
configuration.setDouble(ResourceManagerOptions.MAXIMUM_WORKERS_FAILURE_RATE, 1);
+               
configuration.setLong(ResourceManagerOptions.WORKER_CREATION_RETRY_INTERVAL,
+                       WORKER_CREATION_INTERVAL.toMilliseconds());
+               new Context(configuration) {{
+                       final AtomicInteger requestCount = new AtomicInteger(0);
+
+                       final List<ResourceID> tmResourceIds = new 
ArrayList<>();
+                       tmResourceIds.add(ResourceID.generate());
+                       tmResourceIds.add(ResourceID.generate());
+
+                       final List<CompletableFuture<Long>> 
requestWorkerFromDriverFutures = new ArrayList<>();
+                       requestWorkerFromDriverFutures.add(new 
CompletableFuture<>());
+                       requestWorkerFromDriverFutures.add(new 
CompletableFuture<>());
+
+                       
driverBuilder.setRequestResourceFunction(taskExecutorProcessSpec -> {
+                               int idx = requestCount.getAndIncrement();
+                               assertThat(idx, lessThan(2));
+
+                               
requestWorkerFromDriverFutures.get(idx).complete(System.currentTimeMillis());
+                               return 
CompletableFuture.completedFuture(tmResourceIds.get(idx));
+                       });
+
+                       slotManagerBuilder.setGetRequiredResourcesSupplier(() 
-> Collections.singletonMap(WORKER_RESOURCE_SPEC, 1));
 
-               final Configuration flinkConfig = new Configuration();
+                       runTest(() -> {
+                               // received worker request, verify requesting 
from driver
+                               CompletableFuture<Boolean> startNewWorkerFuture 
= runInMainThread(() ->
+                                       
getResourceManager().startNewWorker(WORKER_RESOURCE_SPEC));
+                               long t1 = 
requestWorkerFromDriverFutures.get(0).get(TIMEOUT_SEC, TimeUnit.SECONDS);
+                               
assertThat(startNewWorkerFuture.get(TIMEOUT_SEC, TimeUnit.SECONDS), is(true));
+
+                               // first worker failed before register, verify 
requesting another worker from driver
+                               runInMainThread(() -> 
getResourceManager().onWorkerTerminated(tmResourceIds.get(0), "terminate for 
testing"));

Review comment:
       Agree. Added another test case accordingly.




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