Repository: ambari
Updated Branches:
  refs/heads/trunk 30e491797 -> b2f392d8f


AMBARI-9416. Remove dfs.namenode.secondary.http-address after configuring 
NameNode HA. (akovalenko)


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

Branch: refs/heads/trunk
Commit: b2f392d8fc5fecd4753aff17f97b84bddac826c3
Parents: 30e4917
Author: Aleksandr Kovalenko <akovale...@hortonworks.com>
Authored: Fri Jan 30 17:51:06 2015 +0200
Committer: Aleksandr Kovalenko <akovale...@hortonworks.com>
Committed: Fri Jan 30 17:51:21 2015 +0200

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |   1 +
 .../nameNode/step3_controller.js                |  27 ++++
 .../nameNode/step3_controller_test.js           | 147 +++++++++++++++++++
 3 files changed, 175 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b2f392d8/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 5d21495..d2cf0e7 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -56,6 +56,7 @@ var files = ['test/init_model_test',
   'test/controllers/main/admin/serviceAccounts_controller_test',
   'test/controllers/main/admin/highAvailability_controller_test',
   'test/controllers/main/admin/highAvailability/progress_controller_test',
+  
'test/controllers/main/admin/highAvailability/nameNode/step3_controller_test',
   
'test/controllers/main/admin/highAvailability/nameNode/step4_controller_test',
   
'test/controllers/main/admin/highAvailability/resourceManager/step3_controller_test',
   'test/controllers/main/admin/security_test',

http://git-wip-us.apache.org/repos/asf/ambari/blob/b2f392d8/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step3_controller.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step3_controller.js
 
b/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step3_controller.js
index 83b4ed0..f146567 100644
--- 
a/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step3_controller.js
+++ 
b/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step3_controller.js
@@ -28,6 +28,14 @@ App.HighAvailabilityWizardStep3Controller = 
Em.Controller.extend({
   isLoaded: false,
   versionLoaded: true,
 
+  /**
+   * Map of sites and properties to delete
+   * @type Object
+   */
+  configsToRemove: {
+    'hdfs-site': ['dfs.namenode.secondary.http-address']
+  },
+
   clearStep: function () {
     this.get('stepConfigs').clear();
     this.serverConfigData = {};
@@ -75,6 +83,7 @@ App.HighAvailabilityWizardStep3Controller = 
Em.Controller.extend({
 
   onLoadConfigs: function (data) {
     this.set('serverConfigData',data);
+    this.removeConfigs(this.get('configsToRemove'));
     this.tweakServiceConfigs(this.get('haConfig.configs'));
     this.renderServiceConfigs(this.get('haConfig'));
     this.set('isLoaded', true);
@@ -134,6 +143,24 @@ App.HighAvailabilityWizardStep3Controller = 
Em.Controller.extend({
     }
   },
 
+  /**
+   * Find and remove config properties in <code>serverConfigData</code>
+   * @param configsToRemove - map of config sites and properties to remove
+   * @returns {Object}
+   */
+  removeConfigs:function (configsToRemove) {
+    var configs = this.get('serverConfigData');
+    Em.keys(configsToRemove).forEach(function(site){
+      var siteConfigs = configs.items.findProperty('type', site);
+      if (siteConfigs) {
+        configsToRemove[site].forEach(function (property) {
+          delete siteConfigs.properties[property];
+        });
+      }
+    });
+    return configs;
+  },
+
   setConfigInitialValue: function(config,value) {
     config.value = value;
     config.defaultValue = value;

http://git-wip-us.apache.org/repos/asf/ambari/blob/b2f392d8/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js
 
b/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js
new file mode 100644
index 0000000..9f6deb8
--- /dev/null
+++ 
b/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js
@@ -0,0 +1,147 @@
+/**
+ * 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');
+
+describe('App.HighAvailabilityWizardStep3Controller', function() {
+  
+  describe('#removeConfigs', function() {
+
+    var tests = [
+      {
+        m: 'should not delete properties if configsToRemove is empty',
+        configs: {
+          items: [
+            {
+              type: 'site1',
+              properties: {
+                property1: 'value1',
+                property2: 'value2',
+                property3: 'value3',
+                property4: 'value4'
+              }
+            }
+          ]
+        },
+        toRemove: {},
+        expected: {
+          items: [
+            {
+              type: 'site1',
+              properties: {
+                property1: 'value1',
+                property2: 'value2',
+                property3: 'value3',
+                property4: 'value4'
+              }
+            }
+          ]
+        }
+      },
+      {
+        m: 'should delete properties from configsToRemove',
+        configs: {
+          items: [
+            {
+              type: 'site1',
+              properties: {
+                property1: 'value1',
+                property2: 'value2',
+                property3: 'value3',
+                property4: 'value4'
+              }
+            }
+          ]
+        },
+        toRemove: {
+          'site1': ['property1', 'property3']
+        },
+        expected: {
+          items: [
+            {
+              type: 'site1',
+              properties: {
+                property2: 'value2',
+                property4: 'value4'
+              }
+            }
+          ]
+        }
+      },
+      {
+        m: 'should delete properties from configsToRemove from different 
sites',
+        configs: {
+          items: [
+            {
+              type: 'site1',
+              properties: {
+                property1: 'value1',
+                property2: 'value2',
+                property3: 'value3',
+                property4: 'value4'
+              }
+            },
+            {
+              type: 'site2',
+              properties: {
+                property1: 'value1',
+                property2: 'value2',
+                property3: 'value3',
+                property4: 'value4'
+              }
+            }
+          ]
+        },
+        toRemove: {
+          'site1': ['property1', 'property3'],
+          'site2': ['property2', 'property4']
+        },
+        expected: {
+          items: [
+            {
+              type: 'site1',
+              properties: {
+                property2: 'value2',
+                property4: 'value4'
+              }
+            },
+            {
+              type: 'site2',
+              properties: {
+                property1: 'value1',
+                property3: 'value3'
+              }
+            }
+          ]
+        }
+      }
+    ];
+
+    tests.forEach(function(test) {
+      it(test.m, function() {
+        var controller = App.HighAvailabilityWizardStep3Controller.create({
+          configsToRemove: test.toRemove,
+          serverConfigData: test.configs
+        });
+        controller.removeConfigs(test.toRemove);
+        
expect(JSON.stringify(controller.get('serverConfigData'))).to.equal(JSON.stringify(test.expected));
+      });
+    });
+  });
+});
+

Reply via email to