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 2015/10/05 14:41:02 UTC

ambari git commit: AMBARI-13054 Pre-Req Endpoint Should Be Used For Determining Upgrade Button Visibility. (atkach)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 da12a565e -> 2bf590caf


AMBARI-13054 Pre-Req Endpoint Should Be Used For Determining Upgrade Button Visibility. (atkach)


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

Branch: refs/heads/branch-2.1
Commit: 2bf590caf53dd0ac76b6943c7da4bdefc7c083d2
Parents: da12a56
Author: Andrii Tkach <at...@hortonworks.com>
Authored: Mon Oct 5 15:40:19 2015 +0300
Committer: Andrii Tkach <at...@hortonworks.com>
Committed: Mon Oct 5 15:40:53 2015 +0300

----------------------------------------------------------------------
 .../stack_upgrade/upgrade_version_box_view.js   |  50 +-----
 .../upgrade_version_box_view_test.js            | 165 +++++++------------
 2 files changed, 63 insertions(+), 152 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2bf590ca/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
index 2248150..fea01f4 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
@@ -32,12 +32,6 @@ App.UpgradeVersionBoxView = Em.View.extend({
   PROGRESS_STATUS: 'IN_PROGRESS',
 
   /**
-   * flag that verify Upgrade availability when version in INSTALL_FAILED state
-   * @type {boolean}
-   */
-  isUpgradeAvailable: false,
-
-  /**
    * @type {boolean}
    */
   upgradeCheckInProgress: false,
@@ -132,7 +126,7 @@ App.UpgradeVersionBoxView = Em.View.extend({
       element.set('text', Em.I18n.t('common.current'));
       element.set('class', 'label label-success');
     }
-    else if (['INIT', 'INSTALL_FAILED', 'OUT_OF_SYNC'].contains(status) && !this.get('isUpgradeAvailable')) {
+    else if (status === 'INIT') {
       element.set('isButton', true);
       element.set('text', Em.I18n.t('admin.stackVersions.version.installNow'));
       element.set('action', 'installRepoVersionConfirmation');
@@ -145,7 +139,7 @@ App.UpgradeVersionBoxView = Em.View.extend({
       element.set('action', 'showProgressPopup');
     }
     else if ((status === 'INSTALLED' && !this.get('isUpgrading')) ||
-             (['INSTALL_FAILED', 'OUT_OF_SYNC'].contains(status) && this.get('isUpgradeAvailable'))) {
+             (['INSTALL_FAILED', 'OUT_OF_SYNC'].contains(status))) {
       if (stringUtils.compareVersions(this.get('content.repositoryVersion'), Em.get(currentVersion, 'repository_version')) === 1) {
         var isDisabled = !App.isAccessible('ADMIN') || this.get('controller.requestInProgress') || isInstalling;
         element.set('isButtonGroup', true);
@@ -207,12 +201,10 @@ App.UpgradeVersionBoxView = Em.View.extend({
     'isUpgrading',
     'controller.requestInProgress',
     'parentView.repoVersions.@each.status',
-    'isUpgradeAvailable',
     'App.router.mainAdminStackAndUpgradeController.isSuspended'
   ),
 
   didInsertElement: function () {
-    this.checkUpgradeAvailability();
     App.tooltip($('.link-tooltip'), {title: Em.I18n.t('admin.stackVersions.version.linkTooltip')});
     App.tooltip($('.hosts-tooltip'));
     App.tooltip($('.out-of-sync-badge'), {title: Em.I18n.t('hosts.host.stackVersions.status.out_of_sync')});
@@ -361,43 +353,5 @@ App.UpgradeVersionBoxView = Em.View.extend({
     App.router.get('mainHostController').filterByStack(displayName, state);
     App.router.get('mainHostController').set('showFilterConditionsFirstLoad', true);
     App.router.transitionTo('hosts.index');
-  },
-
-  /**
-   * when version in INSTALL_FAILED state it still could be upgraded if check passed
-   */
-  checkUpgradeAvailability: function () {
-    if (['INSTALL_FAILED', 'OUT_OF_SYNC'].contains(this.get('content.status'))) {
-      this.runUpgradeCheck();
-    }
-  }.observes('content.status'),
-
-  /**
-   * run Upgrade Check
-   */
-  runUpgradeCheck: function() {
-    if (App.get('supports.preUpgradeCheck') && !this.get('upgradeCheckInProgress')) {
-      App.ajax.send({
-        name: "admin.rolling_upgrade.pre_upgrade_check",
-        sender: this,
-        data: {
-          value: this.get('content.repositoryVersion'),
-          label: this.get('content.displayName')
-        },
-        success: "runUpgradeCheckSuccess",
-        error: "runUpgradeCheckError"
-      });
-      this.set('upgradeCheckInProgress', true);
-    }
-  },
-
-  runUpgradeCheckSuccess: function (data) {
-    this.set('isUpgradeAvailable', !data.items.someProperty('UpgradeChecks.status', 'FAIL'));
-    this.set('upgradeCheckInProgress', false);
-  },
-
-  runUpgradeCheckError: function() {
-    this.set('isUpgradeAvailable', false);
-    this.set('upgradeCheckInProgress', false);
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/2bf590ca/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
index 0911a4d..a638687 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
@@ -393,18 +393,30 @@ describe('App.UpgradeVersionBoxView', function () {
             Em.Object.create({
               status: 'INSTALLING'
             })
-          ]
+          ],
+          'controller.currentVersion': {
+            repository_version: '2.2.0'
+          },
+          'content.repositoryVersion': '2.2.1',
+          'controller.upgradeVersion': 'HDP-2.2.0',
+          'content.displayName': 'HDP-2.2.1'
         },
         setup: function () {
           this.isAccessibleMock.withArgs('ADMIN').returns(false);
         },
         expected: {
           status: 'INSTALL_FAILED',
-          isButton: true,
-          buttons: [],
+          isButtonGroup: true,
+          buttons: [{
+            text: Em.I18n.t('admin.stackVersions.version.reinstall'),
+            action: 'installRepoVersionConfirmation',
+            isDisabled: true
+          }],
+          text: Em.I18n.t('admin.stackVersions.version.performUpgrade'),
+          action: 'confirmUpgrade',
           isDisabled: true
         },
-        title: 'install failed, no admin access, request in progress, another installation running'
+        title: 'INSTALL_FAILED state, no admin access, request in progress, another installation running'
       },
       {
         inputData: {
@@ -417,46 +429,30 @@ describe('App.UpgradeVersionBoxView', function () {
             Em.Object.create({
               status: 'INSTALLING'
             })
-          ]
-        },
-        setup: function () {
-          this.isAccessibleMock.withArgs('ADMIN').returns(false);
-        },
-        expected: {
-          status: 'INSTALL_FAILED',
-          isButton: true,
-          buttons: [],
-          isDisabled: true
-        },
-        title: 'install failed, no admin access, no requests in progress, another installation running'
-      },
-      {
-        inputData: {
+          ],
           'controller.currentVersion': {
             repository_version: '2.2.0'
           },
           'content.repositoryVersion': '2.2.1',
-          'content.status': 'INSTALL_FAILED',
-          'controller.requestInProgress': false,
-          'parentView.repoVersions': [],
-          'isUpgradeAvailable': true
+          'controller.upgradeVersion': 'HDP-2.2.0',
+          'content.displayName': 'HDP-2.2.1'
         },
         setup: function () {
-          this.isAccessibleMock.withArgs('ADMIN').returns(true);
+          this.isAccessibleMock.withArgs('ADMIN').returns(false);
         },
         expected: {
           status: 'INSTALL_FAILED',
           isButtonGroup: true,
-          buttons: [
-            {
-              text: Em.I18n.t('admin.stackVersions.version.reinstall'),
-              action: 'installRepoVersionConfirmation',
-              isDisabled: false
-            }
-          ],
-          isDisabled: false
+          buttons: [{
+            text: Em.I18n.t('admin.stackVersions.version.reinstall'),
+            action: 'installRepoVersionConfirmation',
+            isDisabled: true
+          }],
+          text: Em.I18n.t('admin.stackVersions.version.performUpgrade'),
+          action: 'confirmUpgrade',
+          isDisabled: true
         },
-        title: 'install failed version should be enabled to Upgrade'
+        title: 'INSTALL_FAILED state, no admin access, no requests in progress, another installation running'
       },
       {
         inputData: {
@@ -466,18 +462,30 @@ describe('App.UpgradeVersionBoxView', function () {
             Em.Object.create({
               status: 'OUT_OF_SYNC'
             })
-          ]
+          ],
+          'controller.currentVersion': {
+            repository_version: '2.2.0'
+          },
+          'content.repositoryVersion': '2.2.1',
+          'controller.upgradeVersion': 'HDP-2.2.0',
+          'content.displayName': 'HDP-2.2.1'
         },
         setup: function () {
           this.isAccessibleMock.withArgs('ADMIN').returns(true);
         },
         expected: {
           status: 'OUT_OF_SYNC',
-          isButton: true,
-          buttons: [],
+          isButtonGroup: true,
+          buttons: [{
+            text: Em.I18n.t('admin.stackVersions.version.reinstall'),
+            action: 'installRepoVersionConfirmation',
+            isDisabled: false
+          }],
+          text: Em.I18n.t('admin.stackVersions.version.performUpgrade'),
+          action: 'confirmUpgrade',
           isDisabled: false
         },
-        title: 'version out of sync, admin access, no requests in progress, no installation'
+        title: 'OUT_OF_SYNC state, admin access, no requests in progress, no installation'
       },
       {
         inputData: {
@@ -487,18 +495,30 @@ describe('App.UpgradeVersionBoxView', function () {
             Em.Object.create({
               status: 'OUT_OF_SYNC'
             })
-          ]
+          ],
+          'controller.currentVersion': {
+            repository_version: '2.2.0'
+          },
+          'content.repositoryVersion': '2.2.1',
+          'controller.upgradeVersion': 'HDP-2.2.0',
+          'content.displayName': 'HDP-2.2.1'
         },
         setup: function () {
           this.isAccessibleMock.withArgs('ADMIN').returns(true);
         },
         expected: {
           status: 'OUT_OF_SYNC',
-          isButton: true,
-          buttons: [],
+          isButtonGroup: true,
+          buttons: [{
+            text: Em.I18n.t('admin.stackVersions.version.reinstall'),
+            action: 'installRepoVersionConfirmation',
+            isDisabled: true
+          }],
+          text: Em.I18n.t('admin.stackVersions.version.performUpgrade'),
+          action: 'confirmUpgrade',
           isDisabled: true
         },
-        title: 'version out of sync, admin access, request in progress, no installation'
+        title: 'OUT_OF_SYNC state, admin access, request in progress, no installation'
       },
       {
         inputData: {
@@ -856,67 +876,4 @@ describe('App.UpgradeVersionBoxView', function () {
       });
     });
   });
-
-  describe("#checkUpgradeAvailability()", function () {
-    beforeEach(function () {
-      sinon.stub(view, 'runUpgradeCheck', Em.K);
-    });
-    afterEach(function () {
-      view.runUpgradeCheck.restore();
-    });
-
-    it("status is INSTALLED", function () {
-      view.set('content.status', 'INSTALLED');
-      view.checkUpgradeAvailability();
-      expect(view.runUpgradeCheck.called).to.be.false;
-    });
-    it("status is INSTALL_FAILED", function () {
-      view.set('content.status', 'INSTALL_FAILED');
-      view.checkUpgradeAvailability();
-      expect(view.runUpgradeCheck.calledTwice).to.be.true;
-    });
-  });
-
-  describe("#runUpgradeCheck()", function () {
-    beforeEach(function () {
-      sinon.stub(App.ajax, 'send', Em.K);
-    });
-    afterEach(function () {
-      App.ajax.send.restore();
-    });
-
-    it("upgradeCheckInProgress is true", function () {
-      view.set('upgradeCheckInProgress', true);
-      view.runUpgradeCheck();
-      expect(App.ajax.send.called).to.be.false;
-      expect(view.get('upgradeCheckInProgress')).to.be.true;
-    });
-    it("upgradeCheckInProgress is false", function () {
-      view.set('upgradeCheckInProgress', false);
-      view.runUpgradeCheck();
-      expect(App.ajax.send.calledOnce).to.be.true;
-      expect(view.get('upgradeCheckInProgress')).to.be.true;
-    });
-  });
-
-  describe("#runUpgradeCheckSuccess()", function () {
-    it("check failed", function () {
-      view.runUpgradeCheckSuccess({items: [{UpgradeChecks: {status: 'FAIL'}}]});
-      expect(view.get('isUpgradeAvailable')).to.be.false;
-      expect(view.get('upgradeCheckInProgress')).to.be.false;
-    });
-    it("check passed", function () {
-      view.runUpgradeCheckSuccess({items: [{UpgradeChecks: {status: 'PASS'}}]});
-      expect(view.get('isUpgradeAvailable')).to.be.true;
-      expect(view.get('upgradeCheckInProgress')).to.be.false;
-    });
-  });
-
-  describe("#runUpgradeCheckError()", function () {
-    it("check failed", function () {
-      view.runUpgradeCheckError();
-      expect(view.get('isUpgradeAvailable')).to.be.false;
-      expect(view.get('upgradeCheckInProgress')).to.be.false;
-    });
-  });
 });