Repository: ambari Updated Branches: refs/heads/branch-2.1 6432f63fc -> d6a54ace8
http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a54ace/ambari-web/test/mixins/common/widgets/export_metrics_mixin_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/common/widgets/export_metrics_mixin_test.js b/ambari-web/test/mixins/common/widgets/export_metrics_mixin_test.js index d20b484..ae27912 100644 --- a/ambari-web/test/mixins/common/widgets/export_metrics_mixin_test.js +++ b/ambari-web/test/mixins/common/widgets/export_metrics_mixin_test.js @@ -57,19 +57,50 @@ describe('App.ExportMetricsMixin', function () { var cases = [ { isExportMenuHidden: true, - title: 'menu should remain hidden' + event: { + context: true + }, + isCSV: true, + title: 'CSV, menu should remain hidden' }, { isExportMenuHidden: false, - title: 'menu should become hidden' + event: {}, + isCSV: false, + title: 'JSON, menu should become hidden' } ]; + beforeEach(function () { + sinon.stub(App.ajax, 'send', Em.K); + obj.reopen({ + targetView: { + ajaxIndex: 'index', + getDataForAjaxRequest: function () { + return { + p: 'v' + }; + } + } + }); + }); + + afterEach(function () { + App.ajax.send.restore(); + }); + cases.forEach(function (item) { it(item.title, function () { obj.set('isExportMenuHidden', item.isExportMenuHidden); - obj.exportGraphData(); + obj.exportGraphData(item.event); + var ajaxParams = App.ajax.send.firstCall.args[0]; expect(obj.get('isExportMenuHidden')).to.be.true; + expect(App.ajax.send.calledOnce).to.be.true; + expect(ajaxParams.name).to.equal('index'); + expect(ajaxParams.data).to.eql({ + p: 'v', + isCSV: item.isCSV + }); }); }); @@ -81,8 +112,6 @@ describe('App.ExportMetricsMixin', function () { { response: null, showAlertPopupCallCount: 1, - prepareCSVCallCount: 0, - prepareJSONCallCount: 0, downloadTextFileCallCount: 0, title: 'no response' }, @@ -91,8 +120,6 @@ describe('App.ExportMetricsMixin', function () { metrics: null }, showAlertPopupCallCount: 1, - prepareCSVCallCount: 0, - prepareJSONCallCount: 0, downloadTextFileCallCount: 0, title: 'no metrics object in response' }, @@ -101,8 +128,6 @@ describe('App.ExportMetricsMixin', function () { metrics: {} }, showAlertPopupCallCount: 1, - prepareCSVCallCount: 0, - prepareJSONCallCount: 0, downloadTextFileCallCount: 0, title: 'empty metrics object' }, @@ -116,9 +141,8 @@ describe('App.ExportMetricsMixin', function () { isCSV: true }, showAlertPopupCallCount: 0, - prepareCSVCallCount: 1, - prepareJSONCallCount: 0, downloadTextFileCallCount: 1, + data: '0,1', fileType: 'csv', fileName: 'data.csv', title: 'export to CSV' @@ -133,9 +157,8 @@ describe('App.ExportMetricsMixin', function () { isCSV: false }, showAlertPopupCallCount: 0, - prepareCSVCallCount: 0, - prepareJSONCallCount: 1, downloadTextFileCallCount: 1, + data: '[{"name":"m0","data":[0,1]}]', fileType: 'json', fileName: 'data.json', title: 'export to JSON' @@ -145,24 +168,40 @@ describe('App.ExportMetricsMixin', function () { beforeEach(function () { sinon.stub(App, 'showAlertPopup', Em.K); sinon.stub(fileUtils, 'downloadTextFile', Em.K); - sinon.stub(obj, 'prepareCSV', Em.K); - sinon.stub(obj, 'prepareJSON', Em.K); + sinon.stub(obj, 'prepareCSV').returns('0,1'); + obj.reopen({ + targetView: { + getData: function (response) { + var data = []; + if (response && response.metrics) { + var name = Em.keys(response.metrics)[0]; + if (name && response.metrics[name]) { + data = [ + { + name: name, + data: response.metrics[name] + } + ]; + } + } + return data; + } + } + }); }); afterEach(function () { App.showAlertPopup.restore(); fileUtils.downloadTextFile.restore(); obj.prepareCSV.restore(); - obj.prepareJSON.restore(); }); cases.forEach(function (item) { it(item.title, function () { obj.exportGraphDataSuccessCallback(item.response, null, item.params); - expect(obj.prepareCSV.callCount).to.equal(item.prepareCSVCallCount); - expect(obj.prepareJSON.callCount).to.equal(item.prepareJSONCallCount); expect(fileUtils.downloadTextFile.callCount).to.equal(item.downloadTextFileCallCount); if (item.downloadTextFileCallCount) { + expect(fileUtils.downloadTextFile.firstCall.args[0].replace(/\s/g, '')).to.equal(item.data); expect(fileUtils.downloadTextFile.firstCall.args[1]).to.equal(item.fileType); expect(fileUtils.downloadTextFile.firstCall.args[2]).to.equal(item.fileName); } @@ -196,95 +235,23 @@ describe('App.ExportMetricsMixin', function () { }); - describe('#setMetricsArrays', function () { - - var metrics = [], - titles = [], - data = { - key0: { - key1: { - key2: [[0, 1], [2, 3]], - key3: [[4, 5], [6, 7]] - } - } - }; - - it('should construct arrays with metrics info', function () { - obj.setMetricsArrays(data, metrics, titles); - expect(metrics).to.eql([[[0, 1], [2, 3]], [[4, 5], [6, 7]]]); - expect(titles).to.eql(['key2', 'key3']); - }) - - }); - describe('#prepareCSV', function () { - var cases = [ - { - data: { - metrics: { - key0: [[0, 1], [2, 3]], - key1: [[4, 1], [5, 3]] - } + var data = [ + { + name: 'n0', + data: [[0, 1], [2, 3]] }, - result: 'Timestamp,key0,key1\n1,0,4\n3,2,5\n', - title: 'old style widget metrics' - }, - { - data: [ - { - data: [[6, 7], [8, 9]] - }, - { - data: [[10, 7], [11, 9]] - } - ], - result: 'Timestamp,,\n7,6,10\n9,8,11\n', - title: 'enhanced widget metrics' - } - ]; - - cases.forEach(function (item) { - it(item.title, function () { - expect(obj.prepareCSV(item.data)).to.equal(item.result); - }); - }); - - }); - - describe('#prepareJSON', function () { - - var cases = [ - { - data: { - metrics: { - key0: [[0, 1], [2, 3]], - key1: [[4, 1], [5, 3]] - } - }, - result: "{\"key0\":[[0,1],[2,3]],\"key1\":[[4,1],[5,3]]}", - title: 'old style widget metrics' - }, - { - data: [ - { - name: 'n0', - data: [[6, 7], [8, 9]] - }, - { - name: 'n1', - data: [[10, 7], [11, 9]] - } - ], - result: "[{\"name\":\"n0\",\"data\":[[6,7],[8,9]]},{\"name\":\"n1\",\"data\":[[10,7],[11,9]]}]", - title: 'enhanced widget metrics' - } - ]; + { + name: 'n1', + data: [[4, 1], [5, 3]] + } + ], + result = 'Timestamp,n0,n1\n1,0,4\n3,2,5\n', + title = 'should do CSV export with formatting data as table'; - cases.forEach(function (item) { - it(item.title, function () { - expect(obj.prepareJSON(item.data).replace(/\s/g, '')).to.equal(item.result); - }); + it(title, function () { + expect(obj.prepareCSV(data)).to.equal(result); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a54ace/ambari-web/test/views/common/widget/graph_widget_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/widget/graph_widget_view_test.js b/ambari-web/test/views/common/widget/graph_widget_view_test.js index 7215128..31cf5f0 100644 --- a/ambari-web/test/views/common/widget/graph_widget_view_test.js +++ b/ambari-web/test/views/common/widget/graph_widget_view_test.js @@ -132,16 +132,12 @@ describe('App.GraphWidgetView', function () { var cases = [ { data: null, - prepareCSVCallCount: 0, - prepareJSONCallCount: 0, downloadTextFileCallCount: 0, showAlertPopupCallCount: 1, title: 'no data' }, { data: {}, - prepareCSVCallCount: 0, - prepareJSONCallCount: 0, downloadTextFileCallCount: 0, showAlertPopupCallCount: 1, title: 'invalid data' @@ -152,8 +148,6 @@ describe('App.GraphWidgetView', function () { data: null } ], - prepareCSVCallCount: 0, - prepareJSONCallCount: 0, downloadTextFileCallCount: 0, showAlertPopupCallCount: 1, title: 'empty data' @@ -164,8 +158,6 @@ describe('App.GraphWidgetView', function () { data: {} } ], - prepareCSVCallCount: 0, - prepareJSONCallCount: 0, downloadTextFileCallCount: 0, showAlertPopupCallCount: 1, title: 'malformed data' @@ -173,17 +165,13 @@ describe('App.GraphWidgetView', function () { { data: [ { - data: [ - { - key: 'value' - } - ] + name: 'name', + data: [0,1] } ], - prepareCSVCallCount: 0, - prepareJSONCallCount: 1, downloadTextFileCallCount: 1, showAlertPopupCallCount: 0, + fileData: '[{"name":"name","data":[0,1]}]', title: 'JSON export' }, { @@ -199,24 +187,21 @@ describe('App.GraphWidgetView', function () { event: { context: true }, - prepareCSVCallCount: 1, - prepareJSONCallCount: 0, downloadTextFileCallCount: 1, showAlertPopupCallCount: 0, + fileData: 'key,value', title: 'CSV export' } ]; beforeEach(function () { - sinon.stub(view, 'prepareCSV').returns([]); - sinon.stub(view, 'prepareJSON').returns([]); + sinon.stub(view, 'prepareCSV').returns('key,value'); sinon.stub(fileUtils, 'downloadTextFile', Em.K); sinon.stub(App, 'showAlertPopup', Em.K); }); afterEach(function () { view.prepareCSV.restore(); - view.prepareJSON.restore(); fileUtils.downloadTextFile.restore(); App.showAlertPopup.restore(); }); @@ -225,13 +210,15 @@ describe('App.GraphWidgetView', function () { it(item.title, function () { view.set('data', item.data); view.exportGraphData(item.event || {}); - expect(view.prepareCSV.callCount).to.equal(item.prepareCSVCallCount); - expect(view.prepareJSON.callCount).to.equal(item.prepareJSONCallCount); + expect(view.get('isExportMenuHidden')).to.be.true; expect(fileUtils.downloadTextFile.callCount).to.equal(item.downloadTextFileCallCount); expect(App.showAlertPopup.callCount).to.equal(item.showAlertPopupCallCount); if (item.downloadTextFileCallCount) { - var fileType = item.event && item.event.context ? 'csv' : 'json'; - expect(fileUtils.downloadTextFile.calledWith([], fileType, 'data.' + fileType)).to.be.true; + var fileType = item.event && item.event.context ? 'csv' : 'json', + downloadArgs = fileUtils.downloadTextFile.firstCall.args; + expect(downloadArgs[0].replace(/\s/g, '')).to.equal(item.fileData); + expect(downloadArgs[1]).to.equal(fileType); + expect(downloadArgs[2]).to.equal('data.' + fileType); } }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a54ace/ambari-web/test/views/main/dashboard/cluster_metrics/memory_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/dashboard/cluster_metrics/memory_test.js b/ambari-web/test/views/main/dashboard/cluster_metrics/memory_test.js deleted file mode 100644 index 5e7bc516..0000000 --- a/ambari-web/test/views/main/dashboard/cluster_metrics/memory_test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** - * 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('views/main/dashboard/cluster_metrics/memory'); - -describe('App.ChartClusterMetricsMemory', function () { - - var view; - - beforeEach(function () { - view = App.ChartClusterMetricsMemory.create(); - }); - - describe('#transformToSeries', function () { - - var jsonData = { - metrics: { - memory: { - Buffer: [ - [256, 1000000000], - [512, 1000001000] - ], - Total: [ - [1024, 1100000000], - [2048, 1100001000] - ] - } - } - }, - seriesData = [ - [ - { - x: 1000000000, - y: 262144 - }, - { - x: 1000001000, - y: 524288 - } - ], - [ - { - x: 1100000000, - y: 1048576 - }, - { - x: 1100001000, - y: 2097152 - } - ] - ], - names = ['Buffer', 'Total'], - title = 'should transform data to series'; - - it(title, function () { - var series = view.transformToSeries(jsonData); - expect(series.mapProperty('name')).to.eql(names); - expect(series.mapProperty('data')).to.eql(seriesData); - }); - - }); - -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a54ace/ambari-web/test/views/main/dashboard/widgets/cluster_metrics_widget_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/dashboard/widgets/cluster_metrics_widget_test.js b/ambari-web/test/views/main/dashboard/widgets/cluster_metrics_widget_test.js index 1471aac..f05cd30 100644 --- a/ambari-web/test/views/main/dashboard/widgets/cluster_metrics_widget_test.js +++ b/ambari-web/test/views/main/dashboard/widgets/cluster_metrics_widget_test.js @@ -28,61 +28,25 @@ describe('App.ClusterMetricsDashboardWidgetView', function () { view = App.ClusterMetricsDashboardWidgetView.create(); }); - describe('#exportGraphData', function () { + describe('#exportTargetView', function () { - beforeEach(function () { - sinon.stub(App.ajax, 'send', Em.K); - view.get('childViews').pushObjects([ + var childViews = [ { - ajaxIndex: 'ai0', - getDataForAjaxRequest: function () { - return { - p0: 'v0' - } - } + p0: 'v0' }, { - ajaxIndex: 'ai1', - getDataForAjaxRequest: function () { - return { - p1: 'v1' - } - } + p1: 'v1' } - ]); - }); + ], + title = 'should take last child view'; - afterEach(function () { - App.ajax.send.restore(); + beforeEach(function () { + view.get('childViews').pushObjects(childViews); }); - var cases = [ - { - event: {}, - isCSV: false, - title: 'JSON export' - }, - { - event: { - context: true - }, - isCSV: true, - title: 'CSV export' - } - ]; - - cases.forEach(function (item) { - it(item.title, function () { - view.exportGraphData(item.event); - expect(App.ajax.send.calledOnce).to.be.true; - expect(App.ajax.send.firstCall.args[0].name).to.equal('ai1'); - expect(App.ajax.send.firstCall.args[0].data).to.eql({ - p1: 'v1', - isCSV: item.isCSV - }); - }); + it(title, function () { + expect(view.get('exportTargetView')).to.eql(childViews[1]); }); - }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a54ace/ambari-web/test/views/main/service/info/metrics/flume/channel_size_mma_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/service/info/metrics/flume/channel_size_mma_test.js b/ambari-web/test/views/main/service/info/metrics/flume/channel_size_mma_test.js deleted file mode 100644 index 176d702..0000000 --- a/ambari-web/test/views/main/service/info/metrics/flume/channel_size_mma_test.js +++ /dev/null @@ -1,142 +0,0 @@ -/** - * 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('views/main/service/info/metrics/flume/channel_size_mma'); - -describe('App.ChartServiceMetricsFlume_ChannelSizeMMA', function () { - - var view; - - beforeEach(function () { - view = App.ChartServiceMetricsFlume_ChannelSizeMMA.create(); - }); - - describe('#transformToSeries', function () { - - var cases = [ - { - data: {}, - seriesArray: [], - title: 'empty response' - }, - { - data: { - metrics: {} - }, - seriesArray: [], - title: 'invalid response' - }, - { - data: { - metrics: { - flume: { - flume: { - CHANNEL: { - ChannelSize: { - rate: null - } - } - } - } - } - }, - seriesArray: [], - title: 'empty data' - }, - { - data: { - metrics: { - flume: { - flume: { - CHANNEL: { - ChannelSize: { - rate: { - avg: [ - [0, 1445472000], - [1, 1445472015] - ], - max: [ - [2, 1445472000], - [3, 1445472015] - ], - min: [ - [4, 1445472000], - [5, 1445472015] - ] - } - } - } - } - } - } - }, - seriesArray: [ - { - name: Em.I18n.t('services.service.info.metrics.flume.channelType').format('avg'), - data: [ - { - x: 1445472000, - y: 0 - }, - { - x: 1445472015, - y: 1 - } - ] - }, - { - name: Em.I18n.t('services.service.info.metrics.flume.channelType').format('max'), - data: [ - { - x: 1445472000, - y: 2 - }, - { - x: 1445472015, - y: 3 - } - ] - }, - { - name: Em.I18n.t('services.service.info.metrics.flume.channelType').format('min'), - data: [ - { - x: 1445472000, - y: 4 - }, - { - x: 1445472015, - y: 5 - } - ] - } - ], - title: 'valid data' - } - ]; - - cases.forEach(function (item) { - it(item.title, function () { - expect(view.transformToSeries(item.data)).to.eql(item.seriesArray); - }); - }); - - }); - -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a54ace/ambari-web/test/views/main/service/info/metrics/flume/channel_sum_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/service/info/metrics/flume/channel_sum_test.js b/ambari-web/test/views/main/service/info/metrics/flume/channel_sum_test.js deleted file mode 100644 index 53e78f2..0000000 --- a/ambari-web/test/views/main/service/info/metrics/flume/channel_sum_test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** - * 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('views/main/service/info/metrics/flume/channel_sum'); - -describe('App.ChartServiceMetricsFlume_ChannelSizeSum', function () { - - var view; - - beforeEach(function () { - view = App.ChartServiceMetricsFlume_ChannelSizeSum.create(); - }); - - describe('#transformToSeries', function () { - - var cases = [ - { - data: {}, - seriesArray: [], - title: 'empty response' - }, - { - data: { - metrics: {} - }, - seriesArray: [], - title: 'invalid response' - }, - { - data: { - metrics: { - flume: { - flume: { - CHANNEL: { - ChannelSize: { - rate: null - } - } - } - } - } - }, - seriesArray: [], - title: 'empty data' - }, - { - data: { - metrics: { - flume: { - flume: { - CHANNEL: { - ChannelSize: { - rate: { - sum: [ - [0, 1445472000], - [1, 1445472015] - ] - } - } - } - } - } - } - }, - seriesArray: [ - { - name: Em.I18n.t('services.service.info.metrics.flume.channelSizeSum'), - data: [ - { - x: 1445472000, - y: 0 - }, - { - x: 1445472015, - y: 1 - } - ] - } - ], - title: 'valid data' - } - ]; - - cases.forEach(function (item) { - it(item.title, function () { - expect(view.transformToSeries(item.data)).to.eql(item.seriesArray); - }); - }); - - }); - -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a54ace/ambari-web/test/views/main/service/info/metrics/flume/flume_incoming_mma_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/service/info/metrics/flume/flume_incoming_mma_test.js b/ambari-web/test/views/main/service/info/metrics/flume/flume_incoming_mma_test.js deleted file mode 100644 index 9f61913..0000000 --- a/ambari-web/test/views/main/service/info/metrics/flume/flume_incoming_mma_test.js +++ /dev/null @@ -1,142 +0,0 @@ -/** - * 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('views/main/service/info/metrics/flume/flume_incoming_mma'); - -describe('App.ChartServiceMetricsFlume_IncommingMMA', function () { - - var view; - - beforeEach(function () { - view = App.ChartServiceMetricsFlume_IncommingMMA.create(); - }); - - describe('#transformToSeries', function () { - - var cases = [ - { - data: {}, - seriesArray: [], - title: 'empty response' - }, - { - data: { - metrics: {} - }, - seriesArray: [], - title: 'invalid response' - }, - { - data: { - metrics: { - flume: { - flume: { - CHANNEL: { - EventPutSuccessCount: { - rate: null - } - } - } - } - } - }, - seriesArray: [], - title: 'empty data' - }, - { - data: { - metrics: { - flume: { - flume: { - CHANNEL: { - EventPutSuccessCount: { - rate: { - avg: [ - [0, 1445472000], - [1, 1445472015] - ], - max: [ - [2, 1445472000], - [3, 1445472015] - ], - min: [ - [4, 1445472000], - [5, 1445472015] - ] - } - } - } - } - } - } - }, - seriesArray: [ - { - name: Em.I18n.t('services.service.info.metrics.flume.incoming_mma').format('avg'), - data: [ - { - x: 1445472000, - y: 0 - }, - { - x: 1445472015, - y: 1 - } - ] - }, - { - name: Em.I18n.t('services.service.info.metrics.flume.incoming_mma').format('max'), - data: [ - { - x: 1445472000, - y: 2 - }, - { - x: 1445472015, - y: 3 - } - ] - }, - { - name: Em.I18n.t('services.service.info.metrics.flume.incoming_mma').format('min'), - data: [ - { - x: 1445472000, - y: 4 - }, - { - x: 1445472015, - y: 5 - } - ] - } - ], - title: 'valid data' - } - ]; - - cases.forEach(function (item) { - it(item.title, function () { - expect(view.transformToSeries(item.data)).to.eql(item.seriesArray); - }); - }); - - }); - -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a54ace/ambari-web/test/views/main/service/info/metrics/flume/flume_incoming_sum_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/service/info/metrics/flume/flume_incoming_sum_test.js b/ambari-web/test/views/main/service/info/metrics/flume/flume_incoming_sum_test.js deleted file mode 100644 index 902e8a5..0000000 --- a/ambari-web/test/views/main/service/info/metrics/flume/flume_incoming_sum_test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** - * 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('views/main/service/info/metrics/flume/flume_incoming_sum'); - -describe('App.ChartServiceMetricsFlume_IncommingSum', function () { - - var view; - - beforeEach(function () { - view = App.ChartServiceMetricsFlume_IncommingSum.create(); - }); - - describe('#transformToSeries', function () { - - var cases = [ - { - data: {}, - seriesArray: [], - title: 'empty response' - }, - { - data: { - metrics: {} - }, - seriesArray: [], - title: 'invalid response' - }, - { - data: { - metrics: { - flume: { - flume: { - CHANNEL: { - EventPutSuccessCount: { - rate: null - } - } - } - } - } - }, - seriesArray: [], - title: 'empty data' - }, - { - data: { - metrics: { - flume: { - flume: { - CHANNEL: { - EventPutSuccessCount: { - rate: { - sum: [ - [0, 1445472000], - [1, 1445472015] - ] - } - } - } - } - } - } - }, - seriesArray: [ - { - name: Em.I18n.t('services.service.info.metrics.flume.incoming.sum'), - data: [ - { - x: 1445472000, - y: 0 - }, - { - x: 1445472015, - y: 1 - } - ] - } - ], - title: 'valid data' - } - ]; - - cases.forEach(function (item) { - it(item.title, function () { - expect(view.transformToSeries(item.data)).to.eql(item.seriesArray); - }); - }); - - }); - -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a54ace/ambari-web/test/views/main/service/info/metrics/flume/flume_outgoing_mma_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/service/info/metrics/flume/flume_outgoing_mma_test.js b/ambari-web/test/views/main/service/info/metrics/flume/flume_outgoing_mma_test.js deleted file mode 100644 index 70575a7..0000000 --- a/ambari-web/test/views/main/service/info/metrics/flume/flume_outgoing_mma_test.js +++ /dev/null @@ -1,142 +0,0 @@ -/** - * 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('views/main/service/info/metrics/flume/flume_outgoing_mma'); - -describe('App.ChartServiceMetricsFlume_OutgoingMMA', function () { - - var view; - - beforeEach(function () { - view = App.ChartServiceMetricsFlume_OutgoingMMA.create(); - }); - - describe('#transformToSeries', function () { - - var cases = [ - { - data: {}, - seriesArray: [], - title: 'empty response' - }, - { - data: { - metrics: {} - }, - seriesArray: [], - title: 'invalid response' - }, - { - data: { - metrics: { - flume: { - flume: { - CHANNEL: { - EventTakeSuccessCount: { - rate: null - } - } - } - } - } - }, - seriesArray: [], - title: 'empty data' - }, - { - data: { - metrics: { - flume: { - flume: { - CHANNEL: { - EventTakeSuccessCount: { - rate: { - avg: [ - [0, 1445472000], - [1, 1445472015] - ], - max: [ - [2, 1445472000], - [3, 1445472015] - ], - min: [ - [4, 1445472000], - [5, 1445472015] - ] - } - } - } - } - } - } - }, - seriesArray: [ - { - name: Em.I18n.t('services.service.info.metrics.flume.outgoing_mma').format('avg'), - data: [ - { - x: 1445472000, - y: 0 - }, - { - x: 1445472015, - y: 1 - } - ] - }, - { - name: Em.I18n.t('services.service.info.metrics.flume.outgoing_mma').format('max'), - data: [ - { - x: 1445472000, - y: 2 - }, - { - x: 1445472015, - y: 3 - } - ] - }, - { - name: Em.I18n.t('services.service.info.metrics.flume.outgoing_mma').format('min'), - data: [ - { - x: 1445472000, - y: 4 - }, - { - x: 1445472015, - y: 5 - } - ] - } - ], - title: 'valid data' - } - ]; - - cases.forEach(function (item) { - it(item.title, function () { - expect(view.transformToSeries(item.data)).to.eql(item.seriesArray); - }); - }); - - }); - -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a54ace/ambari-web/test/views/main/service/info/metrics/flume/flume_outgoing_sum_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/service/info/metrics/flume/flume_outgoing_sum_test.js b/ambari-web/test/views/main/service/info/metrics/flume/flume_outgoing_sum_test.js deleted file mode 100644 index 14005d7..0000000 --- a/ambari-web/test/views/main/service/info/metrics/flume/flume_outgoing_sum_test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** - * 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('views/main/service/info/metrics/flume/flume_outgoing_sum'); - -describe('App.ChartServiceMetricsFlume_OutgoingSum', function () { - - var view; - - beforeEach(function () { - view = App.ChartServiceMetricsFlume_OutgoingSum.create(); - }); - - describe('#transformToSeries', function () { - - var cases = [ - { - data: {}, - seriesArray: [], - title: 'empty response' - }, - { - data: { - metrics: {} - }, - seriesArray: [], - title: 'invalid response' - }, - { - data: { - metrics: { - flume: { - flume: { - CHANNEL: { - EventTakeSuccessCount: { - rate: null - } - } - } - } - } - }, - seriesArray: [], - title: 'empty data' - }, - { - data: { - metrics: { - flume: { - flume: { - CHANNEL: { - EventTakeSuccessCount: { - rate: { - sum: [ - [0, 1445472000], - [1, 1445472015] - ] - } - } - } - } - } - } - }, - seriesArray: [ - { - name: Em.I18n.t('services.service.info.metrics.flume.outgoing.sum'), - data: [ - { - x: 1445472000, - y: 0 - }, - { - x: 1445472015, - y: 1 - } - ] - } - ], - title: 'valid data' - } - ]; - - cases.forEach(function (item) { - it(item.title, function () { - expect(view.transformToSeries(item.data)).to.eql(item.seriesArray); - }); - }); - - }); - -}); \ No newline at end of file