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 2015/01/14 17:28:44 UTC

[4/5] incubator-slider git commit: SLIDER-715 REST stop action completed with mini and functional test

SLIDER-715 REST stop action completed with mini and functional test


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

Branch: refs/heads/develop
Commit: 28d296a05fb18ccc9c458d97389a302214e6e161
Parents: 2654946
Author: Steve Loughran <st...@apache.org>
Authored: Wed Jan 14 16:26:32 2015 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Wed Jan 14 16:28:27 2015 +0000

----------------------------------------------------------------------
 .../application/actions/RestActionStop.java     |  5 ++-
 .../slider/agent/rest/RestTestDelegates.groovy  | 47 ++++++++++++++++++--
 .../slider/agent/rest/TestStandaloneREST.groovy |  4 +-
 .../apache/slider/test/SliderTestUtils.groovy   |  2 +-
 .../funtest/lifecycle/AgentWebPagesIT.groovy    | 13 +++---
 5 files changed, 55 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/28d296a0/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/actions/RestActionStop.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/actions/RestActionStop.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/actions/RestActionStop.java
index 703c1e7..f94c983 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/actions/RestActionStop.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/actions/RestActionStop.java
@@ -54,12 +54,13 @@ public class RestActionStop {
     response.text = text;
     ActionStopSlider stopSlider =
         new ActionStopSlider(text,
-            1000, TimeUnit.MILLISECONDS,
+            500,
+            TimeUnit.MILLISECONDS,
             LauncherExitCodes.EXIT_SUCCESS,
             FinalApplicationStatus.SUCCEEDED,
             text);
     log.info("SliderAppMasterApi.stopCluster: {}", stopSlider);
-//    slider.schedule(stopSlider);
+    slider.getQueues().schedule(stopSlider);
     
     return response;
   }

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/28d296a0/slider-core/src/test/groovy/org/apache/slider/agent/rest/RestTestDelegates.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/agent/rest/RestTestDelegates.groovy b/slider-core/src/test/groovy/org/apache/slider/agent/rest/RestTestDelegates.groovy
index 5383425..3431175 100644
--- a/slider-core/src/test/groovy/org/apache/slider/agent/rest/RestTestDelegates.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/agent/rest/RestTestDelegates.groovy
@@ -32,8 +32,8 @@ import org.apache.slider.core.restclient.HttpVerb
 import org.apache.slider.core.restclient.UrlConnectionOperations
 import org.apache.slider.server.appmaster.web.rest.application.ApplicationResource
 import org.apache.slider.server.appmaster.web.rest.application.resources.PingResource
+import org.apache.slider.test.Outcome
 import org.apache.slider.test.SliderTestUtils
-import org.junit.Test
 
 import javax.ws.rs.core.MediaType
 
