ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject ambari git commit: AMBARI-14095. Upgrade: second click shows diff results
Date Tue, 01 Dec 2015 14:00:41 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 9f52815bf -> 52553c290


AMBARI-14095. Upgrade: second click shows diff results


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

Branch: refs/heads/branch-2.1
Commit: 52553c290575fb75c8c457357ffeeb6ca298bc51
Parents: 9f52815
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Tue Dec 1 15:26:50 2015 +0200
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Tue Dec 1 16:00:34 2015 +0200

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |   1 +
 .../app/controllers/main/admin/kerberos.js      |  16 +-
 .../main/admin/stack_and_upgrade_controller.js  |  40 ++-
 .../modal_popups/cluster_check_dialog.hbs       |  24 +-
 .../common/modal_popups/cluster_check_popup.js  | 103 ++-----
 .../admin/stack_and_upgrade_controller_test.js  |   2 +-
 .../modal_popups/cluster_check_popup_test.js    | 271 +++++++++++++++++++
 7 files changed, 356 insertions(+), 101 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/52553c29/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 6393381..677df72 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -205,6 +205,7 @@ var files = ['test/init_model_test',
   'test/views/common/widget/graph_widget_view_test',
   'test/views/common/widget/number_widget_view_test',
   'test/views/common/widget/gauge_widget_view_test',
+  'test/views/common/modal_popups/cluster_check_popup_test',
   'test/views/common/modal_popups/hosts_table_list_popup_test',
   'test/views/common/modal_popups/dependent_configs_list_popup_test',
   'test/views/main/admin_test',

http://git-wip-us.apache.org/repos/asf/ambari/blob/52553c29/ambari-web/app/controllers/main/admin/kerberos.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos.js b/ambari-web/app/controllers/main/admin/kerberos.js
index f9ecc4a..53a8b64 100644
--- a/ambari-web/app/controllers/main/admin/kerberos.js
+++ b/ambari-web/app/controllers/main/admin/kerberos.js
@@ -221,10 +221,18 @@ App.MainAdminKerberosController = App.KerberosWizardStep4Controller.extend({
   runSecurityCheckSuccess: function (data, opt, params) {
     //TODO correct check
     if (data.items.someProperty('UpgradeChecks.status', "FAIL")) {
-      var header = Em.I18n.t('popup.clusterCheck.Security.header').format(params.label);
-      var title = Em.I18n.t('popup.clusterCheck.Security.title');
-      var alert = Em.I18n.t('popup.clusterCheck.Security.alert');
-      App.showClusterCheckPopup(data, header, title, alert);
+      var
+        hasFails = data.items.someProperty('UpgradeChecks.status', 'FAIL'),
+        header = Em.I18n.t('popup.clusterCheck.Security.header').format(params.label)
+         title = Em.I18n.t('popup.clusterCheck.Security.title')
+         alert = Em.I18n.t('popup.clusterCheck.Security.alert');
+
+      App.showClusterCheckPopup(data, {
+        header: header,
+        failTitle: title,
+        failAlert: alert,
+        noCallbackCondition: hasFails
+      });
     } else {
       this.startKerberosWizard();
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/52553c29/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 2eeec4b..c26243a 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
@@ -725,9 +725,11 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
             warningTitle = Em.I18n.t('popup.clusterCheck.Upgrade.warning.title'),
             warningAlert = new Em.Handlebars.SafeString(Em.I18n.t('popup.clusterCheck.Upgrade.warning.alert')),
             configsMergeWarning = data.items.findProperty('UpgradeChecks.id', "CONFIG_MERGE"),
+            popupData = {
+              items: data.items.rejectProperty('UpgradeChecks.id', 'CONFIG_MERGE')
+            },
             configs = [];
           if (configsMergeWarning && Em.get(configsMergeWarning, 'UpgradeChecks.status')
=== 'WARNING') {
-            data.items = data.items.rejectProperty('UpgradeChecks.id', 'CONFIG_MERGE');
             var configsMergeCheckData = Em.get(configsMergeWarning, 'UpgradeChecks.failed_detail');
             if (configsMergeCheckData) {
               configs = configsMergeCheckData.map(function (item) {
@@ -745,12 +747,21 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
               });
             }
           }
-          App.showPreUpgradeCheckPopup(data, header, failTitle, failAlert, warningTitle,
warningAlert, function () {
-            self.runPreUpgradeCheckOnly.call(self, {
-              value: version.get('repositoryVersion'),
-              label: version.get('displayName'),
-              type: event.context.get('type')
-            });
+          App.showClusterCheckPopup(popupData, {
+            header: header,
+            failTitle: failTitle,
+            failAlert: failAlert,
+            warningTitle: warningTitle,
+            warningAlert: warningAlert,
+            primary: Em.I18n.t('admin.stackVersions.version.upgrade.upgradeOptions.preCheck.rerun'),
+            secondary: Em.I18n.t('common.cancel'),
+            callback: function () {
+              self.runPreUpgradeCheckOnly.call(self, {
+                value: version.get('repositoryVersion'),
+                label: version.get('displayName'),
+                type: event.context.get('type')
+              });
+            }
           }, configs, version.get('displayName'));
         }
       }),
@@ -965,7 +976,8 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
     var self = this;
     if (data.items.someProperty('UpgradeChecks.status', 'FAIL') || data.items.someProperty('UpgradeChecks.status',
'WARNING')) {
       this.set('requestInProgress', false);
-      var header = Em.I18n.t('popup.clusterCheck.Upgrade.header').format(params.label),
+      var hasFails = data.items.someProperty('UpgradeChecks.status', 'FAIL'),
+        header = Em.I18n.t('popup.clusterCheck.Upgrade.header').format(params.label),
         failTitle = Em.I18n.t('popup.clusterCheck.Upgrade.fail.title'),
         failAlert = new Em.Handlebars.SafeString(Em.I18n.t('popup.clusterCheck.Upgrade.fail.alert')),
         warningTitle = Em.I18n.t('popup.clusterCheck.Upgrade.warning.title'),
@@ -991,8 +1003,16 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
           });
         }
       }
-      App.showClusterCheckPopup(data, header, failTitle, failAlert, warningTitle, warningAlert,
function () {
-        self.upgrade(params);
+      App.showClusterCheckPopup(data, {
+        header: header,
+        failTitle: failTitle,
+        failAlert: failAlert,
+        warningTitle: warningTitle,
+        warningAlert: warningAlert,
+        noCallbackCondition: hasFails,
+        callback: function () {
+          self.upgrade(params);
+        }
       }, configs, params.label);
     } else {
       this.upgrade(params);

http://git-wip-us.apache.org/repos/asf/ambari/blob/52553c29/ambari-web/app/templates/common/modal_popups/cluster_check_dialog.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/modal_popups/cluster_check_dialog.hbs b/ambari-web/app/templates/common/modal_popups/cluster_check_dialog.hbs
index 8767d70..8fd2746 100644
--- a/ambari-web/app/templates/common/modal_popups/cluster_check_dialog.hbs
+++ b/ambari-web/app/templates/common/modal_popups/cluster_check_dialog.hbs
@@ -20,10 +20,14 @@
     <i class="icon-ok"></i>&nbsp;<span>{{t admin.stackVersions.version.upgrade.upgradeOptions.preCheck.allPassed.msg}}</span>
   {{/if}}
   {{#if view.fails.length}}
-    <h4>{{view.failTitle}}</h4>
-    <div class="alert alert-warning">
-      {{view.failAlert}}
-    </div>
+    {{#if view.failTitle}}
+      <h4>{{view.failTitle}}</h4>
+    {{/if}}
+    {{#if view.failAlert}}
+      <div class="alert alert-warning">
+        {{view.failAlert}}
+      </div>
+    {{/if}}
     <div class="limited-height-2">
       {{#each item in view.fails}}
         <i class="icon-remove"></i>&nbsp;<span>{{item.UpgradeChecks.check}}</span>
@@ -32,10 +36,14 @@
     </div>
   {{/if}}
   {{#if view.warnings.length}}
-    <h4>{{view.warningTitle}}</h4>
-    <div class="alert alert-warning">
-      {{view.warningAlert}}
-    </div>
+    {{#if view.warningTitle}}
+      <h4>{{view.warningTitle}}</h4>
+    {{/if}}
+    {{#if view.warningAlert}}
+      <div class="alert alert-warning">
+        {{view.warningAlert}}
+      </div>
+    {{/if}}
     <div class="limited-height-2">
       {{#each item in view.warnings}}
         <i class="icon-warning-sign"></i>&nbsp;<span>{{item.UpgradeChecks.check}}</span>

http://git-wip-us.apache.org/repos/asf/ambari/blob/52553c29/ambari-web/app/views/common/modal_popups/cluster_check_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/modal_popups/cluster_check_popup.js b/ambari-web/app/views/common/modal_popups/cluster_check_popup.js
index b3f0c4c..d173d1a 100644
--- a/ambari-web/app/views/common/modal_popups/cluster_check_popup.js
+++ b/ambari-web/app/views/common/modal_popups/cluster_check_popup.js
@@ -22,30 +22,33 @@ var App = require('app');
  * popup to display requirements that are not met
  * for current action
  * @param data
- * @param header
- * @param failTitle
- * @param failAlert
- * @param warningTitle
- * @param warningAlert
- * @param callback
+ * @param popup
  * @param configs
  * @param upgradeVersion
  * @returns {*|void}
  */
-App.showClusterCheckPopup = function (data, header, failTitle, failAlert, warningTitle, warningAlert,
callback, configs, upgradeVersion) {
+App.showClusterCheckPopup = function (data, popup, configs, upgradeVersion) {
   var fails = data.items.filterProperty('UpgradeChecks.status', 'FAIL'),
     warnings = data.items.filterProperty('UpgradeChecks.status', 'WARNING'),
     hasConfigsMergeConflicts = !!(configs && configs.length),
-    popupBody = {
-      failTitle: failTitle,
-      failAlert: failAlert,
-      warningTitle: warningTitle,
-      warningAlert: warningAlert,
-      templateName: require('templates/common/modal_popups/cluster_check_dialog'),
-      fails: fails,
-      warnings: warnings,
-      hasConfigsMergeConflicts: hasConfigsMergeConflicts
-    };
+    primary,
+    secondary,
+    popupBody;
+  popup = popup || {};
+  primary = Em.isNone(popup.primary) ?
+    (fails.length ? Em.I18n.t('common.dismiss') : Em.I18n.t('common.proceedAnyway')) : popup.primary;
+  secondary = Em.isNone(popup.secondary) ? (fails.length ? false : Em.I18n.t('common.cancel'))
: popup.secondary;
+  popupBody = {
+    failTitle: popup.failTitle,
+    failAlert: popup.failAlert,
+    warningTitle: popup.warningTitle,
+    warningAlert: popup.warningAlert,
+    templateName: require('templates/common/modal_popups/cluster_check_dialog'),
+    fails: fails,
+    warnings: warnings,
+    hasConfigsMergeConflicts: hasConfigsMergeConflicts,
+    isAllPassed: !fails.length && !warnings.length && !hasConfigsMergeConflicts
+  };
   if (hasConfigsMergeConflicts) {
     popupBody.configsMergeTable = Em.View.extend({
       templateName: require('templates/main/admin/stack_upgrade/upgrade_configs_merge_table'),
@@ -58,71 +61,15 @@ App.showClusterCheckPopup = function (data, header, failTitle, failAlert,
warnin
     });
   }
   return App.ModalPopup.show({
-    primary: fails.length ? Em.I18n.t('common.dismiss') : Em.I18n.t('common.proceedAnyway'),
-    secondary: fails.length ? false : Em.I18n.t('common.cancel'),
-    header: header,
-    classNames: ['cluster-check-popup'],
-    bodyClass: Em.View.extend(popupBody),
-    onPrimary: function () {
-      if (!fails.length && callback) {
-        callback();
-      }
-      this._super();
-    }
-  });
-};
-
-
-/**
- * popup to display requirements that are not met
- * for current action
- * @param data
- * @param header
- * @param failTitle
- * @param failAlert
- * @param warningTitle
- * @param warningAlert
- * @param callback
- * @param configs
- * @param upgradeVersion
- * @returns {*|void}
- */
-App.showPreUpgradeCheckPopup = function (data, header, failTitle, failAlert, warningTitle,
warningAlert, callback, configs, upgradeVersion) {
-  var fails = data.items.filterProperty('UpgradeChecks.status', 'FAIL'),
-    warnings = data.items.filterProperty('UpgradeChecks.status', 'WARNING'),
-    hasConfigsMergeConflicts = !!(configs && configs.length),
-    popupBody = {
-      failTitle: failTitle,
-      failAlert: failAlert,
-      warningTitle: warningTitle,
-      warningAlert: warningAlert,
-      templateName: require('templates/common/modal_popups/cluster_check_dialog'),
-      fails: fails,
-      warnings: warnings,
-      hasConfigsMergeConflicts: hasConfigsMergeConflicts,
-      isAllPassed: !fails.length && !warnings.length && !hasConfigsMergeConflicts.length
-    };
-  if (hasConfigsMergeConflicts) {
-    popupBody.configsMergeTable = Em.View.extend({
-      templateName: require('templates/main/admin/stack_upgrade/upgrade_configs_merge_table'),
-      configs: configs,
-      didInsertElement: function () {
-        App.tooltip($('.recommended-value'), {
-          title: upgradeVersion
-        });
-      }
-    });
-  }
-  return App.ModalPopup.show({
-    primary: Em.I18n.t('admin.stackVersions.version.upgrade.upgradeOptions.preCheck.rerun'),
-    secondary: Em.I18n.t('common.cancel'),
-    header: header,
+    primary: primary,
+    secondary: secondary,
+    header: popup.header,
     classNames: ['cluster-check-popup'],
     bodyClass: Em.View.extend(popupBody),
     onPrimary: function () {
       this._super();
-      if (callback) {
-        callback();
+      if (!popup.noCallbackCondition && popup.callback) {
+        popup.callback();
       }
     }
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/52553c29/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 ff2e39e..0575d26 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
@@ -454,7 +454,7 @@ describe('App.MainAdminStackAndUpgradeController', function() {
         expect(controller.upgrade.callCount).to.equal(item.upgradeCalledCount);
         expect(App.showClusterCheckPopup.callCount).to.equal(item.showClusterCheckPopupCalledCount);
         if (item.check.id == 'CONFIG_MERGE') {
-          expect(App.showClusterCheckPopup.firstCall.args[7]).to.eql(item.configs);
+          expect(App.showClusterCheckPopup.firstCall.args[2]).to.eql(item.configs);
         }
       });
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/52553c29/ambari-web/test/views/common/modal_popups/cluster_check_popup_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/modal_popups/cluster_check_popup_test.js b/ambari-web/test/views/common/modal_popups/cluster_check_popup_test.js
new file mode 100644
index 0000000..7f02730
--- /dev/null
+++ b/ambari-web/test/views/common/modal_popups/cluster_check_popup_test.js
@@ -0,0 +1,271 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+require('views/common/modal_popups/cluster_check_popup');
+
+describe('App.showClusterCheckPopup', function () {
+
+  var isCallbackExecuted,
+    callback = function () {
+      isCallbackExecuted = true;
+    },
+    cases = [
+      {
+        inputData: {
+          data: {
+            items: [
+              {
+                UpgradeChecks: {
+                  id: 'p0',
+                  status: 'PASS'
+                }
+              },
+              {
+                UpgradeChecks: {
+                  id: 'p1',
+                  status: 'PASS'
+                }
+              }
+            ]
+          }
+        },
+        result: {
+          primary: Em.I18n.t('common.proceedAnyway'),
+          secondary: Em.I18n.t('common.cancel'),
+          header: '&nbsp;'
+        },
+        bodyResult: {
+          failTitle: undefined,
+          failAlert: undefined,
+          warningTitle: undefined,
+          warningAlert: undefined,
+          fails: [],
+          warnings: [],
+          hasConfigsMergeConflicts: false,
+          isAllPassed: true
+        },
+        isCallbackExecuted: false,
+        title: 'no fails, no warnings, no popup customization'
+      },
+      {
+        inputData: {
+          data: {
+            items: [
+              {
+                UpgradeChecks: {
+                  id: 'w0',
+                  status: 'WARNING'
+                }
+              },
+              {
+                UpgradeChecks: {
+                  id: 'w1',
+                  status: 'WARNING'
+                }
+              }
+            ]
+          },
+          popup: {
+            header: 'checks',
+            failTitle: 'fail',
+            failAlert: 'something has failed',
+            warningTitle: 'warning',
+            warningAlert: 'something is not good',
+            callback: callback
+          }
+        },
+        result: {
+          primary: Em.I18n.t('common.proceedAnyway'),
+          secondary: Em.I18n.t('common.cancel'),
+          header: 'checks'
+        },
+        bodyResult: {
+          failTitle: 'fail',
+          failAlert: 'something has failed',
+          warningTitle: 'warning',
+          warningAlert: 'something is not good',
+          fails: [],
+          warnings: [
+            {
+              UpgradeChecks: {
+                id: 'w0',
+                status: 'WARNING'
+              }
+            },
+            {
+              UpgradeChecks: {
+                id: 'w1',
+                status: 'WARNING'
+              }
+            }
+          ],
+          hasConfigsMergeConflicts: false,
+          isAllPassed: false
+        },
+        isCallbackExecuted: true,
+        title: 'no fails, default buttons, callback executed'
+      },
+      {
+        inputData: {
+          data: {
+            items: [
+              {
+                UpgradeChecks: {
+                  id: 'f0',
+                  status: 'FAIL'
+                }
+              },
+              {
+                UpgradeChecks: {
+                  id: 'f1',
+                  status: 'FAIL'
+                }
+              }
+            ]
+          },
+          popup: {
+            callback: callback,
+            noCallbackCondition: true
+          }
+        },
+        result: {
+          primary: Em.I18n.t('common.dismiss'),
+          secondary: false,
+          header: '&nbsp;'
+        },
+        bodyResult: {
+          failTitle: undefined,
+          failAlert: undefined,
+          warningTitle: undefined,
+          warningAlert: undefined,
+          fails: [
+            {
+              UpgradeChecks: {
+                id: 'f0',
+                status: 'FAIL'
+              }
+            },
+            {
+              UpgradeChecks: {
+                id: 'f1',
+                status: 'FAIL'
+              }
+            }
+          ],
+          warnings: [],
+          hasConfigsMergeConflicts: false,
+          isAllPassed: false
+        },
+        isCallbackExecuted: false,
+        title: 'fails detected, default buttons, callback not executed'
+      },
+      {
+        inputData: {
+          data: {
+            items: [
+              {
+                UpgradeChecks: {
+                  id: 'p0',
+                  status: 'PASS'
+                }
+              },
+              {
+                UpgradeChecks: {
+                  id: 'p1',
+                  status: 'PASS'
+                }
+              }
+            ]
+          },
+          popup: {
+            primary: 'ok',
+            secondary: 'cancel'
+          },
+          configs: [
+            {
+              name: 'c0'
+            },
+            {
+              name: 'c1'
+            }
+          ],
+          upgradeVersion: 'HDP-2.3.0.0'
+        },
+        result: {
+          primary: 'ok',
+          secondary: 'cancel',
+          header: '&nbsp;'
+        },
+        bodyResult: {
+          failTitle: undefined,
+          failAlert: undefined,
+          warningTitle: undefined,
+          warningAlert: undefined,
+          fails: [],
+          warnings: [],
+          hasConfigsMergeConflicts: true,
+          isAllPassed: false
+        },
+        configsResult: [
+          {
+            name: 'c0'
+          },
+          {
+            name: 'c1'
+          }
+        ],
+        isCallbackExecuted: false,
+        title: 'configs merge conflicts detected, custom buttons'
+      }
+    ];
+
+  beforeEach(function () {
+    isCallbackExecuted = false;
+    sinon.stub(App, 'tooltip', Em.K);
+  });
+
+  afterEach(function () {
+    App.tooltip.restore();
+  });
+
+  cases.forEach(function (item) {
+    it(item.title, function () {
+      var popup = App.showClusterCheckPopup(item.inputData.data, item.inputData.popup, item.inputData.configs,
item.inputData.upgradeVersion),
+        popupBody = popup.bodyClass.create();
+      popup.onPrimary();
+      Em.keys(item.result).forEach(function (key) {
+        expect(popup[key]).to.equal(item.result[key]);
+      });
+      Em.keys(item.bodyResult).forEach(function (key) {
+        expect(popupBody[key]).to.eql(item.bodyResult[key]);
+      });
+      expect(isCallbackExecuted).to.equal(item.isCallbackExecuted);
+      if (item.bodyResult.hasConfigsMergeConflicts) {
+        var configsMergeTable = popupBody.configsMergeTable.create();
+        configsMergeTable.didInsertElement();
+        expect(configsMergeTable.configs).to.eql(item.configsResult);
+        expect(App.tooltip.calledOnce).to.be.true;
+        expect(App.tooltip.firstCall.args[1].title).to.equal(item.inputData.upgradeVersion);
+      } else {
+        expect(App.tooltip.calledOnce).to.be.false;
+      }
+    });
+  });
+
+});


Mime
View raw message