|
@@ -22,7 +22,7 @@ require('views/main/service/info/summary');
|
|
|
|
|
|
describe('App.MainServiceInfoSummaryView', function() {
|
|
describe('App.MainServiceInfoSummaryView', function() {
|
|
|
|
|
|
- var mainServiceInfoSummaryView = App.MainServiceInfoSummaryView.create({
|
|
|
|
|
|
+ var view = App.MainServiceInfoSummaryView.create({
|
|
monitorsLiveTextView: Em.View.create(),
|
|
monitorsLiveTextView: Em.View.create(),
|
|
controller: Em.Object.create({
|
|
controller: Em.Object.create({
|
|
content: Em.Object.create({
|
|
content: Em.Object.create({
|
|
@@ -30,16 +30,17 @@ describe('App.MainServiceInfoSummaryView', function() {
|
|
serviceName: 'HDFS',
|
|
serviceName: 'HDFS',
|
|
hostComponents: []
|
|
hostComponents: []
|
|
})
|
|
})
|
|
- })
|
|
|
|
|
|
+ }),
|
|
|
|
+ alertsController: Em.Object.create()
|
|
});
|
|
});
|
|
|
|
|
|
describe('#servers', function () {
|
|
describe('#servers', function () {
|
|
it('services shuldn\'t have servers except FLUME and ZOOKEEPER', function () {
|
|
it('services shuldn\'t have servers except FLUME and ZOOKEEPER', function () {
|
|
- expect(mainServiceInfoSummaryView.get('servers')).to.be.empty;
|
|
|
|
|
|
+ expect(view.get('servers')).to.be.empty;
|
|
});
|
|
});
|
|
|
|
|
|
it('if one server exists then first server should have isComma and isAnd property false', function () {
|
|
it('if one server exists then first server should have isComma and isAnd property false', function () {
|
|
- mainServiceInfoSummaryView.set('controller.content', Em.Object.create({
|
|
|
|
|
|
+ view.set('controller.content', Em.Object.create({
|
|
id: 'ZOOKEEPER',
|
|
id: 'ZOOKEEPER',
|
|
serviceName: 'ZOOKEEPER',
|
|
serviceName: 'ZOOKEEPER',
|
|
hostComponents: [
|
|
hostComponents: [
|
|
@@ -49,12 +50,12 @@ describe('App.MainServiceInfoSummaryView', function() {
|
|
})
|
|
})
|
|
]
|
|
]
|
|
}));
|
|
}));
|
|
- expect(mainServiceInfoSummaryView.get('servers').objectAt(0).isComma).to.equal(false);
|
|
|
|
- expect(mainServiceInfoSummaryView.get('servers').objectAt(0).isAnd).to.equal(false);
|
|
|
|
|
|
+ expect(view.get('servers').objectAt(0).isComma).to.equal(false);
|
|
|
|
+ expect(view.get('servers').objectAt(0).isAnd).to.equal(false);
|
|
});
|
|
});
|
|
|
|
|
|
it('if more than one servers exist then first server should have isComma - true and isAnd - false', function () {
|
|
it('if more than one servers exist then first server should have isComma - true and isAnd - false', function () {
|
|
- mainServiceInfoSummaryView.set('controller.content', Em.Object.create({
|
|
|
|
|
|
+ view.set('controller.content', Em.Object.create({
|
|
id: 'ZOOKEEPER',
|
|
id: 'ZOOKEEPER',
|
|
serviceName: 'ZOOKEEPER',
|
|
serviceName: 'ZOOKEEPER',
|
|
hostComponents: [
|
|
hostComponents: [
|
|
@@ -68,14 +69,14 @@ describe('App.MainServiceInfoSummaryView', function() {
|
|
})
|
|
})
|
|
]
|
|
]
|
|
}));
|
|
}));
|
|
- expect(mainServiceInfoSummaryView.get('servers').objectAt(0).isComma).to.equal(true);
|
|
|
|
- expect(mainServiceInfoSummaryView.get('servers').objectAt(0).isAnd).to.equal(false);
|
|
|
|
- expect(mainServiceInfoSummaryView.get('servers').objectAt(1).isComma).to.equal(false);
|
|
|
|
- expect(mainServiceInfoSummaryView.get('servers').objectAt(1).isAnd).to.equal(false);
|
|
|
|
|
|
+ expect(view.get('servers').objectAt(0).isComma).to.equal(true);
|
|
|
|
+ expect(view.get('servers').objectAt(0).isAnd).to.equal(false);
|
|
|
|
+ expect(view.get('servers').objectAt(1).isComma).to.equal(false);
|
|
|
|
+ expect(view.get('servers').objectAt(1).isAnd).to.equal(false);
|
|
});
|
|
});
|
|
|
|
|
|
it('if more than two servers exist then second server should have isComma - false and isAnd - true', function () {
|
|
it('if more than two servers exist then second server should have isComma - false and isAnd - true', function () {
|
|
- mainServiceInfoSummaryView.set('controller.content', Em.Object.create({
|
|
|
|
|
|
+ view.set('controller.content', Em.Object.create({
|
|
id: 'ZOOKEEPER',
|
|
id: 'ZOOKEEPER',
|
|
serviceName: 'ZOOKEEPER',
|
|
serviceName: 'ZOOKEEPER',
|
|
hostComponents: [
|
|
hostComponents: [
|
|
@@ -93,12 +94,12 @@ describe('App.MainServiceInfoSummaryView', function() {
|
|
})
|
|
})
|
|
]
|
|
]
|
|
}));
|
|
}));
|
|
- expect(mainServiceInfoSummaryView.get('servers').objectAt(0).isComma).to.equal(true);
|
|
|
|
- expect(mainServiceInfoSummaryView.get('servers').objectAt(0).isAnd).to.equal(false);
|
|
|
|
- expect(mainServiceInfoSummaryView.get('servers').objectAt(1).isComma).to.equal(false);
|
|
|
|
- expect(mainServiceInfoSummaryView.get('servers').objectAt(1).isAnd).to.equal(true);
|
|
|
|
- expect(mainServiceInfoSummaryView.get('servers').objectAt(2).isComma).to.equal(false);
|
|
|
|
- expect(mainServiceInfoSummaryView.get('servers').objectAt(2).isAnd).to.equal(false);
|
|
|
|
|
|
+ expect(view.get('servers').objectAt(0).isComma).to.equal(true);
|
|
|
|
+ expect(view.get('servers').objectAt(0).isAnd).to.equal(false);
|
|
|
|
+ expect(view.get('servers').objectAt(1).isComma).to.equal(false);
|
|
|
|
+ expect(view.get('servers').objectAt(1).isAnd).to.equal(true);
|
|
|
|
+ expect(view.get('servers').objectAt(2).isComma).to.equal(false);
|
|
|
|
+ expect(view.get('servers').objectAt(2).isAnd).to.equal(false);
|
|
});
|
|
});
|
|
|
|
|
|
});
|
|
});
|
|
@@ -107,21 +108,212 @@ describe('App.MainServiceInfoSummaryView', function() {
|
|
it("should return a single array with the items in the fom of '<name>.extend()' when the number of items is less than 4", function() {
|
|
it("should return a single array with the items in the fom of '<name>.extend()' when the number of items is less than 4", function() {
|
|
var graphs = ['HDFS_SpaceUtilization'];
|
|
var graphs = ['HDFS_SpaceUtilization'];
|
|
|
|
|
|
- expect(mainServiceInfoSummaryView.constructGraphObjects(graphs).length).to.equal(1);
|
|
|
|
- expect(mainServiceInfoSummaryView.constructGraphObjects(graphs)[0].length).to.equal(1);
|
|
|
|
|
|
+ expect(view.constructGraphObjects(graphs).length).to.equal(1);
|
|
|
|
+ expect(view.constructGraphObjects(graphs)[0].length).to.equal(1);
|
|
});
|
|
});
|
|
|
|
|
|
it("should return an array with arrays that are grouped into sizes of 4 or less when number of items is greater than 4", function() {
|
|
it("should return an array with arrays that are grouped into sizes of 4 or less when number of items is greater than 4", function() {
|
|
var graphs = ['HDFS_SpaceUtilization', 'YARN_AllocatedMemory', 'MapReduce_JobsStatus',
|
|
var graphs = ['HDFS_SpaceUtilization', 'YARN_AllocatedMemory', 'MapReduce_JobsStatus',
|
|
'HBASE_ClusterRequests', 'Flume_ChannelSizeMMA'];
|
|
'HBASE_ClusterRequests', 'Flume_ChannelSizeMMA'];
|
|
|
|
|
|
- expect(mainServiceInfoSummaryView.constructGraphObjects(graphs).length).to.equal(2);
|
|
|
|
- expect(mainServiceInfoSummaryView.constructGraphObjects(graphs)[0].length).to.equal(4);
|
|
|
|
- expect(mainServiceInfoSummaryView.constructGraphObjects(graphs)[1].length).to.equal(1);
|
|
|
|
|
|
+ expect(view.constructGraphObjects(graphs).length).to.equal(2);
|
|
|
|
+ expect(view.constructGraphObjects(graphs)[0].length).to.equal(4);
|
|
|
|
+ expect(view.constructGraphObjects(graphs)[1].length).to.equal(1);
|
|
});
|
|
});
|
|
|
|
|
|
it("should return an empty array if the graphs array provided is empty", function() {
|
|
it("should return an empty array if the graphs array provided is empty", function() {
|
|
- expect(mainServiceInfoSummaryView.constructGraphObjects([])).to.be.empty;
|
|
|
|
|
|
+ expect(view.constructGraphObjects([])).to.be.empty;
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe("#observeAlerts()", function() {
|
|
|
|
+ it("No alerts loaded", function() {
|
|
|
|
+ var alerts = [];
|
|
|
|
+ view.set('alertsController.alerts', []);
|
|
|
|
+ view.set('alerts', alerts)
|
|
|
|
+ view.observeAlerts();
|
|
|
|
+
|
|
|
|
+ expect(alerts).to.be.empty;
|
|
|
|
+ expect(view.get('alertsMap')).to.be.empty;
|
|
|
|
+ });
|
|
|
|
+ it("One alert loaded", function() {
|
|
|
|
+ var alerts = [];
|
|
|
|
+ view.set('alertsController.alerts', [{
|
|
|
|
+ id: 1
|
|
|
|
+ }]);
|
|
|
|
+ view.set('alerts', alerts)
|
|
|
|
+ view.observeAlerts();
|
|
|
|
+
|
|
|
|
+ expect(alerts[0]).to.be.eql({
|
|
|
|
+ "id": 1
|
|
|
|
+ });
|
|
|
|
+ expect(alerts.length).to.be.equal(1);
|
|
|
|
+ expect(view.get('alertsMap')).to.be.eql({"1": {
|
|
|
|
+ "id": 1
|
|
|
|
+ }});
|
|
|
|
+ });
|
|
|
|
+ it("No new alerts", function() {
|
|
|
|
+ var alerts = [{id: 1}];
|
|
|
|
+ view.set('alertsController.alerts', []);
|
|
|
|
+ view.set('alerts', alerts)
|
|
|
|
+ view.set('alertsMap', {'1': {id: '1'}});
|
|
|
|
+ view.observeAlerts();
|
|
|
|
+
|
|
|
|
+ expect(alerts).to.be.empty;
|
|
|
|
+ expect(view.get('alertsMap')).to.be.empty;
|
|
|
|
+ });
|
|
|
|
+ before(function () {
|
|
|
|
+ sinon.stub(view, 'updateAlerts', Em.K);
|
|
|
|
+ });
|
|
|
|
+ after(function () {
|
|
|
|
+ view.updateAlerts.restore();
|
|
|
|
+ });
|
|
|
|
+ it("Alerts already exist", function() {
|
|
|
|
+ var alerts = [{id: 1}];
|
|
|
|
+ view.set('alertsController.alerts', [{
|
|
|
|
+ id: 1
|
|
|
|
+ }]);
|
|
|
|
+ view.set('alerts', alerts)
|
|
|
|
+ view.set('alertsMap', {'1': {id: '1'}});
|
|
|
|
+ view.observeAlerts();
|
|
|
|
+
|
|
|
|
+ expect(view.updateAlerts.calledWith(
|
|
|
|
+ [{
|
|
|
|
+ id: 1
|
|
|
|
+ }],
|
|
|
|
+ [{id: 1}]
|
|
|
|
+ )).to.be.true;
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe("#updateAlerts()", function() {
|
|
|
|
+ var currentAlerts = [];
|
|
|
|
+ var alertsMap = {};
|
|
|
|
+ var newAlerts = [];
|
|
|
|
+ it("Add new alert", function() {
|
|
|
|
+ newAlerts.clear();
|
|
|
|
+ currentAlerts.clear();
|
|
|
|
+ alertsMap = {};
|
|
|
|
+
|
|
|
|
+ newAlerts.pushObjects([
|
|
|
|
+ Em.Object.create({
|
|
|
|
+ id: '1',
|
|
|
|
+ status: '1',
|
|
|
|
+ isLoaded: true
|
|
|
|
+ }),
|
|
|
|
+ Em.Object.create({
|
|
|
|
+ id: '2',
|
|
|
|
+ status: '2',
|
|
|
|
+ isLoaded: true
|
|
|
|
+ })
|
|
|
|
+ ]);
|
|
|
|
+ var currentAlert = Em.Object.create({
|
|
|
|
+ id: '1',
|
|
|
|
+ status: '1',
|
|
|
|
+ isLoaded: true
|
|
|
|
+ });
|
|
|
|
+ alertsMap['1'] = currentAlert;
|
|
|
|
+ view.set('alertsMap', alertsMap);
|
|
|
|
+ currentAlerts.pushObject(currentAlert);
|
|
|
|
+
|
|
|
|
+ view.updateAlerts(newAlerts, currentAlerts);
|
|
|
|
+ expect(currentAlerts.length).to.be.equal(2);
|
|
|
|
+ expect(currentAlerts[1]).to.be.eql(Em.Object.create({
|
|
|
|
+ id: '2',
|
|
|
|
+ status: '2',
|
|
|
|
+ isLoaded: true
|
|
|
|
+ }));
|
|
|
|
+ expect(alertsMap).to.be.eql({
|
|
|
|
+ "1": Em.Object.create({
|
|
|
|
+ id: '1',
|
|
|
|
+ status: '1',
|
|
|
|
+ isLoaded: true
|
|
|
|
+ }),
|
|
|
|
+ "2": Em.Object.create({
|
|
|
|
+ id: '2',
|
|
|
|
+ status: '2',
|
|
|
|
+ isLoaded: true
|
|
|
|
+ })
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ it("Update properties of existing alert", function() {
|
|
|
|
+ newAlerts.clear();
|
|
|
|
+ currentAlerts.clear();
|
|
|
|
+ alertsMap = {};
|
|
|
|
+
|
|
|
|
+ newAlerts.pushObjects([
|
|
|
|
+ Em.Object.create({
|
|
|
|
+ id: '1',
|
|
|
|
+ status: '2',
|
|
|
|
+ isLoaded: true
|
|
|
|
+ })
|
|
|
|
+ ]);
|
|
|
|
+ var currentAlert = Em.Object.create({
|
|
|
|
+ id: '1',
|
|
|
|
+ status: '1',
|
|
|
|
+ isLoaded: true
|
|
|
|
+ });
|
|
|
|
+ alertsMap['1'] = currentAlert;
|
|
|
|
+ view.set('alertsMap', alertsMap);
|
|
|
|
+ currentAlerts.pushObject(currentAlert);
|
|
|
|
+
|
|
|
|
+ view.updateAlerts(newAlerts, currentAlerts);
|
|
|
|
+ expect(currentAlerts.length).to.be.equal(1);
|
|
|
|
+ expect(currentAlerts[0]).to.be.eql(Em.Object.create({
|
|
|
|
+ id: '1',
|
|
|
|
+ status: '2',
|
|
|
|
+ isLoaded: true
|
|
|
|
+ }));
|
|
|
|
+ expect(alertsMap).to.be.eql({
|
|
|
|
+ "1": Em.Object.create({
|
|
|
|
+ id: '1',
|
|
|
|
+ status: '2',
|
|
|
|
+ isLoaded: true
|
|
|
|
+ })
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ it("delete old alert", function() {
|
|
|
|
+ newAlerts.clear();
|
|
|
|
+ currentAlerts.clear();
|
|
|
|
+ alertsMap = {};
|
|
|
|
+
|
|
|
|
+ newAlerts.pushObjects([
|
|
|
|
+ Em.Object.create({
|
|
|
|
+ id: '1',
|
|
|
|
+ status: '1',
|
|
|
|
+ isLoaded: true
|
|
|
|
+ })
|
|
|
|
+ ]);
|
|
|
|
+ var currentAlert1 = Em.Object.create({
|
|
|
|
+ id: '1',
|
|
|
|
+ status: '1',
|
|
|
|
+ isLoaded: true
|
|
|
|
+ });
|
|
|
|
+ var currentAlert2 = Em.Object.create({
|
|
|
|
+ id: '2',
|
|
|
|
+ status: '2',
|
|
|
|
+ isLoaded: true
|
|
|
|
+ });
|
|
|
|
+ alertsMap["1"] = currentAlert1;
|
|
|
|
+ alertsMap["2"] = currentAlert2;
|
|
|
|
+ view.set('alertsMap', alertsMap);
|
|
|
|
+ currentAlerts.pushObjects([currentAlert1, currentAlert2]);
|
|
|
|
+
|
|
|
|
+ view.updateAlerts(newAlerts, currentAlerts);
|
|
|
|
+
|
|
|
|
+ expect(currentAlerts.length).to.be.equal(1);
|
|
|
|
+ expect(currentAlerts[0]).to.be.eql(Em.Object.create({
|
|
|
|
+ id: '1',
|
|
|
|
+ status: '1',
|
|
|
|
+ isLoaded: true
|
|
|
|
+ }));
|
|
|
|
+ expect(alertsMap).to.be.eql({
|
|
|
|
+ "1": Em.Object.create({
|
|
|
|
+ id: '1',
|
|
|
|
+ status: '1',
|
|
|
|
+ isLoaded: true
|
|
|
|
+ })
|
|
|
|
+ });
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|