Skip to content

Commit

Permalink
Allow deprecation warning for API call GET _cat/master in ExceptionIT…
Browse files Browse the repository at this point in the history
… of mixed cluster BWC test (opensearch-project#2767)

Signed-off-by: Tianli Feng <ftianli@amazon.com>
  • Loading branch information
Tianli Feng committed Apr 7, 2022
1 parent 566ebfa commit 2491557
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ public void testOpensearchException() throws Exception {
private void logClusterNodes() throws IOException {
ObjectPath objectPath = ObjectPath.createFromResponse(client().performRequest(new Request("GET", "_nodes")));
Map<String, ?> nodes = objectPath.evaluate("nodes");
String master = EntityUtils.toString(client().performRequest(new Request("GET", "_cat/master?h=id")).getEntity()).trim();
logger.info("cluster discovered: master id='{}'", master);
// As of 2.0, 'GET _cat/master' API is deprecated to promote inclusive language.
// Allow the deprecation warning for the node running an older version.
// TODO: Replace the API with 'GET _cat/cluster_manager' when dropping compatibility with 1.x versions.
Request catRequest = new Request("GET", "_cat/master?h=id");
catRequest.setOptions(expectWarningsOnce("[GET /_cat/master] is deprecated! Use [GET /_cat/cluster_manager] instead."));
String clusterManager = EntityUtils.toString(client().performRequest(catRequest).getEntity()).trim();
logger.info("cluster discovered: cluster-manager id='{}'", clusterManager);
for (String id : nodes.keySet()) {
logger.info("{}: id='{}', name='{}', version={}",
objectPath.evaluate("nodes." + id + ".http.publish_address"),
Expand Down

0 comments on commit 2491557

Please sign in to comment.