Skip to content

Commit d6a7e25

Browse files
committed
[Docs] Convert more doc snippets (#26359)
This commit converts some remaining doc snippets so that they are now testable.
1 parent 89d7985 commit d6a7e25

File tree

8 files changed

+351
-103
lines changed

8 files changed

+351
-103
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTask.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
9393
*
9494
* `sh` snippets that contain `curl` almost always should be marked
9595
* with `// CONSOLE`. In the exceptionally rare cases where they are
96-
* not communicating with Elasticsearch, like the xamples in the ec2
96+
* not communicating with Elasticsearch, like the examples in the ec2
9797
* and gce discovery plugins, the snippets should be marked
9898
* `// NOTCONSOLE`. */
9999
return snippet.language == 'js' || snippet.curl

docs/build.gradle

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,14 @@ buildRestTests.expectedUnconvertedCandidates = [
3232
'reference/aggregations/matrix/stats-aggregation.asciidoc',
3333
'reference/aggregations/metrics/tophits-aggregation.asciidoc',
3434
'reference/cluster/allocation-explain.asciidoc',
35-
'reference/cluster/nodes-info.asciidoc',
3635
'reference/cluster/pending.asciidoc',
37-
'reference/cluster/state.asciidoc',
38-
'reference/cluster/stats.asciidoc',
3936
'reference/cluster/tasks.asciidoc',
4037
'reference/docs/delete-by-query.asciidoc',
4138
'reference/docs/reindex.asciidoc',
4239
'reference/docs/update-by-query.asciidoc',
4340
'reference/index-modules/similarity.asciidoc',
4441
'reference/index-modules/store.asciidoc',
4542
'reference/index-modules/translog.asciidoc',
46-
'reference/indices/recovery.asciidoc',
47-
'reference/indices/segments.asciidoc',
48-
'reference/indices/shard-stores.asciidoc',
4943
'reference/migration/migrate_6_0/scripting.asciidoc',
5044
'reference/search/profile.asciidoc',
5145
]
@@ -542,4 +536,4 @@ for (int i = 0; i < 5; i++) {
542536
buildRestTests.setups['iprange'] += """
543537
{"index":{}}
544538
{"ip": "12.0.0.$i"}"""
545-
}
539+
}

docs/reference/cluster/nodes-info.asciidoc

Lines changed: 99 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ the cluster nodes information.
66

77
[source,js]
88
--------------------------------------------------
9-
curl -XGET 'http://localhost:9200/_nodes'
10-
curl -XGET 'http://localhost:9200/_nodes/nodeId1,nodeId2'
9+
GET /_nodes
10+
GET /_nodes/nodeId1,nodeId2
1111
--------------------------------------------------
12+
// CONSOLE
1213

1314
The first command retrieves information of all the nodes in the cluster.
1415
The second command selectively retrieves nodes information of only
@@ -52,14 +53,22 @@ It also allows to get only information on `settings`, `os`, `process`, `jvm`,
5253

5354
[source,js]
5455
--------------------------------------------------
55-
curl -XGET 'http://localhost:9200/_nodes/process'
56-
curl -XGET 'http://localhost:9200/_nodes/_all/process'
57-
curl -XGET 'http://localhost:9200/_nodes/nodeId1,nodeId2/jvm,process'
56+
# return just process
57+
GET /_nodes/process
58+
59+
# same as above
60+
GET /_nodes/_all/process
61+
62+
# return just jvm and process of only nodeId1 and nodeId2
63+
GET /_nodes/nodeId1,nodeId2/jvm,process
64+
5865
# same as above
59-
curl -XGET 'http://localhost:9200/_nodes/nodeId1,nodeId2/info/jvm,process'
66+
GET /_nodes/nodeId1,nodeId2/info/jvm,process
6067
61-
curl -XGET 'http://localhost:9200/_nodes/nodeId1,nodeId2/_all
68+
# return all the information of only nodeId1 and nodeId2
69+
GET /_nodes/nodeId1,nodeId2/_all
6270
--------------------------------------------------
71+
// CONSOLE
6372

