reswqa commented on code in PR #22306:
URL: https://github.com/apache/flink/pull/22306#discussion_r1155550049


##########
flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/slotmanager/FineGrainedSlotManagerBuilder.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.resourcemanager.slotmanager;
+
+import org.apache.flink.api.common.time.Time;
+import org.apache.flink.runtime.metrics.groups.SlotManagerMetricGroup;
+import org.apache.flink.runtime.metrics.groups.UnregisteredMetricGroups;
+import org.apache.flink.util.concurrent.ScheduledExecutor;
+
+/** Builder for {@link FineGrainedSlotManager}. */
+public class FineGrainedSlotManagerBuilder {
+    private ResourceTracker resourceTracker = new DefaultResourceTracker();
+    private TaskManagerTracker taskManagerTracker = new 
FineGrainedTaskManagerTracker();
+    private SlotStatusSyncer slotStatusSyncer = new 
DefaultSlotStatusSyncer(Time.seconds(10L));

Review Comment:
   I'd prefer to have `TestingUtils.infiniteTime()` as the default value. If a 
test case does depend on this timeout, it's this specific case's responsibility 
to set this timeout via `setSlotStatusSyncer`. 
   The advantage of this approach is: 
   - It reduces the chance of writing unstable tests.
   - we can clearly see whether a test explicitly depends on this timeout.



##########
flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerTest.java:
##########
@@ -928,9 +975,17 @@ private TestingResourceManager buildAndStart() throws 
Exception {
             }
 
             if (slotManager == null) {
-                slotManager =
-                        
DeclarativeSlotManagerBuilder.newBuilder(rpcService.getScheduledExecutor())
-                                .build();
+                assertThat(slotManagerType).isNotNull();
+                if (slotManagerType == SlotManagerType.FINE_GRAINED) {
+                    slotManager =
+                            new 
FineGrainedSlotManagerBuilder(rpcService.getScheduledExecutor())

Review Comment:
   Maybe we can change this to 
`FineGrainedSlotManagerBuilder.newBuilder(rpcService.getScheduledExecutor())` 
to consistent with of `DeclarativeSlotManagerBuilder`.



##########
flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/slotmanager/FineGrainedSlotManagerDefaultResourceAllocationStrategyITCase.java:
##########
@@ -72,4 +82,77 @@ void 
testWorkerOnlyAllocatedIfRequestedSlotCouldBeFulfilled() throws Exception {
             }
         };
     }
+
+    /**
+     * Tests that un-registration of task managers will cause resource missing 
again in
+     * ResourceTracker.
+     */
+    @Test

Review Comment:
   - Your google doc states that we should add 
`testCloseAfterSuspendDoesNotThrowException`, but I can't find this test case 
for `FineGrainedSlotManager`. 
   - `testRegisterPendingResourceAfterClearingRequirement` is marked as 
`newAdded` but it seems already existed.
   - Why `testAllocationUpdatesIgnoredIfSlotMarkedAsPendingForOtherJob()`  is 
not needed. Shouldn't we be testing that `DefaultSlotStatusSyncer` handles this 
situation correctly.



##########
flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerTest.java:
##########
@@ -928,9 +975,17 @@ private TestingResourceManager buildAndStart() throws 
Exception {
             }
 
             if (slotManager == null) {
-                slotManager =
-                        
DeclarativeSlotManagerBuilder.newBuilder(rpcService.getScheduledExecutor())
-                                .build();
+                assertThat(slotManagerType).isNotNull();
+                if (slotManagerType == SlotManagerType.FINE_GRAINED) {
+                    slotManager =
+                            new 
FineGrainedSlotManagerBuilder(rpcService.getScheduledExecutor())
+                                    .build();
+                } else if (slotManagerType == SlotManagerType.DECLARATIVE) {
+                    slotManager =
+                            DeclarativeSlotManagerBuilder.newBuilder(
+                                            rpcService.getScheduledExecutor())
+                                    .build();
+                }

Review Comment:
   I suggest that extract this part of the logic into a static method and put 
it in the top-level class instead of letting the builder do the creation of the 
`SlotManager`. This is beneficial to the future when we want to make 
`ResourceManagerBuilder` into a independent class file.



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to