Skip to content

Commit

Permalink
GEODE-7339: change /experimental to /v1 (apache#4207)
Browse files Browse the repository at this point in the history
Co-authored-by: Darrel Schneider <[email protected]>
  • Loading branch information
jinmeiliao and dschneider-pivotal authored Oct 24, 2019
1 parent b3ab652 commit 97ed0b2
Show file tree
Hide file tree
Showing 33 changed files with 109 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void sanityCheck() throws Exception {

// verify the management rest api is started correctly
GeodeDevRestClient client =
new GeodeDevRestClient("/management/experimental", "localhost", 7070, false);
new GeodeDevRestClient("/management/v1", "localhost", 7070, false);

client.doGetAndAssert("/ping").hasStatusCode(200).hasResponseBody().isEqualTo("pong");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static void beforeClass() throws IOException {

client = new GeodeDevRestClient("/management", "localhost", locator.getHttpPort(), false);
JsonNode jsonObject =
client.doGetAndAssert("/experimental/api-docs").getJsonObject().get("paths");
client.doGetAndAssert("/v1/api-docs").getJsonObject().get("paths");
Iterator<Map.Entry<String, JsonNode>> urls = jsonObject.fields();
while (urls.hasNext()) {
Map.Entry<String, JsonNode> url = urls.next();
Expand All @@ -118,7 +118,7 @@ public static void afterClass() throws Exception {

@Test
public void getMembers() throws IOException {
String uri = "/experimental/members";
String uri = "/v1/members";
JqResponse response =
getJqResponse(uri, apiWithJQFilters.remove(uri).get("jqFilter").textValue());
Assertions.assertThat(response.hasErrors()).isFalse();
Expand All @@ -128,17 +128,17 @@ public void getMembers() throws IOException {

@Test
public void getMember() throws Exception {
String uri = "/experimental/members/locator-0";
String uri = "/v1/members/locator-0";
JqResponse response = getJqResponse(uri,
apiWithJQFilters.remove("/experimental/members/{id}").get("jqFilter").textValue());
apiWithJQFilters.remove("/v1/members/{id}").get("jqFilter").textValue());
Assertions.assertThat(response.hasErrors()).isFalse();
System.out.println("JQ output: " + response.getOutput());
Assertions.assertThat(response.getOutput()).contains("\"name\": \"locator-0\"");
}

@Test
public void listRegions() throws Exception {
String uri = "/experimental/regions";
String uri = "/v1/regions";
JqResponse response =
getJqResponse(uri, apiWithJQFilters.remove(uri).get("jqFilter").textValue());
Assertions.assertThat(response.hasErrors()).isFalse();
Expand All @@ -155,17 +155,17 @@ JqResponse getJqResponse(String uri, String jqFilter) throws IOException {

@Test
public void getRegion() throws Exception {
String uri = "/experimental/regions/regionA";
String uri = "/v1/regions/regionA";
JqResponse response = getJqResponse(uri,
apiWithJQFilters.remove("/experimental/regions/{id}").get("jqFilter").textValue());
apiWithJQFilters.remove("/v1/regions/{id}").get("jqFilter").textValue());
Assertions.assertThat(response.hasErrors()).isFalse();
System.out.println("JQ output: " + response.getOutput());
Assertions.assertThat(response.getOutput()).contains("\"name\": \"regionA\"");
}

@Test
public void listIndex() throws Exception {
String uri = "/experimental/indexes";
String uri = "/v1/indexes";
JqResponse response =
getJqResponse(uri, apiWithJQFilters.remove(uri).get("jqFilter").textValue());
Assertions.assertThat(response.hasErrors()).isFalse();
Expand All @@ -175,19 +175,19 @@ public void listIndex() throws Exception {

@Test
public void listRegionIndex() throws Exception {
String uri = "/experimental/regions/regionA/indexes";
String uri = "/v1/regions/regionA/indexes";
JqResponse response = getJqResponse(uri, apiWithJQFilters
.remove("/experimental/regions/{regionName}/indexes").get("jqFilter").textValue());
.remove("/v1/regions/{regionName}/indexes").get("jqFilter").textValue());
Assertions.assertThat(response.hasErrors()).isFalse();
System.out.println("JQ output: " + response.getOutput());
Assertions.assertThat(response.getOutput()).contains("\"name\": \"index1\"");
}

@Test
public void getIndex() throws Exception {
String uri = "/experimental/regions/regionA/indexes/index1";
String uri = "/v1/regions/regionA/indexes/index1";
JqResponse response = getJqResponse(uri, apiWithJQFilters
.remove("/experimental/regions/{regionName}/indexes/{id}").get("jqFilter").textValue());
.remove("/v1/regions/{regionName}/indexes/{id}").get("jqFilter").textValue());
Assertions.assertThat(response.hasErrors()).isFalse();
System.out.println("JQ output: " + response.getOutput());
Assertions.assertThat(response.getOutput()).contains("\"name\": \"index1\"");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void clusterManagementRestServiceStillWorksAfterLocatorReconnects() throw
locator = rule.startLocatorVM(0, l -> l.withHttpService());
server = rule.startServerVM(1, locator.getPort());
restClient =
new GeodeDevRestClient("/management/experimental", "localhost", locator.getHttpPort(),
new GeodeDevRestClient("/management/v1", "localhost", locator.getHttpPort(),
false);

makeRestCallAndVerifyResult("customers");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void withOutService() throws Exception {
l -> l.withoutManagementRestService()
.withHttpService());
restClient =
new GeodeDevRestClient("/management/experimental", "localhost", locator.getHttpPort(),
new GeodeDevRestClient("/management/v1", "localhost", locator.getHttpPort(),
false);
restClient.doGetAndAssert("/ping").hasStatusCode(404);
}
Expand All @@ -45,7 +45,7 @@ public void withOutService() throws Exception {
public void withServiceByDefault() throws Exception {
locator = cluster.startLocatorVM(0, l -> l.withHttpService());
restClient =
new GeodeDevRestClient("/management/experimental", "localhost", locator.getHttpPort(),
new GeodeDevRestClient("/management/v1", "localhost", locator.getHttpPort(),
false);
restClient.doGetAndAssert("/ping").hasStatusCode(200).hasResponseBody().isEqualTo("pong");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void checkRequestsAreLogged() {
assertThat(logContents)
.containsSubsequence(
"Management Request:",
" POST[url=/management/experimental/regions];",
" POST[url=/management/v1/regions];",
" user=null;",
" payload={")
.containsSubsequence(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static void beforeClass() throws Exception {
server3 = cluster.startServerVM(3, "group2,group3", locator.getPort());

restClient =
new GeodeDevRestClient("/management/experimental", "localhost", locator.getHttpPort(),
new GeodeDevRestClient("/management/v1", "localhost", locator.getHttpPort(),
false);
cms = ClusterManagementServiceBuilder.buildWithHostAddress()
.setHostAddress("localhost", locator.getHttpPort())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void disabledClusterConfig() throws Exception {
locator.withProperty(ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION, "false")
.withHttpService().startLocator();
GeodeDevRestClient restClient =
new GeodeDevRestClient("/management/experimental", "localhost", locator.getHttpPort(),
new GeodeDevRestClient("/management/v1", "localhost", locator.getHttpPort(),
false);

ClusterManagementResult result =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@


import static org.apache.geode.test.junit.rules.HttpResponseAssert.assertResponse;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

Expand Down Expand Up @@ -54,13 +55,13 @@ public void isSwaggerRunning() throws Exception {

// Check the JSON
JsonNode json =
assertResponse(client.get("/management/experimental/api-docs")).hasStatusCode(200)
assertResponse(client.get("/management/v1/api-docs")).hasStatusCode(200)
.getJsonObject();
assertThat(json.get("swagger").asText(), is("2.0"));

JsonNode info = json.get("info");
assertThat(info.get("description").asText(),
is("REST API and interface to manage Geode components."));
containsString("REST API to manage Geode. This is experimental."));
assertThat(info.get("title").asText(),
is("Apache Geode Management REST API"));
assertThat(info.get("authTokenEnabled").asText(), is("true"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public interface ClusterManagementOperation<V extends OperationResult> {
/**
* must match the REST controller's RequestMapping
*
* @return the portion after /management/experimental, e.g. /operations/name
* @return the portion after /management/v1, e.g. /operations/name
*/
@JsonIgnore
String getEndpoint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public class Links {
public static final String HREF_PREFIX = "#HREF";
public static final String URI_CONTEXT = "/management";
public static final String URI_VERSION = "/experimental";
public static final String URI_VERSION = "/v1";
private String self;
private String list;
private Map<String, String> links;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
*/
public class ClientClusterManagementService implements ClusterManagementService {
// the restTemplate needs to have the context as the baseUrl, and request URI is the part after
// the context (including /experimental), it needs to be set up this way so that spring test
// the context (including /v1), it needs to be set up this way so that spring test
// runner's injected RequestFactory can work
private final RestTemplate restTemplate;
private final ScheduledExecutorService longRunningStatusPollingThreadPool;
Expand Down Expand Up @@ -142,7 +142,7 @@ public <A extends ClusterManagementOperation<V>, V extends OperationResult> Clus
ClusterManagementOperationResult.class)
.getBody());

// our restTemplate requires the url to be modified to start from "/experimental"
// our restTemplate requires the url to be modified to start from "/v1"
return reAnimate(result, op.getEndpoint());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void parse() throws Exception {
String json = mapper.writeValueAsString(links);
System.out.println(json);
assertThat(json).doesNotContain("others")
.contains("\"list\":\"#HREF/management/experimental/regions\"");
.contains("\"list\":\"#HREF/management/v1/regions\"");
// this is to make sure nothing get de-serialized.
Links links2 = mapper.readValue(json, Links.class);
assertThat(links2.getSelf()).isNull();
Expand All @@ -53,8 +53,8 @@ public void parse() throws Exception {
public void getUri() throws Exception {
assertThat(links.getSelf()).isEqualTo("/regions/regionA");
assertThat(links.getList()).isEqualTo("/regions");
assertThat(links.getLinks().get("list")).isEqualTo("#HREF/management/experimental/regions");
assertThat(links.getLinks().get("list")).isEqualTo("#HREF/management/v1/regions");
assertThat(links.getLinks().get("self"))
.isEqualTo("#HREF/management/experimental/regions/regionA");
.isEqualTo("#HREF/management/v1/regions/regionA");
}
}
2 changes: 1 addition & 1 deletion geode-management/src/test/script/list-management-url.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fi
GEODE=$1

$GEODE/bin/gfsh -e "start locator --name=temp-for-api" > /dev/null
curl -H "Content-Type: application/json" http://localhost:7070/management/experimental/api-docs --fail --silent --show-error | jq -r '.paths | to_entries[] | {url:.key, method:.value|keys[]} | .method + " " + .url'
curl -H "Content-Type: application/json" http://localhost:7070/management/v1/api-docs --fail --silent --show-error | jq -r '.paths | to_entries[] | {url:.key, method:.value|keys[]} | .method + " " + .url'

$GEODE/bin/gfsh -e "stop locator --dir=temp-for-api" > /dev/null
rm -r temp-for-api
2 changes: 1 addition & 1 deletion geode-management/src/test/script/update-management-wiki.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

URI_VERSION=/experimental
URI_VERSION=/v1

set -e

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private ApiInfo apiInfo() {
.licenseUrl("http://www.apache.org/licenses/")
.contact(new Contact("the Apache Geode Community",
"http://geode.apache.org",
"dev@geode.apache.org"))
"user@geode.apache.org"))
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package org.apache.geode.management.internal.rest;


import org.apache.geode.internal.security.SecurityService;
import org.apache.geode.management.api.ClusterManagementService;
import org.apache.geode.test.junit.rules.LocatorStarterRule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
Expand All @@ -50,6 +51,7 @@
@ContextConfiguration(locations = {"classpath*:WEB-INF/management-servlet.xml"},
loader = PlainLocatorContextLoader.class)
@WebAppConfiguration
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class ClientClusterManagementServiceDUnitTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
Expand All @@ -49,6 +50,7 @@
@ContextConfiguration(locations = {"classpath*:WEB-INF/management-servlet.xml"},
loader = PlainLocatorContextLoader.class)
@WebAppConfiguration
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class ConfigurePDXDUnitTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
Expand All @@ -49,6 +50,7 @@
@ContextConfiguration(locations = {"classpath*:WEB-INF/management-servlet.xml"},
loader = LocatorLauncherContextLoader.class)
@WebAppConfiguration
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class MemberManagementServiceDUnitTest {

@Autowired
Expand Down Expand Up @@ -151,15 +153,15 @@ public void noMatchWithJavaAPI() {
@Test
@WithMockUser
public void noMatchWithFilter() throws Exception {
webContext.perform(get("/experimental/members?id=server"))
webContext.perform(get("/v1/members?id=server"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.statusCode", is("OK")));
}

@Test
@WithMockUser
public void noMatchWithUriVariable() throws Exception {
webContext.perform(get("/experimental/members/server"))
webContext.perform(get("/v1/members/server"))
.andExpect(status().isNotFound())
.andExpect(jsonPath("$.statusCode", is("ENTITY_NOT_FOUND")))
.andExpect(jsonPath("$.statusMessage",
Expand Down
Loading

0 comments on commit 97ed0b2

Please sign in to comment.