ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lpus...@apache.org
Subject ambari git commit: AMBARI-21126 Exception message generated based on ordered collections to be predictable
Date Thu, 25 May 2017 14:42:56 GMT
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 <lpuskas@apache.org>
Authored: Thu May 25 11:52:59 2017 +0200
Committer: lpuskas <lpuskas@apache.org>
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<String, Map<String, Collection<String>>> requiredPropertiesByService
= getRequiredPropertiesByService(topology.getBlueprint());
 
     // find missing properties in the cluster configuration
-    Map<String, Collection<String>> missingProperties = new HashMap<>();
+    Map<String, Collection<String>> missingProperties = new TreeMap<>();
     Map<String, Map<String, String>> topologyConfiguration = new HashMap<>(topology.getConfiguration().getFullProperties(1));
 
     for (HostGroup hostGroup : topology.getBlueprint().getHostGroups().values()) {
@@ -170,13 +172,13 @@ public class RequiredConfigPropertiesValidator implements TopologyValidator
{
     Map<String, Collection<String>> 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<String>());
+      missing.put(hostGroup, new TreeSet<String>());
     }
 
     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<String> slaveHostGroupServices = new HashSet<>();
   private Collection<String> masterHostGroupServices = new HashSet<>();
   private Map<String, HostGroup> hostGroups = new HashMap<>();
-  private Map<String, Collection<String>> missingProps = new HashMap<>();
+  private Map<String, Collection<String>> 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<String, String>());
     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.<String>newArrayList("kdc_type",
"domains", "realm")));
+    missingProps.put("slave", Sets.newTreeSet(Lists.<String>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<String, String>());
     masterHostGroupConfigurationMap.get("krb5-conf").put("domains", "smthg");
 
-    missingProps.put("slave", Arrays.asList("kdc_type", "domains", "realm"));
+    missingProps.put("slave", Sets.<String>newTreeSet(Lists.<String>newArrayList("kdc_type",
"domains", "realm")));
 
     replayAll();
 


Mime
View raw message