You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2018/05/11 12:26:41 UTC
[ambari] branch trunk updated: AMBARI-23802 Action not shown
immediately in the BG Operations window
This is an automated email from the ASF dual-hosted git repository.
atkach pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new 3bd2ff7 AMBARI-23802 Action not shown immediately in the BG Operations window
3bd2ff7 is described below
commit 3bd2ff7ab12e65f1573f58ac886e7cafdc5efcbf
Author: Andrii Tkach <at...@apache.org>
AuthorDate: Fri May 11 13:46:29 2018 +0300
AMBARI-23802 Action not shown immediately in the BG Operations window
---
.../global/background_operations_controller.js | 19 +++++--------------
.../app/controllers/global/update_controller.js | 1 +
ambari-web/app/controllers/main.js | 2 --
.../controllers/global/background_operations_test.js | 11 ++---------
.../test/controllers/global/update_controller_test.js | 11 +++++++++++
ambari-web/test/controllers/main_test.js | 7 -------
6 files changed, 19 insertions(+), 32 deletions(-)
diff --git a/ambari-web/app/controllers/global/background_operations_controller.js b/ambari-web/app/controllers/global/background_operations_controller.js
index 35231e7..345dec8 100644
--- a/ambari-web/app/controllers/global/background_operations_controller.js
+++ b/ambari-web/app/controllers/global/background_operations_controller.js
@@ -21,11 +21,6 @@ var App = require('app');
App.BackgroundOperationsController = Em.Controller.extend({
name: 'backgroundOperationsController',
- /**
- * Whether we need to refresh background operations or not
- */
- isWorking : false,
-
runningOperationsCount : function() {
return this.get('services').filterProperty('isRunning').length;
}.property('services.@each.isRunning'),
@@ -54,15 +49,11 @@ App.BackgroundOperationsController = Em.Controller.extend({
taskId: null
}),
- handleRequestsUpdates: function () {
- if (this.get('isWorking')) {
- this.requestMostRecent(() => {
- App.StompClient.subscribe('/events/requests', this.updateRequests.bind(this));
- });
- } else {
- App.StompClient.unsubscribe('/events/requests');
- }
- }.observes('isWorking'),
+ subscribeToUpdates: function () {
+ this.requestMostRecent(() => {
+ App.StompClient.subscribe('/events/requests', this.updateRequests.bind(this));
+ });
+ },
updateRequests: function(event) {
if (this.isUpgradeRequest({Requests: {request_context: event.requestContext}})) {
diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js
index c288b6a..9cbb6b9 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -216,6 +216,7 @@ App.UpdateController = Em.Controller.extend({
App.StompClient.subscribe('/events/alert_definitions', App.alertDefinitionsMapperAdapter.map.bind(App.alertDefinitionsMapperAdapter));
App.StompClient.subscribe('/events/alert_group', App.alertGroupsMapperAdapter.map.bind(App.alertGroupsMapperAdapter));
App.StompClient.subscribe('/events/upgrade', App.upgradeStateMapper.map.bind(App.upgradeStateMapper));
+ App.router.get('backgroundOperationsController').subscribeToUpdates();
},
/**
diff --git a/ambari-web/app/controllers/main.js b/ambari-web/app/controllers/main.js
index 9264801..105fee0 100644
--- a/ambari-web/app/controllers/main.js
+++ b/ambari-web/app/controllers/main.js
@@ -104,13 +104,11 @@ App.MainController = Em.Controller.extend({
startPolling: function () {
if (App.router.get('applicationController.isExistingClusterDataLoaded')) {
App.router.get('updateController').set('isWorking', true);
- App.router.get('backgroundOperationsController').set('isWorking', true);
}
}.observes('App.router.applicationController.isExistingClusterDataLoaded'),
stopPolling: function(){
App.router.get('updateController').set('isWorking', false);
- App.router.get('backgroundOperationsController').set('isWorking', false);
},
reloadTimeOut: null,
diff --git a/ambari-web/test/controllers/global/background_operations_test.js b/ambari-web/test/controllers/global/background_operations_test.js
index 300ee38..2474efb 100644
--- a/ambari-web/test/controllers/global/background_operations_test.js
+++ b/ambari-web/test/controllers/global/background_operations_test.js
@@ -735,27 +735,20 @@ describe('App.BackgroundOperationsController', function () {
});
});
- describe('#handleRequestsUpdates', function() {
+ describe('#subscribeToUpdates', function() {
beforeEach(function() {
sinon.stub(controller, 'requestMostRecent', Em.clb);
sinon.stub(App.StompClient, 'subscribe');
- sinon.stub(App.StompClient, 'unsubscribe');
});
afterEach(function() {
controller.requestMostRecent.restore();
App.StompClient.subscribe.restore();
- App.StompClient.unsubscribe.restore();
});
it('App.StompClient.subscribe should be called', function() {
- controller.set('isWorking', true);
+ controller.subscribeToUpdates();
expect(App.StompClient.subscribe.calledWith('/events/requests')).to.be.true;
});
-
- it('App.StompClient.unsubscribe should be called', function() {
- controller.set('isWorking', false);
- expect(App.StompClient.unsubscribe.calledWith('/events/requests')).to.be.true;
- });
});
describe('#updateRequests', function() {
diff --git a/ambari-web/test/controllers/global/update_controller_test.js b/ambari-web/test/controllers/global/update_controller_test.js
index 26b1067..f199fa9 100644
--- a/ambari-web/test/controllers/global/update_controller_test.js
+++ b/ambari-web/test/controllers/global/update_controller_test.js
@@ -70,11 +70,16 @@ describe('App.UpdateController', function () {
});
describe('#startSubscriptions()', function () {
+ var mock = {
+ subscribeToUpdates: sinon.spy()
+ };
beforeEach(function() {
sinon.stub(App.StompClient, 'subscribe');
+ sinon.stub(App.router, 'get').returns(mock);
});
afterEach(function() {
App.StompClient.subscribe.restore();
+ App.router.get.restore();
});
it('should subscribe to all topics', function () {
@@ -89,6 +94,12 @@ describe('App.UpdateController', function () {
expect(App.StompClient.subscribe.calledWith('/events/alert_group')).to.be.true;
expect(App.StompClient.subscribe.calledWith('/events/upgrade')).to.be.true;
});
+
+ it('subscribeToUpdates should be called', function () {
+ controller.startSubscriptions();
+ expect(mock.subscribeToUpdates.called).to.be.true;
+ });
+
});
describe('#getConditionalFields()', function () {
diff --git a/ambari-web/test/controllers/main_test.js b/ambari-web/test/controllers/main_test.js
index 460a667..723d306 100644
--- a/ambari-web/test/controllers/main_test.js
+++ b/ambari-web/test/controllers/main_test.js
@@ -113,15 +113,11 @@ describe('App.MainController', function () {
var mock,
updateController = Em.Object.create({
isWorking: false
- }),
- backgroundOperationsController = Em.Object.create({
- isWorking: false
});
beforeEach(function() {
mock = sinon.stub(App.router, 'get');
mock.withArgs('applicationController.isExistingClusterDataLoaded').returns(true);
mock.withArgs('updateController').returns(updateController);
- mock.withArgs('backgroundOperationsController').returns(backgroundOperationsController);
mainController.startPolling();
});
afterEach(function() {
@@ -132,9 +128,6 @@ describe('App.MainController', function () {
expect(updateController.get('isWorking')).to.be.true;
});
- it('backgroundOperationsController should be working', function() {
- expect(backgroundOperationsController.get('isWorking')).to.be.true;
- });
});
});
--
To stop receiving notification emails like this one, please contact
atkach@apache.org.