You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by el...@apache.org on 2015/01/29 18:23:32 UTC
[09/28] incubator-slider git commit: SLIDER-719 jersey ping test
supports PUT/DELETE/GET/HEAD/POST
SLIDER-719 jersey ping test supports PUT/DELETE/GET/HEAD/POST
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/4418179a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/4418179a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/4418179a
Branch: refs/heads/develop
Commit: 4418179aa645a6bb6d4c8cf4fdae76468b9d1d8d
Parents: dff5985
Author: Steve Loughran <st...@apache.org>
Authored: Tue Jan 20 19:06:37 2015 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Tue Jan 20 19:06:37 2015 +0000
----------------------------------------------------------------------
.../agent/rest/JerseyTestDelegates.groovy | 42 +++++++++-----------
.../slider/agent/rest/RestTestDelegates.groovy | 21 +++++-----
.../slider/agent/rest/TestStandaloneREST.groovy | 26 ++----------
3 files changed, 35 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4418179a/slider-core/src/test/groovy/org/apache/slider/agent/rest/JerseyTestDelegates.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/agent/rest/JerseyTestDelegates.groovy b/slider-core/src/test/groovy/org/apache/slider/agent/rest/JerseyTestDelegates.groovy
index a0fc144..0699800 100644
--- a/slider-core/src/test/groovy/org/apache/slider/agent/rest/JerseyTestDelegates.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/agent/rest/JerseyTestDelegates.groovy
@@ -363,34 +363,30 @@ class JerseyTestDelegates extends SliderTestUtils {
jExec(HttpVerb.PUT, ACTION_PING, PingResource)
jExec(HttpVerb.DELETE, ACTION_PING, PingResource)
jExec(HttpVerb.POST, ACTION_PING, PingResource)
- pingPut(ACTION_PING, "ping-text")
-
+ ping(HttpVerb.PUT, ACTION_PING, "ping-text")
+ ping(HttpVerb.POST, ACTION_PING, "ping-text")
+ ping(HttpVerb.DELETE, ACTION_PING, "ping-text")
}
- private PingResource pingPut(String subpath, String payload) {
- def pinged
+ /**
+ * Execute a ping; assert that a response came back with the relevant
+ * verb if the verb has a response body
+ * @param method method to invoke
+ * @param subpath ping path
+ * @param payload payload
+ * @return the resource if the verb has a response
+ */
+ private PingResource ping(HttpVerb method, String subpath, Object payload) {
def actionPing = applicationResource(ACTION_PING)
- def response = actionPing.put(PingResource, payload)
-
-/*
- def outcome = ops.execHttpOperation(
- verb,
- pingUrl,
- payload.bytes,
- MediaType.TEXT_PLAIN)
- byte[] bytes = outcome.data
- if (verb.hasResponseBody()) {
- assert bytes.length > 0, "0 bytes from ping $verb.verb"
- pinged = deser(PingResource, bytes)
- log.info "Ping $verb.verb: $pinged"
- assert verb.verb == pinged.verb
+ def upload = method.hasUploadBody() ? payload : null
+ if (method.hasResponseBody()) {
+ def pinged = actionPing.method(method.verb, PingResource, upload)
+ assert method.verb == pinged.verb
+ return pinged
} else {
- assert bytes.length ==
- 0, "${bytes.length} bytes of data from ping $verb.verb"
+ actionPing.method(method.verb, upload)
+ return null
}
- return outcome
-*/
- return response
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4418179a/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 bf009c2..dd23926 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
@@ -193,15 +193,6 @@ class RestTestDelegates extends SliderTestUtils {
TEST_GLOBAL_OPTION_PRESENT
}
-
- public void testRestletGetOperations() throws Throwable {
- Client client = createJerseyClient()
- String path = appendToURL(application, LIVE_RESOURCES)
- WebResource webResource = client.resource(path)
- webResource.type(MediaType.APPLICATION_JSON)
- .get(ConfTree.class);
- }
-
public void testPing() {
// GET
String ping = appendToURL(appmaster, SLIDER_PATH_APPLICATION, ACTION_PING)
@@ -306,4 +297,16 @@ class RestTestDelegates extends SliderTestUtils {
}
}
+
+ public void testSuiteGetOperations() {
+
+ testCodahaleOperations()
+ testLiveResources()
+ testLiveContainers();
+ testRESTModel()
+ }
+
+ public void testSuiteComplexVerbs() {
+ testPing();
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4418179a/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 5e00da5..9cea46c 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
@@ -100,36 +100,18 @@ class TestStandaloneREST extends AgentMiniClusterTestBase {
RestTestDelegates proxied = new RestTestDelegates(proxyAM)
RestTestDelegates direct = new RestTestDelegates(directAM)
- direct.testRestletGetOperations();
- proxied.testCodahaleOperations()
- direct.testCodahaleOperations()
-
- describe "base entry lists"
-
- assertPathServesList(proxyAM, LIVE, ApplicationResource.LIVE_ENTRIES)
-
- // now some REST gets
- describe "Application REST ${LIVE_RESOURCES}"
- proxied.testLiveResources()
-
- proxied.testRESTModel()
-
- // PUT & POST &c must go direct for now
- direct.testPing()
- // PUT & POST &c direct
- direct.testPing()
+ proxied.testSuiteGetOperations()
+ direct.testSuiteGetOperations()
+ direct.testSuiteComplexVerbs()
if (!wsBackDoorRequired) {
// and via the proxy
- proxied.testRESTModel()
+ proxied.testSuiteComplexVerbs()
}
direct.logCodahaleMetrics();
// this MUST be the final test
direct.testStop();
-
-
-
}