ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smoha...@apache.org
Subject ambari git commit: [PluggableStackDefinition] End to end testing of pluggable stack definition changes (Eugene Chekanskiy via smohanty)
Date Thu, 06 Aug 2015 19:23:19 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 6257c3f17 -> 014f3405f


[PluggableStackDefinition] End to end testing of pluggable stack definition changes (Eugene
Chekanskiy via smohanty)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/014f3405
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/014f3405
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/014f3405

Branch: refs/heads/branch-2.1
Commit: 014f3405fed642eafe369f443500eb46c4d63885
Parents: 6257c3f
Author: Sumit Mohanty <smohanty@hortonworks.com>
Authored: Thu Aug 6 12:17:52 2015 -0700
Committer: Sumit Mohanty <smohanty@hortonworks.com>
Committed: Thu Aug 6 12:23:09 2015 -0700

----------------------------------------------------------------------
 .../GenerateStackDefinition.py                  |  18 ++-
 .../python/pluggable_stack_definition/test.json | 117 ++++++++++++++-----
 2 files changed, 103 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/014f3405/ambari-common/src/main/python/pluggable_stack_definition/GenerateStackDefinition.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/pluggable_stack_definition/GenerateStackDefinition.py
b/ambari-common/src/main/python/pluggable_stack_definition/GenerateStackDefinition.py
index 100e453..b95a937 100644
--- a/ambari-common/src/main/python/pluggable_stack_definition/GenerateStackDefinition.py
+++ b/ambari-common/src/main/python/pluggable_stack_definition/GenerateStackDefinition.py
@@ -27,8 +27,13 @@ import xml.etree.ElementTree as ET
 from xml.dom import minidom
 import re
 from os.path import join
+import random
+import string
 
 
+def generate_random_string(size=7, chars=string.ascii_uppercase + string.digits):
+  return ''.join(random.choice(chars) for _ in range(size))
+
 class _named_dict(dict):
   """
   Allow to get dict items using attribute notation, eg dict.attr == dict['attr']
@@ -95,9 +100,17 @@ def copy_tree(src, dest, exclude=None, post_copy=None):
     if post_copy:
       post_copy(_src, _dest)
 
-# TODO: Add support for default text replacements based on stack version mapping
 def process_replacements(file_path, config_data, stack_version_changes):
   file_data = open(file_path, 'r').read().decode(encoding='utf-8')
+
+  # save user-defined text before replacements
+  preserved_map = {}
+  if "preservedText" in config_data:
+    for preserved in config_data.preservedText:
+      rnd = generate_random_string()
+      file_data = file_data.replace(preserved, rnd)
+      preserved_map[rnd] = preserved
+
   # replace user defined values
   if 'textReplacements' in config_data:
     for _from, _to in config_data['textReplacements']:
@@ -115,6 +128,9 @@ def process_replacements(file_path, config_data, stack_version_changes):
       file_data = file_data.replace('HDP '+from_version, config_data.stackName+" "+to_version)
     file_data = file_data.replace('hdp', config_data.stackName.lower())
     file_data = file_data.replace('HDP', config_data.stackName)
+  if preserved_map:
+    for _from, _to in preserved_map.iteritems():
+      file_data = file_data.replace(_from, _to)
   with open(file_path, "w") as target:
     target.write(file_data.encode(encoding='utf-8'))
   return file_path

http://git-wip-us.apache.org/repos/asf/ambari/blob/014f3405/ambari-common/src/main/python/pluggable_stack_definition/test.json
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/pluggable_stack_definition/test.json b/ambari-common/src/main/python/pluggable_stack_definition/test.json
index 07b1048..729cc63 100644
--- a/ambari-common/src/main/python/pluggable_stack_definition/test.json
+++ b/ambari-common/src/main/python/pluggable_stack_definition/test.json
@@ -6,31 +6,16 @@
     ["hdp-select", "distro-select"],
     ["conf-select", "phd-conf-select"]
    ],
+  "preservedText": ["ext-2.2", "HDP-oozie", "hdp.version", "HDP_VERSION"],
   "versions": [
     {
       "version": "2.0.6",
       "baseVersion": "2.0.6",
       "active": "false",
-      "repoinfo": {
-        "latest": "http://test.com/test/test_urlinfo.json",
-        "os" : {
-          "redhat6":[
-            {
-              "baseurl":"http://test.com/repo",
-              "repoid": "hello",
-              "reponame": "HELLO"
-            },
-            {
-              "baseurl":"http://test.com/repo2",
-              "repoid": "world",
-              "reponame": "WORLD"
-            }
-          ]
-        }
-      },
       "services": [
         {
           "name": "HDFS"
+
         },
         {
           "name": "ZOOKEEPER"
@@ -43,6 +28,21 @@
         },
         {
           "name": "MAPREDUCE2"
+        },
+        {
+          "name": "HIVE"
+        },
+        {
+          "name": "TEZ"
+        },
+        {
+          "name": "OOZIE"
+        },
+        {
+          "name": "KNOX"
+        },
+        {
+          "name": "PIG"
         }
       ]
     },
@@ -67,19 +67,19 @@
           "name": "MAPREDUCE2"
         },
         {
-          "name": "TEZ",
-          "packages":[
-            {
-              "family": "redhat6,suse11",
-              "packages": [
-                "hello",
-                {
-                  "name": "wolrd",
-                  "skipUpgrade": "true"
-                }
-              ]
-            }
-          ]
+          "name": "HIVE"
+        },
+        {
+          "name": "TEZ"
+        },
+        {
+          "name": "OOZIE"
+        },
+        {
+          "name": "KNOX"
+        },
+        {
+          "name": "PIG"
         }
       ]
     },
@@ -95,7 +95,15 @@
           "name": "ZOOKEEPER"
         },
         {
-          "name": "HBASE"
+          "name": "HBASE",
+          "packages":[
+            {
+              "family": "redhat6,suse11",
+              "packages": [
+                "hbase_3_0_*"
+              ]
+            }
+          ]
         },
         {
           "name": "YARN"
@@ -104,7 +112,42 @@
           "name": "MAPREDUCE2"
         },
         {
+          "name": "HIVE"
+        },
+        {
           "name": "TEZ"
+        },
+        {
+          "name": "OOZIE",
+          "packages":[
+            {
+              "family": "redhat6,suse11",
+              "packages": [
+                "oozie_3_0_*"
+              ]
+            },
+            {
+              "family": "any",
+              "packages": [
+                "zip",
+                "extjs"
+              ]
+            }
+          ]
+        },
+        {
+          "name": "KNOX",
+          "packages":[
+            {
+              "family": "redhat6,suse11",
+              "packages": [
+                "knox_3_0_*"
+              ]
+            }
+          ]
+        },
+        {
+          "name": "PIG"
         }
       ]
     },
@@ -129,7 +172,19 @@
           "name": "MAPREDUCE2"
         },
         {
+          "name": "HIVE"
+        },
+        {
           "name": "TEZ"
+        },
+        {
+          "name": "OOZIE"
+        },
+        {
+          "name": "KNOX"
+        },
+        {
+          "name": "PIG"
         }
       ]
     }


Mime
View raw message