Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 ae4ddea04 -> de1c8b112


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/de1c8b11
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/de1c8b11
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/de1c8b11

Branch: refs/heads/branch-2.2
Commit: de1c8b112faedfe360a5c9c103608448f858b174
Parents: ae4ddea
Author: Jun Aoki <ja...@apache.org>
Authored: Wed Jan 27 15:49:30 2016 -0800
Committer: Jun Aoki <ja...@apache.org>
Committed: Wed Jan 27 15:49:30 2016 -0800

----------------------------------------------------------------------
 .../stacks/HDP/2.3/services/stack_advisor.py    |  8 +++
 .../stacks/2.3/common/test_stack_advisor.py     | 62 +++++++++++++++++++-
 2 files changed, 69 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/de1c8b11/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 2be09a1..0efed8e 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
@@ -704,6 +704,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.")})
+
     return self.toConfigurationValidationProblems(validationItems, "hdfs-site")
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/de1c8b11/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 1e6a1eb..5267fac 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
@@ -1508,4 +1508,64 @@ class TestHDP23StackAdvisor(TestCase):
 
     recommendedConfigurations = {}
     self.stackAdvisor.recommendRangerConfigurations(recommendedConfigurations, 
clusterData, services, None)
-    
self.assertEquals(recommendedConfigurations['ranger-admin-site']['properties']['ranger.audit.solr.zookeepers'],
 'NONE')
\ No newline at end of file
+    
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)
\ No newline at end of file

Reply via email to