|
@@ -18,7 +18,7 @@
|
|
|
|
|
|
var App = require('app');
|
|
|
|
|
|
-describe('App.WidgetMixin', function() {
|
|
|
+describe('App.WidgetMixin', function () {
|
|
|
var mixinClass = Em.Object.extend(App.WidgetMixin, {metrics: [], content: {}});
|
|
|
|
|
|
describe('#loadMetrics()', function () {
|
|
@@ -47,7 +47,7 @@ describe('App.WidgetMixin', function() {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- describe("#extractExpressions()", function() {
|
|
|
+ describe("#extractExpressions()", function () {
|
|
|
var mixinObject = mixinClass.create();
|
|
|
var testCases = [
|
|
|
{
|
|
@@ -79,9 +79,9 @@ describe('App.WidgetMixin', function() {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- describe("#getRequestData()", function() {
|
|
|
+ describe("#getRequestData()", function () {
|
|
|
var mixinObject = mixinClass.create();
|
|
|
- it("", function() {
|
|
|
+ it("", function () {
|
|
|
var data = [
|
|
|
{
|
|
|
"name": "regionserver.Server.percentFilesLocal",
|
|
@@ -111,14 +111,24 @@ describe('App.WidgetMixin', function() {
|
|
|
}
|
|
|
];
|
|
|
|
|
|
- expect(mixinObject.getRequestData(data)).to.eql({
|
|
|
+ expect(JSON.stringify(mixinObject.getRequestData(data))).to.eql(JSON.stringify({
|
|
|
"HBASE_HBASE_REGIONSERVER": {
|
|
|
"name": "regionserver.Server.percentFilesLocal",
|
|
|
"service_name": "HBASE",
|
|
|
"component_name": "HBASE_REGIONSERVER",
|
|
|
"metric_paths": [
|
|
|
- "metrics/hbase/regionserver/percentFilesLocal",
|
|
|
- "w2"
|
|
|
+ {
|
|
|
+ "metric_path": "metrics/hbase/regionserver/percentFilesLocal",
|
|
|
+ "metric_type": "POINT_IN_TIME",
|
|
|
+ "id": "metrics/hbase/regionserver/percentFilesLocal_POINT_IN_TIME",
|
|
|
+ "context": {}
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "metric_path": "w2",
|
|
|
+ "metric_type": "POINT_IN_TIME",
|
|
|
+ "id": "w2_POINT_IN_TIME",
|
|
|
+ "context": {}
|
|
|
+ }
|
|
|
]
|
|
|
},
|
|
|
"HBASE_HBASE_REGIONSERVER_c1": {
|
|
@@ -127,7 +137,12 @@ describe('App.WidgetMixin', function() {
|
|
|
"component_name": "HBASE_REGIONSERVER",
|
|
|
"host_component_criteria": "c1",
|
|
|
"metric_paths": [
|
|
|
- "metrics/hbase/regionserver/percentFilesLocal"
|
|
|
+ {
|
|
|
+ "metric_path": "metrics/hbase/regionserver/percentFilesLocal",
|
|
|
+ "metric_type": "POINT_IN_TIME",
|
|
|
+ "id": "metrics/hbase/regionserver/percentFilesLocal_POINT_IN_TIME",
|
|
|
+ "context": {}
|
|
|
+ }
|
|
|
]
|
|
|
},
|
|
|
"HDFS_DATANODE_c1": {
|
|
@@ -136,10 +151,15 @@ describe('App.WidgetMixin', function() {
|
|
|
"component_name": "DATANODE",
|
|
|
"host_component_criteria": "c1",
|
|
|
"metric_paths": [
|
|
|
- "metrics/hbase/regionserver/percentFilesLocal"
|
|
|
+ {
|
|
|
+ "metric_path": "metrics/hbase/regionserver/percentFilesLocal",
|
|
|
+ "metric_type": "POINT_IN_TIME",
|
|
|
+ "id": "metrics/hbase/regionserver/percentFilesLocal_POINT_IN_TIME",
|
|
|
+ "context": {}
|
|
|
+ }
|
|
|
]
|
|
|
}
|
|
|
- });
|
|
|
+ }));
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -155,7 +175,20 @@ describe('App.WidgetMixin', function() {
|
|
|
var request = {
|
|
|
service_name: 'S1',
|
|
|
component_name: 'C1',
|
|
|
- metric_paths: ['w1', 'w2']
|
|
|
+ metric_paths: [
|
|
|
+ {
|
|
|
+ "metric_path": "w1",
|
|
|
+ "metric_type": "POINT_IN_TIME",
|
|
|
+ "id": "w1_POINT_IN_TIME",
|
|
|
+ "context": {}
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "metric_path": "w2",
|
|
|
+ "metric_type": "POINT_IN_TIME",
|
|
|
+ "id": "w2_POINT_IN_TIME",
|
|
|
+ "context": {}
|
|
|
+ }
|
|
|
+ ]
|
|
|
};
|
|
|
mixinObject.getServiceComponentMetrics(request);
|
|
|
expect(App.ajax.send.getCall(0).args[0]).to.eql({
|
|
@@ -207,7 +240,20 @@ describe('App.WidgetMixin', function() {
|
|
|
it("", function () {
|
|
|
var request = {
|
|
|
component_name: 'C1',
|
|
|
- metric_paths: ['w1', 'w2'],
|
|
|
+ metric_paths: [
|
|
|
+ {
|
|
|
+ "metric_path": "w1",
|
|
|
+ "metric_type": "POINT_IN_TIME",
|
|
|
+ "id": "w1_POINT_IN_TIME",
|
|
|
+ "context": {}
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "metric_path": "w2",
|
|
|
+ "metric_type": "POINT_IN_TIME",
|
|
|
+ "id": "w2_POINT_IN_TIME",
|
|
|
+ "context": {}
|
|
|
+ }
|
|
|
+ ],
|
|
|
host_component_criteria: 'c1'
|
|
|
};
|
|
|
mixinObject.getHostComponentMetrics(request);
|
|
@@ -223,7 +269,7 @@ describe('App.WidgetMixin', function() {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- describe("#calculateValues()", function() {
|
|
|
+ describe("#calculateValues()", function () {
|
|
|
var mixinObject = mixinClass.create();
|
|
|
|
|
|
beforeEach(function () {
|
|
@@ -234,7 +280,7 @@ describe('App.WidgetMixin', function() {
|
|
|
mixinObject.extractExpressions.restore();
|
|
|
this.mock.restore();
|
|
|
});
|
|
|
- it("value compute correctly", function() {
|
|
|
+ it("value compute correctly", function () {
|
|
|
this.mock.returns({'${a}': 1});
|
|
|
mixinObject.set('content.values', [{
|
|
|
value: '${a}'
|
|
@@ -242,7 +288,7 @@ describe('App.WidgetMixin', function() {
|
|
|
mixinObject.calculateValues();
|
|
|
expect(mixinObject.get('content.values')[0].computedValue).to.equal('1');
|
|
|
});
|
|
|
- it("value not available", function() {
|
|
|
+ it("value not available", function () {
|
|
|
this.mock.returns({});
|
|
|
mixinObject.set('content.values', [{
|
|
|
value: '${a}'
|
|
@@ -250,7 +296,7 @@ describe('App.WidgetMixin', function() {
|
|
|
mixinObject.calculateValues();
|
|
|
expect(mixinObject.get('content.values')[0].computedValue).to.be.empty;
|
|
|
});
|
|
|
- it("value is null", function() {
|
|
|
+ it("value is null", function () {
|
|
|
this.mock.returns({'${a}': null});
|
|
|
mixinObject.set('content.values', [{
|
|
|
value: '${a}'
|
|
@@ -260,17 +306,17 @@ describe('App.WidgetMixin', function() {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- describe("#computeExpression()", function() {
|
|
|
+ describe("#computeExpression()", function () {
|
|
|
var mixinObject = mixinClass.create();
|
|
|
|
|
|
- it("expression missing metrics", function() {
|
|
|
+ it("expression missing metrics", function () {
|
|
|
var expressions = ['e.m1'];
|
|
|
var metrics = [];
|
|
|
expect(mixinObject.computeExpression(expressions, metrics)).to.eql({
|
|
|
"${e.m1}": ""
|
|
|
});
|
|
|
});
|
|
|
- it("Value is not correct mathematical expression", function() {
|
|
|
+ it("Value is not correct mathematical expression", function () {
|
|
|
var expressions = ['e.m1'];
|
|
|
var metrics = [{
|
|
|
name: 'e.m1',
|
|
@@ -280,7 +326,7 @@ describe('App.WidgetMixin', function() {
|
|
|
"${e.m1}": ""
|
|
|
});
|
|
|
});
|
|
|
- it("correct expression", function() {
|
|
|
+ it("correct expression", function () {
|
|
|
var expressions = ['e.m1+e.m1'];
|
|
|
var metrics = [{
|
|
|
name: 'e.m1',
|
|
@@ -292,7 +338,7 @@ describe('App.WidgetMixin', function() {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- describe("#cloneWidget()", function() {
|
|
|
+ describe("#cloneWidget()", function () {
|
|
|
var mixinObject = mixinClass.create();
|
|
|
|
|
|
before(function () {
|
|
@@ -303,7 +349,7 @@ describe('App.WidgetMixin', function() {
|
|
|
App.showConfirmationPopup.restore();
|
|
|
mixinObject.postWidgetDefinition.restore();
|
|
|
});
|
|
|
- it("", function() {
|
|
|
+ it("", function () {
|
|
|
var popup = mixinObject.cloneWidget();
|
|
|
expect(App.showConfirmationPopup.calledOnce).to.be.true;
|
|
|
popup.onPrimary();
|
|
@@ -311,7 +357,7 @@ describe('App.WidgetMixin', function() {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- describe("#postWidgetDefinition()", function() {
|
|
|
+ describe("#postWidgetDefinition()", function () {
|
|
|
var mixinObject = mixinClass.create();
|
|
|
|
|
|
before(function () {
|
|
@@ -322,7 +368,7 @@ describe('App.WidgetMixin', function() {
|
|
|
App.ajax.send.restore();
|
|
|
mixinObject.collectWidgetData.restore();
|
|
|
});
|
|
|
- it("", function() {
|
|
|
+ it("", function () {
|
|
|
mixinObject.postWidgetDefinition();
|
|
|
expect(App.ajax.send.getCall(0).args[0]).to.eql({
|
|
|
name: 'widgets.wizard.add',
|
|
@@ -337,7 +383,7 @@ describe('App.WidgetMixin', function() {
|
|
|
});
|
|
|
|
|
|
|
|
|
-describe('App.WidgetLoadAggregator', function() {
|
|
|
+describe('App.WidgetLoadAggregator', function () {
|
|
|
var aggregator = App.WidgetLoadAggregator;
|
|
|
|
|
|
describe("#add()", function () {
|
|
@@ -411,7 +457,7 @@ describe('App.WidgetLoadAggregator', function() {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- describe("#runRequests()", function() {
|
|
|
+ describe("#runRequests()", function () {
|
|
|
var mock = {
|
|
|
f1: function () {
|
|
|
return {
|
|
@@ -421,7 +467,7 @@ describe('App.WidgetLoadAggregator', function() {
|
|
|
}
|
|
|
};
|
|
|
beforeEach(function () {
|
|
|
- sinon.stub(aggregator, 'groupRequests', function(requests){
|
|
|
+ sinon.stub(aggregator, 'groupRequests', function (requests) {
|
|
|
return requests;
|
|
|
});
|
|
|
sinon.spy(mock, 'f1');
|
|
@@ -430,7 +476,7 @@ describe('App.WidgetLoadAggregator', function() {
|
|
|
aggregator.groupRequests.restore();
|
|
|
mock.f1.restore();
|
|
|
});
|
|
|
- it("", function() {
|
|
|
+ it("", function () {
|
|
|
var requests = {
|
|
|
'r1': {
|
|
|
data: {
|