tez-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hit...@apache.org
Subject tez git commit: TEZ-2010. History payload generated from conf has ${var} placeholders. (hitesh)
Date Thu, 29 Jan 2015 20:15:13 GMT
Repository: tez
Updated Branches:
  refs/heads/branch-0.6 20689e8af -> ef77ff06a


TEZ-2010. History payload generated from conf has ${var} placeholders. (hitesh)

(cherry picked from commit 4c215c7aaf97785a45bb9641690cc088ea6a0f17)


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

Branch: refs/heads/branch-0.6
Commit: ef77ff06afb1e8b1feb480129caaa4b0af311163
Parents: 20689e8
Author: Hitesh Shah <hitesh@apache.org>
Authored: Thu Jan 29 12:14:18 2015 -0800
Committer: Hitesh Shah <hitesh@apache.org>
Committed: Thu Jan 29 12:14:55 2015 -0800

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../java/org/apache/tez/common/TezUtils.java    |  2 +-
 .../org/apache/tez/common/TestTezUtils.java     | 65 +++++++++++++++-----
 3 files changed, 53 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tez/blob/ef77ff06/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 419faeb..aecd170 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -118,6 +118,7 @@ TEZ-UI CHANGES (TEZ-8):
 Release 0.5.4: Unreleased
 
 ALL CHANGES:
+  TEZ-2010. History payload generated from conf has ${var} placeholders.
   TEZ-1934. TestAMRecovery may fail due to the execution order is not determined.
   TEZ-1642. TestAMRecovery sometimes fail.
   TEZ-1931. Publish tez version info to Timeline.

http://git-wip-us.apache.org/repos/asf/tez/blob/ef77ff06/tez-api/src/main/java/org/apache/tez/common/TezUtils.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/common/TezUtils.java b/tez-api/src/main/java/org/apache/tez/common/TezUtils.java
index fb2ed78..1cbfbe0 100644
--- a/tez-api/src/main/java/org/apache/tez/common/TezUtils.java
+++ b/tez-api/src/main/java/org/apache/tez/common/TezUtils.java
@@ -169,7 +169,7 @@ public class TezUtils {
         Iterator<Entry<String, String>> iter = conf.iterator();
         while (iter.hasNext()) {
           Entry<String, String> entry = iter.next();
-          confJson.put(entry.getKey(), entry.getValue());
+          confJson.put(entry.getKey(), conf.get(entry.getKey()));
         }
         jsonObject.put(ATSConstants.CONFIG, confJson);
       }

http://git-wip-us.apache.org/repos/asf/tez/blob/ef77ff06/tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java
----------------------------------------------------------------------
diff --git a/tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java b/tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java
index 99408f8..d39c47f 100644
--- a/tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java
+++ b/tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java
@@ -150,6 +150,16 @@ public class TestTezUtils {
 
   }
 
+  private void checkJSONConfigObj(JSONObject confObject) throws JSONException {
+    Assert.assertNotNull(confObject);
+    Assert.assertEquals("value1", confObject.getString("test1"));
+    Assert.assertEquals("true", confObject.getString("test2"));
+    Assert.assertEquals("1.2345", confObject.getString("test3"));
+    Assert.assertEquals("34567", confObject.getString("test4"));
+    Assert.assertEquals("1234567890", confObject.getString("test5"));
+    Assert.assertEquals("S1,S2,S3", confObject.getString("test6"));
+  }
+
   @Test (timeout=2000)
   public void testConvertToHistoryText() throws JSONException {
     Configuration conf = getConf();
@@ -162,13 +172,7 @@ public class TestTezUtils {
     Assert.assertTrue(jsonObject.has(ATSConstants.CONFIG));
 
     JSONObject confObject = jsonObject.getJSONObject(ATSConstants.CONFIG);
-    Assert.assertNotNull(confObject);
-    Assert.assertEquals("value1", confObject.getString("test1"));
-    Assert.assertEquals("true", confObject.getString("test2"));
-    Assert.assertEquals("1.2345", confObject.getString("test3"));
-    Assert.assertEquals("34567", confObject.getString("test4"));
-    Assert.assertEquals("1234567890", confObject.getString("test5"));
-    Assert.assertEquals("S1,S2,S3", confObject.getString("test6"));
+    checkJSONConfigObj(confObject);
 
     String desc = "desc123";
     confToJson = TezUtils.convertToHistoryText(desc, conf);
@@ -180,13 +184,46 @@ public class TestTezUtils {
 
     Assert.assertTrue(jsonObject.has(ATSConstants.CONFIG));
     confObject = jsonObject.getJSONObject("config");
-    Assert.assertNotNull(confObject);
-    Assert.assertEquals("value1", confObject.getString("test1"));
-    Assert.assertEquals("true", confObject.getString("test2"));
-    Assert.assertEquals("1.2345", confObject.getString("test3"));
-    Assert.assertEquals("34567", confObject.getString("test4"));
-    Assert.assertEquals("1234567890", confObject.getString("test5"));
-    Assert.assertEquals("S1,S2,S3", confObject.getString("test6"));
+    checkJSONConfigObj(confObject);
 
   }
+
+  @Test (timeout=2000)
+  public void testConvertToHistoryTextWithReplaceVars() throws JSONException {
+    Configuration conf = getConf();
+    conf.set("user", "user1");
+    conf.set("location", "/tmp/${user}/");
+
+    String location = "/tmp/user1/";
+    Assert.assertEquals(location, conf.get("location"));
+
+    String confToJson = TezUtils.convertToHistoryText(conf);
+
+    JSONObject jsonObject = new JSONObject(confToJson);
+
+    Assert.assertFalse(jsonObject.has(ATSConstants.DESCRIPTION));
+    Assert.assertTrue(jsonObject.has(ATSConstants.CONFIG));
+
+    JSONObject confObject = jsonObject.getJSONObject(ATSConstants.CONFIG);
+    checkJSONConfigObj(confObject);
+    Assert.assertEquals("user1", confObject.getString("user"));
+    Assert.assertEquals(location, confObject.getString("location"));
+
+    String desc = "desc123";
+    confToJson = TezUtils.convertToHistoryText(desc, conf);
+    jsonObject = new JSONObject(confToJson);
+
+    Assert.assertTrue(jsonObject.has(ATSConstants.DESCRIPTION));
+    String descFromJson = jsonObject.getString(ATSConstants.DESCRIPTION);
+    Assert.assertEquals(desc, descFromJson);
+
+    Assert.assertTrue(jsonObject.has(ATSConstants.CONFIG));
+    confObject = jsonObject.getJSONObject("config");
+    checkJSONConfigObj(confObject);
+    Assert.assertEquals("user1", confObject.getString("user"));
+    Assert.assertEquals(location, confObject.getString("location"));
+
+  }
+
+
 }


Mime
View raw message