@@ -60,12 +60,18 @@ class RestTestDelegates extends SliderTestUtils {
 
   public void testCodahaleOperations() throws Throwable {
     describe "Codahale operations"
-    // now switch to the Hadoop URL connection, with SPNEGO escalation
     getWebPage(appmaster)
     getWebPage(appmaster, SYSTEM_THREADS)
     getWebPage(appmaster, SYSTEM_HEALTHCHECK)
+    getWebPage(appmaster, SYSTEM_PING)
     getWebPage(appmaster, SYSTEM_METRICS_JSON)
   }
+  
+  public void logCodahaleMetrics() {
+    // query Coda Hale metrics
+    log.info getWebPage(appmaster, SYSTEM_HEALTHCHECK)
+    log.info getWebPage(appmaster, SYSTEM_METRICS)
+  }
 
   public void testLiveResources() throws Throwable {
     describe "Live Resources"
@@ -237,8 +243,6 @@ class RestTestDelegates extends SliderTestUtils {
   public void testStop() {
     String target = appendToURL(appmaster, SLIDER_PATH_APPLICATION, ACTION_STOP)
     describe "Stop URL $target"
-
-
     URL targetUrl = new URL(target)
     def outcome = connectionFactory.execHttpOperation(
         HttpVerb.POST,
@@ -247,8 +251,43 @@ class RestTestDelegates extends SliderTestUtils {
         MediaType.TEXT_PLAIN)
     log.info "Stopped: $outcome"
 
+    // await the shutdown
+    sleep(1000)
+    
+    // now a ping is expected to fail
+    String ping = appendToURL(appmaster, SLIDER_PATH_APPLICATION, ACTION_PING)
+    URL pingUrl = new URL(ping)
 
+    repeatUntilSuccess("probe for missing registry entry",
+        this.&probePingFailing, 30000, 500,
+        [url: ping],
+        true,
+        "AM failed to shut down") {
+      def pinged = fetchType(
+          PingResource,
+          appmaster,
+          ACTION_PING + "?body=hello")
+      fail("AM didn't shut down; Ping GET= $pinged")
+    }
+    
   }
 
+  /**
+   * Probe that spins until the url specified by "url") refuses
+   * connections
+   * @param args argument map
+   * @return the outcome
+   */
+  Outcome probePingFailing(Map args) {
+    String ping = args["url"]
+    URL pingUrl = new URL(ping)
+    try {
+      def response = pingAction(HttpVerb.HEAD, pingUrl, "should not be running")
+      return Outcome.Retry
+    } catch (IOException e) {
+      // expected
+      return Outcome.Success
+    }
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/28d296a0/slider-core/src/test/groovy/org/apache/slider/agent/rest/TestStandaloneREST.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/agent/rest/TestStandaloneREST.groovy b/slider-core/src/test/groovy/org/apache/slider/agent/rest/TestStandaloneREST.groovy
index 7ae8e2f..a3378a8 100644
--- a/slider-core/src/test/groovy/org/apache/slider/agent/rest/TestStandaloneREST.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/agent/rest/TestStandaloneREST.groovy
@@ -39,7 +39,7 @@ class TestStandaloneREST extends AgentMiniClusterTestBase {
 
 
   @Test
-  public void testStandaloneAgentWeb() throws Throwable {
+  public void testStandaloneREST() throws Throwable {
 
     describe "create a standalone AM then perform actions on it"
     //launch fake master
@@ -74,7 +74,6 @@ class TestStandaloneREST extends AgentMiniClusterTestBase {
       log.info metrics
     }
     
-    sleep(5000)
     def appmaster = report.trackingUrl
 
     GET(appmaster)
@@ -113,6 +112,7 @@ class TestStandaloneREST extends AgentMiniClusterTestBase {
       proxied.testRESTModel()
     }
     
+    direct.logCodahaleMetrics();
     direct.testStop();
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/28d296a0/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
index 82436e2..2c6b5fe 100644
--- a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
@@ -1189,7 +1189,7 @@ class SliderTestUtils extends Assert {
     if (timeout < 1000) {
       fail("Timeout $timeout too low: milliseconds are expected, not seconds")
     }
-    int attemptCount = 0
+    int attemptCount = 1
     boolean succeeded = false;
     boolean completed = false;
     Duration duration = new Duration(timeout)

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/28d296a0/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentWebPagesIT.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentWebPagesIT.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentWebPagesIT.groovy
index 9e5e2cd..ce1d955 100644
--- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentWebPagesIT.groovy
+++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentWebPagesIT.groovy
@@ -56,7 +56,7 @@ public class AgentWebPagesIT extends AgentCommandTestBase
 
   @Test
   public void testAgentWeb() throws Throwable {
-    describe("Create a 0-role cluster and make web queries against it")
+    describe("Web queries & REST operations against an AM")
     
     // verify the ws/ path is open for all HTTP verbs
     def sliderConfiguration = ConfigHelper.loadSliderConfiguration();
@@ -98,12 +98,6 @@ public class AgentWebPagesIT extends AgentCommandTestBase
     // get the root page, 
     getWebPage(appmaster)
     
-    // query Coda Hale metrics
-    log.info getWebPage(appmaster, RestPaths.SYSTEM_METRICS)
-    log.info getWebPage(appmaster, RestPaths.SYSTEM_THREADS)
-    log.info getWebPage(appmaster, RestPaths.SYSTEM_HEALTHCHECK)
-    log.info getWebPage(appmaster, RestPaths.SYSTEM_PING)
-
     def realappmaster = report.origTrackingUrl;
     // now attempt direct-to-AM pings
     RestTestDelegates proxied = new RestTestDelegates(appmaster)
@@ -121,6 +115,11 @@ public class AgentWebPagesIT extends AgentCommandTestBase
       // and via the proxy
       proxied.testRESTModel()
     }
+    
+    direct.logCodahaleMetrics();
+    
+    // finally, stop the AM
+    direct.testStop();
   }
 
 }