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-21704 Upgrade Wizard Has Incorrect Title. (atkach)
Date Fri, 11 Aug 2017 09:23:19 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-21450 83e9d89f2 -> 9232f35cb


AMBARI-21704 Upgrade Wizard Has Incorrect Title. (atkach)


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

Branch: refs/heads/branch-feature-AMBARI-21450
Commit: 9232f35cb8d8223854abb988299c517af387fc92
Parents: 83e9d89
Author: Andrii Tkach <atkach@apache.org>
Authored: Thu Aug 10 19:31:06 2017 +0300
Committer: Andrii Tkach <atkach@apache.org>
Committed: Thu Aug 10 20:40:32 2017 +0300

----------------------------------------------------------------------
 .../main/admin/stack_and_upgrade_controller.js  | 59 ++++++++++++++------
 ambari-web/app/messages.js                      |  9 +--
 ambari-web/app/routes/stack_upgrade_routes.js   |  9 +--
 ambari-web/app/utils/ajax/ajax.js               |  2 +-
 .../stack_upgrade/upgrade_version_box_view.js   | 11 ++--
 .../admin/stack_and_upgrade_controller_test.js  | 39 +++++++++----
 .../upgrade_version_box_view_test.js            |  6 +-
 7 files changed, 87 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9232f35c/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 d3bcb45..740562c 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
@@ -133,12 +133,33 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
    * @type {string}
    */
   wizardModalTitle: function () {
-    if (this.get('isDowngrade')) {
-      return Em.I18n.t('admin.stackUpgrade.dialog.downgrade.header').format(this.get('upgradeVersion'));
-    }
-    return Em.I18n.t('admin.stackUpgrade.dialog.header').format(this.get('upgradeVersion'));
+    var repoVersion = App.RepositoryVersion.find().findProperty('repositoryVersion', this.get('toVersion'));
+    return this.getUpgradeDowngradeHeader(
+      this.get('upgradeTypeDisplayName'),
+      this.get('upgradeVersion'),
+      this.get('isDowngrade'),
+      repoVersion && repoVersion.get('isPatch')
+    );
   }.property('upgradeTypeDisplayName', 'upgradeVersion', 'isDowngrade'),
 
