Преглед изворни кода

MAPREDUCE-4404. Test case for TestMRJobClient to verify user name. Contributed by Mayank Bansal.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.22@1361071 13f79535-47bb-0310-9956-ffa450edef68
Konstantin Shvachko пре 13 година
родитељ
комит
0128260609

+ 3 - 0
mapreduce/CHANGES.txt

@@ -11,6 +11,9 @@ Release 0.22.1 - Unreleased
     MAPREDUCE-4403. Test case for job resubmission in TestRecoveryManager.
     (Mayank Bansal via shv)
 
+    MAPREDUCE-4404. Test case for TestMRJobClient to verify user name.
+    (Mayank Bansal via shv)
+
   OPTIMIZATIONS
 
   BUG FIXES

+ 22 - 2
mapreduce/src/test/mapred/org/apache/hadoop/mapreduce/TestMRJobClient.java

@@ -87,9 +87,29 @@ public class TestMRJobClient extends ClusterMapReduceTestCase {
   }
 
   @Test
-  public void testJobList(String jobId,
-      Configuration conf) throws Exception {
+  public void testJobList(String jobId, Configuration conf) throws Exception {
     verifyJobPriority(jobId, "HIGH", conf, createJobClient());
+    verifyJobUser(jobId, System.getProperty("user.name"), conf,
+        createJobClient());
+  }
+
+  protected void verifyJobUser(String jobId, String user, Configuration conf,
+      CLI jc) throws Exception {
+    PipedInputStream pis = new PipedInputStream();
+    PipedOutputStream pos = new PipedOutputStream(pis);
+    int exitCode = runTool(conf, jc, new String[] { "-list", "all" }, pos);
+    assertEquals("Exit code", 0, exitCode);
+    BufferedReader br = new BufferedReader(new InputStreamReader(pis));
+    String line = null;
+    while ((line = br.readLine()) != null) {
+      LOG.info("line = " + line);
+      if (!line.startsWith(jobId)) {
+        continue;
+      }
+      assertTrue(line.contains(user));
+      break;
+    }
+    pis.close();
   }
 
   protected void verifyJobPriority(String jobId, String priority,