ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject ambari git commit: AMBARI-17125 Wizards operation gets into inconsistent state when logged into from a different browser
Date Thu, 09 Jun 2016 09:54:07 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 47c9b2160 -> 1671d615a


AMBARI-17125 Wizards operation gets into inconsistent state when logged into from a different
browser


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

Branch: refs/heads/trunk
Commit: 1671d615a7b4a88314bbcbaed860029fc20ffdb2
Parents: 47c9b21
Author: Andrii Tkach <atkach@apache.org>
Authored: Wed Jun 8 19:21:08 2016 +0300
Committer: Andrii Tkach <atkach@apache.org>
Committed: Thu Jun 9 12:52:16 2016 +0300

----------------------------------------------------------------------
 .../global/background_operations_controller.js  |  2 +-
 .../controllers/global/cluster_controller.js    |  5 +++
 .../main/admin/stack_and_upgrade_controller.js  | 43 ++++++++++----------
 .../global/cluster_controller_test.js           | 27 ++++++++++++
 .../admin/stack_and_upgrade_controller_test.js  | 16 ++++++++
 5 files changed, 71 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1671d615/ambari-web/app/controllers/global/background_operations_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/background_operations_controller.js b/ambari-web/app/controllers/global/background_operations_controller.js
index a26dbfd..518f5ba 100644
--- a/ambari-web/app/controllers/global/background_operations_controller.js
+++ b/ambari-web/app/controllers/global/background_operations_controller.js
@@ -211,7 +211,7 @@ App.BackgroundOperationsController = Em.Controller.extend({
 
     data.items.forEach(function (request) {
       if (this.isUpgradeRequest(request)) {
-        if (!App.get('upgradeIsRunning') && !App.get('testMode') && Em.get(request,
'Requests.request_status') !== 'COMPLETED') {
+        if (!App.get('upgradeIsRunning') && !App.get('testMode')) {
           restoreUpgradeState = true;
         }
         return;

http://git-wip-us.apache.org/repos/asf/ambari/blob/1671d615/ambari-web/app/controllers/global/cluster_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js
index 1741704..d8a3664 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -302,6 +302,11 @@ App.ClusterController = Em.Controller.extend(App.ReloadPopupMixin, {
       var lastUpgradeData = data.items.sortProperty('Upgrade.request_id').pop();
       var dbUpgradeState = App.db.get('MainAdminStackAndUpgrade', 'upgradeState');
 
+      //completed upgrade shouldn't be restored
+      if (lastUpgradeData && lastUpgradeData.Upgrade.request_status === "COMPLETED")
{
+        return;
+      }
+
       if (!Em.isNone(dbUpgradeState)) {
         App.set('upgradeState', dbUpgradeState);
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/1671d615/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 20cfe40..01a9978 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
@@ -390,6 +390,9 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
         isRetryPending: false
       });
     }
+    if (data.Upgrade.request_status === 'COMPLETED') {
+      this.finish();
+    }
   },
 
   /**
@@ -1541,28 +1544,26 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
    * and clean auxiliary data
    */
   finish: function () {
-    if (App.get('upgradeState') === 'COMPLETED') {
-      var upgradeVersion = this.get('upgradeVersion') && this.get('upgradeVersion').match(/[a-zA-Z]+\-\d+\.\d+/);
-      this.setDBProperties({
-        upgradeId: undefined,
-        upgradeState: 'INIT',
-        upgradeVersion: undefined,
-        currentVersion: undefined,
-        upgradeTypeDisplayName: undefined,
-        upgradeType: undefined,
-        failuresTolerance: undefined,
-        isDowngrade: undefined,
-        downgradeAllowed: undefined
-      });
-      App.clusterStatus.setClusterStatus({
-        localdb: App.db.data
-      });
-      if (upgradeVersion && upgradeVersion[0]) {
-        App.set('currentStackVersion', upgradeVersion[0]);
-      }
-      App.set('upgradeState', 'INIT');
+    var upgradeVersion = this.get('upgradeVersion') && this.get('upgradeVersion').match(/[a-zA-Z]+\-\d+\.\d+/);
+    this.setDBProperties({
+      upgradeId: undefined,
+      upgradeState: 'INIT',
+      upgradeVersion: undefined,
+      currentVersion: undefined,
+      upgradeTypeDisplayName: undefined,
+      upgradeType: undefined,
+      failuresTolerance: undefined,
+      isDowngrade: undefined,
+      downgradeAllowed: undefined
+    });
+    App.clusterStatus.setClusterStatus({
+      localdb: App.db.data
+    });
+    if (upgradeVersion && upgradeVersion[0]) {
+      App.set('currentStackVersion', upgradeVersion[0]);
     }
-  }.observes('App.upgradeState'),
+    App.set('upgradeState', 'INIT');
+  },
 
   /**
    * Check <code>App.upgradeState</code> for HOLDING

http://git-wip-us.apache.org/repos/asf/ambari/blob/1671d615/ambari-web/test/controllers/global/cluster_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/global/cluster_controller_test.js b/ambari-web/test/controllers/global/cluster_controller_test.js
index 2bf4ab4..0fb8b22 100644
--- a/ambari-web/test/controllers/global/cluster_controller_test.js
+++ b/ambari-web/test/controllers/global/cluster_controller_test.js
@@ -489,6 +489,33 @@ describe('App.clusterController', function () {
 
     });
 
+    describe("has completed upgrade request", function() {
+
+      beforeEach(function () {
+        data.upgradeData = {items: [
+          {
+            Upgrade: {
+              request_id: 1,
+              request_status: 'COMPLETED'
+            }
+          }
+        ]};
+        controller.restoreUpgradeState();
+      });
+
+      it('getAllUpgrades is called once', function () {
+        expect(controller.getAllUpgrades.calledOnce).to.be.true;
+      });
+
+      it('restoreLastUpgrade should not be called', function () {
+        expect(upgradeController.restoreLastUpgrade.called).to.be.false;
+      });
+
+      it('loadStackVersionsToModel should not be called', function () {
+        expect(upgradeController.loadStackVersionsToModel.called).to.be.false;
+      });
+    });
+
     describe("does not have upgrade request", function() {
 
       beforeEach(function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/1671d615/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 e547d73..3817ace 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
@@ -219,11 +219,15 @@ describe('App.MainAdminStackAndUpgradeController', function() {
     beforeEach(function () {
       sinon.stub(controller, 'updateUpgradeData', Em.K);
       sinon.stub(controller, 'setDBProperty', Em.K);
+      sinon.stub(controller, 'finish');
     });
     afterEach(function () {
       controller.updateUpgradeData.restore();
       controller.setDBProperty.restore();
+      controller.finish.restore();
+      App.set('upgradeState', 'INIT');
     });
+
     it("correct data", function() {
       var data = {
         "Upgrade": {
@@ -242,12 +246,24 @@ describe('App.MainAdminStackAndUpgradeController', function() {
       expect(controller.updateUpgradeData.calledOnce).to.be.true;
       expect(controller.setDBProperty.calledWith('upgradeState', 'UPGRADED')).to.be.true;
     });
+
     it("data is null", function() {
       var data = null;
       controller.loadUpgradeDataSuccessCallback(data);
       expect(controller.updateUpgradeData.called).to.be.false;
       expect(controller.setDBProperty.called).to.be.false;
     });
+
+    it("finish should be called", function() {
+      var data = {
+        "Upgrade": {
+          "request_status": "COMPLETED"
+        }
+      };
+      controller.loadUpgradeDataSuccessCallback(data);
+      expect(controller.finish.calledOnce).to.be.true;
+    });
+
     retryCases.forEach(function (item) {
       it(item.title, function () {
         var data = {


Mime
View raw message