diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.health/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.health/10_basic.yml index 731fc5d166eca..0d945d01a6ddb 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.health/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.health/10_basic.yml @@ -1,11 +1,19 @@ --- -"Help": +"Help - before 2.0.0": - skip: - version: " - 7.10.99" - reason: "discovered_master added in OpenSearch 1.0.0" + version: " - 7.10.99 , 2.0.0 - " + reason: "discovered_master added in OpenSearch 1.0.0, and renamed to discovered_cluster_manager in 2.0.0" + features: node_selector - do: cat.health: help: true + node_selector: + # Only send request to nodes in <2.0 versions, especially during ':qa:mixed-cluster:v1.x.x#mixedClusterTest'. + # Because YAML REST test takes the minimum OpenSearch version in the cluster to apply the filter in 'skip' section, + # see OpenSearchClientYamlSuiteTestCase#initAndResetContext() for detail. + # During 'mixedClusterTest', the cluster can be mixed with nodes in 1.x and 2.x versions, + # so node_selector is required, and only filtering version in 'skip' is not enough. + version: "1.0.0 - 1.4.99" - match: $body: | @@ -27,6 +35,34 @@ $/ +--- +"Help": + - skip: + version: " - 1.4.99" + reason: "discovered_cluster_manager is added in OpenSearch 2.0.0" + - do: + cat.health: + help: true + + - match: + $body: | + /^ epoch .+ \n + timestamp .+ \n + cluster .+ \n + status .+ \n + node.total .+ \n + node.data .+ \n + discovered_cluster_manager .+ \n + shards .+ \n + pri .+ \n + relo .+ \n + init .+ \n + unassign .+ \n + pending_tasks .+ \n + max_task_wait_time .+ \n + active_shards_percent .+ \n + + $/ --- "Empty cluster": diff --git a/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java b/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java index b6e945620f918..c05b0b9c77129 100644 --- a/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java +++ b/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java @@ -88,7 +88,12 @@ protected Table getTableWithHeader(final RestRequest request) { t.addCell("status", "alias:st;desc:health status"); t.addCell("node.total", "alias:nt,nodeTotal;text-align:right;desc:total number of nodes"); t.addCell("node.data", "alias:nd,nodeData;text-align:right;desc:number of nodes that can store data"); - t.addCell("discovered_master", "alias:dm;text-align:right;desc:discovered master"); + // TODO: Remove the header alias 'discovered_master', after removing MASTER_ROLE. + // The alias 'discovered_master' is added for compatibility when using request parameter 'h=discovered_master'. + t.addCell( + "discovered_cluster_manager", + "alias:dcm,dm,discovered_master;text-align:right;desc:cluster manager is discovered or not" + ); t.addCell("shards", "alias:t,sh,shards.total,shardsTotal;text-align:right;desc:total number of shards"); t.addCell("pri", "alias:p,shards.primary,shardsPrimary;text-align:right;desc:number of primary shards"); t.addCell("relo", "alias:r,shards.relocating,shardsRelocating;text-align:right;desc:number of relocating nodes");