From c22dcdd1917932fe0d871a0627427ae443136ae7 Mon Sep 17 00:00:00 2001 From: Xuan Date: Tue, 3 Feb 2015 15:12:54 -0800 Subject: [PATCH] YARN-3056. Add verification for containerLaunchDuration in TestNodeManagerMetrics. Contributed by zhihai Xu (cherry picked from commit b73e776abc3e2479e397729c2bab9668f469e593) --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../server/nodemanager/metrics/TestNodeManagerMetrics.java | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 326c674a6f5..cd939c6d0a3 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -433,6 +433,9 @@ Release 2.7.0 - UNRELEASED YARN-3113. Release audit warning for Sorting icons.psd. (stevel via kihwal) + YARN-3056. Add verification for containerLaunchDuration + in TestNodeManagerMetrics. (zhihai xu via xgong) + Release 2.6.0 - 2014-11-18 INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/metrics/TestNodeManagerMetrics.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/metrics/TestNodeManagerMetrics.java index d2a06916171..4dc4648cf41 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/metrics/TestNodeManagerMetrics.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/metrics/TestNodeManagerMetrics.java @@ -17,17 +17,20 @@ */ package org.apache.hadoop.yarn.server.nodemanager.metrics; +import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; import org.apache.hadoop.metrics2.MetricsRecordBuilder; import static org.apache.hadoop.test.MetricsAsserts.*; import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.util.Records; +import org.junit.Assert; import org.junit.Test; public class TestNodeManagerMetrics { static final int GiB = 1024; // MiB @Test public void testNames() { + DefaultMetricsSystem.initialize("NodeManager"); NodeManagerMetrics metrics = NodeManagerMetrics.create(); Resource total = Records.newRecord(Resource.class); total.setMemory(8*GiB); @@ -61,7 +64,10 @@ public class TestNodeManagerMetrics { metrics.initingContainer(); metrics.runningContainer(); + + Assert.assertTrue(!metrics.containerLaunchDuration.changed()); metrics.addContainerLaunchDuration(1); + Assert.assertTrue(metrics.containerLaunchDuration.changed()); // availableGB is expected to be floored, // while allocatedGB is expected to be ceiled.