9uapaw commented on a change in pull request #3715:
URL: https://github.com/apache/hadoop/pull/3715#discussion_r759376408



##########
File path: 
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerConfigValidator.java
##########
@@ -361,4 +530,93 @@ public static RMContext prepareRMContext() {
             .thenReturn(queuePlacementManager);
     return rmContext;
   }
+
+  private void setUpMockRM(boolean useDominantRC) throws Exception {
+    YarnConfiguration conf = new YarnConfiguration();
+    conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
+        ResourceScheduler.class);
+    setupResources(useDominantRC);
+    setupResourceValues(useDominantRC);
+    CapacitySchedulerConfiguration csConf = setupCSConfiguration(conf, 
useDominantRC);
+
+    mockRM = new MockRM(csConf);
+
+    cs = (CapacityScheduler) mockRM.getResourceScheduler();
+    mockRM.start();
+    cs.start();
+
+    setupNodes(mockRM);
+  }
+
+  private void setupNodes(MockRM newMockRM) throws Exception {
+      nm1 = new MockNM("h1:1234",
+          Resource.newInstance(NODE_MEMORY * GB, NODE1_VCORES, NODE_GPU),
+          newMockRM.getResourceTrackerService(),
+          YarnVersionInfo.getVersion());
+
+      nm1.registerNode();
+
+      nm2 = new MockNM("h2:1234",
+          Resource.newInstance(NODE_MEMORY * GB, NODE2_VCORES, NODE_GPU),
+          newMockRM.getResourceTrackerService(),
+          YarnVersionInfo.getVersion());
+      nm2.registerNode();
+
+      nm3 = new MockNM("h3:1234",
+          Resource.newInstance(NODE_MEMORY * GB, NODE3_VCORES, NODE_GPU),
+          newMockRM.getResourceTrackerService(),
+          YarnVersionInfo.getVersion());
+      nm3.registerNode();
+  }
+
+  private void setupResourceValues(boolean useGpu) {
+    A_MINRES = Resource.newInstance(16 * GB, 10);
+    B_MINRES = Resource.newInstance(32 * GB, 5);
+    FULL_MAXRES = Resource.newInstance(48 * GB, 30);
+    PARTIAL_MAXRES = Resource.newInstance(16 * GB, 10);
+    VCORE_EXCEEDED_MAXRES = Resource.newInstance(16 * GB, 50);
+    GPU_EXCEEDED_MAXRES = Resource.newInstance(16 * GB, 10);

Review comment:
       Nit: These could go at the definition, thus making the constants final.

##########
File path: 
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerConfigValidator.java
##########
@@ -361,4 +530,93 @@ public static RMContext prepareRMContext() {
             .thenReturn(queuePlacementManager);
     return rmContext;
   }
+
+  private void setUpMockRM(boolean useDominantRC) throws Exception {
+    YarnConfiguration conf = new YarnConfiguration();
+    conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
+        ResourceScheduler.class);
+    setupResources(useDominantRC);
+    setupResourceValues(useDominantRC);
+    CapacitySchedulerConfiguration csConf = setupCSConfiguration(conf, 
useDominantRC);
+
+    mockRM = new MockRM(csConf);
+
+    cs = (CapacityScheduler) mockRM.getResourceScheduler();
+    mockRM.start();
+    cs.start();
+
+    setupNodes(mockRM);
+  }
+
+  private void setupNodes(MockRM newMockRM) throws Exception {
+      nm1 = new MockNM("h1:1234",
+          Resource.newInstance(NODE_MEMORY * GB, NODE1_VCORES, NODE_GPU),
+          newMockRM.getResourceTrackerService(),
+          YarnVersionInfo.getVersion());
+
+      nm1.registerNode();
+
+      nm2 = new MockNM("h2:1234",
+          Resource.newInstance(NODE_MEMORY * GB, NODE2_VCORES, NODE_GPU),
+          newMockRM.getResourceTrackerService(),
+          YarnVersionInfo.getVersion());
+      nm2.registerNode();
+
+      nm3 = new MockNM("h3:1234",
+          Resource.newInstance(NODE_MEMORY * GB, NODE3_VCORES, NODE_GPU),
+          newMockRM.getResourceTrackerService(),
+          YarnVersionInfo.getVersion());
+      nm3.registerNode();
+  }
+
+  private void setupResourceValues(boolean useGpu) {
+    A_MINRES = Resource.newInstance(16 * GB, 10);
+    B_MINRES = Resource.newInstance(32 * GB, 5);
+    FULL_MAXRES = Resource.newInstance(48 * GB, 30);
+    PARTIAL_MAXRES = Resource.newInstance(16 * GB, 10);
+    VCORE_EXCEEDED_MAXRES = Resource.newInstance(16 * GB, 50);
+    GPU_EXCEEDED_MAXRES = Resource.newInstance(16 * GB, 10);
+
+    if (useGpu) {
+      A_MINRES.setResourceInformation(GPU_URI,
+          ResourceInformation.newInstance(GPU_URI, "", 2));
+      B_MINRES.setResourceInformation(GPU_URI,
+          ResourceInformation.newInstance(GPU_URI, "", 2));
+      FULL_MAXRES.setResourceInformation(GPU_URI,
+          ResourceInformation.newInstance(GPU_URI, "", 6));
+      PARTIAL_MAXRES.setResourceInformation(GPU_URI,
+          ResourceInformation.newInstance(GPU_URI, "", 4));
+      VCORE_EXCEEDED_MAXRES.setResourceInformation(GPU_URI,
+          ResourceInformation.newInstance(GPU_URI, "", 6));
+      GPU_EXCEEDED_MAXRES.setResourceInformation(GPU_URI,
+          ResourceInformation.newInstance(GPU_URI, "", 50));

Review comment:
       I think making separate A_MINRES_GPU constants would be more 
appropriate. Modifying static constants is rarely a good idea.




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

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



---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to