From 297b2906323dc89b41d7e01561cdaa8a6e8b31ae Mon Sep 17 00:00:00 2001 From: Xi Chen Date: Fri, 24 Apr 2020 19:47:50 -0700 Subject: [PATCH 1/3] Add voting config exclusion add and clear API spec and integration test cases --- .../client/RestHighLevelClientTests.java | 2 + ...uster.delete_voting_config_exclusions.json | 26 ++++ ...cluster.post_voting_config_exclusions.json | 34 +++++ .../10_basic.yml | 137 ++++++++++++++++++ 4 files changed, 199 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 b067bd20c731c..4869992c6221a 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 void testApiNamingConventions() throws Exception { "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 0000000000000..d3db7dedd6ca2 --- /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 0000000000000..4dbaf80c33b85 --- /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 0000000000000..de2e2323bfb16 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.voting_config_exclusions/10_basic.yml @@ -0,0 +1,137 @@ +teardown: + - do: + cluster.delete_voting_config_exclusions: {} + +--- +"Get cluster state without voting config exclusions": + - do: + cluster.state: {} + + - length: { metadata.cluster_coordination.voting_config_exclusions: 0 } + +--- +"Add voting config exclusion by unknonw node Id": + - 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 unknonw node Ids": + - skip: + reason: "contains is a newly added assertion" + features: contains + + - 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 unknonw node name": + - 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 unknonw node names": + - skip: + reason: "contains is a newly added assertion" + features: contains + + - 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"} } + +#--- +# THIS TEST CASE WILL CAUSE TIMEOUT FOR CLEAR VOTING CONFIG OPERATION, HENCE BREAKING ALL TESTS +#"Add voting config exclusion by known node id": +# - do: +# cluster.delete_voting_config_exclusions: {} +# +# - do: +# nodes.info: {} +# - set: +# nodes._arbitrary_key_: node_id +# - set: +# nodes.$node_id.name: node_name +# +# - do: +# catch: /timeout_exception/ # Is timing out (even with default 30s) an expected behavior here? +# cluster.post_voting_config_exclusions: +# node_ids: $node_id +# timeout: 10s +# +# - do: +# cluster.state: {} +# +# - length: { metadata.cluster_coordination.voting_config_exclusions: 1 } +# - match: { metadata.cluster_coordination.voting_config_exclusions.0.node_id: $node_id } +# - match: { metadata.cluster_coordination.voting_config_exclusions.0.node_name: $node_name } + +#--- +# THIS TEST CASE WILL CAUSE TIMEOUT FOR CLEAR VOTING CONFIG OPERATION, HENCE BREAKING ALL TESTS +#"Add voting config exclusion by known node name": +# - do: +# cluster.delete_voting_config_exclusions: {} +# +# - do: +# nodes.info: {} +# - set: +# nodes._arbitrary_key_: node_id +# - set: +# nodes.$node_id.name: node_name +# +# - do: +# catch: /timeout_exception/ # Is timing out (even with default 30s) an expected behavior here? +# cluster.post_voting_config_exclusions: +# node_names: $node_name +# timeout: 10s +# +# - do: +# cluster.state: {} +# +# - length: { metadata.cluster_coordination.voting_config_exclusions: 1 } +# - match: { metadata.cluster_coordination.voting_config_exclusions.0.node_id: $node_id } +# - match: { metadata.cluster_coordination.voting_config_exclusions.0.node_name: $node_name } + +--- +"Throw exception when adding voting config exclusion without specifying nodes": + - 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": + - 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 + From 8883227d777c8707f8c9a71980d30d4b467cf1c3 Mon Sep 17 00:00:00 2001 From: Xi Chen Date: Sun, 26 Apr 2020 11:50:08 -0700 Subject: [PATCH 2/3] Remove tests that exclude voting config using master node id or name, which caused timeout exception --- .../10_basic.yml | 52 ------------------- 1 file changed, 52 deletions(-) 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 index de2e2323bfb16..b978500e3462e 100644 --- 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 @@ -69,58 +69,6 @@ teardown: - 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"} } -#--- -# THIS TEST CASE WILL CAUSE TIMEOUT FOR CLEAR VOTING CONFIG OPERATION, HENCE BREAKING ALL TESTS -#"Add voting config exclusion by known node id": -# - do: -# cluster.delete_voting_config_exclusions: {} -# -# - do: -# nodes.info: {} -# - set: -# nodes._arbitrary_key_: node_id -# - set: -# nodes.$node_id.name: node_name -# -# - do: -# catch: /timeout_exception/ # Is timing out (even with default 30s) an expected behavior here? -# cluster.post_voting_config_exclusions: -# node_ids: $node_id -# timeout: 10s -# -# - do: -# cluster.state: {} -# -# - length: { metadata.cluster_coordination.voting_config_exclusions: 1 } -# - match: { metadata.cluster_coordination.voting_config_exclusions.0.node_id: $node_id } -# - match: { metadata.cluster_coordination.voting_config_exclusions.0.node_name: $node_name } - -#--- -# THIS TEST CASE WILL CAUSE TIMEOUT FOR CLEAR VOTING CONFIG OPERATION, HENCE BREAKING ALL TESTS -#"Add voting config exclusion by known node name": -# - do: -# cluster.delete_voting_config_exclusions: {} -# -# - do: -# nodes.info: {} -# - set: -# nodes._arbitrary_key_: node_id -# - set: -# nodes.$node_id.name: node_name -# -# - do: -# catch: /timeout_exception/ # Is timing out (even with default 30s) an expected behavior here? -# cluster.post_voting_config_exclusions: -# node_names: $node_name -# timeout: 10s -# -# - do: -# cluster.state: {} -# -# - length: { metadata.cluster_coordination.voting_config_exclusions: 1 } -# - match: { metadata.cluster_coordination.voting_config_exclusions.0.node_id: $node_id } -# - match: { metadata.cluster_coordination.voting_config_exclusions.0.node_name: $node_name } - --- "Throw exception when adding voting config exclusion without specifying nodes": - do: From 3aa92510c5b6faaefd84572f6ed93d6bad214934 Mon Sep 17 00:00:00 2001 From: Xi Chen Date: Tue, 28 Apr 2020 18:01:27 -0700 Subject: [PATCH 3/3] Fix typo and update error msg --- .../cluster.voting_config_exclusions/10_basic.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 index b978500e3462e..b0aa1529de989 100644 --- 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 @@ -10,7 +10,7 @@ teardown: - length: { metadata.cluster_coordination.voting_config_exclusions: 0 } --- -"Add voting config exclusion by unknonw node Id": +"Add voting config exclusion by unknown node Id": - do: cluster.post_voting_config_exclusions: node_ids: nodeId @@ -23,7 +23,7 @@ teardown: - match: { metadata.cluster_coordination.voting_config_exclusions.0.node_name: "_absent_" } --- -"Add voting config exclusion by unknonw node Ids": +"Add voting config exclusion by unknown node Ids": - skip: reason: "contains is a newly added assertion" features: contains @@ -40,7 +40,7 @@ teardown: - contains : { metadata.cluster_coordination.voting_config_exclusions: {node_id: "nodeId2", node_name: "_absent_"} } --- -"Add voting config exclusion by unknonw node name": +"Add voting config exclusion by unknown node name": - do: cluster.post_voting_config_exclusions: node_names: nodeName @@ -53,7 +53,7 @@ teardown: - match: { metadata.cluster_coordination.voting_config_exclusions.0.node_name: "nodeName" } --- -"Add voting config exclusion by unknonw node names": +"Add voting config exclusion by unknown node names": - skip: reason: "contains is a newly added assertion" features: contains @@ -72,13 +72,13 @@ teardown: --- "Throw exception when adding voting config exclusion without specifying nodes": - do: - catch: /Please set node identifiers correctly. One and only one of \[node_name\], \[node_names\] and \[node_ids\] has to be set/ + catch: /You must set \[node_names\] or \[node_ids\] but not both/ cluster.post_voting_config_exclusions: {} --- "Throw exception when adding voting config exclusion and specifying both node_ids and node_names": - do: - catch: /Please set node identifiers correctly. One and only one of \[node_name\], \[node_names\] and \[node_ids\] has to be set/ + catch: /You must set \[node_names\] or \[node_ids\] but not both/ cluster.post_voting_config_exclusions: node_ids: nodeId node_names: nodeName