You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2013/08/24 00:06:34 UTC
git commit: AMBARI-2914. HeatMaps Unit tests. (onechiporenko via
yusaku)
Updated Branches:
refs/heads/trunk 90f1aa4a5 -> 4f4524474
AMBARI-2914. HeatMaps Unit tests. (onechiporenko via yusaku)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/4f452447
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/4f452447
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/4f452447
Branch: refs/heads/trunk
Commit: 4f4524474c1470845750fd5d0df89449aa4fe225
Parents: 90f1aa4
Author: Yusaku Sako <yu...@hortonworks.com>
Authored: Fri Aug 23 15:06:03 2013 -0700
Committer: Yusaku Sako <yu...@hortonworks.com>
Committed: Fri Aug 23 15:06:03 2013 -0700
----------------------------------------------------------------------
ambari-web/app/assets/test/tests.js | 8 ++
.../charts/heatmap_metrics/heatmap_metric.js | 4 +-
.../heatmap_metrics/heatmap_metric_dfs.js | 30 +---
.../heatmap_metric_dfs_bytesread.js | 2 +-
.../heatmap_metric_dfs_byteswritten.js | 2 +-
.../heatmap_metrics/heatmap_metric_hbase.js | 31 +----
.../heatmap_metrics/heatmap_metric_mapreduce.js | 31 +----
.../heatmap_metrics/heatmap_metric_yarn.js | 32 +----
ambari-web/app/utils/heatmap.js | 49 +++++++
.../main/admin/security/add/step3_test.js | 2 +-
.../heatmap_metric_cpuWaitIO_test.js | 113 +++++++++++++++
.../heatmap_metric_dfs_bytesread_test.js | 45 ++++++
.../heatmap_metric_dfs_byteswritten_test.js | 45 ++++++
.../heatmap_metrics/heatmap_metric_dfs_test.js | 115 ++++++++++++++++
.../heatmap_metric_diskspaceused_test.js | 116 ++++++++++++++++
.../heatmap_metric_hbase_test.js | 125 +++++++++++++++++
.../heatmap_metric_memoryused_test.js | 136 +++++++++++++++++++
.../heatmap_metrics/heatmap_metric_yarn_test.js | 115 ++++++++++++++++
18 files changed, 889 insertions(+), 112 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4f452447/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index a3d7947..62ca5c6 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -26,6 +26,14 @@ require('test/controllers/main/admin/security/add/step3_test');
require('test/controllers/main/admin/security/add/step4_test');
require('test/controllers/main/charts/heatmap_test');
require('test/controllers/main/charts/heatmap_metrics/heatmap_metric_test');
+require('test/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_test');
+require('test/controllers/main/charts/heatmap_metrics/heatmap_metric_hbase_test');
+require('test/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_test');
+require('test/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_bytesread_test');
+require('test/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_byteswritten_test');
+require('test/controllers/main/charts/heatmap_metrics/heatmap_metric_cpuWaitIO_test');
+require('test/controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused_test');
+require('test/controllers/main/charts/heatmap_metrics/heatmap_metric_memoryused_test');
require('test/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_ResourceUsed_test');
require('test/controllers/main/service/reassign_controller_test');
require('test/controllers/main/dashboard_test');
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4f452447/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric.js b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric.js
index c24e9dd..b64b8a9 100644
--- a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric.js
+++ b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric.js
@@ -18,6 +18,8 @@
var App = require('app');
var date = require('utils/date');
+var heatmap = require('utils/heatmap');
+
/**
* Base class for any heatmap metric.
*
@@ -30,7 +32,7 @@ var date = require('utils/date');
* </ul>
*
*/
-App.MainChartHeatmapMetric = Em.Object.extend({
+App.MainChartHeatmapMetric = Em.Object.extend(heatmap.mappers, {
/**
* Name of this metric
*/
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4f452447/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs.js b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs.js
index 5692188..336b081 100644
--- a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs.js
+++ b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs.js
@@ -26,38 +26,14 @@ App.MainChartHeatmapDFSMetrics = App.MainChartHeatmapMetric.extend({
/**
* Custom mapper for DFS metrics
*/
- metricMapper: function (json) {
- var hostToValueMap = {};
- var metricName = this.get('defaultMetric');
- if (json.host_components) {
- var props = metricName.split('.');
- transformValueFunction = this.get('transformValue');
- json.host_components.forEach(function (hc) {
- var value = hc;
- props.forEach(function (prop) {
- if (value != null && prop in value) {
- value = value[prop];
- } else {
- value = null;
- }
- });
- if (value != null) {
- if (transformValueFunction) {
- value = transformValueFunction(value);
- }
- var hostName = hc.HostRoles.host_name;
- hostToValueMap[hostName] = value;
- }
- });
- }
- return hostToValueMap;
+ metricMapper: function(json) {
+ return this.metricMapperWithTransform(json, this.get('defaultMetric'), this.get('transformValue'));
},
-
/**
* Utility function which allows extending classes to transform the value
* assigned to a host.
*
* @type Function
*/
- tranformValue: null
+ transformValue: null
});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4f452447/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_bytesread.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_bytesread.js b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_bytesread.js
index 9d77c80..0d28eb0 100644
--- a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_bytesread.js
+++ b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_bytesread.js
@@ -27,6 +27,6 @@ App.MainChartHeatmapDFSBytesReadMetric = App.MainChartHeatmapDFSMetrics.extend({
units: 'MB',
slotDefinitionLabelSuffix: 'MB',
transformValue: function (value) {
- return value / (1 << 6); // bytes divided by 1MB.
+ return value / (1024 * 1024); // bytes divided by 1MB.
}
});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4f452447/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_byteswritten.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_byteswritten.js b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_byteswritten.js
index 855b084..9306241 100644
--- a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_byteswritten.js
+++ b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_byteswritten.js
@@ -27,6 +27,6 @@ App.MainChartHeatmapDFSBytesWrittenMetric = App.MainChartHeatmapDFSMetrics.exten
units: 'MB',
slotDefinitionLabelSuffix: 'MB',
transformValue: function (value) {
- return value / (1 << 6); // bytes divided by 1MB.
+ return value / (1024 * 1024); // bytes divided by 1MB.
}
});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4f452447/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_hbase.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_hbase.js b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_hbase.js
index 6c63df6..e0005bf 100644
--- a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_hbase.js
+++ b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_hbase.js
@@ -24,33 +24,10 @@ App.MainChartHeatmapHbaseMetrics = App.MainChartHeatmapMetric.extend({
metricUrlTemplate: "/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=host_components/{metricName}",
/**
- * Custom mapper for DFS metrics
+ * Custom mapper for HBase metrics
*/
- metricMapper: function (json) {
- var hostToValueMap = {};
- var metricName = this.get('defaultMetric');
- if (json.host_components) {
- var props = metricName.split('.');
- transformValueFunction = this.get('transformValue');
- json.host_components.forEach(function (hc) {
- var value = hc;
- props.forEach(function (prop) {
- if (value != null && prop in value) {
- value = value[prop];
- } else {
- value = null;
- }
- });
- if (value != null) {
- if (transformValueFunction) {
- value = transformValueFunction(value);
- }
- var hostName = hc.HostRoles.host_name;
- hostToValueMap[hostName] = value;
- }
- });
- }
- return hostToValueMap;
+ metricMapper: function(json) {
+ return this.metricMapperWithTransform(json, this.get('defaultMetric'), this.get('transformValue'));
},
/**
@@ -59,5 +36,5 @@ App.MainChartHeatmapHbaseMetrics = App.MainChartHeatmapMetric.extend({
*
* @type Function
*/
- tranformValue: null
+ transformValue: null
});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4f452447/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce.js b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce.js
index 6b910cf..e26a33f 100644
--- a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce.js
+++ b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce.js
@@ -24,33 +24,10 @@ App.MainChartHeatmapMapreduceMetrics = App.MainChartHeatmapMetric.extend({
metricUrlTemplate: "/clusters/{clusterName}/services/MAPREDUCE/components/TASKTRACKER?fields=host_components/{metricName}",
/**
- * Custom mapper for DFS metrics
+ * Custom mapper for MapReduce metrics
*/
- metricMapper: function (json) {
- var hostToValueMap = {};
- var metricName = this.get('defaultMetric');
- if (json.host_components) {
- var props = metricName.split('.');
- transformValueFunction = this.get('transformValue');
- json.host_components.forEach(function (hc) {
- var value = hc;
- props.forEach(function (prop) {
- if (value != null && prop in value) {
- value = value[prop];
- } else {
- value = null;
- }
- });
- if (value != null) {
- if (transformValueFunction) {
- value = transformValueFunction(value);
- }
- var hostName = hc.HostRoles.host_name;
- hostToValueMap[hostName] = value;
- }
- });
- }
- return hostToValueMap;
+ metricMapper: function(json) {
+ return this.metricMapperWithTransform(json, this.get('defaultMetric'), this.get('transformValue'));
},
/**
@@ -59,5 +36,5 @@ App.MainChartHeatmapMapreduceMetrics = App.MainChartHeatmapMetric.extend({
*
* @type Function
*/
- tranformValue: null
+ transformValue: null
});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4f452447/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn.js b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn.js
index 299f00b..e266560 100644
--- a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn.js
+++ b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn.js
@@ -24,33 +24,11 @@ App.MainChartHeatmapYarnMetrics = App.MainChartHeatmapMetric.extend({
metricUrlTemplate: "/clusters/{clusterName}/services/YARN/components/NODEMANAGER?fields=host_components/{metricName}",
/**
- * Custom mapper for DFS metrics
+ * Custom mapper for YARN metrics
*/
- metricMapper: function (json) {
- var hostToValueMap = {};
- var metricName = this.get('defaultMetric');
- if (json.host_components) {
- var props = metricName.split('.');
- transformValueFunction = this.get('transformValue');
- json.host_components.forEach(function (hc) {
- var value = hc;
- props.forEach(function (prop) {
- if (value != null && prop in value) {
- value = value[prop];
- } else {
- value = null;
- }
- });
- if (value != null) {
- if (transformValueFunction) {
- value = transformValueFunction(value);
- }
- var hostName = hc.HostRoles.host_name;
- hostToValueMap[hostName] = value;
- }
- });
- }
- return hostToValueMap;
+
+ metricMapper: function(json) {
+ return this.metricMapperWithTransform(json, this.get('defaultMetric'), this.get('transformValue'));
},
/**
@@ -59,5 +37,5 @@ App.MainChartHeatmapYarnMetrics = App.MainChartHeatmapMetric.extend({
*
* @type Function
*/
- tranformValue: null
+ transformValue: null
});
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4f452447/ambari-web/app/utils/heatmap.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/heatmap.js b/ambari-web/app/utils/heatmap.js
new file mode 100644
index 0000000..d8672b1
--- /dev/null
+++ b/ambari-web/app/utils/heatmap.js
@@ -0,0 +1,49 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+module.exports = {
+ mappers: Em.Mixin.create({
+ metricMapperWithTransform: function (json, metricName, transformValueFunction) {
+ var hostToValueMap = {};
+ //var metricName = this.get('defaultMetric');
+ if (json.host_components) {
+ var props = metricName.split('.');
+ //var transformValueFunction = this.get('transformValue');
+ json.host_components.forEach(function (hc) {
+ var value = hc;
+ props.forEach(function (prop) {
+ if (value != null && prop in value) {
+ value = value[prop];
+ } else {
+ value = null;
+ }
+ });
+ if (value != null) {
+ if (transformValueFunction) {
+ value = transformValueFunction(value);
+ }
+ var hostName = hc.HostRoles.host_name;
+ hostToValueMap[hostName] = value;
+ }
+ });
+ }
+ return hostToValueMap;
+ }
+ })
+};
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4f452447/ambari-web/test/controllers/main/admin/security/add/step3_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/security/add/step3_test.js b/ambari-web/test/controllers/main/admin/security/add/step3_test.js
index 4d12829..847ed53 100644
--- a/ambari-web/test/controllers/main/admin/security/add/step3_test.js
+++ b/ambari-web/test/controllers/main/admin/security/add/step3_test.js
@@ -31,7 +31,7 @@ describe('App.MainAdminSecurityAddStep3Controller', function () {
describe('#getSecurityUsers', function() {
it('no hosts, just check users (testMode = true)', function() {
App.testMode = true;
- expect(mainAdminSecurityAddStep3Controller.getSecurityUsers().length).to.equal(9);
+ expect(mainAdminSecurityAddStep3Controller.getSecurityUsers().length).to.equal(10);
});
});
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4f452447/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_cpuWaitIO_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_cpuWaitIO_test.js b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_cpuWaitIO_test.js
new file mode 100644
index 0000000..6f46539
--- /dev/null
+++ b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_cpuWaitIO_test.js
@@ -0,0 +1,113 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+require('messages');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_cpuWaitIO');
+
+describe('App.MainChartHeatmapCpuWaitIOMetric', function () {
+
+ var tests = [
+ {
+ json: {
+ "items" : [
+ {
+ "Hosts" : {
+ "host_name" : "dev01.hortonworks.com"
+ },
+ "metrics" : {
+ "cpu" : {
+ "cpu_wio" : 0.4
+ }
+ }
+ }
+ ]
+ },
+ m: 'One host',
+ e: {'dev01.hortonworks.com': '40.0'}
+ },
+ {
+ json: {
+ "items" : [
+ {
+ "Hosts" : {
+ "host_name" : "dev01.hortonworks.com"
+ },
+ "metrics" : {
+ "cpu" : {
+ "cpu_wio" : 0.4
+ }
+ }
+ },
+ {
+ "Hosts" : {
+ "host_name" : "dev02.hortonworks.com"
+ },
+ "metrics" : {
+ "cpu" : {
+ "cpu_wio" : 0.34566
+ }
+ }
+ }
+ ]
+ },
+ m: 'Two hosts',
+ e: {'dev01.hortonworks.com': '40.0', 'dev02.hortonworks.com': '34.6'}
+ },
+ {
+ json: {
+ "items" : [
+ {
+ "Hosts" : {
+ "host_name" : "dev01.hortonworks.com"
+ },
+ "metrics" : {
+ "cpu" : {
+ "cpu_wio" : 0.4
+ }
+ }
+ },
+ {
+ "Hosts" : {
+ "host_name" : "dev02.hortonworks.com"
+ },
+ "metrics" : {
+ "cpu" : {
+ }
+ }
+ }
+ ]
+ },
+ m: 'Two hosts, One without metric',
+ e: {'dev01.hortonworks.com': '40.0'}
+ }
+ ];
+
+ describe('#metricMapper()', function() {
+ var mainChartHeatmapCpuWaitIOMetric = App.MainChartHeatmapCpuWaitIOMetric.create();
+
+ tests.forEach(function(test) {
+ it(test.m, function() {
+ var r = mainChartHeatmapCpuWaitIOMetric.metricMapper(test.json);
+ expect(r).to.eql(test.e);
+ });
+ });
+
+ });
+
+});
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4f452447/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_bytesread_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_bytesread_test.js b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_bytesread_test.js
new file mode 100644
index 0000000..cebf41d
--- /dev/null
+++ b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_bytesread_test.js
@@ -0,0 +1,45 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+require('messages');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_dfs');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_bytesread');
+
+describe('App.MainChartHeatmapDFSBytesReadMetric', function () {
+
+ var tests = [
+ {i: 0, e: 0},
+ {i: 0.5 * 1024* 1024, e: 0.5},
+ {i: 1024* 1024, e: 1},
+ {i: 10.5 * 1024 * 1024,e: 10.5}
+ ];
+
+ describe('#transformValue()', function() {
+ var mainChartHeatmapDFSBytesReadMetric = App.MainChartHeatmapDFSBytesReadMetric.create();
+
+ tests.forEach(function(test) {
+ it(test.i + ' bytes to ' + test.e + ' MB', function() {
+ var r = mainChartHeatmapDFSBytesReadMetric.transformValue(test.i);
+ expect(r).to.eql(test.e);
+ });
+ });
+
+ });
+
+});
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4f452447/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_byteswritten_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_byteswritten_test.js b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_byteswritten_test.js
new file mode 100644
index 0000000..240802e
--- /dev/null
+++ b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_byteswritten_test.js
@@ -0,0 +1,45 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+require('messages');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_dfs');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_byteswritten');
+
+describe('App.MainChartHeatmapDFSBytesWrittenMetric', function () {
+
+ var tests = [
+ {i: 0, e: 0},
+ {i: 0.5 * 1024* 1024, e: 0.5},
+ {i: 1024* 1024, e: 1},
+ {i: 10.5 * 1024 * 1024,e: 10.5}
+ ];
+
+ describe('#transformValue()', function() {
+ var mainChartHeatmapDFSBytesWrittenMetric = App.MainChartHeatmapDFSBytesWrittenMetric.create();
+
+ tests.forEach(function(test) {
+ it(test.i + ' bytes to ' + test.e + ' MB', function() {
+ var r = mainChartHeatmapDFSBytesWrittenMetric.transformValue(test.i);
+ expect(r).to.eql(test.e);
+ });
+ });
+
+ });
+
+});
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4f452447/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_test.js b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_test.js
new file mode 100644
index 0000000..06d62c2
--- /dev/null
+++ b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_test.js
@@ -0,0 +1,115 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+require('messages');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_dfs');
+
+describe('App.MainChartHeatmapDFSMetrics', function () {
+
+ var tests = [
+ {
+ json: {
+ "host_components" : [
+ {
+ "HostRoles" : {
+ "host_name" : "dev01.hortonworks.com"
+ },
+ "metrics" : {
+ "jvm" : {
+ "gcTimeMillis" : 285
+ }
+ }
+ }
+ ]
+ },
+ result: {'dev01.hortonworks.com': 285},
+ m: 'One host_component'
+ },
+ {
+ json: {
+ "host_components" : [
+ {
+ "HostRoles" : {
+ "host_name" : "dev01.hortonworks.com"
+ },
+ "metrics" : {
+ "jvm" : {
+ "gcTimeMillis" : 285
+ }
+ }
+ },
+ {
+ "HostRoles" : {
+ "host_name" : "dev02.hortonworks.com"
+ },
+ "metrics" : {
+ "jvm" : {
+ "gcTimeMillis" : 124
+ }
+ }
+ }
+ ]
+ },
+ result: {'dev01.hortonworks.com': 285, 'dev02.hortonworks.com': 124},
+ m: 'Two host_components'
+ },
+ {
+ json: {
+ "host_components" : [
+ {
+ "HostRoles" : {
+ "host_name" : "dev01.hortonworks.com"
+ },
+ "metrics" : {
+ "jvm" : {
+ "gcTimeMillis" : 285
+ }
+ }
+ },
+ {
+ "HostRoles" : {
+ "host_name" : "dev02.hortonworks.com"
+ },
+ "metrics" : {
+ "jvm" : {
+
+ }
+ }
+ }
+ ]
+ },
+ result: {'dev01.hortonworks.com': 285},
+ m: 'Two host_components, one without metric'
+ }
+ ];
+
+ describe('#metricMapper()', function() {
+ var mainChartHeatmapDFSMetrics = App.MainChartHeatmapDFSMetrics.create();
+ mainChartHeatmapDFSMetrics.set('defaultMetric', 'metrics.jvm.gcTimeMillis');
+
+ tests.forEach(function(test) {
+ it(test.m, function() {
+ var r = mainChartHeatmapDFSMetrics.metricMapper(test.json);
+ expect(r).to.eql(test.result);
+ });
+ });
+
+ });
+
+});
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4f452447/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused_test.js b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused_test.js
new file mode 100644
index 0000000..2875fa7
--- /dev/null
+++ b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused_test.js
@@ -0,0 +1,116 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+require('messages');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused');
+
+describe('App.MainChartHeatmapDiskSpaceUsedMetric', function () {
+
+ var tests = [
+ {
+ json:{
+ "items" : [
+ {
+ "Hosts" : {
+ "host_name" : "dev01.hortonworks.com"
+ },
+ "metrics" : {
+ "disk" : {
+ "disk_free" : 89.973,
+ "disk_total" : 101.515
+ }
+ }
+ }
+ ]
+ },
+ m: 'One host',
+ e: {'dev01.hortonworks.com': '11.4'}
+ },
+ {
+ json:{
+ "items" : [
+ {
+ "Hosts" : {
+ "host_name" : "dev01.hortonworks.com"
+ },
+ "metrics" : {
+ "disk" : {
+ "disk_free" : 89.973,
+ "disk_total" : 101.515
+ }
+ }
+ },
+ {
+ "Hosts" : {
+ "host_name" : "dev02.hortonworks.com"
+ },
+ "metrics" : {
+ "disk" : {
+ "disk_free" : 89.973,
+ "disk_total" : 101.515
+ }
+ }
+ }
+ ]
+ },
+ m: 'Two hosts',
+ e: {'dev01.hortonworks.com': '11.4', 'dev02.hortonworks.com': '11.4'}
+ },
+ {
+ json:{
+ "items" : [
+ {
+ "Hosts" : {
+ "host_name" : "dev01.hortonworks.com"
+ },
+ "metrics" : {
+ "disk" : {
+ "disk_free" : 89.973,
+ "disk_total" : 101.515
+ }
+ }
+ },
+ {
+ "Hosts" : {
+ "host_name" : "dev02.hortonworks.com"
+ },
+ "metrics" : {
+
+ }
+ }
+ ]
+ },
+ m: 'Two hosts, One without metric',
+ e: {'dev01.hortonworks.com': '11.4'}
+ }
+ ];
+
+ describe('#metricMapper()', function() {
+ var mainChartHeatmapDiskSpaceUsedMetric = App.MainChartHeatmapDiskSpaceUsedMetric.create();
+
+ tests.forEach(function(test) {
+ it(test.m, function() {
+ var r = mainChartHeatmapDiskSpaceUsedMetric.metricMapper(test.json);
+ expect(r).to.eql(test.e);
+ });
+ });
+
+ });
+
+});
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4f452447/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_hbase_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_hbase_test.js b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_hbase_test.js
new file mode 100644
index 0000000..a1f0325
--- /dev/null
+++ b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_hbase_test.js
@@ -0,0 +1,125 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+require('messages');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_hbase');
+
+describe('App.MainChartHeatmapHbaseMetrics', function () {
+
+ var tests = [
+ {
+ json: {
+ "host_components" : [
+ {
+ "HostRoles" : {
+ "host_name" : "dev01.hortonworks.com"
+ },
+ "metrics" : {
+ "hbase" : {
+ "regionserver" : {
+ "readRequestsCount" : 0.0
+ }
+ }
+ }
+ }
+ ]
+ },
+ result: {'dev01.hortonworks.com': 0},
+ m: 'One host_component'
+ },
+ {
+ json: {
+ "host_components" : [
+ {
+ "HostRoles" : {
+ "host_name" : "dev01.hortonworks.com"
+ },
+ "metrics" : {
+ "hbase" : {
+ "regionserver" : {
+ "readRequestsCount" : 0.0
+ }
+ }
+ }
+ },
+ {
+ "HostRoles" : {
+ "host_name" : "dev02.hortonworks.com"
+ },
+ "metrics" : {
+ "hbase" : {
+ "regionserver" : {
+ "readRequestsCount" : 1.0
+ }
+ }
+ }
+ }
+ ]
+ },
+ result: {'dev01.hortonworks.com': 0, 'dev02.hortonworks.com': 1},
+ m: 'Two host_components'
+ },
+ {
+ json: {
+ "host_components" : [
+ {
+ "HostRoles" : {
+ "host_name" : "dev01.hortonworks.com"
+ },
+ "metrics" : {
+ "hbase" : {
+ "regionserver" : {
+ "readRequestsCount" : 0.0
+ }
+ }
+ }
+ },
+ {
+ "HostRoles" : {
+ "host_name" : "dev02.hortonworks.com"
+ },
+ "metrics" : {
+ "hbase" : {
+ "regionserver" : {
+
+ }
+ }
+ }
+ }
+ ]
+ },
+ result: {'dev01.hortonworks.com': 0},
+ m: 'Two host_components, one without metric'
+ }
+ ];
+
+ describe('#metricMapper()', function() {
+ var mainChartHeatmapHbaseMetrics = App.MainChartHeatmapHbaseMetrics.create();
+ mainChartHeatmapHbaseMetrics.set('defaultMetric', 'metrics.hbase.regionserver.readRequestsCount');
+
+ tests.forEach(function(test) {
+ it(test.m, function() {
+ var r = mainChartHeatmapHbaseMetrics.metricMapper(test.json);
+ expect(r).to.eql(test.result);
+ });
+ });
+
+ });
+
+});
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4f452447/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_memoryused_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_memoryused_test.js b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_memoryused_test.js
new file mode 100644
index 0000000..8886d8a
--- /dev/null
+++ b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_memoryused_test.js
@@ -0,0 +1,136 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+require('messages');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_memoryused');
+
+describe('App.MainChartHeatmapMemoryUsedMetric', function () {
+
+ var tests = [
+ {
+ json:{
+ "items" : [
+ {
+ "Hosts" : {
+ "host_name" : "dev01.hortonworks.com"
+ },
+ "metrics" : {
+ "memory" : {
+ "mem_buffers" : 109888.0,
+ "mem_cached" : 1965624.0,
+ "mem_free" : 261632.0,
+ "mem_shared" : 0.0,
+ "mem_total" : 6123776.0,
+ "swap_free" : 4126820.0,
+ "swap_total" : 4128760.0
+ }
+ }
+ }
+ ]
+ },
+ m: 'One host',
+ e: {'dev01.hortonworks.com': '63.6'}
+ },
+ {
+ json:{
+ "items" : [
+ {
+ "Hosts" : {
+ "host_name" : "dev01.hortonworks.com"
+ },
+ "metrics" : {
+ "memory" : {
+ "mem_buffers" : 109888.0,
+ "mem_cached" : 1965624.0,
+ "mem_free" : 261632.0,
+ "mem_shared" : 0.0,
+ "mem_total" : 6123776.0,
+ "swap_free" : 4126820.0,
+ "swap_total" : 4128760.0
+ }
+ }
+ },
+ {
+ "Hosts" : {
+ "host_name" : "dev02.hortonworks.com"
+ },
+ "metrics" : {
+ "memory" : {
+ "mem_buffers" : 109888.0,
+ "mem_cached" : 1965624.0,
+ "mem_free" : 261632.0,
+ "mem_shared" : 0.0,
+ "mem_total" : 6123776.0,
+ "swap_free" : 4126820.0,
+ "swap_total" : 4128760.0
+ }
+ }
+ }
+ ]
+ },
+ m: 'Two hosts',
+ e: {'dev01.hortonworks.com': '63.6', 'dev02.hortonworks.com': '63.6'}
+ },
+ {
+ json:{
+ "items" : [
+ {
+ "Hosts" : {
+ "host_name" : "dev01.hortonworks.com"
+ },
+ "metrics" : {
+ "memory" : {
+ "mem_buffers" : 109888.0,
+ "mem_cached" : 1965624.0,
+ "mem_free" : 261632.0,
+ "mem_shared" : 0.0,
+ "mem_total" : 6123776.0,
+ "swap_free" : 4126820.0,
+ "swap_total" : 4128760.0
+ }
+ }
+ },
+ {
+ "Hosts" : {
+ "host_name" : "dev02.hortonworks.com"
+ },
+ "metrics" : {
+
+ }
+ }
+ ]
+ },
+ m: 'Two hosts, One without metric',
+ e: {'dev01.hortonworks.com': '63.6'}
+ }
+ ];
+
+ describe('#metricMapper()', function() {
+ var mainChartHeatmapMemoryUsedMetric = App.MainChartHeatmapMemoryUsedMetric.create();
+
+ tests.forEach(function(test) {
+ it(test.m, function() {
+ var r = mainChartHeatmapMemoryUsedMetric.metricMapper(test.json);
+ expect(r).to.eql(test.e);
+ });
+ });
+
+ });
+
+});
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4f452447/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_test.js b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_test.js
new file mode 100644
index 0000000..d8744cd
--- /dev/null
+++ b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_test.js
@@ -0,0 +1,115 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+require('messages');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric');
+require('controllers/main/charts/heatmap_metrics/heatmap_metric_yarn');
+
+describe('App.MainChartHeatmapYarnMetrics', function () {
+
+ var tests = [
+ {
+ json: {
+ "host_components" : [
+ {
+ "HostRoles" : {
+ "host_name" : "dev01.hortonworks.com"
+ },
+ "metrics" : {
+ "jvm" : {
+ "memHeapUsedM" : 10
+ }
+ }
+ }
+ ]
+ },
+ result: {'dev01.hortonworks.com': 10},
+ m: 'One host_component'
+ },
+ {
+ json: {
+ "host_components" : [
+ {
+ "HostRoles" : {
+ "host_name" : "dev01.hortonworks.com"
+ },
+ "metrics" : {
+ "jvm" : {
+ "memHeapUsedM" : 10
+ }
+ }
+ },
+ {
+ "HostRoles" : {
+ "host_name" : "dev02.hortonworks.com"
+ },
+ "metrics" : {
+ "jvm" : {
+ "memHeapUsedM" : 20
+ }
+ }
+ }
+ ]
+ },
+ result: {'dev01.hortonworks.com': 10, 'dev02.hortonworks.com': 20},
+ m: 'Two host_components'
+ },
+ {
+ json: {
+ "host_components" : [
+ {
+ "HostRoles" : {
+ "host_name" : "dev01.hortonworks.com"
+ },
+ "metrics" : {
+ "jvm" : {
+ "memHeapUsedM" : 10
+ }
+ }
+ },
+ {
+ "HostRoles" : {
+ "host_name" : "dev02.hortonworks.com"
+ },
+ "metrics" : {
+ "jvm" : {
+
+ }
+ }
+ }
+ ]
+ },
+ result: {'dev01.hortonworks.com': 10},
+ m: 'Two host_components, one without metric'
+ }
+ ];
+
+ describe('#metricMapper()', function() {
+ var mainChartHeatmapYarnMetrics = App.MainChartHeatmapYarnMetrics.create();
+ mainChartHeatmapYarnMetrics.set('defaultMetric', 'metrics.jvm.memHeapUsedM');
+
+ tests.forEach(function(test) {
+ it(test.m, function() {
+ var r = mainChartHeatmapYarnMetrics.metricMapper(test.json);
+ expect(r).to.eql(test.result);
+ });
+ });
+
+ });
+
+});