From 5ca511622f0952228de99785b10f6870aecc6a54 Mon Sep 17 00:00:00 2001 From: David Turner Date: Wed, 29 Apr 2020 14:00:36 +0100 Subject: [PATCH] Add API specs for voting config exclusions (#55919) Closes #48131 Backport of #55760 Co-authored-by: zacharymorn --- .../client/RestHighLevelClientTests.java | 2 + ...uster.delete_voting_config_exclusions.json | 26 +++++ ...cluster.post_voting_config_exclusions.json | 34 ++++++ .../10_basic.yml | 107 ++++++++++++++++++ 4 files changed, 169 insertions(+) create mode 100644 rest-api-spec/src/main/resources/rest-api-spec/api/cluster.delete_voting_config_exclusions.json create mode 100644 rest-api-spec/src/main/resources/rest-api-spec/api/cluster.post_voting_config_exclusions.json create mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/cluster.voting_config_exclusions/10_basic.yml diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java index d1a32c93ffd..b6440dcddc6 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java @@ -869,6 +869,8 @@ public class RestHighLevelClientTests extends ESTestCase { "cluster.reroute", "cluster.state", "cluster.stats", + "cluster.post_voting_config_exclusions", + "cluster.delete_voting_config_exclusions", "indices.shard_stores", "indices.upgrade", "indices.recovery", diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.delete_voting_config_exclusions.json b/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.delete_voting_config_exclusions.json new file mode 100644 index 00000000000..d3db7dedd6c --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.delete_voting_config_exclusions.json @@ -0,0 +1,26 @@ +{ + "cluster.delete_voting_config_exclusions":{ + "documentation":{ + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/voting-config-exclusions.html", + "description":"Clears cluster voting config exclusions." + }, + "stability":"stable", + "url":{ + "paths":[ + { + "path":"/_cluster/voting_config_exclusions", + "methods":[ + "DELETE" + ] + } + ] + }, + "params":{ + "wait_for_removal": { + "type":"boolean", + "description":"Specifies whether to wait for all excluded nodes to be removed from the cluster before clearing the voting configuration exclusions list.", + "default":true + } + } + } +} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.post_voting_config_exclusions.json b/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.post_voting_config_exclusions.json new file mode 100644 index 00000000000..4dbaf80c33b --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.post_voting_config_exclusions.json @@ -0,0 +1,34 @@ +{ + "cluster.post_voting_config_exclusions":{ + "documentation":{ + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/voting-config-exclusions.html", + "description":"Updates the cluster voting config exclusions by node ids or node names." + }, + "stability":"stable", + "url":{ + "paths":[ + { + "path":"/_cluster/voting_config_exclusions", + "methods":[ + "POST" + ] + } + ] + }, + "params":{ + "node_ids":{ + "type":"string", + "description":"A comma-separated list of the persistent ids of the nodes to exclude from the voting configuration. If specified, you may not also specify ?node_names." + }, + "node_names":{ + "type":"string", + "description":"A comma-separated list of the names of the nodes to exclude from the voting configuration. If specified, you may not also specify ?node_ids." + }, + "timeout":{ + "type":"time", + "description":"Explicit operation timeout", + "default":"30s" + } + } + } +} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.voting_config_exclusions/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.voting_config_exclusions/10_basic.yml new file mode 100644 index 00000000000..5474c9bdf4d --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.voting_config_exclusions/10_basic.yml @@ -0,0 +1,107 @@ +teardown: + - do: + cluster.delete_voting_config_exclusions: {} + +--- +"Get cluster state without voting config exclusions": + - skip: + version: " - 6.99.99" + reason: Voting config exclusions were introduced in 7.0.0 + + - do: + cluster.state: {} + + - length: { metadata.cluster_coordination.voting_config_exclusions: 0 } + +--- +"Add voting config exclusion by unknown node Id": + - skip: + version: " - 7.7.99" + reason: Tests the new voting config exclusions API introduced in 7.8.0 + + - do: + cluster.post_voting_config_exclusions: + node_ids: nodeId + + - do: + cluster.state: {} + + - length: { metadata.cluster_coordination.voting_config_exclusions: 1 } + - match: { metadata.cluster_coordination.voting_config_exclusions.0.node_id: "nodeId" } + - match: { metadata.cluster_coordination.voting_config_exclusions.0.node_name: "_absent_" } + +--- +"Add voting config exclusion by unknown node Ids": + - skip: + version: " - 7.7.99" + features: contains + reason: "contains is a newly added assertion, and this tests the new voting config exclusions API introduced in 7.8.0" + + - do: + cluster.post_voting_config_exclusions: + node_ids: nodeId1,nodeId2 + + - do: + cluster.state: {} + + - length: { metadata.cluster_coordination.voting_config_exclusions: 2 } + - contains : { metadata.cluster_coordination.voting_config_exclusions: {node_id: "nodeId1", node_name: "_absent_"} } + - contains : { metadata.cluster_coordination.voting_config_exclusions: {node_id: "nodeId2", node_name: "_absent_"} } + +--- +"Add voting config exclusion by unknown node name": + - skip: + version: " - 7.7.99" + reason: Tests the new voting config exclusions API introduced in 7.8.0 + + - do: + cluster.post_voting_config_exclusions: + node_names: nodeName + + - do: + cluster.state: {} + + - length: { metadata.cluster_coordination.voting_config_exclusions: 1 } + - match: { metadata.cluster_coordination.voting_config_exclusions.0.node_id: "_absent_" } + - match: { metadata.cluster_coordination.voting_config_exclusions.0.node_name: "nodeName" } + +--- +"Add voting config exclusion by unknown node names": + - skip: + version: " - 7.7.99" + features: contains + reason: "contains is a newly added assertion, and this tests the new voting config exclusions API introduced in 7.8.0" + + - do: + cluster.post_voting_config_exclusions: + node_names: nodeName1,nodeName2 + + - do: + cluster.state: {} + + - length: { metadata.cluster_coordination.voting_config_exclusions: 2 } + - contains : { metadata.cluster_coordination.voting_config_exclusions: {node_id: "_absent_", node_name: "nodeName1"} } + - contains : { metadata.cluster_coordination.voting_config_exclusions: {node_id: "_absent_", node_name: "nodeName2"} } + +--- +"Throw exception when adding voting config exclusion without specifying nodes": + - skip: + version: " - 7.7.99" + reason: Tests the new voting config exclusions API introduced in 7.8.0 + + - do: + catch: /Please set node identifiers correctly. One and only one of \[node_name\], \[node_names\] and \[node_ids\] has to be set/ + cluster.post_voting_config_exclusions: {} + +--- +"Throw exception when adding voting config exclusion and specifying both node_ids and node_names": + - skip: + version: " - 7.7.99" + reason: Tests the new voting config exclusions API introduced in 7.8.0 + + - do: + catch: /Please set node identifiers correctly. One and only one of \[node_name\], \[node_names\] and \[node_ids\] has to be set/ + cluster.post_voting_config_exclusions: + node_ids: nodeId + node_names: nodeName +