Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 598FE18DF6 for ; Thu, 12 Nov 2015 19:58:02 +0000 (UTC) Received: (qmail 49124 invoked by uid 500); 12 Nov 2015 19:58:02 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 49096 invoked by uid 500); 12 Nov 2015 19:58:02 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 49087 invoked by uid 99); 12 Nov 2015 19:58:02 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Nov 2015 19:58:02 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1DDBAE5E2A; Thu, 12 Nov 2015 19:58:02 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rlevas@apache.org To: commits@ambari.apache.org Message-Id: <485c8894c81649029af9ff7c25350c40@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: ambari git commit: AMBARI-13836. NPE when enabling security during Update Configurations stage (Sandor Magyari via rlevas) Date: Thu, 12 Nov 2015 19:58:02 +0000 (UTC) Repository: ambari Updated Branches: refs/heads/branch-2.1 62a7deb07 -> 9d10cecbf 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/9d10cecb Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9d10cecb Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9d10cecb Branch: refs/heads/branch-2.1 Commit: 9d10cecbf69d2704dbfb7a06ea4a0f7ec97add54 Parents: 62a7deb Author: Sandor Magyari Authored: Thu Nov 12 14:55:14 2015 -0500 Committer: Robert Levas Committed: Thu Nov 12 14:57:56 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/9d10cecb/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/9d10cecb/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() {{ add(clusterRequest3); }}, null); + + // oozie-site + ConfigurationRequest cr4 = new ConfigurationRequest(); + cr4.setClusterName(clusterName); + cr4.setType("oozie-site"); + cr4.setVersionTag("version1"); + cr4.setProperties(new HashMap() {{ + 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() {{ + 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> globalAttrs = effectiveAttributes.get("global"); @@ -595,6 +615,35 @@ public class ConfigHelperTest { } @Test + public void testUpdateConfigTypeNoPropertyAttributes() throws Exception { + Config currentConfig = cluster.getDesiredConfigByType("oozie-site"); + Map 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 updates = new HashMap(); + 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 schReturn = new HashMap();