Skip to content

Commit d11770b

Browse files
committed
Docs: Use the default distribution to test docs (#31251)
This switches the docs tests from the `oss-zip` distribution to the `zip` distribution so they have xpack installed and configured with the default basic license. The goal is to be able to merge the `x-pack/docs` directory into the `docs` directory, marking the x-pack docs with some kind of marker. This is the first step in that process. This also enables `-Dtests.distribution` support for the `docs` directory so you can run the tests against the `oss-zip` distribution with something like ``` ./gradlew -p docs check -Dtests.distribution=oss-zip ``` We can set up Jenkins to run both. Relates to #30665
1 parent d37ffb6 commit d11770b

File tree

10 files changed

+66
-32
lines changed

10 files changed

+66
-32
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public class DocsTestPlugin extends RestTestPlugin {
3232
public void apply(Project project) {
3333
project.pluginManager.apply('elasticsearch.standalone-rest-test')
3434
super.apply(project)
35+
// The distribution can be configured with -Dtests.distribution on the command line
36+
project.integTestCluster.distribution = System.getProperty('tests.distribution', 'zip')
3537
// Docs are published separately so no need to assemble
3638
project.tasks.remove(project.assemble)
3739
project.build.dependsOn.remove('assemble')
@@ -43,6 +45,8 @@ public class DocsTestPlugin extends RestTestPlugin {
4345
'\\{version\\}':
4446
VersionProperties.elasticsearch.toString().replace('-SNAPSHOT', ''),
4547
'\\{lucene_version\\}' : VersionProperties.lucene.replaceAll('-snapshot-\\w+$', ''),
48+
'\\{build_flavor\\}' :
49+
project.integTestCluster.distribution.startsWith('oss-') ? 'oss' : 'default',
4650
]
4751
Task listSnippets = project.tasks.create('listSnippets', SnippetsTask)
4852
listSnippets.group 'Docs'

docs/Versions.asciidoc

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
:branch: 6.3
66
:jdk: 1.8.0_131
77
:jdk_major: 8
8+
:build_flavor: default
89

910
//////////
1011
release-state can be: released | prerelease | unreleased

docs/build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
apply plugin: 'elasticsearch.docs-test'
2121

2222
integTestCluster {
23-
distribution = 'oss-zip'
2423
/* Enable regexes in painless so our tests don't complain about example
2524
* snippets that use them. */
2625
setting 'script.painless.regex.enabled', 'true'

docs/plugins/discovery-azure-classic.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ This command should give you a JSON result:
372372
"cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",
373373
"version" : {
374374
"number" : "{version}",
375-
"build_flavor" : "oss",
375+
"build_flavor" : "{build_flavor}",
376376
"build_type" : "zip",
377377
"build_hash" : "f27399d",
378378
"build_date" : "2016-03-30T09:51:41.449Z",

docs/reference/cat/nodeattrs.asciidoc

+21-4
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,23 @@ For example:
99
GET /_cat/nodeattrs?v
1010
--------------------------------------------------
1111
// CONSOLE
12+
// TEST[s/\?v/\?v&s=node,attr/]
13+
// Sort the resulting attributes so we can assert on them more easilly
1214

1315
Could look like:
1416

1517
[source,txt]
1618
--------------------------------------------------
1719
node host ip attr value
18-
EK_AsJb 127.0.0.1 127.0.0.1 testattr test
20+
...
21+
node-0 127.0.0.1 127.0.0.1 testattr test
22+
...
1923
--------------------------------------------------
20-
// TESTRESPONSE[s/EK_AsJb/.+/ _cat]
24+
// TESTRESPONSE[s/\.\.\.\n$/\n(.+ xpack\\.installed true\n)?\n/]
25+
// TESTRESPONSE[s/\.\.\.\n/(.+ ml\\..+\n)*/ _cat]
26+
// If xpack is not installed then neither ... with match anything
27+
// If xpack is installed then the first ... contains ml attributes
28+
// and the second contains xpack.installed=true
2129

2230
The first few columns (`node`, `host`, `ip`) give you basic info per node
2331
and the `attr` and `value` columns give you the custom node attributes,
@@ -46,15 +54,24 @@ mode (`v`). The header name will match the supplied value (e.g.,
4654
GET /_cat/nodeattrs?v&h=name,pid,attr,value
4755
--------------------------------------------------
4856
// CONSOLE
57+
// TEST[s/,value/,value&s=node,attr/]
58+
// Sort the resulting attributes so we can assert on them more easilly
4959

5060
Might look like:
5161

5262
[source,txt]
5363
--------------------------------------------------
5464
name pid attr value
55-
EK_AsJb 19566 testattr test
65+
...
66+
node-0 19566 testattr test
67+
...
5668
--------------------------------------------------
57-
// TESTRESPONSE[s/EK_AsJb/.+/ s/19566/\\d*/ _cat]
69+
// TESTRESPONSE[s/19566/\\d*/]
70+
// TESTRESPONSE[s/\.\.\.\n$/\n(.+ xpack\\.installed true\n)?\n/]
71+
// TESTRESPONSE[s/\.\.\.\n/(.+ ml\\..+\n)*/ _cat]
72+
// If xpack is not installed then neither ... with match anything
73+
// If xpack is installed then the first ... contains ml attributes
74+
// and the second contains xpack.installed=true
5875

5976
[cols="<,<,<,<,<",options="header",subs="normal"]
6077
|=======================================================================

docs/reference/cat/templates.asciidoc

+7
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@ The `templates` command provides information about existing templates.
88
GET /_cat/templates?v&s=name
99
--------------------------------------------------
1010
// CONSOLE
11+
// TEST[s/templates/templates\/template*/]
1112
// TEST[s/^/PUT _template\/template0\n{"index_patterns": "te*", "order": 0}\n/]
1213
// TEST[s/^/PUT _template\/template1\n{"index_patterns": "tea*", "order": 1}\n/]
1314
// TEST[s/^/PUT _template\/template2\n{"index_patterns": "teak*", "order": 2, "version": 7}\n/]
15+
// The substitions do two things:
16+
// 1. Filter the response to just templates matching the te* pattern
17+
// so that we only get the templates we expect regardless of which
18+
// templates exist. If xpack is installed there will be unexpected
19+
// templates.
20+
// 2. Create some templates to expect in the response.
1421

1522
which looks like
1623

docs/reference/cat/thread_pool.asciidoc

+16-10
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ node-0 analyze 0 0 0
1818
node-0 fetch_shard_started 0 0 0
1919
node-0 fetch_shard_store 0 0 0
2020
node-0 flush 0 0 0
21-
node-0 force_merge 0 0 0
22-
node-0 generic 0 0 0
23-
node-0 get 0 0 0
24-
node-0 index 0 0 0
25-
node-0 listener 0 0 0
26-
node-0 management 1 0 0
27-
node-0 refresh 0 0 0
28-
node-0 search 0 0 0
29-
node-0 snapshot 0 0 0
30-
node-0 warmer 0 0 0
21+
...
3122
node-0 write 0 0 0
3223
--------------------------------------------------
24+
// TESTRESPONSE[s/\.\.\./(node-0 .+ 0 0 0\n)+/]
3325
// TESTRESPONSE[s/\d+/\\d+/ _cat]
26+
// The substitutions do two things:
27+
// 1. Expect any number of extra thread pools. This allows us to only list a
28+
// few thread pools. The list would be super long otherwise. In addition,
29+
// if xpack is installed then the list will contain more thread pools and
30+
// this way we don't have to assert about them.
31+
// 2. Expect any number of active, queued, or rejected items. We really don't
32+
// know how many there will be and we just want to assert that there are
33+
// numbers in the response, not *which* numbers are there.
3434

3535
The first column is the node name
3636

@@ -54,10 +54,16 @@ get
5454
index
5555
listener
5656
management
57+
ml_autodetect (default distro only)
58+
ml_datafeed (default distro only)
59+
ml_utility (default distro only)
5760
refresh
61+
rollup_indexing (default distro only)`
5862
search
63+
security-token-key (default distro only)
5964
snapshot
6065
warmer
66+
watcher (default distro only)
6167
write
6268
--------------------------------------------------
6369

docs/reference/cluster/nodes-info.asciidoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ The result will look similar to:
142142
"host": "node-0.elastic.co",
143143
"ip": "192.168.17",
144144
"version": "{version}",
145-
"build_flavor": "oss",
145+
"build_flavor": "{build_flavor}",
146146
"build_type": "zip",
147147
"build_hash": "587409e",
148148
"roles": [
@@ -237,7 +237,7 @@ The result will look similar to:
237237
"host": "node-0.elastic.co",
238238
"ip": "192.168.17",
239239
"version": "{version}",
240-
"build_flavor": "oss",
240+
"build_flavor": "{build_flavor}",
241241
"build_type": "zip",
242242
"build_hash": "587409e",
243243
"roles": [],

docs/reference/cluster/stats.asciidoc

+13-13
Original file line numberDiff line numberDiff line change
@@ -192,23 +192,23 @@ Will return, for example:
192192
"description": "Ingest processor that extracts information from a user agent",
193193
"classname": "org.elasticsearch.ingest.useragent.IngestUserAgentPlugin",
194194
"has_native_controller": false
195-
}
195+
},
196+
...
196197
],
197-
"network_types" : {
198-
"transport_types" : {
199-
"netty4" : 1
200-
},
201-
"http_types" : {
202-
"netty4" : 1
203-
}
204-
}
198+
...
205199
}
206200
}
207201
--------------------------------------------------
208202
// TESTRESPONSE[s/"plugins": \[[^\]]*\]/"plugins": $body.$_path/]
203+
// TESTRESPONSE[s/\.\.\./"network_types": "replace_me"/]
209204
// TESTRESPONSE[s/: (\-)?[0-9]+/: $body.$_path/]
210205
// 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-
////
206+
// These replacements do a few things:
207+
// 1. Ignore the contents of the `plugins` object because we don't know all of
208+
// the plugins that will be in it. And because we figure folks don't need to
209+
// see an exhaustive list anyway.
210+
// 2. The last ... contains more things that we don't think are important to
211+
// include in the output.
212+
// 3. All of the numbers and strings on the right hand side of *every* field in
213+
// the response are ignored. So we're really only asserting things about the
214+
// the shape of this response, not the values in it.

docs/reference/setup/install/check-running.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ which should give you a response something like this:
1919
"cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",
2020
"version" : {
2121
"number" : "{version}",
22-
"build_flavor" : "oss",
22+
"build_flavor" : "{build_flavor}",
2323
"build_type" : "zip",
2424
"build_hash" : "f27399d",
2525
"build_date" : "2016-03-30T09:51:41.449Z",

0 commit comments

Comments
 (0)