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
This commit is contained in:
parent
ea92864eb1
commit
73549281e8
buildSrc/src/main/groovy/org/elasticsearch/gradle/doc
docs
|
@ -32,6 +32,8 @@ public class DocsTestPlugin extends RestTestPlugin {
|
|||
public void apply(Project project) {
|
||||
project.pluginManager.apply('elasticsearch.standalone-rest-test')
|
||||
super.apply(project)
|
||||
// The distribution can be configured with -Dtests.distribution on the command line
|
||||
project.integTestCluster.distribution = System.getProperty('tests.distribution', 'zip')
|
||||
// Docs are published separately so no need to assemble
|
||||
project.tasks.remove(project.assemble)
|
||||
project.build.dependsOn.remove('assemble')
|
||||
|
@ -43,6 +45,8 @@ public class DocsTestPlugin extends RestTestPlugin {
|
|||
'\\{version\\}':
|
||||
VersionProperties.elasticsearch.toString().replace('-SNAPSHOT', ''),
|
||||
'\\{lucene_version\\}' : VersionProperties.lucene.replaceAll('-snapshot-\\w+$', ''),
|
||||
'\\{build_flavor\\}' :
|
||||
project.integTestCluster.distribution.startsWith('oss-') ? 'oss' : 'default',
|
||||
]
|
||||
Task listSnippets = project.tasks.create('listSnippets', SnippetsTask)
|
||||
listSnippets.group 'Docs'
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
:branch: master
|
||||
:jdk: 1.8.0_131
|
||||
:jdk_major: 8
|
||||
:build_flavor: default
|
||||
|
||||
//////////
|
||||
release-state can be: released | prerelease | unreleased
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
apply plugin: 'elasticsearch.docs-test'
|
||||
|
||||
integTestCluster {
|
||||
distribution = 'oss-zip'
|
||||
/* Enable regexes in painless so our tests don't complain about example
|
||||
* snippets that use them. */
|
||||
setting 'script.painless.regex.enabled', 'true'
|
||||
|
|
|
@ -372,7 +372,7 @@ This command should give you a JSON result:
|
|||
"cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",
|
||||
"version" : {
|
||||
"number" : "{version}",
|
||||
"build_flavor" : "oss",
|
||||
"build_flavor" : "{build_flavor}",
|
||||
"build_type" : "zip",
|
||||
"build_hash" : "f27399d",
|
||||
"build_date" : "2016-03-30T09:51:41.449Z",
|
||||
|
|
|
@ -9,15 +9,23 @@ For example:
|
|||
GET /_cat/nodeattrs?v
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[s/\?v/\?v&s=node,attr/]
|
||||
// Sort the resulting attributes so we can assert on them more easilly
|
||||
|
||||
Could look like:
|
||||
|
||||
[source,txt]
|
||||
--------------------------------------------------
|
||||
node host ip attr value
|
||||
EK_AsJb 127.0.0.1 127.0.0.1 testattr test
|
||||
...
|
||||
node-0 127.0.0.1 127.0.0.1 testattr test
|
||||
...
|
||||
--------------------------------------------------
|
||||
// TESTRESPONSE[s/EK_AsJb/.+/ _cat]
|
||||
// TESTRESPONSE[s/\.\.\.\n$/\n(.+ xpack\\.installed true\n)?\n/]
|
||||
// TESTRESPONSE[s/\.\.\.\n/(.+ ml\\..+\n)*/ _cat]
|
||||
// If xpack is not installed then neither ... with match anything
|
||||
// If xpack is installed then the first ... contains ml attributes
|
||||
// and the second contains xpack.installed=true
|
||||
|
||||
The first few columns (`node`, `host`, `ip`) give you basic info per node
|
||||
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.,
|
|||
GET /_cat/nodeattrs?v&h=name,pid,attr,value
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[s/,value/,value&s=node,attr/]
|
||||
// Sort the resulting attributes so we can assert on them more easilly
|
||||
|
||||
Might look like:
|
||||
|
||||
[source,txt]
|
||||
--------------------------------------------------
|
||||
name pid attr value
|
||||
EK_AsJb 19566 testattr test
|
||||
...
|
||||
node-0 19566 testattr test
|
||||
...
|
||||
--------------------------------------------------
|
||||
// TESTRESPONSE[s/EK_AsJb/.+/ s/19566/\\d*/ _cat]
|
||||
// TESTRESPONSE[s/19566/\\d*/]
|
||||
// TESTRESPONSE[s/\.\.\.\n$/\n(.+ xpack\\.installed true\n)?\n/]
|
||||
// TESTRESPONSE[s/\.\.\.\n/(.+ ml\\..+\n)*/ _cat]
|
||||
// If xpack is not installed then neither ... with match anything
|
||||
// If xpack is installed then the first ... contains ml attributes
|
||||
// and the second contains xpack.installed=true
|
||||
|
||||
[cols="<,<,<,<,<",options="header",subs="normal"]
|
||||
|=======================================================================
|
||||
|
|
|
@ -8,9 +8,16 @@ The `templates` command provides information about existing templates.
|
|||
GET /_cat/templates?v&s=name
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[s/templates/templates\/template*/]
|
||||
// TEST[s/^/PUT _template\/template0\n{"index_patterns": "te*", "order": 0}\n/]
|
||||
// TEST[s/^/PUT _template\/template1\n{"index_patterns": "tea*", "order": 1}\n/]
|
||||
// TEST[s/^/PUT _template\/template2\n{"index_patterns": "teak*", "order": 2, "version": 7}\n/]
|
||||
// The substitions do two things:
|
||||
// 1. Filter the response to just templates matching the te* pattern
|
||||
// so that we only get the templates we expect regardless of which
|
||||
// templates exist. If xpack is installed there will be unexpected
|
||||
// templates.
|
||||
// 2. Create some templates to expect in the response.
|
||||
|
||||
which looks like
|
||||
|
||||
|
|
|
@ -18,18 +18,19 @@ node-0 analyze 0 0 0
|
|||
node-0 fetch_shard_started 0 0 0
|
||||
node-0 fetch_shard_store 0 0 0
|
||||
node-0 flush 0 0 0
|
||||
node-0 force_merge 0 0 0
|
||||
node-0 generic 0 0 0
|
||||
node-0 get 0 0 0
|
||||
node-0 listener 0 0 0
|
||||
node-0 management 1 0 0
|
||||
node-0 refresh 0 0 0
|
||||
node-0 search 0 0 0
|
||||
node-0 snapshot 0 0 0
|
||||
node-0 warmer 0 0 0
|
||||
...
|
||||
node-0 write 0 0 0
|
||||
--------------------------------------------------
|
||||
// TESTRESPONSE[s/\.\.\./(node-0 .+ 0 0 0\n)+/]
|
||||
// TESTRESPONSE[s/\d+/\\d+/ _cat]
|
||||
// The substitutions do two things:
|
||||
// 1. Expect any number of extra thread pools. This allows us to only list a
|
||||
// few thread pools. The list would be super long otherwise. In addition,
|
||||
// if xpack is installed then the list will contain more thread pools and
|
||||
// this way we don't have to assert about them.
|
||||
// 2. Expect any number of active, queued, or rejected items. We really don't
|
||||
// know how many there will be and we just want to assert that there are
|
||||
// numbers in the response, not *which* numbers are there.
|
||||
|
||||
The first column is the node name
|
||||
|
||||
|
@ -52,10 +53,16 @@ generic
|
|||
get
|
||||
listener
|
||||
management
|
||||
ml_autodetect (default distro only)
|
||||
ml_datafeed (default distro only)
|
||||
ml_utility (default distro only)
|
||||
refresh
|
||||
rollup_indexing (default distro only)`
|
||||
search
|
||||
security-token-key (default distro only)
|
||||
snapshot
|
||||
warmer
|
||||
watcher (default distro only)
|
||||
write
|
||||
--------------------------------------------------
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ The result will look similar to:
|
|||
"host": "node-0.elastic.co",
|
||||
"ip": "192.168.17",
|
||||
"version": "{version}",
|
||||
"build_flavor": "oss",
|
||||
"build_flavor": "{build_flavor}",
|
||||
"build_type": "zip",
|
||||
"build_hash": "587409e",
|
||||
"roles": [
|
||||
|
@ -237,7 +237,7 @@ The result will look similar to:
|
|||
"host": "node-0.elastic.co",
|
||||
"ip": "192.168.17",
|
||||
"version": "{version}",
|
||||
"build_flavor": "oss",
|
||||
"build_flavor": "{build_flavor}",
|
||||
"build_type": "zip",
|
||||
"build_hash": "587409e",
|
||||
"roles": [],
|
||||
|
|
|
@ -192,23 +192,23 @@ Will return, for example:
|
|||
"description": "Ingest processor that extracts information from a user agent",
|
||||
"classname": "org.elasticsearch.ingest.useragent.IngestUserAgentPlugin",
|
||||
"has_native_controller": false
|
||||
}
|
||||
},
|
||||
...
|
||||
],
|
||||
"network_types" : {
|
||||
"transport_types" : {
|
||||
"netty4" : 1
|
||||
},
|
||||
"http_types" : {
|
||||
"netty4" : 1
|
||||
}
|
||||
}
|
||||
...
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// TESTRESPONSE[s/"plugins": \[[^\]]*\]/"plugins": $body.$_path/]
|
||||
// TESTRESPONSE[s/\.\.\./"network_types": "replace_me"/]
|
||||
// TESTRESPONSE[s/: (\-)?[0-9]+/: $body.$_path/]
|
||||
// TESTRESPONSE[s/: "[^"]*"/: $body.$_path/]
|
||||
////
|
||||
The TESTRESPONSE above replace all the fields values by the expected ones in the test,
|
||||
because we don't really care about the field values but we want to check the fields names.
|
||||
////
|
||||
// These replacements do a few things:
|
||||
// 1. Ignore the contents of the `plugins` object because we don't know all of
|
||||
// the plugins that will be in it. And because we figure folks don't need to
|
||||
// see an exhaustive list anyway.
|
||||
// 2. The last ... contains more things that we don't think are important to
|
||||
// include in the output.
|
||||
// 3. All of the numbers and strings on the right hand side of *every* field in
|
||||
// the response are ignored. So we're really only asserting things about the
|
||||
// the shape of this response, not the values in it.
|
||||
|
|
|
@ -19,7 +19,7 @@ which should give you a response something like this:
|
|||
"cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",
|
||||
"version" : {
|
||||
"number" : "{version}",
|
||||
"build_flavor" : "oss",
|
||||
"build_flavor" : "{build_flavor}",
|
||||
"build_type" : "zip",
|
||||
"build_hash" : "f27399d",
|
||||
"build_date" : "2016-03-30T09:51:41.449Z",
|
||||
|
|
Loading…
Reference in New Issue