You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ab...@apache.org on 2017/02/27 15:49:24 UTC

ambari git commit: AMBARI-20211 UI asking user to "refresh yarn queue" on stopped yarn service, which results to infinite refresh time as yarn is stopped. (ababiichuk)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 ac0fb82c7 -> 1ba483fb9


AMBARI-20211 UI asking user to "refresh yarn queue" on stopped yarn service, which results to infinite refresh time as yarn is stopped. (ababiichuk)


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

Branch: refs/heads/branch-2.5
Commit: 1ba483fb9b99acf19ef6b7db5a1f1a8134942a87
Parents: ac0fb82
Author: ababiichuk <ab...@hortonworks.com>
Authored: Mon Feb 27 17:04:01 2017 +0200
Committer: ababiichuk <ab...@hortonworks.com>
Committed: Mon Feb 27 17:04:01 2017 +0200

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |   1 +
 .../configs/component_actions_by_configs.js     |  44 +--
 .../component_actions_by_configs_test.js        | 332 +++++++++++++++++++
 3 files changed, 358 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1ba483fb/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 aae27ea..11ab9a5 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -170,6 +170,7 @@ var files = [
   'test/mixins/main/host/details/host_components/install_component_test',
   'test/mixins/main/service/configs/widget_popover_support_test',
   'test/mixins/main/service/configs/config_overridable_test',
+  'test/mixins/main/service/configs/component_actions_by_configs_test',
   'test/mixins/routers/redirections_test',
   'test/mixins/wizard/addSeccurityConfigs_test',
   'test/mixins/wizard/assign_master_components_test',

http://git-wip-us.apache.org/repos/asf/ambari/blob/1ba483fb/ambari-web/app/mixins/main/service/configs/component_actions_by_configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/service/configs/component_actions_by_configs.js b/ambari-web/app/mixins/main/service/configs/component_actions_by_configs.js
index 42e2dac..b01c784 100644
--- a/ambari-web/app/mixins/main/service/configs/component_actions_by_configs.js
+++ b/ambari-web/app/mixins/main/service/configs/component_actions_by_configs.js
@@ -61,27 +61,33 @@ App.ComponentActionsByConfigs = Em.Mixin.create({
         });
 
         if (configs.length) {
-          if(config_action.get('fileName') === 'capacity-scheduler.xml' && !self.isYarnQueueRefreshed) {
-            var hsiInstance = App.HostComponent.find().filterProperty('componentName', "HIVE_SERVER_INTERACTIVE");
-            if(self.get('content.serviceName') === 'HIVE') {
-              // Auto refresh yarn capacity scheduler if capacity-scheduler configs are changed from Hive configs page
-              self.popupPrimaryButtonCallback(config_action);
-              // Show a popup to restart HSI if HSI is enabled
-              if(hsiInstance.length > 0) {
-                self.showHsiRestartPopup(hsiInstance);
-              }
-            } else {
-              self.configAction = config_action;
-              var body = config_action.get('popupProperties').body;
-              if(config_action.get('popupProperties').hasOwnProperty('conditionalWarning') && config_action.get('popupProperties').conditionalWarning === true) {
-                // Check if Hive Server 2 Interactive is enabled and show a warning message if it is enabled
-                if(hsiInstance.length > 0) {
-                  body += "<br/><br/>" + config_action.get('popupProperties').warningMessage;
+          var hostComponents = App.HostComponent.find();
+          if (config_action.get('fileName') === 'capacity-scheduler.xml' && !self.isYarnQueueRefreshed) {
+            var isRMRunning = hostComponents.some(function (component) {
+              return component.get('componentName') === 'RESOURCEMANAGER' && component.get('isRunning');
+            });
+            if (isRMRunning) {
+              var hsiInstance = hostComponents.filterProperty('componentName', 'HIVE_SERVER_INTERACTIVE');
+              if (self.get('content.serviceName') === 'HIVE') {
+                // Auto refresh yarn capacity scheduler if capacity-scheduler configs are changed from Hive configs page
+                self.popupPrimaryButtonCallback(config_action);
+                // Show a popup to restart HSI if HSI is enabled
+                if (hsiInstance.length > 0) {
+                  self.showHsiRestartPopup(hsiInstance);
                 }
+              } else {
+                self.configAction = config_action;
+                var body = config_action.get('popupProperties').body;
+                if (config_action.get('popupProperties').hasOwnProperty('conditionalWarning') && config_action.get('popupProperties').conditionalWarning === true) {
+                  // Check if Hive Server 2 Interactive is enabled and show a warning message if it is enabled
+                  if (hsiInstance.length > 0) {
+                    body += "<br/><br/>" + config_action.get('popupProperties').warningMessage;
+                  }
+                }
+                App.showConfirmationPopup(function () {
+                  self.popupPrimaryButtonCallback(config_action);
+                }, body, null, Em.I18n.t('popup.confirmation.commonHeader'), config_action.get('popupProperties').primaryButton.label, false, 'refresh_yarn_queues')
               }
-              App.showConfirmationPopup(function () {
-                self.popupPrimaryButtonCallback(config_action);
-              }, body, null, Em.I18n.t('popup.confirmation.commonHeader'), config_action.get('popupProperties').primaryButton.label, false, 'refresh_yarn_queues')
             }
           }
         }

http://git-wip-us.apache.org/repos/asf/ambari/blob/1ba483fb/ambari-web/test/mixins/main/service/configs/component_actions_by_configs_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/main/service/configs/component_actions_by_configs_test.js b/ambari-web/test/mixins/main/service/configs/component_actions_by_configs_test.js
new file mode 100644
index 0000000..f7b6681
--- /dev/null
+++ b/ambari-web/test/mixins/main/service/configs/component_actions_by_configs_test.js
@@ -0,0 +1,332 @@
+/**
+ * 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.
+ */
+
+require('mixins/main/service/configs/component_actions_by_configs');
+
+var mixin;
+
+describe('App.ComponentActionsByConfigs', function () {
+
+  beforeEach(function() {
+    mixin = Em.Object.create(App.ComponentActionsByConfigs, {
+      content: Em.Object.create()
+    });
+  });
+
+  describe('#showPopup', function () {
+
+    var testCases = [
+        {
+          configActions: [],
+          popupPrimaryButtonCallbackCallCount: 0,
+          showHsiRestartPopupCallCount: 0,
+          showConfirmationPopupCallCount: 0,
+          title: 'no config actions'
+        },
+        {
+          configActions: [
+            {
+              actionType: 'none'
+            },
+            {
+              actionType: null
+            },
+            {}
+          ],
+          popupPrimaryButtonCallbackCallCount: 0,
+          showHsiRestartPopupCallCount: 0,
+          showConfirmationPopupCallCount: 0,
+          title: 'no popup config actions'
+        },
+        {
+          configActions: [
+            Em.Object.create({
+              actionType: 'showPopup',
+              fileName: 'f0'
+            })
+          ],
+          mixinProperties: {
+            allConfigs: [
+              Em.Object.create({
+                filename: 'f1',
+                value: 0,
+                initialValue: 1
+              })
+            ]
+          },
+          popupPrimaryButtonCallbackCallCount: 0,
+          showHsiRestartPopupCallCount: 0,
+          showConfirmationPopupCallCount: 0,
+          title: 'no associated configs'
+        },
+        {
+          configActions: [
+            Em.Object.create({
+              actionType: 'showPopup',
+              fileName: 'f2'
+            })
+          ],
+          mixinProperties: {
+            allConfigs: [
+              Em.Object.create({
+                filename: 'f2',
+                value: 0,
+                initialValue: 0
+              })
+            ]
+          },
+          popupPrimaryButtonCallbackCallCount: 0,
+          showHsiRestartPopupCallCount: 0,
+          showConfirmationPopupCallCount: 0,
+          title: 'no changes in associated configs'
+        },
+        {
+          configActions: [
+            Em.Object.create({
+              actionType: 'showPopup',
+              fileName: 'f3'
+            })
+          ],
+          mixinProperties: {
+            allConfigs: [
+              Em.Object.create({
+                filename: 'f3',
+                value: 0,
+                initialValue: 1
+              })
+            ]
+          },
+          popupPrimaryButtonCallbackCallCount: 0,
+          showHsiRestartPopupCallCount: 0,
+          showConfirmationPopupCallCount: 0,
+          title: 'no capacity-scheduler actions defined'
+        },
+        {
+          configActions: [
+            Em.Object.create({
+              actionType: 'showPopup',
+              fileName: 'capacity-scheduler.xml'
+            })
+          ],
+          mixinProperties: {
+            allConfigs: [
+              Em.Object.create({
+                filename: 'capacity-scheduler.xml',
+                value: 0,
+                initialValue: 1
+              })
+            ],
+            isYarnQueueRefreshed: true
+          },
+          popupPrimaryButtonCallbackCallCount: 0,
+          showHsiRestartPopupCallCount: 0,
+          showConfirmationPopupCallCount: 0,
+          title: 'YARN queue refreshed'
+        },
+        {
+          configActions: [
+            Em.Object.create({
+              actionType: 'showPopup',
+              fileName: 'capacity-scheduler.xml'
+            })
+          ],
+          hostComponents: [
+            Em.Object.create({
+              componentName: 'RESOURCEMANAGER'
+            }),
+            Em.Object.create({
+              componentName: 'RESOURCEMANAGER',
+              isRunning: false
+            }),
+            Em.Object.create({
+              componentName: 'COMPONENT',
+              isRunning: true
+            })
+          ],
+          mixinProperties: {
+            allConfigs: [
+              Em.Object.create({
+                filename: 'capacity-scheduler.xml',
+                value: 0,
+                initialValue: 1
+              })
+            ],
+            isYarnQueueRefreshed: false
+          },
+          popupPrimaryButtonCallbackCallCount: 0,
+          showHsiRestartPopupCallCount: 0,
+          showConfirmationPopupCallCount: 0,
+          title: 'no ResourceManagers running'
+        },
+        {
+          configActions: [
+            Em.Object.create({
+              actionType: 'showPopup',
+              fileName: 'capacity-scheduler.xml'
+            })
+          ],
+          hostComponents: [
+            Em.Object.create({
+              componentName: 'RESOURCEMANAGER'
+            }),
+            Em.Object.create({
+              componentName: 'RESOURCEMANAGER',
+              isRunning: false
+            }),
+            Em.Object.create({
+              componentName: 'RESOURCEMANAGER',
+              isRunning: true
+            }),
+            Em.Object.create({
+              componentName: 'HIVE_SERVER_INTERACTIVE'
+            })
+          ],
+          mixinProperties: {
+            'allConfigs': [
+              Em.Object.create({
+                filename: 'capacity-scheduler.xml',
+                value: 0,
+                initialValue: 1
+              })
+            ],
+            'isYarnQueueRefreshed': false,
+            'content.serviceName': 'HIVE'
+          },
+          popupPrimaryButtonCallbackCallCount: 1,
+          showHsiRestartPopupCallCount: 1,
+          showConfirmationPopupCallCount: 0,
+          title: 'change from Hive page, Hive Server Interactive present'
+        },
+        {
+          configActions: [
+            Em.Object.create({
+              actionType: 'showPopup',
+              fileName: 'capacity-scheduler.xml'
+            })
+          ],
+          hostComponents: [
+            Em.Object.create({
+              componentName: 'RESOURCEMANAGER'
+            }),
+            Em.Object.create({
+              componentName: 'RESOURCEMANAGER',
+              isRunning: false
+            }),
+            Em.Object.create({
+              componentName: 'RESOURCEMANAGER',
+              isRunning: true
+            })
+          ],
+          mixinProperties: {
+            'allConfigs': [
+              Em.Object.create({
+                filename: 'capacity-scheduler.xml',
+                value: 0,
+                initialValue: 1
+              })
+            ],
+            'isYarnQueueRefreshed': false,
+            'content.serviceName': 'HIVE'
+          },
+          popupPrimaryButtonCallbackCallCount: 1,
+          showHsiRestartPopupCallCount: 0,
+          showConfirmationPopupCallCount: 0,
+          title: 'change from Hive page, no Hive Server Interactive'
+        },
+        {
+          configActions: [
+            Em.Object.create({
+              actionType: 'showPopup',
+              fileName: 'capacity-scheduler.xml',
+              popupProperties: {
+                primaryButton: {}
+              }
+            })
+          ],
+          hostComponents: [
+            Em.Object.create({
+              componentName: 'RESOURCEMANAGER'
+            }),
+            Em.Object.create({
+              componentName: 'RESOURCEMANAGER',
+              isRunning: false
+            }),
+            Em.Object.create({
+              componentName: 'RESOURCEMANAGER',
+              isRunning: true
+            })
+          ],
+          mixinProperties: {
+            'allConfigs': [
+              Em.Object.create({
+                filename: 'capacity-scheduler.xml',
+                value: 0,
+                initialValue: 1
+              })
+            ],
+            'isYarnQueueRefreshed': false,
+            'content.serviceName': 'YARN'
+          },
+          popupPrimaryButtonCallbackCallCount: 0,
+          showHsiRestartPopupCallCount: 0,
+          showConfirmationPopupCallCount: 1,
+          title: 'change from YARN page'
+        }
+      ];
+
+    testCases.forEach(function (test) {
+
+      describe(test.title, function () {
+
+        beforeEach(function () {
+          sinon.stub(App.ConfigAction, 'find').returns(test.configActions);
+          sinon.stub(App.HostComponent, 'find').returns(test.hostComponents || []);
+          sinon.stub(mixin, 'popupPrimaryButtonCallback', Em.K);
+          sinon.stub(mixin, 'showHsiRestartPopup', Em.K);
+          sinon.stub(App, 'showConfirmationPopup', Em.K);
+          mixin.setProperties(test.mixinProperties);
+          mixin.showPopup();
+        });
+
+        afterEach(function () {
+          App.ConfigAction.find.restore();
+          App.HostComponent.find.restore();
+          mixin.popupPrimaryButtonCallback.restore();
+          mixin.showHsiRestartPopup.restore();
+          App.showConfirmationPopup.restore();
+        });
+
+        it('popup callback', function () {
+          expect(mixin.popupPrimaryButtonCallback.callCount).to.eql(test.popupPrimaryButtonCallbackCallCount);
+        });
+
+        it('HSI restart popup', function () {
+          expect(mixin.showHsiRestartPopup.callCount).to.eql(test.showHsiRestartPopupCallCount);
+        });
+
+        it('confirmation popup', function () {
+          expect(App.showConfirmationPopup.callCount).to.eql(test.showConfirmationPopupCallCount);
+        });
+
+      });
+
+    });
+
+  });
+
+});
\ No newline at end of file