|
@@ -0,0 +1,102 @@
|
|
|
+/*
|
|
|
+ * To change this template, choose Tools | Templates
|
|
|
+ * and open the template in the editor.
|
|
|
+ */
|
|
|
+package org.apache.ambari.server.controller.ganglia;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import org.junit.Test;
|
|
|
+import static org.junit.Assert.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @author root
|
|
|
+ */
|
|
|
+public class GangliaMetricTest {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Test of setDatapoints method, of class GangliaMetric.
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void testSetDatapointsOfPercentValue() {
|
|
|
+ System.out.println("setDatapoints");
|
|
|
+ List<GangliaMetric.TemporalMetric> listTemporalMetrics =
|
|
|
+ new ArrayList<GangliaMetric.TemporalMetric>();
|
|
|
+ GangliaMetric instance = new GangliaMetric();
|
|
|
+ instance.setDs_name("dsName");
|
|
|
+ instance.setCluster_name("c1");
|
|
|
+ instance.setHost_name("localhost");
|
|
|
+ instance.setMetric_name("cpu_wio");
|
|
|
+
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("111.0", new Long(1362440880)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("11.0", new Long(1362440881)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("100.0", new Long(1362440882)));
|
|
|
+ instance.setDatapointsFromList(listTemporalMetrics);
|
|
|
+ assertTrue(instance.getDatapoints().length == 2);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Test of setDatapoints method, of class GangliaMetric.
|
|
|
+ */
|
|
|
+ //@Test
|
|
|
+ public void testSetDatapointsOfgcTimeMillisValue() {
|
|
|
+ System.out.println("setDatapoints");
|
|
|
+ List<GangliaMetric.TemporalMetric> listTemporalMetrics =
|
|
|
+ new ArrayList<GangliaMetric.TemporalMetric>();
|
|
|
+ GangliaMetric instance = new GangliaMetric();
|
|
|
+ instance.setDs_name("dsName");
|
|
|
+ instance.setCluster_name("c1");
|
|
|
+ instance.setHost_name("localhost");
|
|
|
+ instance.setMetric_name("jvm.metrics.gcTimeMillis");
|
|
|
+
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("0.0", new Long(1)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("0.0", new Long(2)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("0.0", new Long(3)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("111.0", new Long(4)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("11.0", new Long(5)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("100.0", new Long(6)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("0.0", new Long(7)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("11.0", new Long(8)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("0.0", new Long(9)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("0.0", new Long(10)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("0.0", new Long(11)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("0.0", new Long(12)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("11.0", new Long(13)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("100.0", new Long(14)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("0.0", new Long(15)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("0.0", new Long(16)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("0.0", new Long(17)));
|
|
|
+ listTemporalMetrics.add(new GangliaMetric.TemporalMetric("0.0", new Long(18)));
|
|
|
+ instance.setDatapointsFromList(listTemporalMetrics);
|
|
|
+ System.out.println(instance.toString());
|
|
|
+ assertTrue(instance.getDatapoints().length == 11);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Test of GangliaMetric.TemporalMetric constructor.
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void testTemporalMetricFineValue() {
|
|
|
+ System.out.println("GangliaMetric.TemporalMetric");
|
|
|
+ GangliaMetric.TemporalMetric tm;
|
|
|
+ tm = new GangliaMetric.TemporalMetric("100", new Long(1362440880));
|
|
|
+ assertFalse("GangliaMetric.TemporalMetric is valid", tm.isIsInvalid());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Test of GangliaMetric.TemporalMetric constructor.
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void testTemporalMetricIsNaNValue() {
|
|
|
+ System.out.println("GangliaMetric.TemporalMetric");
|
|
|
+ GangliaMetric.TemporalMetric tm;
|
|
|
+ tm = new GangliaMetric.TemporalMetric("any string", new Long(1362440880));
|
|
|
+ assertTrue("GangliaMetric.TemporalMetric is invalid", tm.isIsInvalid());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|