|
@@ -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.
|