From 34eef6aa56eaacb03e58a1ba30be8e16d6c3609e Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Tue, 5 Jun 2018 08:03:21 -0400 Subject: [PATCH 1/9] Docs: Test snippets against default distro 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 --- .../gradle/doc/DocsTestPlugin.groovy | 4 ++++ docs/Versions.asciidoc | 1 + docs/build.gradle | 7 ++++++- docs/reference/cat/nodeattrs.asciidoc | 7 +++++-- docs/reference/cat/thread_pool.asciidoc | 17 ++++++++--------- docs/reference/cluster/nodes-info.asciidoc | 2 +- docs/reference/cluster/stats.asciidoc | 15 +++++---------- .../setup/install/check-running.asciidoc | 2 +- 8 files changed, 31 insertions(+), 24 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy index f674dbd33cdfd..27f122b8610ee 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy @@ -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' diff --git a/docs/Versions.asciidoc b/docs/Versions.asciidoc index 608d5b9288e6e..948a3387f0350 100644 --- a/docs/Versions.asciidoc +++ b/docs/Versions.asciidoc @@ -5,6 +5,7 @@ :branch: master :jdk: 1.8.0_131 :jdk_major: 8 +:build_flavor: default ////////// release-state can be: released | prerelease | unreleased diff --git a/docs/build.gradle b/docs/build.gradle index 6498de0218120..8ec918cb12538 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -17,10 +17,15 @@ * under the License. */ +import org.elasticsearch.gradle.doc.SnippetsTask + apply plugin: 'elasticsearch.docs-test' +// tasks.withType(SnippetsTask.class) { +// defaultSubstitutions[''] +// } + 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' diff --git a/docs/reference/cat/nodeattrs.asciidoc b/docs/reference/cat/nodeattrs.asciidoc index 196f142cc35e1..b095799701a4e 100644 --- a/docs/reference/cat/nodeattrs.asciidoc +++ b/docs/reference/cat/nodeattrs.asciidoc @@ -9,6 +9,7 @@ For example: GET /_cat/nodeattrs?v -------------------------------------------------- // CONSOLE +// TEST[s/\?v/\?v&s=node,attr/] Could look like: @@ -17,7 +18,7 @@ Could look like: node host ip attr value EK_AsJb 127.0.0.1 127.0.0.1 testattr test -------------------------------------------------- -// TESTRESPONSE[s/EK_AsJb/.+/ _cat] +// TESTRESPONSE[s/EK_AsJb/(.+ml\\..+\n)*.+/ s/\n$/\n(.+xpack\\.installed true\n)?\n/ _cat] 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,6 +47,7 @@ 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/] Might look like: @@ -54,7 +56,8 @@ Might look like: name pid attr value EK_AsJb 19566 testattr test -------------------------------------------------- -// TESTRESPONSE[s/EK_AsJb/.+/ s/19566/\\d*/ _cat] +// TESTRESPONSE[s/19566/\\d*/] +// TESTRESPONSE[s/EK_AsJb/(.+ml\\..+\n)*.+/ s/\n$/\n(.+xpack\\.installed true\n)?\n/ _cat] [cols="<,<,<,<,<",options="header",subs="normal"] |======================================================================= diff --git a/docs/reference/cat/thread_pool.asciidoc b/docs/reference/cat/thread_pool.asciidoc index 306650feb958b..d19d58c2a3517 100644 --- a/docs/reference/cat/thread_pool.asciidoc +++ b/docs/reference/cat/thread_pool.asciidoc @@ -18,17 +18,10 @@ 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 first column is the node name @@ -52,10 +45,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 -------------------------------------------------- diff --git a/docs/reference/cluster/nodes-info.asciidoc b/docs/reference/cluster/nodes-info.asciidoc index 6522d0f5ad68a..c2156babde286 100644 --- a/docs/reference/cluster/nodes-info.asciidoc +++ b/docs/reference/cluster/nodes-info.asciidoc @@ -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": [ diff --git a/docs/reference/cluster/stats.asciidoc b/docs/reference/cluster/stats.asciidoc index 6efb4dced8bb8..862a2189dd43f 100644 --- a/docs/reference/cluster/stats.asciidoc +++ b/docs/reference/cluster/stats.asciidoc @@ -192,23 +192,18 @@ 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/: (\-)?[0-9]+/: $body.$_path/] +// TESTRESPONSE[s/\.\.\./"network_types": "replace_me"/] // 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. -//// \ No newline at end of file +//// diff --git a/docs/reference/setup/install/check-running.asciidoc b/docs/reference/setup/install/check-running.asciidoc index 0cfc4b329ecfa..7b95a10158d2f 100644 --- a/docs/reference/setup/install/check-running.asciidoc +++ b/docs/reference/setup/install/check-running.asciidoc @@ -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", From 18a77a05cb0c6b7bccf0d104aed1096c8c90b535 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Mon, 11 Jun 2018 14:03:15 -0400 Subject: [PATCH 2/9] Docs: Use the default distribution for docs tests This will allow us to merge xpack docs into the regular docs directory! Relates to #30665 --- docs/plugins/discovery-azure-classic.asciidoc | 2 +- docs/reference/cat/nodeattrs.asciidoc | 6 ++++-- docs/reference/cat/templates.asciidoc | 4 +++- docs/reference/cluster/nodes-info.asciidoc | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/plugins/discovery-azure-classic.asciidoc b/docs/plugins/discovery-azure-classic.asciidoc index c56991b8f507f..a7f8993fb46de 100644 --- a/docs/plugins/discovery-azure-classic.asciidoc +++ b/docs/plugins/discovery-azure-classic.asciidoc @@ -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" : "{distribution}", "build_type" : "zip", "build_hash" : "f27399d", "build_date" : "2016-03-30T09:51:41.449Z", diff --git a/docs/reference/cat/nodeattrs.asciidoc b/docs/reference/cat/nodeattrs.asciidoc index b095799701a4e..5a6db6a25ae21 100644 --- a/docs/reference/cat/nodeattrs.asciidoc +++ b/docs/reference/cat/nodeattrs.asciidoc @@ -16,9 +16,11 @@ 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/(.+ml\\..+\n)*.+/ s/\n$/\n(.+xpack\\.installed true\n)?\n/ _cat] +// TESTRESPONSE[s/\.\.\.\n$/\n(.+ xpack\\.installed true\n)?\n/ s/\.\.\.\n/(.+ ml\\..+\n)*/ _cat] 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, diff --git a/docs/reference/cat/templates.asciidoc b/docs/reference/cat/templates.asciidoc index bc221d13552c0..9332168666801 100644 --- a/docs/reference/cat/templates.asciidoc +++ b/docs/reference/cat/templates.asciidoc @@ -17,11 +17,13 @@ which looks like [source,txt] -------------------------------------------------- name index_patterns order version +... template0 [te*] 0 template1 [tea*] 1 template2 [teak*] 2 7 -------------------------------------------------- -// TESTRESPONSE[s/\*/\\*/ s/\[/\\[/ s/\]/\\]/ _cat] +// TESTRESPONSE[s/\*/\\*/ s/\[/\\[/ s/\]/\\]/] +// TESTRESPONSE[s/\.\.\.\n/(.+\n)*/ _cat] The output shows that there are three existing templates, with template2 having a version value. diff --git a/docs/reference/cluster/nodes-info.asciidoc b/docs/reference/cluster/nodes-info.asciidoc index c2156babde286..967ca19eacffe 100644 --- a/docs/reference/cluster/nodes-info.asciidoc +++ b/docs/reference/cluster/nodes-info.asciidoc @@ -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": "{distribution}", "build_type": "zip", "build_hash": "587409e", "roles": [], From cfba4babd060c67948ae4dd3d03f4d13235ac4fb Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Mon, 11 Jun 2018 14:16:47 -0400 Subject: [PATCH 3/9] Fix distribution --- docs/plugins/discovery-azure-classic.asciidoc | 2 +- docs/reference/cluster/nodes-info.asciidoc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/plugins/discovery-azure-classic.asciidoc b/docs/plugins/discovery-azure-classic.asciidoc index a7f8993fb46de..1c1925de878aa 100644 --- a/docs/plugins/discovery-azure-classic.asciidoc +++ b/docs/plugins/discovery-azure-classic.asciidoc @@ -372,7 +372,7 @@ This command should give you a JSON result: "cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA", "version" : { "number" : "{version}", - "build_flavor" : "{distribution}", + "build_flavor" : "{build_flavor}", "build_type" : "zip", "build_hash" : "f27399d", "build_date" : "2016-03-30T09:51:41.449Z", diff --git a/docs/reference/cluster/nodes-info.asciidoc b/docs/reference/cluster/nodes-info.asciidoc index 967ca19eacffe..2cd61dd905ff6 100644 --- a/docs/reference/cluster/nodes-info.asciidoc +++ b/docs/reference/cluster/nodes-info.asciidoc @@ -237,7 +237,7 @@ The result will look similar to: "host": "node-0.elastic.co", "ip": "192.168.17", "version": "{version}", - "build_flavor": "{distribution}", + "build_flavor": "{build_flavor}", "build_type": "zip", "build_hash": "587409e", "roles": [], From 567996e02466a817473ae42f0c0f446a670b26ab Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Mon, 11 Jun 2018 14:34:35 -0400 Subject: [PATCH 4/9] Revert extra --- docs/build.gradle | 6 ------ 1 file changed, 6 deletions(-) diff --git a/docs/build.gradle b/docs/build.gradle index 8ec918cb12538..f1d1324192b16 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -17,14 +17,8 @@ * under the License. */ -import org.elasticsearch.gradle.doc.SnippetsTask - apply plugin: 'elasticsearch.docs-test' -// tasks.withType(SnippetsTask.class) { -// defaultSubstitutions[''] -// } - integTestCluster { /* Enable regexes in painless so our tests don't complain about example * snippets that use them. */ From a416fd4dd609ab2a8d601f8db7cb37e27f8c8bf4 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Tue, 12 Jun 2018 09:01:21 -0400 Subject: [PATCH 5/9] Increase timeout --- .../elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java b/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java index 02bc304317e68..ba2c7f5fbd6fc 100644 --- a/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java +++ b/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java @@ -21,9 +21,12 @@ import org.apache.http.HttpHost; import org.apache.lucene.util.BytesRef; +import org.apache.lucene.util.TimeUnits; import com.carrotsearch.randomizedtesting.annotations.Name; import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; +import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite; + import org.elasticsearch.Version; import org.elasticsearch.client.RestClient; import org.elasticsearch.common.ParseField; @@ -54,6 +57,7 @@ import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; +@TimeoutSuite(millis = 30 * TimeUnits.MINUTE) // as default timeout seems not enough on the jenkins VMs public class DocsClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { public DocsClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) { From 588864e176d8203c80734d51f7425be166238384 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Tue, 12 Jun 2018 11:51:29 -0400 Subject: [PATCH 6/9] Filter out xpack templates --- docs/reference/cat/templates.asciidoc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/reference/cat/templates.asciidoc b/docs/reference/cat/templates.asciidoc index 9332168666801..8b8d6b000ab75 100644 --- a/docs/reference/cat/templates.asciidoc +++ b/docs/reference/cat/templates.asciidoc @@ -8,6 +8,7 @@ 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/] @@ -17,13 +18,11 @@ which looks like [source,txt] -------------------------------------------------- name index_patterns order version -... template0 [te*] 0 template1 [tea*] 1 template2 [teak*] 2 7 -------------------------------------------------- -// TESTRESPONSE[s/\*/\\*/ s/\[/\\[/ s/\]/\\]/] -// TESTRESPONSE[s/\.\.\.\n/(.+\n)*/ _cat] +// TESTRESPONSE[s/\*/\\*/ s/\[/\\[/ s/\]/\\]/ _cat] The output shows that there are three existing templates, with template2 having a version value. From 038a99b8fadf9d90a91ef40de714f417ffe3baa2 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Tue, 12 Jun 2018 11:52:03 -0400 Subject: [PATCH 7/9] Drop extra timeout --- .../org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java b/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java index ba2c7f5fbd6fc..d95f863c89c14 100644 --- a/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java +++ b/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java @@ -21,11 +21,9 @@ import org.apache.http.HttpHost; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.TimeUnits; import com.carrotsearch.randomizedtesting.annotations.Name; import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; -import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite; import org.elasticsearch.Version; import org.elasticsearch.client.RestClient; @@ -57,7 +55,6 @@ import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; -@TimeoutSuite(millis = 30 * TimeUnits.MINUTE) // as default timeout seems not enough on the jenkins VMs public class DocsClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { public DocsClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) { From 6eab823bfb99c4c11ba2b9010d1e22b88a297cde Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Wed, 13 Jun 2018 13:18:46 -0400 Subject: [PATCH 8/9] Remove extra newline --- .../org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java b/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java index d95f863c89c14..02bc304317e68 100644 --- a/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java +++ b/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java @@ -24,7 +24,6 @@ import com.carrotsearch.randomizedtesting.annotations.Name; import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; - import org.elasticsearch.Version; import org.elasticsearch.client.RestClient; import org.elasticsearch.common.ParseField; From 1b402d37afabe12a30159a90485a6a07573a0a01 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 14 Jun 2018 16:07:25 -0400 Subject: [PATCH 9/9] Document funky subs --- docs/reference/cat/nodeattrs.asciidoc | 18 +++++++++++++++--- docs/reference/cat/templates.asciidoc | 6 ++++++ docs/reference/cat/thread_pool.asciidoc | 8 ++++++++ docs/reference/cluster/stats.asciidoc | 15 ++++++++++----- 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/docs/reference/cat/nodeattrs.asciidoc b/docs/reference/cat/nodeattrs.asciidoc index 5a6db6a25ae21..6c474c2117943 100644 --- a/docs/reference/cat/nodeattrs.asciidoc +++ b/docs/reference/cat/nodeattrs.asciidoc @@ -10,6 +10,7 @@ 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: @@ -20,7 +21,11 @@ node host ip attr value node-0 127.0.0.1 127.0.0.1 testattr test ... -------------------------------------------------- -// TESTRESPONSE[s/\.\.\.\n$/\n(.+ xpack\\.installed true\n)?\n/ s/\.\.\.\n/(.+ ml\\..+\n)*/ _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, @@ -50,16 +55,23 @@ 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/19566/\\d*/] -// TESTRESPONSE[s/EK_AsJb/(.+ml\\..+\n)*.+/ s/\n$/\n(.+xpack\\.installed true\n)?\n/ _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 [cols="<,<,<,<,<",options="header",subs="normal"] |======================================================================= diff --git a/docs/reference/cat/templates.asciidoc b/docs/reference/cat/templates.asciidoc index 8b8d6b000ab75..076e84b72b5d3 100644 --- a/docs/reference/cat/templates.asciidoc +++ b/docs/reference/cat/templates.asciidoc @@ -12,6 +12,12 @@ GET /_cat/templates?v&s=name // 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 diff --git a/docs/reference/cat/thread_pool.asciidoc b/docs/reference/cat/thread_pool.asciidoc index d19d58c2a3517..9528b7829e37f 100644 --- a/docs/reference/cat/thread_pool.asciidoc +++ b/docs/reference/cat/thread_pool.asciidoc @@ -23,6 +23,14 @@ 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 diff --git a/docs/reference/cluster/stats.asciidoc b/docs/reference/cluster/stats.asciidoc index 862a2189dd43f..191da2660d668 100644 --- a/docs/reference/cluster/stats.asciidoc +++ b/docs/reference/cluster/stats.asciidoc @@ -200,10 +200,15 @@ Will return, for example: } -------------------------------------------------- // TESTRESPONSE[s/"plugins": \[[^\]]*\]/"plugins": $body.$_path/] -// TESTRESPONSE[s/: (\-)?[0-9]+/: $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.