Browse Source

MAPREDUCE-4569. Fixed TestHsWebServicesJobsQuery to pass on JDK7 by not depending on test order. Contributed by Thomas Graves.
svn merge --ignore-ancestry -c 1379146 ../../trunk/


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1379148 13f79535-47bb-0310-9956-ffa450edef68

Vinod Kumar Vavilapalli 12 years ago
parent
commit
e591c4f4dc

+ 3 - 0
hadoop-mapreduce-project/CHANGES.txt

@@ -429,6 +429,9 @@ Release 0.23.3 - UNRELEASED
     MAPREDUCE-4375. Show Configuration Tracability in MR UI (bobby 
     MAPREDUCE-4375. Show Configuration Tracability in MR UI (bobby 
     via tgraves)
     via tgraves)
 
 
+    MAPREDUCE-4569. Fixed TestHsWebServicesJobsQuery to pass on JDK7 by not
+    depending on test order. (Thomas Graves via vinodkv)
+
   OPTIMIZATIONS
   OPTIMIZATIONS
 
 
     MAPREDUCE-3850. Avoid redundant calls for tokens in TokenCache (Daryn
     MAPREDUCE-3850. Avoid redundant calls for tokens in TokenCache (Daryn

+ 16 - 1
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServicesJobsQuery.java

@@ -25,6 +25,7 @@ import static org.mockito.Mockito.when;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.Collections;
 import java.util.Map;
 import java.util.Map;
 
 
@@ -217,9 +218,23 @@ public class TestHsWebServicesJobsQuery extends JerseyTest {
   @Test
   @Test
   public void testJobsQueryStateNone() throws JSONException, Exception {
   public void testJobsQueryStateNone() throws JSONException, Exception {
     WebResource r = resource();
     WebResource r = resource();
+
+     ArrayList<JobState> JOB_STATES = 
+         new ArrayList<JobState>(Arrays.asList(JobState.values()));
+
+      // find a state that isn't in use
+      Map<JobId, Job> jobsMap = appContext.getAllJobs();
+      for (Map.Entry<JobId, Job> entry : jobsMap.entrySet()) {
+        JOB_STATES.remove(entry.getValue().getState());
+      }
+
+    assertTrue("No unused job states", JOB_STATES.size() > 0);
+    JobState notInUse = JOB_STATES.get(0);
+
     ClientResponse response = r.path("ws").path("v1").path("history")
     ClientResponse response = r.path("ws").path("v1").path("history")
-        .path("mapreduce").path("jobs").queryParam("state", JobState.KILL_WAIT.toString())
+        .path("mapreduce").path("jobs").queryParam("state", notInUse.toString())
         .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
         .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
     assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
     assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
     JSONObject json = response.getEntity(JSONObject.class);
     JSONObject json = response.getEntity(JSONObject.class);
     assertEquals("incorrect number of elements", 1, json.length());
     assertEquals("incorrect number of elements", 1, json.length());