Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E6080200C80 for ; Thu, 25 May 2017 16:42:57 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E47D9160BCA; Thu, 25 May 2017 14:42:57 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1075C160BC7 for ; Thu, 25 May 2017 16:42:56 +0200 (CEST) Received: (qmail 69049 invoked by uid 500); 25 May 2017 14:42:56 -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 69038 invoked by uid 99); 25 May 2017 14:42:56 -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, 25 May 2017 14:42:56 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 21267E0016; Thu, 25 May 2017 14:42:56 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: lpuskas@apache.org To: commits@ambari.apache.org Message-Id: <7e5b365a75024464b62ea4890351e450@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: ambari git commit: AMBARI-21126 Exception message generated based on ordered collections to be predictable Date: Thu, 25 May 2017 14:42:56 +0000 (UTC) archived-at: Thu, 25 May 2017 14:42:58 -0000 Repository: ambari Updated Branches: refs/heads/trunk 9dbf8f15e -> 14acc0ae3 AMBARI-21126 Exception message generated based on ordered collections to be predictable Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/14acc0ae Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/14acc0ae Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/14acc0ae Branch: refs/heads/trunk Commit: 14acc0ae32a274184830a8e7bf847f5ede8ac953 Parents: 9dbf8f1 Author: lpuskas Authored: Thu May 25 11:52:59 2017 +0200 Committer: lpuskas Committed: Thu May 25 16:42:20 2017 +0200 ---------------------------------------------------------------------- .../RequiredConfigPropertiesValidator.java | 10 +++--- .../RequiredConfigPropertiesValidatorTest.java | 35 +++++++++++--------- 2 files changed, 25 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/14acc0ae/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java index 759d9e9..85be82c 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java @@ -18,6 +18,8 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.TreeMap; +import java.util.TreeSet; import org.apache.ambari.server.controller.internal.Stack; import org.apache.ambari.server.state.PropertyInfo; @@ -54,7 +56,7 @@ public class RequiredConfigPropertiesValidator implements TopologyValidator { Map>> requiredPropertiesByService = getRequiredPropertiesByService(topology.getBlueprint()); // find missing properties in the cluster configuration - Map> missingProperties = new HashMap<>(); + Map> missingProperties = new TreeMap<>(); Map> topologyConfiguration = new HashMap<>(topology.getConfiguration().getFullProperties(1)); for (HostGroup hostGroup : topology.getBlueprint().getHostGroups().values()) { @@ -170,13 +172,13 @@ public class RequiredConfigPropertiesValidator implements TopologyValidator { Map> missing; if (missingProperties == null) { - missing = new HashMap<>(); + missing = new TreeMap<>(); } else { - missing = new HashMap<>(missingProperties); + missing = new TreeMap<>(missingProperties); } if (!missing.containsKey(hostGroup)) { - missing.put(hostGroup, new HashSet()); + missing.put(hostGroup, new TreeSet()); } missing.get(hostGroup).addAll(values); http://git-wip-us.apache.org/repos/asf/ambari/blob/14acc0ae/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidatorTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidatorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidatorTest.java index 8ead623..82a4ed0 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidatorTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidatorTest.java @@ -14,12 +14,13 @@ package org.apache.ambari.server.topology.validators; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.TreeMap; +import java.util.TreeSet; import org.apache.ambari.server.controller.internal.Stack; import org.apache.ambari.server.topology.Blueprint; @@ -37,6 +38,9 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; + public class RequiredConfigPropertiesValidatorTest extends EasyMockSupport { @Rule @@ -74,7 +78,7 @@ public class RequiredConfigPropertiesValidatorTest extends EasyMockSupport { private Collection slaveHostGroupServices = new HashSet<>(); private Collection masterHostGroupServices = new HashSet<>(); private Map hostGroups = new HashMap<>(); - private Map> missingProps = new HashMap<>(); + private Map> missingProps = new TreeMap<>(); @TestSubject private RequiredConfigPropertiesValidator testSubject = new RequiredConfigPropertiesValidator(); @@ -112,21 +116,21 @@ public class RequiredConfigPropertiesValidatorTest extends EasyMockSupport { hostGroups.put("slave", slaveHostGroupMock); // services in the blueprint - bpServices.addAll(Arrays.asList("KERBEROS", "OOZIE")); + bpServices.addAll(Lists.newArrayList("KERBEROS", "OOZIE")); // host group services - masterHostGroupServices.addAll(Arrays.asList("KERBEROS")); - slaveHostGroupServices.addAll(Arrays.asList("KERBEROS")); + masterHostGroupServices.addAll(Collections.singletonList("KERBEROS")); + slaveHostGroupServices.addAll(Collections.singletonList("KERBEROS")); EasyMock.expect(masterHostGroupConfigurationMock.getProperties()).andReturn(masterHostGroupConfigurationMap); EasyMock.expect(slaveHostGroupConfigurationMock.getProperties()).andReturn(slaveHostGroupConfigurationMap); // services in the blueprint - bpServices.addAll(Arrays.asList("KERBEROS", "OOZIE")); + bpServices.addAll(Lists.newArrayList("KERBEROS", "OOZIE")); // required properties for listed services EasyMock.expect(stackMock.getRequiredConfigurationProperties("KERBEROS")). - andReturn(Arrays.asList( + andReturn(Lists.newArrayList( new Stack.ConfigProperty("kerberos-env", "realm", "value"), new Stack.ConfigProperty("kerberos-env", "kdc_type", "value"), // this is missing! new Stack.ConfigProperty("krb5-conf", "domains", "smthg"))); @@ -145,8 +149,8 @@ public class RequiredConfigPropertiesValidatorTest extends EasyMockSupport { topologyConfigurationMap.get("kerberos-env").put("kdc_type", "mit-kdc"); // note, that the krb-5 config type is missing! (see the required properties in the fixture!) - missingProps.put("slave", Arrays.asList("domains")); - missingProps.put("master", Arrays.asList("domains")); + missingProps.put("slave", new TreeSet<>(Collections.singletonList("domains"))); + missingProps.put("master", new TreeSet<>(Collections.singletonList("domains"))); replayAll(); @@ -177,8 +181,8 @@ public class RequiredConfigPropertiesValidatorTest extends EasyMockSupport { topologyConfigurationMap.put("krb5-conf", new HashMap()); topologyConfigurationMap.get("krb5-conf").put("domains", "smthg"); - missingProps.put("master", Arrays.asList("kdc_type")); - missingProps.put("slave", Arrays.asList("kdc_type")); + missingProps.put("master", Collections.singletonList("kdc_type")); + missingProps.put("slave", Collections.singletonList("kdc_type")); replayAll(); @@ -202,9 +206,8 @@ public class RequiredConfigPropertiesValidatorTest extends EasyMockSupport { public void testShouldValidationFailWhenHostGroupConfigurationProvidedAndRequiredConfigTypesAreMissingFromBothHostgroups() throws Exception { // GIVEN // configuration come in the host groups, there are missing config types in both hostgroups - - missingProps.put("master", Arrays.asList("kdc_type", "domains", "realm")); - missingProps.put("slave", Arrays.asList("kdc_type", "domains", "realm")); + missingProps.put("master", Sets.newTreeSet(Lists.newArrayList("kdc_type", "domains", "realm"))); + missingProps.put("slave", Sets.newTreeSet(Lists.newArrayList("kdc_type", "domains", "realm"))); replayAll(); @@ -218,7 +221,7 @@ public class RequiredConfigPropertiesValidatorTest extends EasyMockSupport { } // THEN - // Exception is thrown, as the krb5-conf typee is not provideds + // Exception is thrown, as the krb5-conf typee is not provided Assert.assertEquals("The exception message should be the expected one", expectedMsg, actualMsg); } @@ -232,7 +235,7 @@ public class RequiredConfigPropertiesValidatorTest extends EasyMockSupport { masterHostGroupConfigurationMap.put("krb5-conf", new HashMap()); masterHostGroupConfigurationMap.get("krb5-conf").put("domains", "smthg"); - missingProps.put("slave", Arrays.asList("kdc_type", "domains", "realm")); + missingProps.put("slave", Sets.newTreeSet(Lists.newArrayList("kdc_type", "domains", "realm"))); replayAll();