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 2015/10/12 11:34:57 UTC

ambari git commit: AMBARI-13385. Host name properties duplicate after several moving next/back on the step7/step8 (onechiporenko)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 e2bfb331a -> dab1f5d0d


AMBARI-13385. Host name properties duplicate after several moving next/back on the step7/step8 (onechiporenko)


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

Branch: refs/heads/branch-2.1
Commit: dab1f5d0d9e57a55c6bfb7f343f0627fa8eda7b3
Parents: e2bfb33
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Fri Oct 9 16:44:07 2015 +0300
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Mon Oct 12 12:32:37 2015 +0300

----------------------------------------------------------------------
 .../app/controllers/wizard/step7_controller.js  |  7 +++-
 .../test/controllers/wizard/step7_test.js       | 39 ++++++++++++++++++++
 2 files changed, 44 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/dab1f5d0/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index 1b3ca3c..189d700 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -838,7 +838,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
   },
 
   /**
-   * Add host name properties to appropriate categories (for installer only)
+   * Add host name properties to appropriate categories (for installer and add service)
    * @param serviceConfig
    * @param masterComponents
    * @param slaveComponents
@@ -859,7 +859,10 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
         }
         var stackComponent = App.StackServiceComponent.find(componentName);
         var hProperty = App.config.createHostNameProperty(serviceConfig.get('serviceName'), componentName, value, stackComponent);
-        serviceConfig.get('configs').push(App.ServiceConfigProperty.create(hProperty));
+        var newConfigName = Em.get(hProperty, 'name');
+        if (!serviceConfig.get('configs').someProperty('name', newConfigName)) {
+          serviceConfig.get('configs').push(App.ServiceConfigProperty.create(hProperty));
+        }
       }
     }, this);
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/dab1f5d0/ambari-web/test/controllers/wizard/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js
index c33040f..0a5c621 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -2099,4 +2099,43 @@ describe('App.InstallerStep7Controller', function () {
       });
     });
   });
+
+  describe('#addHostNamesToConfigs', function() {
+
+    beforeEach(function () {
+      sinon.stub(App.StackServiceComponent, 'find', function () {
+        return Em.Object.create({
+          id: 'NAMENODE',
+          displayName: 'NameNode'
+        });
+      });
+    });
+
+    afterEach(function () {
+      App.StackServiceComponent.find.restore();
+    });
+
+    it('should not create duplicate configs', function () {
+      var serviceConfig = Em.Object.create({
+        configs: [],
+        serviceName: 'HDFS',
+        configCategories: [
+          {
+            showHost: true,
+            name: 'NAMENODE'
+          }
+        ]
+      });
+      var masterComponents = [
+        {component: 'NAMENODE', hostName: 'h1'}
+      ];
+      var slaveComponents = [];
+      installerStep7Controller.addHostNamesToConfigs(serviceConfig, masterComponents, slaveComponents);
+      expect(serviceConfig.get('configs').filterProperty('name', 'namenode_host').length).to.equal(1);
+      installerStep7Controller.addHostNamesToConfigs(serviceConfig, masterComponents, slaveComponents);
+      expect(serviceConfig.get('configs').filterProperty('name', 'namenode_host').length).to.equal(1);
+    });
+
+  });
+
 });