You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/11/10 23:45:54 UTC

[04/24] incubator-slider git commit: SLIDER-622 tests sometimes converting exe failure to timeout - race condition in tests?

SLIDER-622 tests sometimes converting exe failure to timeout - race condition in tests?


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

Branch: refs/heads/develop
Commit: fc7fa311400bf003baf625ececd83a3a13915265
Parents: b277c79
Author: Steve Loughran <st...@apache.org>
Authored: Mon Nov 10 16:53:13 2014 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Mon Nov 10 16:53:13 2014 +0000

----------------------------------------------------------------------
 .../java/org/apache/slider/common/tools/SliderUtils.java  | 10 ++++------
 .../server/services/utility/EndOfServiceWaiter.java       |  1 +
 .../apache/slider/common/tools/TestWindowsSupport.groovy  |  4 +---
 .../workflow/TestWorkflowForkedProcessService.java        |  4 +---
 4 files changed, 7 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/fc7fa311/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java b/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java
index db398a6..fa3f0bd 100644
--- a/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java
+++ b/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java
@@ -60,7 +60,6 @@ import org.apache.slider.core.exceptions.ErrorStrings;
 import org.apache.slider.core.exceptions.SliderException;
 import org.apache.slider.core.launch.ClasspathConstructor;
 import org.apache.slider.core.main.LauncherExitCodes;
-import org.apache.slider.server.services.utility.EndOfServiceWaiter;
 import org.apache.slider.server.services.utility.PatternValidator;
 import org.apache.slider.server.services.workflow.ForkedProcessService;
 import org.apache.zookeeper.server.util.KerberosUtil;
@@ -75,7 +74,6 @@ import java.io.FileReader;
 import java.io.FilenameFilter;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InterruptedIOException;
 import java.io.PrintWriter;
 import java.io.Serializable;
 import java.io.StringWriter;
@@ -1910,10 +1908,12 @@ public final class SliderUtils {
     process.setProcessLog(logger);
     process.init(new Configuration());
     String errorText = null;
-    EndOfServiceWaiter waiter = new EndOfServiceWaiter(process);
     process.start();
     try {
-      waiter.waitForServiceToStop(timeoutMillis);
+      if (process.waitForServiceToStop(timeoutMillis)) {
+        throw new TimeoutException(
+            "Process did not stop in " + timeoutMillis + "mS");
+      }
       int exitCode = process.getExitCode();
       List<String> recentOutput = process.getRecentOutput();
       if (status != exitCode) {
@@ -1939,8 +1939,6 @@ public final class SliderUtils {
         return process;
       }
 
-    } catch (InterruptedException e) {
-      throw new InterruptedIOException(e.toString());
     } catch (TimeoutException e) {
       errorText = e.toString();
     }

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/fc7fa311/slider-core/src/main/java/org/apache/slider/server/services/utility/EndOfServiceWaiter.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/services/utility/EndOfServiceWaiter.java b/slider-core/src/main/java/org/apache/slider/server/services/utility/EndOfServiceWaiter.java
index 4a57133..40ceab8 100644
--- a/slider-core/src/main/java/org/apache/slider/server/services/utility/EndOfServiceWaiter.java
+++ b/slider-core/src/main/java/org/apache/slider/server/services/utility/EndOfServiceWaiter.java
@@ -59,6 +59,7 @@ public class EndOfServiceWaiter implements ServiceStateChangeListener {
 
   public synchronized void waitForServiceToStop(long timeout) throws
       InterruptedException, TimeoutException {
+    service.waitForServiceToStop(timeout);
     if (!finished.get()) {
       wait(timeout);
       if (!finished.get()) {

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/fc7fa311/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
index 6351c14..d7f4121 100644
--- a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
@@ -27,7 +27,6 @@ import org.apache.hadoop.fs.Path
 import org.apache.hadoop.fs.FileSystem as HadoopFS
 import org.apache.hadoop.util.Shell
 import org.apache.slider.providers.agent.AgentUtils
-import org.apache.slider.server.services.utility.EndOfServiceWaiter
 import org.apache.slider.server.services.workflow.ForkedProcessService
 import org.apache.slider.test.SliderTestBase
 import org.junit.Test
@@ -174,9 +173,8 @@ class TestWindowsSupport extends SliderTestBase {
         [:],
         commands);
     process.init(new Configuration());
-    EndOfServiceWaiter waiter = new EndOfServiceWaiter(process);
     process.start();
-    waiter.waitForServiceToStop(10000);
+    process.waitForServiceToStop(10000);
     process
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/fc7fa311/slider-core/src/test/java/org/apache/slider/server/services/workflow/TestWorkflowForkedProcessService.java
----------------------------------------------------------------------
diff --git a/slider-core/src/test/java/org/apache/slider/server/services/workflow/TestWorkflowForkedProcessService.java b/slider-core/src/test/java/org/apache/slider/server/services/workflow/TestWorkflowForkedProcessService.java
index c8c576b..cf0afc1 100644
--- a/slider-core/src/test/java/org/apache/slider/server/services/workflow/TestWorkflowForkedProcessService.java
+++ b/slider-core/src/test/java/org/apache/slider/server/services/workflow/TestWorkflowForkedProcessService.java
@@ -20,7 +20,6 @@ package org.apache.slider.server.services.workflow;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.service.ServiceOperations;
-import org.apache.slider.server.services.utility.EndOfServiceWaiter;
 import org.apache.slider.test.SliderTestUtils;
 import org.junit.After;
 import org.junit.Before;
@@ -137,9 +136,8 @@ public class TestWorkflowForkedProcessService extends WorkflowServiceTestBase {
 
   public void exec() throws InterruptedException, TimeoutException {
     assertNotNull(process);
-    EndOfServiceWaiter waiter = new EndOfServiceWaiter(process);
     process.start();
-    waiter.waitForServiceToStop(5000);
+    process.waitForServiceToStop(5000);
   }
 
 }