hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r784848 - /hadoop/core/branches/HADOOP-3628-2/src/test/mapred/org/apache/hadoop/mapred/TestTaskTrackerLifecycle.java
Date Mon, 15 Jun 2009 16:28:46 GMT
Author: stevel
Date: Mon Jun 15 16:28:46 2009
New Revision: 784848

URL: http://svn.apache.org/viewvc?rev=784848&view=rev
Log:
HADOOP-3628: handle protected ping() method by not calling it; timeout on JT connect to cut
2 minutes off the test.

Modified:
    hadoop/core/branches/HADOOP-3628-2/src/test/mapred/org/apache/hadoop/mapred/TestTaskTrackerLifecycle.java

Modified: hadoop/core/branches/HADOOP-3628-2/src/test/mapred/org/apache/hadoop/mapred/TestTaskTrackerLifecycle.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/HADOOP-3628-2/src/test/mapred/org/apache/hadoop/mapred/TestTaskTrackerLifecycle.java?rev=784848&r1=784847&r2=784848&view=diff
==============================================================================
--- hadoop/core/branches/HADOOP-3628-2/src/test/mapred/org/apache/hadoop/mapred/TestTaskTrackerLifecycle.java
(original)
+++ hadoop/core/branches/HADOOP-3628-2/src/test/mapred/org/apache/hadoop/mapred/TestTaskTrackerLifecycle.java
Mon Jun 15 16:28:46 2009
@@ -50,6 +50,8 @@
    */
   private JobConf createJobConf() {
     JobConf config = new JobConf();
+    //extra fast timeout
+    config.set("mapred.task.tracker.connect.timeout","10");
     String dataDir = System.getProperty("test.build.data");
     File hdfsDir = new File(dataDir, "dfs");
     config.set("dfs.name.dir", new File(hdfsDir, "name1").getPath());
@@ -60,10 +62,19 @@
     return config;
   }
 
-  private void assertConnectionRefused(IOException e) throws Throwable {
-    if(!e.getMessage().contains("Connection refused")) {
-      LOG.error("Wrong exception",e);
-      throw e;
+  /**
+   * Assert that the throwable is some kind of IOException, 
+   * containing the string "Connection refused"
+   * @param thrown what was thrown
+   * @throws Throwable the exception, rethrown, if it is not what was expected
+   */
+  private void assertConnectionRefused(Throwable thrown) throws Throwable {
+    assertNotNull("Null Exception", thrown);
+    if (!(thrown instanceof IOException)) {
+      throw thrown;
+    }
+    if (!thrown.getMessage().contains("Connection refused")) {
+      throw thrown;
     }
   }
 
@@ -73,7 +84,6 @@
    */
   public void testTerminateUnstartedTracker() throws Throwable {
     tracker = new TaskTracker(createJobConf(), false);
-    tracker.ping();
     tracker.close();
   }
 
@@ -106,9 +116,9 @@
       assertConnectionRefused(e);
       assertEquals(Service.ServiceState.CLOSED, tracker.getServiceState());
     }
-    tracker.ping();
+    assertConnectionRefused(tracker.getFailureCause());
     tracker.close();
-    tracker.ping();
+    assertConnectionRefused(tracker.getFailureCause());
   }
 
 }



Mime
View raw message