Repository: ambari Updated Branches: refs/heads/trunk 21b6b3169 -> 132c5350e
AMBARI-14656: dfs.allow.truncate property check for Add Service wizard of HAWQ Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/132c5350 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/132c5350 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/132c5350 Branch: refs/heads/trunk Commit: 132c5350e40be4964b88d6f3feca275457523d92 Parents: 21b6b31 Author: Jun Aoki <ja...@apache.org> Authored: Mon Jan 18 13:10:51 2016 -0800 Committer: Jun Aoki <ja...@apache.org> Committed: Mon Jan 18 13:10:51 2016 -0800 ---------------------------------------------------------------------- .../stacks/HDP/2.3/services/stack_advisor.py | 8 +++ .../stacks/2.3/common/test_stack_advisor.py | 60 ++++++++++++++++++++ 2 files changed, 68 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/132c5350/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py index ed241ff..0544f5a 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py +++ b/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py @@ -703,6 +703,14 @@ class HDP23StackAdvisor(HDP22StackAdvisor): validationItems.append({"config-name": 'dfs.namenode.inode.attributes.provider.class', "item": self.getWarnItem( "dfs.namenode.inode.attributes.provider.class needs to be set to 'org.apache.ranger.authorization.hadoop.RangerHdfsAuthorizer' if Ranger HDFS Plugin is enabled.")}) + + # Check if dfs.allow.truncate is true + if "HAWQ" in servicesList and \ + not ("dfs.allow.truncate" in services["configurations"]["hdfs-site"]["properties"] and \ + services["configurations"]["hdfs-site"]["properties"]["dfs.allow.truncate"].lower() == 'true'): + validationItems.append({"config-name": "dfs.allow.truncate", + "item": self.getWarnItem("HAWQ requires dfs.allow.truncate in hdfs-site.xml set to True.")}) + validationProblems = self.toConfigurationValidationProblems(validationItems, "hdfs-site") validationProblems.extend(parentValidationProblems) return validationProblems http://git-wip-us.apache.org/repos/asf/ambari/blob/132c5350/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py index 7e59a6f..362a7cd 100644 --- a/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py +++ b/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py @@ -1521,3 +1521,63 @@ class TestHDP23StackAdvisor(TestCase): recommendedConfigurations = {} self.stackAdvisor.recommendRangerConfigurations(recommendedConfigurations, clusterData, services, None) self.assertEquals(recommendedConfigurations['ranger-admin-site']['properties']['ranger.audit.solr.zookeepers'], 'NONE') + + def test_validateHDFSConfigurations(self): + properties = {} + recommendedDefaults = {} + configurations = { + "core-site": {"properties": {}}, + } + services = self.load_json("services-hawq-3-hosts.json") + services["configurations"]["hdfs-site"] = {} + services["configurations"]["hdfs-site"]["properties"] = {} + hosts = {} + + expected_warning = { + 'config-type':'hdfs-site', + 'message':'HAWQ requires dfs.allow.truncate in hdfs-site.xml set to True.', + 'type':'configuration', + 'config-name':'dfs.allow.truncate', + 'level':'WARN' + } + + # Test following cases: + # when HAWQ is being installed and dfs.allow.truncate is not set at all, warning + # when HAWQ is being installed and dfs.allow.truncate is set to True, no warning + # when HAWQ is being installed and dfs.allow.truncate is not set to True, warning + # when HAWQ is not installed and dfs.allow.truncate is not set at all, no warning + # when HAWQ is not installed and dfs.allow.truncate is set to True, no warning + # when HAWQ is not installed and dfs.allow.truncate is not set to True, no warning + # 1 + problems = self.stackAdvisor.validateHDFSConfigurations(properties, recommendedDefaults, configurations, services, hosts) + self.assertEqual(len(problems), 1) + self.assertEqual(problems[0], expected_warning) + + # 2 + services["configurations"]["hdfs-site"]["properties"]["dfs.allow.truncate"] = "True" + problems = self.stackAdvisor.validateHDFSConfigurations(properties, recommendedDefaults, configurations, services, hosts) + self.assertEqual(len(problems), 0) + + # 3 + services["configurations"]["hdfs-site"]["properties"]["dfs.allow.truncate"] = "false" + problems = self.stackAdvisor.validateHDFSConfigurations(properties, recommendedDefaults, configurations, services, hosts) + self.assertEqual(len(problems), 1) + self.assertEqual(problems[0], expected_warning) + + del services["configurations"]["hdfs-site"]["properties"]["dfs.allow.truncate"] + servicesElementWithoutHAWQ = [service for service in services["services"] if service["StackServices"]["service_name"] != "HAWQ"] + services["services"] = servicesElementWithoutHAWQ + + # 4 + problems = self.stackAdvisor.validateHDFSConfigurations(properties, recommendedDefaults, configurations, services, hosts) + self.assertEqual(len(problems), 0) + + # 5 + services["configurations"]["hdfs-site"]["properties"]["dfs.allow.truncate"] = "True" + problems = self.stackAdvisor.validateHDFSConfigurations(properties, recommendedDefaults, configurations, services, hosts) + self.assertEqual(len(problems), 0) + + # 6 + services["configurations"]["hdfs-site"]["properties"]["dfs.allow.truncate"] = "false" + problems = self.stackAdvisor.validateHDFSConfigurations(properties, recommendedDefaults, configurations, services, hosts) + self.assertEqual(len(problems), 0)