+
+  /**
+   * @param {string} upgradeType
+   * @param {string} upgradeVersion
+   * @param {boolean} isDowngrade
+   * @param {boolean} isPatch
+   * @returns {string}
+   */
+  getUpgradeDowngradeHeader: function(upgradeType, upgradeVersion, isDowngrade, isPatch)
{
+    if (isDowngrade) {
+      return Em.I18n.t('admin.stackUpgrade.dialog.downgrade.header').format(upgradeVersion);
+    }
+    if (isPatch) {
+      return Em.I18n.t('admin.stackUpgrade.dialog.upgrade.patch.header').format(upgradeType,
upgradeVersion);
+    }
+    return Em.I18n.t('admin.stackUpgrade.dialog.upgrade.header').format(upgradeType, upgradeVersion);
+  },
+
   /**
    * methods through which cluster could be upgraded, "allowed" indicated if the method is
allowed
    * by stack upgrade path
@@ -239,6 +260,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
   wizardStorageProperties: [
     'upgradeId',
     'upgradeVersion',
+    'toVersion',
     'currentVersion',
     'upgradeTypeDisplayName',
     'upgradeType',
@@ -665,7 +687,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
       },
       Em.I18n.t('admin.stackUpgrade.downgrade.body').format(currentVersion.repository_name),
       null,
-      Em.I18n.t('admin.stackUpgrade.dialog.downgrade.header').format(currentVersion.repository_name),
+      Em.I18n.t('admin.stackUpgrade.dialog.downgrade.header').format(this.get('upgradeVersion')),
       Em.I18n.t('admin.stackUpgrade.downgrade.proceed')
     );
   },
@@ -714,7 +736,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
       sender: this,
       data: {
         value: currentVersion.repository_version,
-        label: currentVersion.repository_name,
+        label: this.get('upgradeVersion'),
         id: currentVersion.id,
         isDowngrade: true,
         upgradeType: this.get('upgradeType')
@@ -875,7 +897,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
   upgradeSuccessCallback: function (data, opt, params) {
     this.set('upgradeData', null);
     this.set('upgradeId', data.resources[0].Upgrade.request_id);
-    this.set('fromVersion', params.isDowngrade ? data.resources[0].Upgrade.associated_version
: null);
+    this.set('toVersion', params.value);
     this.set('upgradeVersion', params.label);
     this.set('isDowngrade', !!params.isDowngrade);
     var upgradeMethod = this.get('upgradeMethods').findProperty('type', params.type),
@@ -899,7 +921,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
     this.setDBProperties({
       upgradeVersion: params.label,
       upgradeId: data.resources[0].Upgrade.request_id,
-      fromVersion: params.isDowngrade ? data.resources[0].Upgrade.associated_version : null,
+      toVersion: params.value,
       upgradeState: 'PENDING',
       isDowngrade: !!params.isDowngrade,
       upgradeType: upgradeType,
@@ -938,7 +960,8 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
     this.get('upgradeMethods').forEach(function (method) {
       if (method.get('allowed')) {
         this.runPreUpgradeCheckOnly({
-          value: version.get('id'),
+          id: version.get('id'),
+          value: version.get('repositoryVersion'),
           label: version.get('displayName'),
           type: method.get('type')
         });
@@ -1327,7 +1350,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
   runPreUpgradeCheck: function(version) {
     var params = {
       id: version.get('id'),
-      value: version.get('id'),
+      value: version.get('repositoryVersion'),
       label: version.get('displayName'),
       type: version.get('upgradeType'),
       skipComponentFailures: version.get('skipComponentFailures') ? 'true' : 'false',
@@ -1400,7 +1423,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
       },
       Em.I18n.t('admin.stackUpgrade.upgrade.retry.confirm.body').format(version.get('displayName')),
       null,
-      Em.I18n.t('admin.stackUpgrade.dialog.header').format(version.get('upgradeTypeDislayName'),
version.get('displayName'))
+      this.getUpgradeDowngradeHeader(version.get('upgradeTypeDislayName'), version.get('displayName'),
false)
     );
   },
 
@@ -2016,11 +2039,9 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
       data: {
         upgradeId: upgrade && upgrade.get('upgradeId'),
         id: version.get('id'),
-        value: version.get('id'),
+        value: version.get('repositoryVersion'),
         label: version.get('displayName'),
-        type: version.get('upgradeType'),
-        skipComponentFailures: version.get('skipComponentFailures') ? 'true' : 'false',
-        skipSCFailures: version.get('skipSCFailures') ? 'true' : 'false'
+        isDowngrade: true
       }
     });
   },
@@ -2034,7 +2055,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
     var upgradeType = this.get('upgradeMethods').findProperty('type', lastUpgradeData.Upgrade.upgrade_type);
     var isDowngrade = lastUpgradeData.Upgrade.direction === 'DOWNGRADE';
     this.setDBProperties({
-      fromVersion: isDowngrade ? lastUpgradeData.Upgrade.associated_version : null,
+      toVersion: lastUpgradeData.Upgrade.associated_version,
       upgradeId: lastUpgradeData.Upgrade.request_id,
       isDowngrade: isDowngrade,
       upgradeState: lastUpgradeData.Upgrade.request_status,
@@ -2048,8 +2069,10 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
       })
     });
     this.loadRepoVersionsToModel().done(function () {
-      var toVersion = isDowngrade ? null : App.RepositoryVersion.find().findProperty('repositoryVersion',
lastUpgradeData.Upgrade.associated_version);
-      self.setDBProperty('upgradeVersion', toVersion && toVersion.get('displayName'));
+      var toVersion = App.RepositoryVersion.find().findProperty('repositoryVersion', lastUpgradeData.Upgrade.associated_version);
+      if (!isDowngrade) {
+        self.setDBProperty('upgradeVersion', toVersion && toVersion.get('displayName'));
+      }
       self.initDBProperties();
       self.loadUpgradeData(true);
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/9232f35c/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 178d5d0..1e30536 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1742,10 +1742,10 @@ Em.I18n.translations = {
   'admin.stackVersions.version.upgrade.upgradeOptions.tolerance.option1': "Skip all Slave
Component failures",
   'admin.stackVersions.version.upgrade.upgradeOptions.tolerance.option2': "Skip all Service
Check failures",
   'admin.stackVersions.version.upgrade.upgradeOptions.tolerance.tooltip': "These upgrade
failure tolerance options are useful when performing an upgrade on a large cluster and you
want to minimize user intervention.",
-  'admin.stackVersions.version.upgrade.upgradeOptions.RU.title': "Rolling Upgrade",
+  'admin.stackVersions.version.upgrade.upgradeOptions.RU.title': "Rolling",
   'admin.stackVersions.version.upgrade.upgradeOptions.RU.description': "Services remain running
while the upgrade is performed. Minimized disruption but slower upgrade.",
-  'admin.stackVersions.version.upgrade.upgradeOptions.EU.title': "Express Upgrade",
-  'admin.stackVersions.version.upgrade.upgradeOptions.HOU.title': "Host Ordered Upgrade",
+  'admin.stackVersions.version.upgrade.upgradeOptions.EU.title': "Express",
+  'admin.stackVersions.version.upgrade.upgradeOptions.HOU.title': "Host Ordered",
   'admin.stackVersions.version.upgrade.upgradeOptions.EU.description': "Services are stopped
while the upgrade is performed. Incurs downtime, but faster upgrade.",
   'admin.stackVersions.version.upgrade.upgradeOptions.errors_bypassed': "Upgrade Checks Bypassed.",
   'admin.stackVersions.version.upgrade.upgradeOptions.preCheck.rerun':'Rerun Checks',
@@ -1846,7 +1846,8 @@ Em.I18n.translations = {
   'admin.stackUpgrade.state.paused.downgrade': "Downgrade Paused",
   'admin.stackUpgrade.state.aborted.downgrade': "Downgrade Aborted",
   'admin.stackUpgrade.state.completed.downgrade': "Downgrade Finished",
-  'admin.stackUpgrade.dialog.header': "Upgrade to {0}",
+  'admin.stackUpgrade.dialog.upgrade.header': "{0} Upgrade to {1}",
+  'admin.stackUpgrade.dialog.upgrade.patch.header': "{0} Patch Upgrade to {1}",
   'admin.stackUpgrade.dialog.downgrade.header': "Downgrade from {0}",
   'admin.stackUpgrade.dialog.operationFailed': "This operation failed.",
   'admin.stackUpgrade.dialog.stop': "Stop Upgrade",

http://git-wip-us.apache.org/repos/asf/ambari/blob/9232f35c/ambari-web/app/routes/stack_upgrade_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/stack_upgrade_routes.js b/ambari-web/app/routes/stack_upgrade_routes.js
index 339c770..1d4dc61 100644
--- a/ambari-web/app/routes/stack_upgrade_routes.js
+++ b/ambari-web/app/routes/stack_upgrade_routes.js
@@ -35,14 +35,7 @@ module.exports = App.WizardRoute.extend({
 
           return App.ModalPopup.show({
             classNames: ['full-width-modal'],
-            header: function () {
-              var controller = App.router.get('mainAdminStackAndUpgradeController');
-              if (controller.get('isDowngrade')) {
-                return Em.I18n.t('admin.stackUpgrade.dialog.downgrade.header').format(controller.get('upgradeVersion'));
-              } else {
-                return Em.I18n.t('admin.stackUpgrade.dialog.header').format(controller.get('upgradeTypeDisplayName'),
controller.get('upgradeVersion'));
-              }
-            }.property('App.router.mainAdminStackAndUpgradeController.upgradeVersion', 'App.router.mainAdminStackAndUpgradeController.isDowngrade'),
+            header: Em.computed.alias('App.router.mainAdminStackAndUpgradeController.wizardModalTitle'),
             bodyClass: App.upgradeWizardView,
             primary: Em.I18n.t('common.dismiss'),
             secondary: null,

http://git-wip-us.apache.org/repos/asf/ambari/blob/9232f35c/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 85745e8..89a3a84 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -1874,7 +1874,7 @@ var urls = {
   },
 
   'admin.upgrade.pre_upgrade_check': {
-    'real': '/clusters/{clusterName}/rolling_upgrades_check?fields=*&UpgradeChecks/repository_version_id={value}&UpgradeChecks/upgrade_type={type}',
+    'real': '/clusters/{clusterName}/rolling_upgrades_check?fields=*&UpgradeChecks/repository_version_id={id}&UpgradeChecks/upgrade_type={type}',
     'mock': '/data/stack_versions/pre_upgrade_check.json'
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/9232f35c/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 39516a3..5f74bc6 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
@@ -177,12 +177,11 @@ App.UpgradeVersionBoxView = Em.View.extend({
     });
     var isSuspended = App.get('upgradeSuspended');
 
-    if (['INSTALLING', 'CURRENT'].contains(status)) {
-      if (this.get('content.isPatch') && status === 'CURRENT') {
-        element.setProperties(statePropertiesMap['CURRENT_PATCH']);
-      } else {
-        element.setProperties(statePropertiesMap[status]);
-      }
+    if (status === 'CURRENT' && this.get('content.isPatch') && !this.get('isUpgrading'))
{
+      element.setProperties(statePropertiesMap['CURRENT_PATCH']);
+    }
+    else if (['INSTALLING', 'CURRENT'].contains(status) && !this.get('content.isPatch'))
{
+      element.setProperties(statePropertiesMap[status]);
     }
     else if (status === 'NOT_REQUIRED') {
       requestInProgressRepoId && requestInProgressRepoId == this.get('content.id')
? element.setProperties(statePropertiesMap['LOADING']) : element.setProperties(statePropertiesMap[status]);

http://git-wip-us.apache.org/repos/asf/ambari/blob/9232f35c/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 a737abe..4d76d5d 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
@@ -405,7 +405,7 @@ describe('App.MainAdminStackAndUpgradeController', function() {
       expect(args[0].sender).to.be.eql(controller);
       expect(args[0].data).to.be.eql({
         id: '1',
-        value: '1',
+        value: '2.2',
         label: 'HDP-2.2',
         type: 'ROLLING',
         skipComponentFailures: 'false',
@@ -1173,7 +1173,7 @@ describe('App.MainAdminStackAndUpgradeController', function() {
       expect(this.callArgs.data).to.eql({
         id: '1',
         value: '2.2',
-        label: 'HDP-2.2',
+        label: 'HDP-2.3',
         isDowngrade: true,
         upgradeType: "NON_ROLLING"
       });
@@ -1753,11 +1753,13 @@ describe('App.MainAdminStackAndUpgradeController', function() {
     it("Rolling method allowed", function () {
       controller.get('upgradeMethods').setEach('allowed', true);
       controller.runUpgradeMethodChecks(Em.Object.create({
-        id: '1',
+        id: 1,
+        repositoryVersion: '1.2',
         displayName: 'V1'
       }));
       expect(controller.runPreUpgradeCheckOnly.calledWith({
-        value: '1',
+        id: 1,
+        value: '1.2',
         label: 'V1',
         type: 'ROLLING'
       })).to.be.true;
@@ -1808,7 +1810,7 @@ describe('App.MainAdminStackAndUpgradeController', function() {
     });
     it('proper data is saved to the localDB', function () {
       expect(controller.setDBProperties.getCall(0).args[0]).to.eql({
-        fromVersion: null,
+        toVersion: '1.1',
         upgradeId: 1,
         isDowngrade: false,
         upgradeState: 'PENDING',
@@ -3506,16 +3508,33 @@ describe('App.MainAdminStackAndUpgradeController', function() {
       expect(args[0]).to.exists;
       expect(args[0].data).to.be.eql({
         upgradeId: 1,
+        isDowngrade: true,
         id: 2,
-        value: 2,
-        label: '1.2',
-        type: 'EXPRESS',
-        skipComponentFailures: 'false',
-        skipSCFailures: 'false'
+        value: '1.1',
+        label: '1.2'
       });
       args[0].callback();
       expect(controller.get('requestInProgress')).to.be.false;
     });
   });
 
+  describe('#getUpgradeDowngradeHeader', function() {
+
+    it('should return downgrade header', function() {
+      expect(controller.getUpgradeDowngradeHeader('t1', 'v1', true)).to.be.equal(
+        Em.I18n.t('admin.stackUpgrade.dialog.downgrade.header').format('v1')
+      );
+    });
+    it('should return patch upgrade header', function() {
+      expect(controller.getUpgradeDowngradeHeader('t1', 'v1', false, true)).to.be.equal(
+        Em.I18n.t('admin.stackUpgrade.dialog.upgrade.patch.header').format('t1', 'v1')
+      );
+    });
+    it('should return upgrade header', function() {
+      expect(controller.getUpgradeDowngradeHeader('t1', 'v1', false, false)).to.be.equal(
+        Em.I18n.t('admin.stackUpgrade.dialog.upgrade.header').format('t1', 'v1')
+      );
+    });
+  });
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/9232f35c/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 2c08dd3..09ac9df 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
@@ -368,7 +368,8 @@ describe('App.UpgradeVersionBoxView', function () {
       {
         inputData: {
           'content.status': 'CURRENT',
-          'content.isPatch': true
+          'content.isPatch': true,
+          'isUpgrading': false
         },
         expected: {
           status: 'CURRENT',
@@ -937,6 +938,9 @@ describe('App.UpgradeVersionBoxView', function () {
         if (item.setup) {
           item.setup.call(this);
         }
+        view.reopen({
+          isUpgrading: item.inputData.isUpgrading
+        });
         view.setProperties(item.inputData);
         var result = view.get('stateElement').getProperties(Em.keys(item.expected));
         if (result.buttons) {


Mime
View raw message