You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2014/11/03 12:45:38 UTC

git commit: AMBARI-8114. Unknown component state shown and empty during save configs. (onechiporenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk c3eff5074 -> 3ee81bce1


AMBARI-8114. Unknown component state shown and empty during save configs. (onechiporenko)


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

Branch: refs/heads/trunk
Commit: 3ee81bce18be5e8772b593839cc12b1451d96681
Parents: c3eff50
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Mon Nov 3 13:01:52 2014 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Mon Nov 3 13:01:52 2014 +0200

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    | 24 ++++++++--
 .../main/service/info/config_test.js            | 50 +++++++++++++++++++-
 2 files changed, 68 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3ee81bce/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index f72fd66..1673831 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -1383,6 +1383,8 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
 
   /**
    * Show save configs popup
+   * @method showSaveConfigsPopup
+   * @return {App.ModalPopup}
    */
   showSaveConfigsPopup: function (header, flag, message, messageClass, value, status, urlParams) {
     var self = this;
@@ -1390,7 +1392,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
       this.set('forceTransition', flag);
       self.loadStep();
     }
-    App.ModalPopup.show({
+    return App.ModalPopup.show({
       header: header,
       primary: Em.I18n.t('ok'),
       secondary: null,
@@ -1435,17 +1437,31 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
                 context: view
               });
             },
+            /**
+             * Map components for their hosts
+             * Return format:
+             * <code>
+             *   {
+             *    host1: [component1, component2, ...],
+             *    host2: [component3, component4, ...]
+             *   }
+             * </code>
+             * @return {object}
+             */
             setComponents = function (item, components) {
               item.host_components.forEach(function (c) {
                 var name = c.HostRoles.host_name;
                 if (!components[name]) {
                   components[name] = [];
-                } else {
-                  components[name].push(App.format.role(item.ServiceComponentInfo.component_name));
                 }
+                components[name].push(App.format.role(item.ServiceComponentInfo.component_name));
               });
               return components;
             },
+            /**
+             * Map result of <code>setComponents</code> to array
+             * @return {{name: string, components: string}[]}
+             */
             setHosts = function (components) {
               var hosts = [];
               Em.keys(components).forEach(function (key) {
@@ -1490,7 +1506,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
           this.set('isLoaded', true);
         },
         didInsertElement: function () {
-          App.ajax.send({
+          return App.ajax.send({
             name: 'components.filter_by_status',
             sender: this,
             data: {

http://git-wip-us.apache.org/repos/asf/ambari/blob/3ee81bce/ambari-web/test/controllers/main/service/info/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/info/config_test.js b/ambari-web/test/controllers/main/service/info/config_test.js
index 0c60d9e..2cca645 100644
--- a/ambari-web/test/controllers/main/service/info/config_test.js
+++ b/ambari-web/test/controllers/main/service/info/config_test.js
@@ -262,7 +262,7 @@ describe("App.MainServiceInfoConfigsController", function () {
     });
   });
 
-  describe("rollingRestartStaleConfigSlaveComponents", function () {
+  describe("#rollingRestartStaleConfigSlaveComponents", function () {
     var tests = [
       {
         componentName: {
@@ -1388,7 +1388,7 @@ describe("App.MainServiceInfoConfigsController", function () {
     });
   });
 
-  describe("setCompareDefaultGroupConfig", function() {
+  describe("#setCompareDefaultGroupConfig", function() {
     beforeEach(function() {
       sinon.stub(mainServiceInfoConfigsController, "getComparisonConfig").returns("compConfig");
       sinon.stub(mainServiceInfoConfigsController, "getMockComparisonConfig").returns("mockConfig");
@@ -1419,4 +1419,50 @@ describe("App.MainServiceInfoConfigsController", function () {
     });
 
   });
+
+  describe('#showSaveConfigsPopup', function () {
+
+    var bodyView;
+
+    describe('#bodyClass', function () {
+      beforeEach(function() {
+        sinon.stub(App.ajax, 'send', Em.K);
+        // default implementation
+        bodyView = mainServiceInfoConfigsController.showSaveConfigsPopup().get('bodyClass').create({
+          parentView: Em.View.create()
+        });
+      });
+
+      afterEach(function() {
+        App.ajax.send.restore();
+      });
+
+      describe('#componentsFilterSuccessCallback', function () {
+        it('check components with unknown state', function () {
+          bodyView = mainServiceInfoConfigsController.showSaveConfigsPopup('', true, '', {}, '', 'unknown', '').get('bodyClass').create({
+            parentView: Em.View.create()
+          });
+          bodyView.componentsFilterSuccessCallback({
+            items: [
+              {
+                ServiceComponentInfo: {
+                  total_count: 4,
+                  started_count: 2,
+                  installed_count: 1,
+                  component_name: 'c1'
+                },
+                host_components: [
+                  {HostRoles: {host_name: 'h1'}}
+                ]
+              }
+            ]
+          });
+          var unknownHosts = bodyView.get('unknownHosts');
+          expect(unknownHosts.length).to.equal(1);
+          expect(unknownHosts[0]).to.eql({name: 'h1', components: 'C1'});
+        });
+      });
+    });
+  });
+
 });