6473
The `_all` flag can be set to return all the information - or you can simply omit it.
6574

@@ -110,23 +119,36 @@ the current running process:
110119
[[plugins-info]]
111120
==== Plugins information
112121

113-
`plugins` - if set, the result will contain details about the installed plugins
114-
per node:
122+
`plugins` - if set, the result will contain details about the installed plugins and modules per node:
115123

116-
* `name`: plugin name
117-
* `version`: version of Elasticsearch the plugin was built for
118-
* `description`: short description of the plugin's purpose
119-
* `classname`: fully-qualified class name of the plugin's entry point
120-
* `has_native_controller`: whether or not the plugin has a native controller process
124+
[source,js]
125+
--------------------------------------------------
126+
GET /_nodes/plugins
127+
--------------------------------------------------
128+
// CONSOLE
129+
// TEST[setup:node]
121130

122131
The result will look similar to:
123132

124133
[source,js]
125134
--------------------------------------------------
126135
{
136+
"_nodes": ...
127137
"cluster_name": "elasticsearch",
128138
"nodes": {
129-
"O70_wBv6S9aPPcAKdSUBtw": {
139+
"USpTGYaBSIKbgSUJR2Z9lg": {
140+
"name": "node-0",
141+
"transport_address": "192.168.17:9300",
142+
"host": "node-0.elastic.co",
143+
"ip": "192.168.17",
144+
"version": "{version}",
145+
"build_hash": "587409e",
146+
"roles": [
147+
"master",
148+
"data",
149+
"ingest"
150+
],
151+
"attributes": {},
130152
"plugins": [
131153
{
132154
"name": "analysis-icu",
@@ -149,11 +171,41 @@ The result will look similar to:
149171
"classname": "org.elasticsearch.ingest.useragent.IngestUserAgentPlugin",
150172
"has_native_controller": false
151173
}
174+
],
175+
"modules": [
176+
{
177+
"name": "lang-painless",
178+
"version": "{version}",
179+
"description": "An easy, safe and fast scripting language for Elasticsearch",
180+
"classname": "org.elasticsearch.painless.PainlessPlugin",
181+
"has_native_controller": false
182+
}
152183
]
153184
}
154185
}
155186
}
156187
--------------------------------------------------
188+
// TESTRESPONSE[s/"_nodes": \.\.\./"_nodes": $body.$_path,/]
189+
// TESTRESPONSE[s/"elasticsearch"/$body.cluster_name/]
190+
// TESTRESPONSE[s/"USpTGYaBSIKbgSUJR2Z9lg"/\$node_name/]
191+
// TESTRESPONSE[s/"name": "node-0"/"name": $body.$_path/]
192+
// TESTRESPONSE[s/"transport_address": "192.168.17:9300"/"transport_address": $body.$_path/]
193+
// TESTRESPONSE[s/"host": "node-0.elastic.co"/"host": $body.$_path/]
194+
// TESTRESPONSE[s/"ip": "192.168.17"/"ip": $body.$_path/]
195+
// TESTRESPONSE[s/"build_hash": "587409e"/"build_hash": $body.$_path/]
196+
// TESTRESPONSE[s/"roles": \[[^\]]*\]/"roles": $body.$_path/]
197+
// TESTRESPONSE[s/"attributes": \{[^\}]*\}/"attributes": $body.$_path/]
198+
// TESTRESPONSE[s/"plugins": \[[^\]]*\]/"plugins": $body.$_path/]
199+
// TESTRESPONSE[s/"modules": \[[^\]]*\]/"modules": $body.$_path/]
200+
201+
The following information are available for each plugin and module:
202+
203+
* `name`: plugin name
204+
* `version`: version of Elasticsearch the plugin was built for
205+
* `description`: short description of the plugin's purpose
206+
* `classname`: fully-qualified class name of the plugin's entry point
207+
* `has_native_controller`: whether or not the plugin has a native controller process
208+
157209

158210
[float]
159211
[[ingest-info]]
@@ -162,16 +214,30 @@ The result will look similar to:
162214
`ingest` - if set, the result will contain details about the available
163215
processors per node:
164216

165-
* `type`: the processor type
217+
[source,js]
218+
--------------------------------------------------
219+
GET /_nodes/ingest
220+
--------------------------------------------------
221+
// CONSOLE
222+
// TEST[setup:node]
166223

167224
The result will look similar to:
168225

169226
[source,js]
170227
--------------------------------------------------
171228
{
229+
"_nodes": ...
172230
"cluster_name": "elasticsearch",
173231
"nodes": {
174-
"O70_wBv6S9aPPcAKdSUBtw": {
232+
"USpTGYaBSIKbgSUJR2Z9lg": {
233+
"name": "node-0",
234+
"transport_address": "192.168.17:9300",
235+
"host": "node-0.elastic.co",
236+
"ip": "192.168.17",
237+
"version": "{version}",
238+
"build_hash": "587409e",
239+
"roles": [],
240+
"attributes": {},
175241
"ingest": {
176242
"processors": [
177243
{
@@ -221,4 +287,19 @@ The result will look similar to:
221287
}
222288
}
223289
}
224-
--------------------------------------------------
290+
--------------------------------------------------
291+
// TESTRESPONSE[s/"_nodes": \.\.\./"_nodes": $body.$_path,/]
292+
// TESTRESPONSE[s/"elasticsearch"/$body.cluster_name/]
293+
// TESTRESPONSE[s/"USpTGYaBSIKbgSUJR2Z9lg"/\$node_name/]
294+
// TESTRESPONSE[s/"name": "node-0"/"name": $body.$_path/]
295+
// TESTRESPONSE[s/"transport_address": "192.168.17:9300"/"transport_address": $body.$_path/]
296+
// TESTRESPONSE[s/"host": "node-0.elastic.co"/"host": $body.$_path/]
297+
// TESTRESPONSE[s/"ip": "192.168.17"/"ip": $body.$_path/]
298+
// TESTRESPONSE[s/"build_hash": "587409e"/"build_hash": $body.$_path/]
299+
// TESTRESPONSE[s/"roles": \[[^\]]*\]/"roles": $body.$_path/]
300+
// TESTRESPONSE[s/"attributes": \{[^\}]*\}/"attributes": $body.$_path/]
301+
// TESTRESPONSE[s/"processors": \[[^\]]*\]/"processors": $body.$_path/]
302+
303+
The following information are available for each ingest processor:
304+
305+
* `type`: the processor type

docs/reference/cluster/state.asciidoc

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ the whole cluster.
66

77
[source,js]
88
--------------------------------------------------
9-
$ curl -XGET 'http://localhost:9200/_cluster/state'
9+
GET /_cluster/state
1010
--------------------------------------------------
11+
// CONSOLE
1112

1213
The response provides the cluster name, the total compressed size
1314
of the cluster state (its size when serialized for transmission over
@@ -27,8 +28,9 @@ it is possible to filter the cluster state response specifying the parts in the
2728

2829
[source,js]
2930
--------------------------------------------------
30-
$ curl -XGET 'http://localhost:9200/_cluster/state/{metrics}/{indices}'
31+
GET /_cluster/state/{metrics}/{indices}
3132
--------------------------------------------------
33+
// CONSOLE
3234

3335
`metrics` can be a comma-separated list of
3436

@@ -50,17 +52,27 @@ $ curl -XGET 'http://localhost:9200/_cluster/state/{metrics}/{indices}'
5052
`blocks`::
5153
Shows the `blocks` part of the response
5254

53-
A couple of example calls:
55+
The following example returns only `metadata` and `routing_table` data for the `foo` and `bar` indices:
5456

5557
[source,js]
5658
--------------------------------------------------
57-
# return only metadata and routing_table data for specified indices
58-
$ curl -XGET 'http://localhost:9200/_cluster/state/metadata,routing_table/foo,bar'
59+
GET /_cluster/state/metadata,routing_table/foo,bar
60+
--------------------------------------------------
61+
// CONSOLE
62+
63+
The next example returns everything for the `foo` and `bar` indices:
5964

60-
# return everything for these two indices
61-
$ curl -XGET 'http://localhost:9200/_cluster/state/_all/foo,bar'
65+
[source,js]
66+
--------------------------------------------------
67+
GET /_cluster/state/_all/foo,bar
68+
--------------------------------------------------
69+
// CONSOLE
6270

63-
# Return only blocks data
64-
$ curl -XGET 'http://localhost:9200/_cluster/state/blocks'
71+
And this example return only `blocks` data:
72+
[source,js]
6573
--------------------------------------------------
74+
GET /_cluster/state/blocks
75+
--------------------------------------------------
76+
// CONSOLE
77+
6678

docs/reference/cluster/stats.asciidoc

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,28 @@ versions, memory usage, cpu and installed plugins).
88

99
[source,js]
1010
--------------------------------------------------
11-
curl -XGET 'http://localhost:9200/_cluster/stats?human&pretty'
11+
GET /_cluster/stats?human&pretty
1212
--------------------------------------------------
13+
// CONSOLE
14+
// TEST[setup:twitter]
1315

1416
Will return, for example:
1517
["source","js",subs="attributes,callouts"]
1618
--------------------------------------------------
1719
{
18-
"timestamp": 1459427693515,
20+
"_nodes" : {
21+
"total" : 1,
22+
"successful" : 1,
23+
"failed" : 0
24+
},
1925
"cluster_name": "elasticsearch",
26+
"timestamp": 1459427693515,
2027
"status": "green",
2128
"indices": {
22-
"count": 2,
29+
"count": 1,
2330
"shards": {
24-
"total": 10,
25-
"primaries": 10,
31+
"total": 5,
32+
"primaries": 5,
2633
"replication": 0,
2734
"index": {
2835
"shards": {
@@ -48,9 +55,7 @@ Will return, for example:
4855
},
4956
"store": {
5057
"size": "16.2kb",
51-
"size_in_bytes": 16684,
52-
"throttle_time": "0s",
53-
"throttle_time_in_millis": 0
58+
"size_in_bytes": 16684
5459
},
5560
"fielddata": {
5661
"memory_size": "0b",
@@ -83,6 +88,8 @@ Will return, for example:
8388
"term_vectors_memory_in_bytes": 0,
8489
"norms_memory": "384b",
8590
"norms_memory_in_bytes": 384,
91+
"points_memory" : "0b",
92+
"points_memory_in_bytes" : 0,
8693
"doc_values_memory": "744b",
8794
"doc_values_memory_in_bytes": 744,
8895
"index_writer_memory": "0b",
@@ -91,10 +98,8 @@ Will return, for example:
9198
"version_map_memory_in_bytes": 0,
9299
"fixed_bit_set": "0b",
93100
"fixed_bit_set_memory_in_bytes": 0,
101+
"max_unsafe_auto_id_timestamp" : -9223372036854775808,
94102
"file_sizes": {}
95-
},
96-
"percolator": {
97-
"num_queries": 0
98103
}
99104
},
100105
"nodes": {
@@ -188,8 +193,22 @@ Will return, for example:
188193
"classname": "org.elasticsearch.ingest.useragent.IngestUserAgentPlugin",
189194
"has_native_controller": false
190195
}
191-
]
196+
],
197+
"network_types" : {
198+
"transport_types" : {
199+
"netty4" : 1
200+
},
201+
"http_types" : {
202+
"netty4" : 1
203+
}
204+
}
192205
}
193206
}
194207
--------------------------------------------------
195-
208+
// TESTRESPONSE[s/"plugins": \[[^\]]*\]/"plugins": $body.$_path/]
209+
// TESTRESPONSE[s/: (\-)?[0-9]+/: $body.$_path/]
210+
// TESTRESPONSE[s/: "[^"]*"/: $body.$_path/]
211+
////
212+
The TESTRESPONSE above replace all the fields values by the expected ones in the test,
213+
because we don't really care about the field values but we want to check the fields names.
214+
////

0 commit comments

Comments
 (0)