Skip to content

Commit 7d2d140

Browse files
authored
Get node ID from nodes info in REST tests (#40052)
* Get master identity from nodes info in REST tests We discussed recently that the cluster state API should be considered "internal" and therefore our usual cast-iron stability guarantees do not hold for this API. However, there are a good number of REST tests that need to identify the master node. Today they call `GET /_cluster/state` API and extract the master node ID from the response. An alternative that avoids the unstable cluster state API is to call `GET _nodes/_master`: the master node ID is the unique key in the `nodes` map in the response. This change adds the ability for YAML-based REST tests to extract the unique key of a singleton map so that they can obtain the master node ID from the nodes info API instead of the cluster state API. * Allow access to an arbitrary node ID and adjust all YAML tests to use this * Warnings
1 parent 4cec0ae commit 7d2d140

File tree

18 files changed

+404
-324
lines changed

18 files changed

+404
-324
lines changed

rest-api-spec/src/main/resources/rest-api-spec/test/cluster.allocation_explain/10_basic.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212

1313
- match: { acknowledged: true }
1414

15-
- do:
16-
cluster.state:
17-
metric: [ master_node ]
18-
1915
- do:
2016
cluster.allocation_explain:
2117
body: { "index": "test", "shard": 0, "primary": true }
@@ -37,10 +33,6 @@
3733
index: test
3834
body: { "settings": { "index.number_of_shards": 1, "index.number_of_replicas": 9 } }
3935

40-
- do:
41-
cluster.state:
42-
metric: [ master_node ]
43-
4436
- do:
4537
cluster.allocation_explain:
4638
include_disk_info: true

rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/11_explain.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ setup:
2525

2626
---
2727
"Explain API for non-existent node & shard":
28+
- skip:
29+
features: [arbitrary_key]
2830

2931
- do:
30-
cluster.state:
31-
metric: [ master_node ]
32-
33-
- set: {master_node: node_id}
32+
nodes.info:
33+
node_id: data:true
34+
- set:
35+
nodes._arbitrary_key_: node_id
3436

3537
- do:
3638
cluster.reroute:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.shrink/10_basic.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,29 @@
33
- skip:
44
version: " - 6.9.99"
55
reason: expects warnings that pre-7.0.0 will not send
6-
features: "warnings"
7-
# creates an index with one document solely allocated on the master node
6+
features: [warnings, arbitrary_key]
7+
8+
# creates an index with one document solely allocated on a particular data node
89
# and shrinks it into a new index with a single shard
910
# we don't do the relocation to a single node after the index is created
1011
# here since in a mixed version cluster we can't identify
1112
# which node is the one with the highest version and that is the only one that can safely
1213
# be used to shrink the index.
13-
- do:
14-
cluster.state: {}
15-
# Get master node id
1614

17-
- set: { master_node: master }
15+
- do:
16+
nodes.info:
17+
node_id: data:true
18+
- set:
19+
nodes._arbitrary_key_: node_id
1820

1921
- do:
2022
indices.create:
2123
index: source
2224
wait_for_active_shards: 1
2325
body:
2426
settings:
25-
# ensure everything is allocated on a single node
26-
index.routing.allocation.include._id: $master
27+
# ensure everything is allocated on the same data node
28+
index.routing.allocation.include._id: $node_id
2729
index.number_of_shards: 2
2830
index.number_of_replicas: 0
2931
- do:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.shrink/20_source_mapping.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
- skip:
44
version: " - 6.9.99"
55
reason: expects warnings that pre-7.0.0 will not send
6-
features: "warnings"
6+
features: [warnings, arbitrary_key]
77

88
- do:
9-
cluster.state: {}
10-
# Get master node id
11-
12-
- set: { master_node: master }
9+
nodes.info:
10+
node_id: data:true
11+
- set:
12+
nodes._arbitrary_key_: node_id
1313

1414
# create index
1515
- do:
@@ -19,7 +19,7 @@
1919
body:
2020
settings:
2121
# ensure everything is allocated on a single node
22-
index.routing.allocation.include._id: $master
22+
index.routing.allocation.include._id: $node_id
2323
index.number_of_shards: 2
2424
index.number_of_replicas: 0
2525
mappings:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.shrink/30_copy_settings.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
- skip:
44
version: " - 6.9.99"
55
reason: expects warnings that pre-7.0.0 will not send
6-
features: "warnings"
6+
features: [warnings, arbitrary_key]
77

88
- do:
9-
cluster.state: {}
10-
11-
# get master node id
12-
- set: { master_node: master }
9+
nodes.info:
10+
node_id: data:true
11+
- set:
12+
nodes._arbitrary_key_: node_id
1313

1414
- do:
1515
indices.create:
1616
index: source
1717
wait_for_active_shards: 1
1818
body:
1919
settings:
20-
# ensure everything is allocated on the master node
21-
index.routing.allocation.include._id: $master
20+
# ensure everything is allocated on the same node
21+
index.routing.allocation.include._id: $node_id
2222
index.number_of_shards: 2
2323
index.number_of_replicas: 0
2424
index.merge.scheduler.max_merge_count: 4
@@ -60,4 +60,4 @@
6060
- match: { copy-settings-target.settings.index.merge.scheduler.max_merge_count: "4" }
6161
- match: { copy-settings-target.settings.index.merge.scheduler.max_thread_count: "2" }
6262
- match: { copy-settings-target.settings.index.blocks.write: "true" }
63-
- match: { copy-settings-target.settings.index.routing.allocation.include._id: $master }
63+
- match: { copy-settings-target.settings.index.routing.allocation.include._id: $node_id }

rest-api-spec/src/main/resources/rest-api-spec/test/indices.split/30_copy_settings.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
- skip:
44
version: " - 6.9.99"
55
reason: expects warnings that pre-7.0.0 will not send
6-
features: "warnings"
6+
features: [arbitrary_key, warnings]
77

88
- do:
9-
cluster.state: {}
10-
11-
# get master node id
12-
- set: { master_node: master }
9+
nodes.info:
10+
node_id: data:true
11+
- set:
12+
nodes._arbitrary_key_: node_id
1313

1414
- do:
1515
indices.create:
1616
index: source
1717
wait_for_active_shards: 1
1818
body:
1919
settings:
20-
# ensure everything is allocated on the master node
21-
index.routing.allocation.include._id: $master
20+
# ensure everything is allocated on the same node
21+
index.routing.allocation.include._id: $node_id
2222
index.number_of_replicas: 0
2323
index.number_of_shards: 1
2424
index.number_of_routing_shards: 4
@@ -62,4 +62,4 @@
6262
- match: { copy-settings-target.settings.index.merge.scheduler.max_merge_count: "4" }
6363
- match: { copy-settings-target.settings.index.merge.scheduler.max_thread_count: "2" }
6464
- match: { copy-settings-target.settings.index.blocks.write: "true" }
65-
- match: { copy-settings-target.settings.index.routing.allocation.include._id: $master }
65+
- match: { copy-settings-target.settings.index.routing.allocation.include._id: $node_id }
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1+
setup:
2+
- skip:
3+
features: [arbitrary_key]
14
---
25
"node_info test":
3-
- do:
4-
cluster.state: {}
5-
6-
# Get master node id
7-
- set: { master_node: master }
8-
96
- do:
107
nodes.info: {}
8+
- set:
9+
nodes._arbitrary_key_: node_id
1110

1211
- is_true: nodes
1312
- is_true: cluster_name
14-
- is_true: nodes.$master.roles
13+
- is_true: nodes.$node_id.roles

rest-api-spec/src/main/resources/rest-api-spec/test/nodes.info/20_transport.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
"node_info test profile is empty":
44
- skip:
5-
features: stash_in_path
5+
features: [stash_in_path, arbitrary_key]
66

77
- do:
8-
cluster.state: {}
9-
10-
- set: {master_node: master}
8+
nodes.info: {}
9+
- set:
10+
nodes._arbitrary_key_: node_id
1111

1212
- do:
1313
nodes.info:
1414
metric: [ transport ]
1515

16-
- is_true: nodes.$master.transport.profiles
16+
- is_true: nodes.$node_id.transport.profiles
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
---
22
"node_info test flat_settings":
3-
- do:
4-
cluster.state: {}
3+
- skip:
4+
features: [arbitrary_key]
55

6-
- set: { master_node: master }
6+
- do:
7+
nodes.info: {}
8+
- set:
9+
nodes._arbitrary_key_: node_id
710

811
- do:
912
nodes.info:
1013
metric: [ settings ]
1114

12-
- match : { nodes.$master.settings.client.type: node }
15+
- match : { nodes.$node_id.settings.client.type: node }
1316

1417
- do:
1518
nodes.info:
1619
metric: [ settings ]
1720
flat_settings: true
1821

19-
- match : { nodes.$master.settings.client\.type: node }
22+
- match : { nodes.$node_id.settings.client\.type: node }

rest-api-spec/src/main/resources/rest-api-spec/test/nodes.stats/10_basic.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@
99

1010
---
1111
"Nodes stats level":
12-
- do:
13-
cluster.state: {}
12+
- skip:
13+
features: [arbitrary_key]
1414

15-
- set: { master_node: master }
15+
- do:
16+
nodes.info: {}
17+
- set:
18+
nodes._arbitrary_key_: node_id
1619

1720
- do:
1821
nodes.stats:
1922
metric: [ indices ]
2023
level: "indices"
2124

22-
- is_true: nodes.$master.indices.indices
25+
- is_true: nodes.$node_id.indices.indices
2326

2427
---
2528
"Nodes stats unrecognized parameter":

0 commit comments

Comments
 (0)