Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 5af5ba301 -> ca1433180


AMBARI-17741 Upgrade is not available if preUpgradeCheck feature is disabled 
(akovalenko)


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

Branch: refs/heads/branch-2.4
Commit: ca1433180fdbf7566d669d41158af64b087cab09
Parents: 5af5ba3
Author: Aleksandr Kovalenko <[email protected]>
Authored: Fri Jul 15 21:38:06 2016 +0300
Committer: Aleksandr Kovalenko <[email protected]>
Committed: Fri Jul 15 22:46:10 2016 +0300

----------------------------------------------------------------------
 .../main/admin/stack_and_upgrade_controller.js  | 11 +++-
 .../admin/stack_upgrade/upgrade_options.hbs     |  4 +-
 .../admin/stack_and_upgrade_controller_test.js  | 55 ++++++++++++++++++++
 3 files changed, 67 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ca143318/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 e083f65..bbf7523 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
@@ -940,6 +940,7 @@ App.MainAdminStackAndUpgradeController = 
Em.Controller.extend(App.LocalStorage,
           return self.get('upgradeMethods');
         }.property().volatile(),
         isInUpgradeWizard: isInUpgradeWizard,
+        showPreUpgradeChecks: App.get('supports.preUpgradeCheck') && 
!isInUpgradeWizard,
         versionText: isInUpgradeWizard ? '' : 
Em.I18n.t('admin.stackVersions.version.upgrade.upgradeOptions.bodyMsg.version').format(version.get('displayName')),
         selectMethod: function (event) {
           if (isInUpgradeWizard || !event.context.get('allowed') || 
event.context.get('isPrecheckFailed')) return;
@@ -1015,7 +1016,15 @@ App.MainAdminStackAndUpgradeController = 
Em.Controller.extend(App.LocalStorage,
       disablePrimary: function () {
         if (isInUpgradeWizard) return false;
         var selectedMethod = this.get('selectedMethod');
-        return (selectedMethod ? (selectedMethod.get('isPrecheckFailed') || 
selectedMethod.get('isCheckRequestInProgress')) : true);
+        if (selectedMethod) {
+          if (App.get('supports.preUpgradeCheck')) {
+            return selectedMethod.get('isPrecheckFailed') || 
selectedMethod.get('isCheckRequestInProgress');
+          } else {
+            return false;
+          }
+        } else {
+          return true;
+        }
       }.property('selectedMethod', 'selectedMethod.isPrecheckFailed', 
'selectedMethod.isCheckRequestInProgress'),
       onPrimary: function () {
         this.hide();

http://git-wip-us.apache.org/repos/asf/ambari/blob/ca143318/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_options.hbs
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_options.hbs 
b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_options.hbs
index f5972bd..5369ebd 100644
--- a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_options.hbs
+++ b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_options.hbs
@@ -29,7 +29,7 @@
             <div {{bindAttr class="method.icon :method-icon"}}></div>
             <div class="method-name">{{method.displayName}}</div>
             <div class="method-description">{{{method.description}}}</div>
-            {{#unless view.isInUpgradeWizard}}
+            {{#if view.showPreUpgradeChecks}}
               {{#if method.isCheckRequestInProgress}}
                 <div class="method-precheck-message checking">
                   {{view App.SpinnerView 
message="admin.stackVersions.version.upgrade.upgradeOptions.preCheck.msg.checking"}}
@@ -46,7 +46,7 @@
                   {{/if}}
                 </div>
               {{/if}}
-            {{/unless}}
+            {{/if}}
         </div>
       </div>
     {{/each}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ca143318/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 c78c35b..feaeafc 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
@@ -1012,6 +1012,61 @@ describe('App.MainAdminStackAndUpgradeController', 
function() {
 
       });
 
+      describe('#popup.disablePrimary', function () {
+
+        beforeEach(function() {
+          this.mock = sinon.stub(App, 'get');
+        });
+
+        afterEach(function() {
+          App.get.restore();
+        });
+
+        it('should be disabled if no method is selected', function () {
+          expect(this.popup.get('disablePrimary')).to.be.true;
+        });
+
+        it('should be disabled if preupgradecheck is supproted and 
isPrecheckFailed is true', function () {
+          this.mock.returns(true);
+          this.popup.set('selectedMethod', Em.Object.create({
+            selected: true,
+            isPrecheckFailed: true,
+            isCheckRequestInProgress: false
+          }));
+
+          expect(this.popup.get('disablePrimary')).to.be.true;
+        });
+
+        it('should be disabled if preupgradecheck is supproted and 
isCheckRequestInProgress is true', function () {
+          this.popup.set('selectedMethod', Em.Object.create({
+            selected: true,
+            isPrecheckFailed: false,
+            isCheckRequestInProgress: true
+          }));
+          this.mock.returns(true);
+          expect(this.popup.get('disablePrimary')).to.be.true;
+        });
+
+        it('should be enabled with preupgrade check', function () {
+          this.popup.set('selectedMethod', Em.Object.create({
+            selected: true,
+            isPrecheckFailed: false,
+            isCheckRequestInProgress: false
+          }));
+          this.mock.returns(true);
+          expect(this.popup.get('disablePrimary')).to.be.false;
+        });
+
+        it('should be enabled without preupgrade check', function () {
+          this.popup.set('selectedMethod', Em.Object.create({
+            selected: true
+          }));
+          this.mock.returns(false);
+          expect(this.popup.get('disablePrimary')).to.be.false;
+        });
+
+      });
+
     });
 
     describe("NOT show confirmation popup on Downgrade", function() {

Reply via email to