ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject ambari git commit: AMBARI-13385. Host name properties duplicate after several moving next/back on the step7/step8 (onechiporenko)
Date Mon, 12 Oct 2015 09:39:14 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 03c399c0f -> 15bdb7104


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/15bdb710
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/15bdb710
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/15bdb710

Branch: refs/heads/trunk
Commit: 15bdb71047f33f77bf9fef451f24ec2e2b0b4e34
Parents: 03c399c
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Fri Oct 9 16:44:07 2015 +0300
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Mon Oct 12 12:39:03 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/15bdb710/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 973f6c5..635b26a 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -822,7 +822,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
@@ -843,7 +843,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/15bdb710/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 4be0891..16abeb5 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -2052,4 +2052,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);
+    });
+
+  });
+
 });


Mime
View raw message