You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2021/03/03 04:58:27 UTC

[GitHub] [geode] nabarunnag opened a new pull request #6080: GEODE-8996: Fixed rebalance gfsh and REST API in mixed version mode

nabarunnag opened a new pull request #6080:
URL: https://github.com/apache/geode/pull/6080


      * Moved new child RebalanceFunction and CacheRealizationFunction to pre 1.12.0 locations.
      * While talking to pre-1.12.0 servers, the locators send the function from the old package.
      * While talking to 1.12.0 server, the new package function is used.
      * For RebalanceFunction and CacheRealizationFunction the serialVersionUID is set to the one create by 1.11.0 for old package location and serialVersionUID created by 1.12.0 for the later.
   
   Thank you for submitting a contribution to Apache Geode.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically `develop`)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   - [ ] Does `gradlew build` run cleanly?
   
   - [ ] Have you written or updated unit tests to verify your changes?
   
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   
   ### Note:
   Please ensure that once the PR is submitted, check Concourse for build issues and
   submit an update to your PR as soon as possible. If you need help, please send an
   email to dev@geode.apache.org.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] nabarunnag commented on a change in pull request #6080: GEODE-8996: Fixed rebalance gfsh and REST API in mixed version mode

Posted by GitBox <gi...@apache.org>.
nabarunnag commented on a change in pull request #6080:
URL: https://github.com/apache/geode/pull/6080#discussion_r586648043



##########
File path: geode-core/src/main/java/org/apache/geode/management/internal/operation/RebalanceOperationPerformer.java
##########
@@ -445,6 +448,20 @@ RebalanceResult executeRebalanceOnDS(ManagementService managementService,
     return rebalanceResult;
   }
 
+  @NotNull
+  private Function getRebalanceFunction(InternalDistributedMember dsMember) {
+    Function rebalanceFunction;
+    System.out.println("NABA " + dsMember.getVersion().toString());

Review comment:
       removed.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] onichols-pivotal commented on a change in pull request #6080: GEODE-8996: Fixed rebalance gfsh and REST API in mixed version mode

Posted by GitBox <gi...@apache.org>.
onichols-pivotal commented on a change in pull request #6080:
URL: https://github.com/apache/geode/pull/6080#discussion_r586726019



