Repository: ambari Updated Branches: refs/heads/branch-2.5 50b192979 -> 7bb1e3335
Revert "AMBARI-20542 Fixed configuration type validation in case of blueprint deployments." This reverts commit 50b192979eca936bdb8ea1ecb9a1bb624c28e7fc. Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/95d7cc2c Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/95d7cc2c Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/95d7cc2c Branch: refs/heads/branch-2.5 Commit: 95d7cc2c000c350dc0e5efa5a0660098f21da547 Parents: 50b1929 Author: lpuskas <lpus...@apache.org> Authored: Thu Mar 23 18:13:08 2017 +0100 Committer: lpuskas <lpus...@apache.org> Committed: Thu Mar 23 18:13:08 2017 +0100 ---------------------------------------------------------------------- .../validators/ClusterConfigTypeValidator.java | 19 ++++++------ .../ClusterConfigTypeValidatorTest.java | 31 ++++---------------- 2 files changed, 16 insertions(+), 34 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/95d7cc2c/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java index 305c88e..18d08b9 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java @@ -44,28 +44,29 @@ public class ClusterConfigTypeValidator implements TopologyValidator { } // config types in from the request - Set<String> topologyClusterConfigTypes = new HashSet(topology.getConfiguration().getAllConfigTypes()); - LOGGER.debug("Cluster config types: {}", topologyClusterConfigTypes); + Set<String> clusterConfigTypes = topology.getConfiguration().getProperties().keySet(); + LOGGER.debug("Cluster config types: {}", clusterConfigTypes); - if (topologyClusterConfigTypes == null || topologyClusterConfigTypes.isEmpty()) { + if (clusterConfigTypes == null || clusterConfigTypes.isEmpty()) { LOGGER.debug("No config types to be checked."); return; } // collecting all config types for services in the blueprint (from the related stack) - Set<String> stackServiceConfigTypes = new HashSet<>(); + Set<String> serviceConfigTypes = new HashSet<>(); for (String serviceName : topology.getBlueprint().getServices()) { - stackServiceConfigTypes.addAll(topology.getBlueprint().getStack().getConfigurationTypes(serviceName)); + serviceConfigTypes.addAll(topology.getBlueprint().getStack().getConfigurationTypes(serviceName)); } // identifying invalid config types - Set<String> configTypeIntersection = new HashSet<String>(topologyClusterConfigTypes); + Set<String> configTypeIntersection = new HashSet<String>(serviceConfigTypes); - if (configTypeIntersection.retainAll(stackServiceConfigTypes)) { - // there are config types not present in the stack for the services listed in the blueprint + // if the intersection is changed, there's been some wrong config type provided in the cluster configuration + if (configTypeIntersection.retainAll(clusterConfigTypes)) { + LOGGER.debug("Valid config types: {}", configTypeIntersection); // get the wrong config types - Set<String> invalidConfigTypes = new HashSet<>(topologyClusterConfigTypes); + Set<String> invalidConfigTypes = new HashSet<>(clusterConfigTypes); invalidConfigTypes.removeAll(configTypeIntersection); LOGGER.error("The following config typess are wrong: {}", invalidConfigTypes); http://git-wip-us.apache.org/repos/asf/ambari/blob/95d7cc2c/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidatorTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidatorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidatorTest.java index bb10df9..24fa8b8 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidatorTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidatorTest.java @@ -74,19 +74,8 @@ public class ClusterConfigTypeValidatorTest extends EasyMockSupport { resetAll(); } - - @Test - public void testShouldValidationPassIfNoConfigTypesSpecifiedInCCTemplate() throws Exception { - //GIVEN - EasyMock.expect(clusterConfigurationMapMock.keySet()).andReturn(Collections.<String>emptySet()); - replayAll(); - - //WHEN - clusterConfigTypeValidator.validate(clusterTopologyMock); - } - @Test(expected = InvalidTopologyException.class) - public void testShouldValidationFailWhenInvalidConfigGroupsSpecifiedInCCTemplate() throws Exception { + public void testShouldValidationFailWhenInvalidConfigGroupSpecifiedInCCTemplate() throws Exception { // given EasyMock.expect(clusterConfigurationMapMock.keySet()).andReturn(new HashSet<String>(Arrays.asList("oozie-site"))); EasyMock.expect(blueprintMock.getServices()).andReturn(new HashSet<String>(Arrays.asList("YARN", "HDFS"))); @@ -103,23 +92,15 @@ public class ClusterConfigTypeValidatorTest extends EasyMockSupport { // Exception is thrown } - - @Test(expected = InvalidTopologyException.class) - public void testShouldValidationFailWhenInvalidConfigGroupProvided() throws Exception { - // given - EasyMock.expect(clusterConfigurationMapMock.keySet()).andReturn(new HashSet<String>(Arrays.asList("core-site", "yarn-site", "oozie-site"))); - EasyMock.expect(blueprintMock.getServices()).andReturn(new HashSet<String>(Arrays.asList("YARN", "HDFS"))); - - EasyMock.expect(stackMock.getConfigurationTypes("HDFS")).andReturn(Arrays.asList("core-site")); - EasyMock.expect(stackMock.getConfigurationTypes("YARN")).andReturn(Arrays.asList("yarn-site")); - + @Test + public void testShouldValidationPassIfNoConfigTypesSpecifiedInCCTemplate() throws Exception { + //GIVEN + EasyMock.expect(clusterConfigurationMapMock.keySet()).andReturn(Collections.<String>emptySet()); replayAll(); - //when + //WHEN clusterConfigTypeValidator.validate(clusterTopologyMock); - // then - // Exception is thrown } @Test