hadoop-yarn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r1502071 - in /hadoop/common/branches/branch-2.1-beta/hadoop-yarn-project: ./ hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resource/
Date Thu, 11 Jul 2013 00:15:15 GMT
Author: tucu
Date: Thu Jul 11 00:15:15 2013
New Revision: 1502071

URL: http://svn.apache.org/r1502071
Log:
YARN-866. Add test for class ResourceWeights. (ywskycn via tucu)

Added:
    hadoop/common/branches/branch-2.1-beta/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resource/TestResourceWeights.java
Modified:
    hadoop/common/branches/branch-2.1-beta/hadoop-yarn-project/CHANGES.txt

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-yarn-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-yarn-project/CHANGES.txt?rev=1502071&r1=1502070&r2=1502071&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-yarn-project/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-yarn-project/CHANGES.txt Thu Jul 11 00:15:15
2013
@@ -426,6 +426,8 @@ Release 2.1.0-beta - 2013-07-02
     YARN-827. Need to make Resource arithmetic methods accessible (Jian He via
     bikas)
 
+    YARN-866. Add test for class ResourceWeights. (ywskycn via tucu)
+
   OPTIMIZATIONS
 
     YARN-512. Log aggregation root directory check is more expensive than it

Added: hadoop/common/branches/branch-2.1-beta/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resource/TestResourceWeights.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resource/TestResourceWeights.java?rev=1502071&view=auto
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resource/TestResourceWeights.java
(added)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resource/TestResourceWeights.java
Thu Jul 11 00:15:15 2013
@@ -0,0 +1,55 @@
+/**
+ * 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.hadoop.yarn.server.resourcemanager.resource;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+public class TestResourceWeights {
+  
+  @Test(timeout=3000)
+  public void testWeights() {
+    ResourceWeights rw1 = new ResourceWeights();
+    Assert.assertEquals("Default CPU weight should be 0.0f.", 0.0f, 
+        rw1.getWeight(ResourceType.CPU), 0.00001f);
+    Assert.assertEquals("Default memory weight should be 0.0f", 0.0f, 
+        rw1.getWeight(ResourceType.MEMORY), 0.00001f);
+
+    ResourceWeights rw2 = new ResourceWeights(2.0f);
+    Assert.assertEquals("The CPU weight should be 2.0f.", 2.0f, 
+        rw2.getWeight(ResourceType.CPU), 0.00001f);
+    Assert.assertEquals("The memory weight should be 2.0f", 2.0f, 
+        rw2.getWeight(ResourceType.MEMORY), 0.00001f);
+
+    // set each individually
+    ResourceWeights rw3 = new ResourceWeights(1.5f, 2.0f);
+    Assert.assertEquals("The CPU weight should be 2.0f", 2.0f, 
+        rw3.getWeight(ResourceType.CPU), 0.00001f);
+    Assert.assertEquals("The memory weight should be 1.5f", 1.5f, 
+        rw3.getWeight(ResourceType.MEMORY), 0.00001f);
+
+    // reset weights
+    rw3.setWeight(ResourceType.CPU, 2.5f);
+    Assert.assertEquals("The CPU weight should be set to 2.5f.", 2.5f,
+        rw3.getWeight(ResourceType.CPU), 0.00001f);
+    rw3.setWeight(ResourceType.MEMORY, 4.0f);
+    Assert.assertEquals("The memory weight should be set to 4.0f.", 4.0f, 
+        rw3.getWeight(ResourceType.MEMORY), 0.00001f);
+  }
+}
\ No newline at end of file



Mime
View raw message