##########
File path: geode-assembly/src/distributedTest/java/org/apache/geode/rest/internal/web/controllers/RestAPICompatibilityTest.java
##########
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ */
+package org.apache.geode.rest.internal.web.controllers;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.management.configuration.DiskStore;
+import org.apache.geode.management.operation.RebalanceOperation;
+import org.apache.geode.management.operation.RestoreRedundancyRequest;
+import org.apache.geode.test.dunit.rules.ClusterStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.BackwardCompatibilityTest;
+import org.apache.geode.test.junit.rules.GfshCommandRule;
+import org.apache.geode.test.junit.rules.MemberStarterRule;
+import org.apache.geode.test.version.TestVersion;
+import org.apache.geode.test.version.VersionManager;
+import org.apache.geode.util.internal.GeodeJsonMapper;
+
+@Category({BackwardCompatibilityTest.class})
+@RunWith(Parameterized.class)
+public class RestAPICompatibilityTest {
+  private final String oldVersion;
+  private static ObjectMapper mapper = GeodeJsonMapper.getMapper();
+
+  @Parameterized.Parameters(name = "{0}")
+  public static Collection<String> data() {
+    List<String> result = VersionManager.getInstance().getVersionsWithoutCurrent();
+    result.removeIf(s -> TestVersion.compare(s, "1.11.0") < 0);
+    return result;
+  }
+
+  @Rule
+  public ClusterStartupRule cluster = new ClusterStartupRule();
+
+  @Rule
+  public GfshCommandRule gfsh = new GfshCommandRule();
+
+  public RestAPICompatibilityTest(String oldVersion) throws JsonProcessingException {
+    this.oldVersion = oldVersion;
+    DiskStore diskStore = new DiskStore();
+    diskStore.setName("diskStore");
+    postRESTAPICalls = new HashMap<>();
+    // {REST endpoint,{Body, Successful Status Message, Introduced in version}}
+    postRESTAPICalls.put("/management/v1/operations/rebalances",
+        new String[] {mapper.writeValueAsString(new RebalanceOperation()), "Operation started",
+            "1.11.0"});
+    postRESTAPICalls.put("/management/v1/operations/restoreRedundancy",
+        new String[] {mapper.writeValueAsString(new RestoreRedundancyRequest()),
+            "Operation started", "1.13.1"});
+  }
+
+  private static Map<String, String[]> postRESTAPICalls;
+
+
+  private static final String[][] getRESTAPICalls = {
+      // REST endpoint , status
+      {"/geode-mgmt/v1/management/commands?cmd=rebalance", "OK"}
+  };
+
+  @Test
+  public void restCommandExecutedOnLatestLocatorShouldBeBackwardsCompatible() throws Exception {
+    // Initialize all cluster members with old versions
+    MemberVM locator1 =
+        cluster.startLocatorVM(0, 0, oldVersion, MemberStarterRule::withHttpService);
+    int locatorPort1 = locator1.getPort();
+    MemberVM locator2 =
+        cluster.startLocatorVM(1, 0, oldVersion,
+            x -> x.withConnectionToLocator(locatorPort1).withHttpService());
+    int locatorPort2 = locator2.getPort();
+    cluster
+        .startServerVM(2, oldVersion, s -> s.withRegion(RegionShortcut.PARTITION, "region")
+            .withConnectionToLocator(locatorPort1, locatorPort2));
+    cluster
+        .startServerVM(3, oldVersion, s -> s.withRegion(RegionShortcut.PARTITION, "region")
+            .withConnectionToLocator(locatorPort1, locatorPort2));
+
+    // Roll locators to the current version
+    cluster.stop(0);
+    // gradle sets a property telling us where the build is located
+    final String buildDir = System.getProperty("geode.build.dir", System.getProperty("user.dir"));
+    locator1 = cluster.startLocatorVM(0, l -> l.withHttpService().withPort(locatorPort1)
+        .withConnectionToLocator(locatorPort2)
+        .withSystemProperty("geode.build.dir", buildDir));
+    cluster.stop(1);
+
+    cluster.startLocatorVM(1,
+        x -> x.withConnectionToLocator(locatorPort1).withHttpService().withPort(locatorPort2)
+            .withConnectionToLocator(locatorPort1)
+            .withSystemProperty("geode.build.dir", buildDir));
+
+    gfsh.connectAndVerify(locator1);
+    gfsh.execute("list members");
+    // Execute REST api calls to from the new locators to the old servers to ensure that backwards
+    // compatibility is maintained
+
+    executeAndValidatePOSTRESTCalls(locator1.getHttpPort());
+    executeAndValidateGETRESTCalls(locator1.getHttpPort());
+
+  }
+
+  void executeAndValidatePOSTRESTCalls(int locator) throws Exception {
+
+    CloseableHttpClient httpClient = HttpClients.createDefault();
+    for (Map.Entry<String, String[]> entry : postRESTAPICalls.entrySet()) {
+      // Skip the test is the version is before the REST api was introduced.
+      if (TestVersion.compare(oldVersion, entry.getValue()[2]) < 0) {
+        continue;
+      }
+      HttpPost post =
+          new HttpPost("http://localhost:" + locator + entry.getKey());
+      post.addHeader("Content-Type", "application/json");
+      post.addHeader("Accept", "application/json");
+      StringEntity jsonStringEntity =
+          new StringEntity(entry.getValue()[0], ContentType.DEFAULT_TEXT);
+      post.setEntity(jsonStringEntity);
+      CloseableHttpResponse response = httpClient.execute(post);
+
+      HttpEntity entity = response.getEntity();
+      InputStream content = entity.getContent();
+
+      BufferedReader reader = new BufferedReader(new InputStreamReader(content));

Review comment:
       or IOUtils has lots of convenience methods to snarf a stream




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] nabarunnag merged pull request #6080: GEODE-8996: Fixed rebalance gfsh and REST API in mixed version mode

Posted by GitBox <gi...@apache.org>.
nabarunnag merged pull request #6080:
URL: https://github.com/apache/geode/pull/6080


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] dickcav commented on a change in pull request #6080: GEODE-8996: Fixed rebalance gfsh and REST API in mixed version mode

Posted by GitBox <gi...@apache.org>.
dickcav commented on a change in pull request #6080:
URL: https://github.com/apache/geode/pull/6080#discussion_r586640274



##########
File path: geode-core/src/main/java/org/apache/geode/management/internal/operation/RebalanceOperationPerformer.java
##########
@@ -445,6 +448,20 @@ RebalanceResult executeRebalanceOnDS(ManagementService managementService,
     return rebalanceResult;
   }
 
+  @NotNull
+  private Function getRebalanceFunction(InternalDistributedMember dsMember) {
+    Function rebalanceFunction;
+    System.out.println("NABA " + dsMember.getVersion().toString());

Review comment:
       Remove this? 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] kirklund commented on a change in pull request #6080: GEODE-8996: Fixed rebalance gfsh and REST API in mixed version mode

Posted by GitBox <gi...@apache.org>.
kirklund commented on a change in pull request #6080:
URL: https://github.com/apache/geode/pull/6080#discussion_r586693423



##########
File path: geode-assembly/src/distributedTest/java/org/apache/geode/rest/internal/web/controllers/RestAPICompatibilityTest.java
##########
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ */
+package org.apache.geode.rest.internal.web.controllers;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.management.configuration.DiskStore;
+import org.apache.geode.management.operation.RebalanceOperation;
+import org.apache.geode.management.operation.RestoreRedundancyRequest;
+import org.apache.geode.test.dunit.rules.ClusterStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.BackwardCompatibilityTest;
+import org.apache.geode.test.junit.rules.GfshCommandRule;
+import org.apache.geode.test.junit.rules.MemberStarterRule;
+import org.apache.geode.test.version.TestVersion;
+import org.apache.geode.test.version.VersionManager;
+import org.apache.geode.util.internal.GeodeJsonMapper;
+
+@Category({BackwardCompatibilityTest.class})
+@RunWith(Parameterized.class)
+public class RestAPICompatibilityTest {
+  private final String oldVersion;
+  private static ObjectMapper mapper = GeodeJsonMapper.getMapper();
+
+  @Parameterized.Parameters(name = "{0}")
+  public static Collection<String> data() {
+    List<String> result = VersionManager.getInstance().getVersionsWithoutCurrent();
+    result.removeIf(s -> TestVersion.compare(s, "1.11.0") < 0);
+    return result;
+  }
+
+  @Rule
+  public ClusterStartupRule cluster = new ClusterStartupRule();
+
+  @Rule
+  public GfshCommandRule gfsh = new GfshCommandRule();
+
+  public RestAPICompatibilityTest(String oldVersion) throws JsonProcessingException {
+    this.oldVersion = oldVersion;
+    DiskStore diskStore = new DiskStore();
+    diskStore.setName("diskStore");
+    postRESTAPICalls = new HashMap<>();
+    // {REST endpoint,{Body, Successful Status Message, Introduced in version}}
+    postRESTAPICalls.put("/management/v1/operations/rebalances",
+        new String[] {mapper.writeValueAsString(new RebalanceOperation()), "Operation started",
+            "1.11.0"});
+    postRESTAPICalls.put("/management/v1/operations/restoreRedundancy",
+        new String[] {mapper.writeValueAsString(new RestoreRedundancyRequest()),
+            "Operation started", "1.13.1"});
+  }
+
+  private static Map<String, String[]> postRESTAPICalls;
+
+
+  private static final String[][] getRESTAPICalls = {
+      // REST endpoint , status
+      {"/geode-mgmt/v1/management/commands?cmd=rebalance", "OK"}
+  };
+
+  @Test
+  public void restCommandExecutedOnLatestLocatorShouldBeBackwardsCompatible() throws Exception {
+    // Initialize all cluster members with old versions
+    MemberVM locator1 =
+        cluster.startLocatorVM(0, 0, oldVersion, MemberStarterRule::withHttpService);
+    int locatorPort1 = locator1.getPort();
+    MemberVM locator2 =
+        cluster.startLocatorVM(1, 0, oldVersion,
+            x -> x.withConnectionToLocator(locatorPort1).withHttpService());
+    int locatorPort2 = locator2.getPort();
+    cluster
+        .startServerVM(2, oldVersion, s -> s.withRegion(RegionShortcut.PARTITION, "region")
+            .withConnectionToLocator(locatorPort1, locatorPort2));
+    cluster
+        .startServerVM(3, oldVersion, s -> s.withRegion(RegionShortcut.PARTITION, "region")
+            .withConnectionToLocator(locatorPort1, locatorPort2));
+
+    // Roll locators to the current version
+    cluster.stop(0);
+    // gradle sets a property telling us where the build is located
+    final String buildDir = System.getProperty("geode.build.dir", System.getProperty("user.dir"));
+    locator1 = cluster.startLocatorVM(0, l -> l.withHttpService().withPort(locatorPort1)
+        .withConnectionToLocator(locatorPort2)
+        .withSystemProperty("geode.build.dir", buildDir));
+    cluster.stop(1);
+
+    cluster.startLocatorVM(1,
+        x -> x.withConnectionToLocator(locatorPort1).withHttpService().withPort(locatorPort2)
+            .withConnectionToLocator(locatorPort1)
+            .withSystemProperty("geode.build.dir", buildDir));
+
+    gfsh.connectAndVerify(locator1);
+    gfsh.execute("list members");
+    // Execute REST api calls to from the new locators to the old servers to ensure that backwards
+    // compatibility is maintained
+
+    executeAndValidatePOSTRESTCalls(locator1.getHttpPort());
+    executeAndValidateGETRESTCalls(locator1.getHttpPort());
+
+  }
+
+  void executeAndValidatePOSTRESTCalls(int locator) throws Exception {
+
+    CloseableHttpClient httpClient = HttpClients.createDefault();
+    for (Map.Entry<String, String[]> entry : postRESTAPICalls.entrySet()) {
+      // Skip the test is the version is before the REST api was introduced.
+      if (TestVersion.compare(oldVersion, entry.getValue()[2]) < 0) {
+        continue;
+      }
+      HttpPost post =
+          new HttpPost("http://localhost:" + locator + entry.getKey());
+      post.addHeader("Content-Type", "application/json");
+      post.addHeader("Accept", "application/json");
+      StringEntity jsonStringEntity =
+          new StringEntity(entry.getValue()[0], ContentType.DEFAULT_TEXT);
+      post.setEntity(jsonStringEntity);
+      CloseableHttpResponse response = httpClient.execute(post);
+
+      HttpEntity entity = response.getEntity();
+      InputStream content = entity.getContent();
+
+      BufferedReader reader = new BufferedReader(new InputStreamReader(content));
+      String line;
+      StringBuilder sb = new StringBuilder();
+      while ((line = reader.readLine()) != null) {
+        sb.append(line);
+      }
+      JsonNode jsonObject = mapper.readTree(sb.toString());
+      String statusCode = jsonObject.findValue("statusCode").textValue();
+      assertTrue(statusCode.equals("ACCEPTED") || statusCode.contains("OK"));
+      String statusMessage = jsonObject.findValue("statusMessage").textValue();
+      assertTrue(statusMessage.contains(entry.getValue()[1]));

Review comment:
       This assertion will also just fail with:
   ```
   java.lang.AssertionError 
           at org.junit.Assert.fail(Assert.java:87) 
           at org.junit.Assert.assertTrue(Assert.java:42) 
           at org.junit.Assert.assertTrue(Assert.java:53)
   	at org.apache.geode.rest.internal.web.controllers.RestAPICompatibilityTest.executeAndValidatePOSTRESTCalls(RestAPICompatibilityTest.java:170)
   	at org.apache.geode.rest.internal.web.controllers.RestAPICompatibilityTest.restCommandExecutedOnLatestLocatorShouldBeBackwardsCompatible (RestAPICompatibilityTest.java:135)
   ```
   While AssertJ failure will look like:
   ```
   java.lang.AssertionError: 
   Expecting:
     "A really long message that has other entry value"
   to contain:
     "expected entry value" 
   
   	at org.apache.geode.rest.internal.web.controllers.RestAPICompatibilityTest.executeAndValidatePOSTRESTCalls(RestAPICompatibilityTest.java:170)
   	at org.apache.geode.rest.internal.web.controllers.RestAPICompatibilityTest.restCommandExecutedOnLatestLocatorShouldBeBackwardsCompatible (RestAPICompatibilityTest.java:135)
   ```
   

##########
File path: geode-assembly/src/distributedTest/java/org/apache/geode/rest/internal/web/controllers/RestAPICompatibilityTest.java
##########
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ */
+package org.apache.geode.rest.internal.web.controllers;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.management.configuration.DiskStore;
+import org.apache.geode.management.operation.RebalanceOperation;
+import org.apache.geode.management.operation.RestoreRedundancyRequest;
+import org.apache.geode.test.dunit.rules.ClusterStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.BackwardCompatibilityTest;
+import org.apache.geode.test.junit.rules.GfshCommandRule;
+import org.apache.geode.test.junit.rules.MemberStarterRule;
+import org.apache.geode.test.version.TestVersion;
+import org.apache.geode.test.version.VersionManager;
+import org.apache.geode.util.internal.GeodeJsonMapper;
+
+@Category({BackwardCompatibilityTest.class})
+@RunWith(Parameterized.class)
+public class RestAPICompatibilityTest {
+  private final String oldVersion;
+  private static ObjectMapper mapper = GeodeJsonMapper.getMapper();
+
+  @Parameterized.Parameters(name = "{0}")
+  public static Collection<String> data() {
+    List<String> result = VersionManager.getInstance().getVersionsWithoutCurrent();
+    result.removeIf(s -> TestVersion.compare(s, "1.11.0") < 0);
+    return result;
+  }
+
+  @Rule
+  public ClusterStartupRule cluster = new ClusterStartupRule();
+
+  @Rule
+  public GfshCommandRule gfsh = new GfshCommandRule();
+
+  public RestAPICompatibilityTest(String oldVersion) throws JsonProcessingException {
+    this.oldVersion = oldVersion;
+    DiskStore diskStore = new DiskStore();
+    diskStore.setName("diskStore");
+    postRESTAPICalls = new HashMap<>();
+    // {REST endpoint,{Body, Successful Status Message, Introduced in version}}
+    postRESTAPICalls.put("/management/v1/operations/rebalances",
+        new String[] {mapper.writeValueAsString(new RebalanceOperation()), "Operation started",
+            "1.11.0"});
+    postRESTAPICalls.put("/management/v1/operations/restoreRedundancy",
+        new String[] {mapper.writeValueAsString(new RestoreRedundancyRequest()),
+            "Operation started", "1.13.1"});
+  }
+
+  private static Map<String, String[]> postRESTAPICalls;
+
+
+  private static final String[][] getRESTAPICalls = {
+      // REST endpoint , status
+      {"/geode-mgmt/v1/management/commands?cmd=rebalance", "OK"}
+  };
+
+  @Test
+  public void restCommandExecutedOnLatestLocatorShouldBeBackwardsCompatible() throws Exception {
+    // Initialize all cluster members with old versions
+    MemberVM locator1 =
+        cluster.startLocatorVM(0, 0, oldVersion, MemberStarterRule::withHttpService);
+    int locatorPort1 = locator1.getPort();
+    MemberVM locator2 =
+        cluster.startLocatorVM(1, 0, oldVersion,
+            x -> x.withConnectionToLocator(locatorPort1).withHttpService());
+    int locatorPort2 = locator2.getPort();
+    cluster
+        .startServerVM(2, oldVersion, s -> s.withRegion(RegionShortcut.PARTITION, "region")
+            .withConnectionToLocator(locatorPort1, locatorPort2));
+    cluster
+        .startServerVM(3, oldVersion, s -> s.withRegion(RegionShortcut.PARTITION, "region")
+            .withConnectionToLocator(locatorPort1, locatorPort2));
+
+    // Roll locators to the current version
+    cluster.stop(0);
+    // gradle sets a property telling us where the build is located
+    final String buildDir = System.getProperty("geode.build.dir", System.getProperty("user.dir"));
+    locator1 = cluster.startLocatorVM(0, l -> l.withHttpService().withPort(locatorPort1)
+        .withConnectionToLocator(locatorPort2)
+        .withSystemProperty("geode.build.dir", buildDir));
+    cluster.stop(1);
+
+    cluster.startLocatorVM(1,
+        x -> x.withConnectionToLocator(locatorPort1).withHttpService().withPort(locatorPort2)
+            .withConnectionToLocator(locatorPort1)
+            .withSystemProperty("geode.build.dir", buildDir));
+
+    gfsh.connectAndVerify(locator1);
+    gfsh.execute("list members");
+    // Execute REST api calls to from the new locators to the old servers to ensure that backwards
+    // compatibility is maintained
+
+    executeAndValidatePOSTRESTCalls(locator1.getHttpPort());
+    executeAndValidateGETRESTCalls(locator1.getHttpPort());
+
+  }
+
+  void executeAndValidatePOSTRESTCalls(int locator) throws Exception {
+
+    CloseableHttpClient httpClient = HttpClients.createDefault();
+    for (Map.Entry<String, String[]> entry : postRESTAPICalls.entrySet()) {
+      // Skip the test is the version is before the REST api was introduced.
+      if (TestVersion.compare(oldVersion, entry.getValue()[2]) < 0) {
+        continue;
+      }
+      HttpPost post =
+          new HttpPost("http://localhost:" + locator + entry.getKey());
+      post.addHeader("Content-Type", "application/json");
+      post.addHeader("Accept", "application/json");
+      StringEntity jsonStringEntity =
+          new StringEntity(entry.getValue()[0], ContentType.DEFAULT_TEXT);
+      post.setEntity(jsonStringEntity);
+      CloseableHttpResponse response = httpClient.execute(post);
+
+      HttpEntity entity = response.getEntity();
+      InputStream content = entity.getContent();
+
+      BufferedReader reader = new BufferedReader(new InputStreamReader(content));
+      String line;
+      StringBuilder sb = new StringBuilder();
+      while ((line = reader.readLine()) != null) {
+        sb.append(line);
+      }
+      JsonNode jsonObject = mapper.readTree(sb.toString());
+      String statusCode = jsonObject.findValue("statusCode").textValue();
+      assertTrue(statusCode.equals("ACCEPTED") || statusCode.contains("OK"));

Review comment:
       I strongly recommend AssertJ rather than JUnit Assert especially in this case. The AssertJ failure message has much better information about why it failed.
   
   The JUnit assertTrue will fail with a message like this:
   ```
   java.lang.AssertionError 
           at org.junit.Assert.fail(Assert.java:87) 
           at org.junit.Assert.assertTrue(Assert.java:42) 
           at org.junit.Assert.assertTrue(Assert.java:53)
   	at org.apache.geode.rest.internal.web.controllers.RestAPICompatibilityTest.executeAndValidatePOSTRESTCalls(RestAPICompatibilityTest.java:168)
   	at org.apache.geode.rest.internal.web.controllers.RestAPICompatibilityTest.restCommandExecutedOnLatestLocatorShouldBeBackwardsCompatible (RestAPICompatibilityTest.java:135)
   ```
   If you use AssertJ:
   ```
   assertThat(statusCode).satisfiesAnyOf(
     value -> assertThat(value).isEqualTo("ACCEPTED"),
     value -> assertThat(value).contains("OK")
   );
   ```
   Then you will get a failure message like this:
   ```
   org.assertj.core.error.MultipleAssertionsError: 
   The following 2 assertions failed:
   1) 
   Expected :"[ACCEPTED]"
   Actual   :"[FAIL]"
   
   	at org.assertj.core.error.AssertionErrorCreator.multipleAssertionsError(AssertionErrorCreator.java:106)
   	at org.assertj.core.api.AbstractAssert.multipleAssertionsError(AbstractAssert.java:947)
   	at org.assertj.core.api.AbstractAssert.satisfiesAnyOfAssertionsGroups(AbstractAssert.java:942)
   	at org.assertj.core.api.AbstractAssert.satisfiesAnyOf(AbstractAssert.java:855)
   	at org.apache.geode.AwaitTest.executeAndValidatePOSTRESTCalls(AwaitTest.java:50)
   	at org.apache.geode.rest.internal.web.controllers.RestAPICompatibilityTest.executeAndValidatePOSTRESTCalls(RestAPICompatibilityTest.java:168)
   	at org.apache.geode.rest.internal.web.controllers.RestAPICompatibilityTest.restCommandExecutedOnLatestLocatorShouldBeBackwardsCompatible (RestAPICompatibilityTest.java:135)
   ```

##########
File path: geode-assembly/src/distributedTest/java/org/apache/geode/rest/internal/web/controllers/RestAPICompatibilityTest.java
##########
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ */
+package org.apache.geode.rest.internal.web.controllers;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.management.configuration.DiskStore;
+import org.apache.geode.management.operation.RebalanceOperation;
+import org.apache.geode.management.operation.RestoreRedundancyRequest;
+import org.apache.geode.test.dunit.rules.ClusterStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.BackwardCompatibilityTest;
+import org.apache.geode.test.junit.rules.GfshCommandRule;
+import org.apache.geode.test.junit.rules.MemberStarterRule;
+import org.apache.geode.test.version.TestVersion;
+import org.apache.geode.test.version.VersionManager;
+import org.apache.geode.util.internal.GeodeJsonMapper;
+
+@Category({BackwardCompatibilityTest.class})
+@RunWith(Parameterized.class)
+public class RestAPICompatibilityTest {
+  private final String oldVersion;
+  private static ObjectMapper mapper = GeodeJsonMapper.getMapper();
+
+  @Parameterized.Parameters(name = "{0}")
+  public static Collection<String> data() {
+    List<String> result = VersionManager.getInstance().getVersionsWithoutCurrent();
+    result.removeIf(s -> TestVersion.compare(s, "1.11.0") < 0);
+    return result;
+  }
+
+  @Rule
+  public ClusterStartupRule cluster = new ClusterStartupRule();
+
+  @Rule
+  public GfshCommandRule gfsh = new GfshCommandRule();
+
+  public RestAPICompatibilityTest(String oldVersion) throws JsonProcessingException {
+    this.oldVersion = oldVersion;
+    DiskStore diskStore = new DiskStore();
+    diskStore.setName("diskStore");
+    postRESTAPICalls = new HashMap<>();
+    // {REST endpoint,{Body, Successful Status Message, Introduced in version}}
+    postRESTAPICalls.put("/management/v1/operations/rebalances",
+        new String[] {mapper.writeValueAsString(new RebalanceOperation()), "Operation started",
+            "1.11.0"});
+    postRESTAPICalls.put("/management/v1/operations/restoreRedundancy",
+        new String[] {mapper.writeValueAsString(new RestoreRedundancyRequest()),
+            "Operation started", "1.13.1"});
+  }
+
+  private static Map<String, String[]> postRESTAPICalls;
+
+
+  private static final String[][] getRESTAPICalls = {
+      // REST endpoint , status
+      {"/geode-mgmt/v1/management/commands?cmd=rebalance", "OK"}
+  };
+
+  @Test
+  public void restCommandExecutedOnLatestLocatorShouldBeBackwardsCompatible() throws Exception {
+    // Initialize all cluster members with old versions
+    MemberVM locator1 =
+        cluster.startLocatorVM(0, 0, oldVersion, MemberStarterRule::withHttpService);
+    int locatorPort1 = locator1.getPort();
+    MemberVM locator2 =
+        cluster.startLocatorVM(1, 0, oldVersion,
+            x -> x.withConnectionToLocator(locatorPort1).withHttpService());
+    int locatorPort2 = locator2.getPort();
+    cluster
+        .startServerVM(2, oldVersion, s -> s.withRegion(RegionShortcut.PARTITION, "region")
+            .withConnectionToLocator(locatorPort1, locatorPort2));
+    cluster
+        .startServerVM(3, oldVersion, s -> s.withRegion(RegionShortcut.PARTITION, "region")
+            .withConnectionToLocator(locatorPort1, locatorPort2));
+
+    // Roll locators to the current version
+    cluster.stop(0);
+    // gradle sets a property telling us where the build is located
+    final String buildDir = System.getProperty("geode.build.dir", System.getProperty("user.dir"));
+    locator1 = cluster.startLocatorVM(0, l -> l.withHttpService().withPort(locatorPort1)
+        .withConnectionToLocator(locatorPort2)
+        .withSystemProperty("geode.build.dir", buildDir));
+    cluster.stop(1);
+
+    cluster.startLocatorVM(1,
+        x -> x.withConnectionToLocator(locatorPort1).withHttpService().withPort(locatorPort2)
+            .withConnectionToLocator(locatorPort1)
+            .withSystemProperty("geode.build.dir", buildDir));
+
+    gfsh.connectAndVerify(locator1);
+    gfsh.execute("list members");
+    // Execute REST api calls to from the new locators to the old servers to ensure that backwards
+    // compatibility is maintained
+
+    executeAndValidatePOSTRESTCalls(locator1.getHttpPort());
+    executeAndValidateGETRESTCalls(locator1.getHttpPort());
+
+  }
+
+  void executeAndValidatePOSTRESTCalls(int locator) throws Exception {
+
+    CloseableHttpClient httpClient = HttpClients.createDefault();
+    for (Map.Entry<String, String[]> entry : postRESTAPICalls.entrySet()) {
+      // Skip the test is the version is before the REST api was introduced.
+      if (TestVersion.compare(oldVersion, entry.getValue()[2]) < 0) {
+        continue;
+      }
+      HttpPost post =
+          new HttpPost("http://localhost:" + locator + entry.getKey());
+      post.addHeader("Content-Type", "application/json");
+      post.addHeader("Accept", "application/json");
+      StringEntity jsonStringEntity =
+          new StringEntity(entry.getValue()[0], ContentType.DEFAULT_TEXT);
+      post.setEntity(jsonStringEntity);
+      CloseableHttpResponse response = httpClient.execute(post);
+
+      HttpEntity entity = response.getEntity();
+      InputStream content = entity.getContent();
+
+      BufferedReader reader = new BufferedReader(new InputStreamReader(content));

Review comment:
       BufferedReader should be used in a try-with-resources statement which auto-closes it:
   ```
   try (BufferedReader readerĀ = new BufferedReader(new InputStreamReader(content))) {
     while ((line = reader.readLine()) != null) {
       sb.append(line);
     }
   }
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org