AMBARI-22480. Validate blueprint does not allow lzo enable without setup with license agreement. Added io.compression.codecs property validation. (mpapirkovskyy)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f6fd9b5c Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f6fd9b5c Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f6fd9b5c Branch: refs/heads/branch-3.0-perf Commit: f6fd9b5c5e04998ed0b0631c87c2d4b521e99a44 Parents: e12efe3 Author: Myroslav Papirkovskyi <[email protected]> Authored: Tue Nov 28 14:51:58 2017 +0200 Committer: Myroslav Papirkovskyi <[email protected]> Committed: Wed Nov 29 18:30:08 2017 +0200 ---------------------------------------------------------------------- .../server/topology/BlueprintValidatorImpl.java | 4 +++- .../server/topology/BlueprintImplTest.java | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/f6fd9b5c/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java index 87b5936..fbd0e4b 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java @@ -49,6 +49,7 @@ public class BlueprintValidatorImpl implements BlueprintValidator { private final Stack stack; public static final String LZO_CODEC_CLASS_PROPERTY_NAME = "io.compression.codec.lzo.class"; + public static final String CODEC_CLASSES_PROPERTY_NAME = "io.compression.codecs"; public static final String LZO_CODEC_CLASS = "com.hadoop.compression.lzo.LzoCodec"; @Inject @@ -114,7 +115,8 @@ public class BlueprintValidatorImpl implements BlueprintValidator { String propertyName = propertyEntry.getKey(); String propertyValue = propertyEntry.getValue(); if (propertyValue != null) { - if (!gplEnabled && configType.equals("core-site") && propertyName.equals(LZO_CODEC_CLASS_PROPERTY_NAME) + if (!gplEnabled && configType.equals("core-site") + && (propertyName.equals(LZO_CODEC_CLASS_PROPERTY_NAME) || propertyName.equals(CODEC_CLASSES_PROPERTY_NAME)) && propertyValue.contains(LZO_CODEC_CLASS)) { throw new GPLLicenseNotAcceptedException("Your Ambari server has not been configured to download LZO GPL software. " + "Please refer to documentation to configure Ambari before proceeding."); http://git-wip-us.apache.org/repos/asf/ambari/blob/f6fd9b5c/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintImplTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintImplTest.java index 6d3179e..dd0adcc 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintImplTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintImplTest.java @@ -299,7 +299,24 @@ public class BlueprintImplTest { } @Test(expected = GPLLicenseNotAcceptedException.class) - public void testValidateConfigurations__gplIsNotAllowed() throws InvalidTopologyException, + public void testValidateConfigurations__gplIsNotAllowedCodecsProperty() throws InvalidTopologyException, + GPLLicenseNotAcceptedException, NoSuchFieldException, IllegalAccessException { + Map<String, Map<String, String>> lzoProperties = new HashMap<>(); + lzoProperties.put("core-site", new HashMap<String, String>(){{ + put(BlueprintValidatorImpl.CODEC_CLASSES_PROPERTY_NAME, "OtherCodec, " + BlueprintValidatorImpl.LZO_CODEC_CLASS); + }}); + Configuration lzoUsageConfiguration = new Configuration(lzoProperties, EMPTY_ATTRIBUTES, EMPTY_CONFIGURATION); + + org.apache.ambari.server.configuration.Configuration serverConfig = setupConfigurationWithGPLLicense(false); + replay(stack, group1, group2, serverConfig); + + Blueprint blueprint = new BlueprintImpl("test", hostGroups, stack, lzoUsageConfiguration, null); + blueprint.validateRequiredProperties(); + verify(stack, group1, group2, serverConfig); + } + + @Test(expected = GPLLicenseNotAcceptedException.class) + public void testValidateConfigurations__gplIsNotAllowedLZOProperty() throws InvalidTopologyException, GPLLicenseNotAcceptedException, NoSuchFieldException, IllegalAccessException { Map<String, Map<String, String>> lzoProperties = new HashMap<>(); lzoProperties.put("core-site", new HashMap<String, String>(){{ @@ -321,6 +338,7 @@ public class BlueprintImplTest { Map<String, Map<String, String>> lzoProperties = new HashMap<>(); lzoProperties.put("core-site", new HashMap<String, String>(){{ put(BlueprintValidatorImpl.LZO_CODEC_CLASS_PROPERTY_NAME, BlueprintValidatorImpl.LZO_CODEC_CLASS); + put(BlueprintValidatorImpl.CODEC_CLASSES_PROPERTY_NAME, "OtherCodec, " + BlueprintValidatorImpl.LZO_CODEC_CLASS); }}); Configuration lzoUsageConfiguration = new Configuration(lzoProperties, EMPTY_ATTRIBUTES, EMPTY_CONFIGURATION);
