ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rle...@apache.org
Subject ambari git commit: AMBARI-13836. NPE when enabling security during Update Configurations stage (Sandor Magyari via rlevas)
Date Thu, 12 Nov 2015 18:53:30 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 3083cdbab -> d5ae6ae03


AMBARI-13836. NPE when enabling security during Update Configurations stage (Sandor Magyari
via rlevas)


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

Branch: refs/heads/trunk
Commit: d5ae6ae035d4dd634d0a42aa8066342d2aa256bc
Parents: 3083cdb
Author: Sandor Magyari <smagyari@hortonworks.com>
Authored: Thu Nov 12 13:53:17 2015 -0500
Committer: Robert Levas <rlevas@hortonworks.com>
Committed: Thu Nov 12 13:53:25 2015 -0500

----------------------------------------------------------------------
 .../ambari/server/state/ConfigHelper.java       |  6 ++-
 .../ambari/server/state/ConfigHelperTest.java   | 51 +++++++++++++++++++-
 2 files changed, 54 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d5ae6ae0/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
index 62c3b61..2acd62b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
@@ -686,9 +686,11 @@ public class ConfigHelper {
       } else {
         oldConfigProperties = oldConfig.getProperties();
         if (oldConfigProperties != null) {
-          properties.putAll(oldConfig.getProperties());
+          properties.putAll(oldConfigProperties);
+        }
+        if (oldConfig.getPropertiesAttributes() != null) {
+          propertiesAttributes.putAll(oldConfig.getPropertiesAttributes());
         }
-        propertiesAttributes.putAll(oldConfig.getPropertiesAttributes());
       }
 
       properties.putAll(updates);

http://git-wip-us.apache.org/repos/asf/ambari/blob/d5ae6ae0/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
index 57185c7..06c99f4 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
@@ -164,6 +164,26 @@ public class ConfigHelperTest {
       managementController.updateClusters(new HashSet<ClusterRequest>() {{
         add(clusterRequest3);
       }}, null);
+
+      // oozie-site
+      ConfigurationRequest cr4 = new ConfigurationRequest();
+      cr4.setClusterName(clusterName);
+      cr4.setType("oozie-site");
+      cr4.setVersionTag("version1");
+      cr4.setProperties(new HashMap<String, String>() {{
+        put("oozie.authentication.type", "simple");
+        put("oozie.service.HadoopAccessorService.kerberos.enabled", "false");
+      }});
+      cr4.setPropertiesAttributes(null);
+
+      final ClusterRequest clusterRequest4 =
+        new ClusterRequest(cluster.getClusterId(), clusterName,
+          cluster.getDesiredStackVersion().getStackVersion(), null);
+
+      clusterRequest4.setDesiredConfig(Collections.singletonList(cr4));
+      managementController.updateClusters(new HashSet<ClusterRequest>() {{
+        add(clusterRequest4);
+      }}, null);
     }
 
     @After
@@ -304,7 +324,7 @@ public class ConfigHelperTest {
               configHelper.getEffectiveDesiredTags(cluster, "h1"));
 
       Assert.assertNotNull(effectiveAttributes);
-      Assert.assertEquals(3, effectiveAttributes.size());
+      Assert.assertEquals(4, effectiveAttributes.size());
 
       Assert.assertTrue(effectiveAttributes.containsKey("global"));
       Map<String, Map<String, String>> globalAttrs = effectiveAttributes.get("global");
@@ -595,6 +615,35 @@ public class ConfigHelperTest {
     }
 
     @Test
+    public void testUpdateConfigTypeNoPropertyAttributes() throws Exception {
+      Config currentConfig = cluster.getDesiredConfigByType("oozie-site");
+      Map<String, String> properties = currentConfig.getProperties();
+      // Config tag before update
+      Assert.assertEquals("version1", currentConfig.getTag());
+      // Properties before update
+      Assert.assertEquals("simple", properties.get("oozie.authentication.type"));
+      Assert.assertEquals("false", properties.get("oozie.service.HadoopAccessorService.kerberos.enabled"));
+
+      Map<String, String> updates = new HashMap<String, String>();
+      updates.put("oozie.authentication.type", "kerberos");
+      updates.put("oozie.service.HadoopAccessorService.kerberos.enabled", "true");
+
+      configHelper.updateConfigType(cluster, managementController, "oozie-site", updates,
null, "admin", "Test " +
+        "note");
+
+      Config updatedConfig = cluster.getDesiredConfigByType("oozie-site");
+      // Config tag updated
+      Assert.assertFalse("version1".equals(updatedConfig.getTag()));
+      // Property added
+      properties = updatedConfig.getProperties();
+      Assert.assertTrue(properties.containsKey("oozie.authentication.type"));
+      Assert.assertEquals("kerberos", properties.get("oozie.authentication.type"));
+      // Property updated
+      Assert.assertTrue(properties.containsKey("oozie.service.HadoopAccessorService.kerberos.enabled"));
+      Assert.assertEquals("true", properties.get("oozie.service.HadoopAccessorService.kerberos.enabled"));
+    }
+
+    @Test
     public void testCalculateIsStaleConfigs() throws Exception {
 
       Map<String, HostConfig> schReturn = new HashMap<String, HostConfig>();


Mime
View raw message