You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yarn-commits@hadoop.apache.org by tu...@apache.org on 2013/06/21 18:24:53 UTC
svn commit: r1495494 - in /hadoop/common/trunk/hadoop-yarn-project:
CHANGES.txt
hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resource/TestResourceWeights.java
Author: tucu
Date: Fri Jun 21 16:24:53 2013
New Revision: 1495494
URL: http://svn.apache.org/r1495494
Log:
YARN-866. Add test for class ResourceWeights. (ywskycn via tucu)
Added:
hadoop/common/trunk/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/trunk/hadoop-yarn-project/CHANGES.txt
Modified: hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt?rev=1495494&r1=1495493&r2=1495494&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt Fri Jun 21 16:24:53 2013
@@ -37,6 +37,8 @@ Release 2.2.0 - UNRELEASED
IMPROVEMENTS
+ YARN-866. Add test for class ResourceWeights. (ywskycn via tucu)
+
OPTIMIZATIONS
BUG FIXES
Added: hadoop/common/trunk/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/trunk/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=1495494&view=auto
==============================================================================
--- hadoop/common/trunk/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/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resource/TestResourceWeights.java Fri Jun 21 16:24:53 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