ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject [1/2] ambari git commit: AMBARI-16704 UI - RU/EU, when initiating a downgrade, should ensure that request to ABORT upgrade returns 200.(ababiichuk)
Date Tue, 17 May 2016 15:04:21 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 7e93fc334 -> 3e1d7cb6e


AMBARI-16704 UI - RU/EU, when initiating a downgrade, should ensure that request to ABORT
upgrade returns 200.(ababiichuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d6987b36
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d6987b36
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d6987b36

Branch: refs/heads/branch-2.4
Commit: d6987b36bb88596a38b166d7a21fbc916136eaa2
Parents: 7e93fc3
Author: ababiichuk <ababiichuk@hortonworks.com>
Authored: Tue May 17 16:48:06 2016 +0300
Committer: ababiichuk <ababiichuk@hortonworks.com>
Committed: Tue May 17 18:03:45 2016 +0300

----------------------------------------------------------------------
 .../main/admin/stack_and_upgrade_controller.js  | 42 ++++++++++++--------
 .../admin/stack_and_upgrade_controller_test.js  | 35 ++++++++++++----
 2 files changed, 53 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d6987b36/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
index cdc2aa7..53fdc03 100644
--- a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
+++ b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
@@ -560,22 +560,10 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
    * @param {object} event
    */
   downgrade: function (currentVersion, event) {
+    var self = this;
     this.set('requestInProgress', true);
-    this.abortUpgrade();
-    App.ajax.send({
-      name: 'admin.downgrade.start',
-      sender: this,
-      data: {
-        from: App.RepositoryVersion.find().findProperty('displayName', this.get('upgradeVersion')).get('repositoryVersion'),
-        value: currentVersion.repository_version,
-        label: currentVersion.repository_name,
-        isDowngrade: true,
-        upgradeType: this.get('upgradeType')
-      },
-      success: 'upgradeSuccessCallback',
-      callback: function() {
-        this.sender.set('requestInProgress', false);
-      }
+    this.abortUpgrade().done(function() {
+      self.startDowngrade(currentVersion);
     });
   },
 
@@ -594,7 +582,29 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
       error: errorCallback
     });
   },
-  
+
+  /**
+   * just request ro start downgrade,
+   * should be performed only if <code>abortUpgrade<code> was completed
+   */
+  startDowngrade: function(currentVersion) {
+   App.ajax.send({
+      name: 'admin.downgrade.start',
+      sender: this,
+      data: {
+        from: App.RepositoryVersion.find().findProperty('displayName', this.get('upgradeVersion')).get('repositoryVersion'),
+        value: currentVersion.repository_version,
+        label: currentVersion.repository_name,
+        isDowngrade: true,
+        upgradeType: this.get('upgradeType')
+      },
+      success: 'upgradeSuccessCallback',
+      callback: function() {
+        this.sender.set('requestInProgress', false);
+      }
+    });
+  },
+
   /**
    * suspend upgrade (in order to restart it later)
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6987b36/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
index 2481bdd..193ed44 100644
--- a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
@@ -998,9 +998,32 @@ describe('App.MainAdminStackAndUpgradeController', function() {
     });
   });
 
-  describe("#downgrade()", function() {
+  describe("#downgrade", function() {
+    beforeEach(function () {
+      sinon.stub(controller, 'abortUpgrade').returns({
+        done: function(callback) {callback()}
+      });
+      sinon.stub(controller, 'startDowngrade');
+      controller.downgrade('versionInfo');
+    });
+
+    afterEach(function () {
+      controller.abortUpgrade.restore();
+      controller.startDowngrade.restore();
+    });
+
+    it('should run abortUpgrade', function() {
+      expect(controller.abortUpgrade.calledOnce).to.be.true;
+    });
+
+    it('should run startDowngrade on done', function() {
+      expect(controller.startDowngrade.calledWith('versionInfo')).to.be.true;
+    });
+
+  });
+
+  describe("#startDowngrade()", function() {
     beforeEach(function () {
-      sinon.stub(controller, 'abortUpgrade');
       sinon.stub(App.RepositoryVersion, 'find').returns([
         Em.Object.create({
           displayName: 'HDP-2.3',
@@ -1009,21 +1032,17 @@ describe('App.MainAdminStackAndUpgradeController', function() {
       ]);
       controller.set('upgradeVersion', 'HDP-2.3');
       controller.set('upgradeType', 'NON_ROLLING');
-      controller.downgrade(Em.Object.create({
+      controller.startDowngrade(Em.Object.create({
         repository_version: '2.2',
         repository_name: 'HDP-2.2'
-      }), {context: 'context'});
+      }));
       this.callArgs = testHelpers.findAjaxRequest('name', 'admin.downgrade.start')[0];
     });
 
     afterEach(function () {
-      controller.abortUpgrade.restore();
       App.RepositoryVersion.find.restore();
     });
 
-    it('abortUpgrade is called once', function() {
-      expect(controller.abortUpgrade.calledOnce).to.be.true;
-    });
     it('request-data is valid', function () {
       expect(this.callArgs.data).to.eql({
         from: '2.3',


Mime
View raw message