Răsfoiți Sursa

Port gradle docs test plugin to use internal yaml rest test plugin (#86598)

Remove usage of deprecated elasticsearch.rest-test in DocsTestPlugin

we keep some files in src/test in docs projects as moving them would require more changes
in build-docs project outside this repository
Rene Groeschke 3 ani în urmă
părinte
comite
62d5aa986c

+ 6 - 6
build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/doc/DocsTestPlugin.groovy

@@ -10,6 +10,8 @@ package org.elasticsearch.gradle.internal.doc
 import org.elasticsearch.gradle.OS
 import org.elasticsearch.gradle.Version
 import org.elasticsearch.gradle.VersionProperties
+import org.elasticsearch.gradle.internal.test.rest.CopyRestApiTask
+import org.elasticsearch.gradle.internal.test.rest.CopyRestTestsTask
 import org.gradle.api.Plugin
 import org.gradle.api.Project
 import org.gradle.api.file.Directory
@@ -23,14 +25,12 @@ class DocsTestPlugin implements Plugin<Project> {
 
     @Override
     void apply(Project project) {
-        project.pluginManager.apply('elasticsearch.internal-testclusters')
-        project.pluginManager.apply('elasticsearch.standalone-rest-test')
-        project.pluginManager.apply('elasticsearch.rest-test')
+        project.pluginManager.apply('elasticsearch.internal-yaml-rest-test')
 
         String distribution = System.getProperty('tests.distribution', 'default')
         // The distribution can be configured with -Dtests.distribution on the command line
-        project.testClusters.matching { it.name.equals("integTest") }.configureEach { testDistribution = distribution.toUpperCase() }
-        project.testClusters.matching { it.name.equals("integTest") }.configureEach { nameCustomization = { it.replace("integTest", "node") } }
+        project.testClusters.matching { it.name.equals("yamlRestTest") }.configureEach { testDistribution = distribution.toUpperCase() }
+        project.testClusters.matching { it.name.equals("yamlRestTest") }.configureEach { nameCustomization = { it.replace("yamlRestTest", "node") } }
         // Docs are published separately so no need to assemble
         project.tasks.named("assemble").configure {enabled = false }
         Map<String, String> commonDefaultSubstitutions = [
@@ -72,6 +72,6 @@ class DocsTestPlugin implements Plugin<Project> {
         }
 
         // TODO: This effectively makes testRoot not customizable, which we don't do anyway atm
-        project.sourceSets.test.output.dir(restRootDir, builtBy: buildRestTests)
+        project.sourceSets.yamlRestTest.output.dir(restRootDir, builtBy: buildRestTests)
     }
 }

+ 1 - 1
docs/README.asciidoc

@@ -83,7 +83,7 @@ You don't have to do that.
 Snippets marked with `[source,console]` are automatically annotated with
 "VIEW IN CONSOLE" and "COPY AS CURL" in the documentation and are automatically
 tested by the command `./gradlew -pdocs check`. To test just the docs from a
-single page, use e.g. `./gradlew -pdocs integTest --tests "\*rollover*"`.
+single page, use e.g. `./gradlew -pdocs yamlRestTest --tests "\*rollover*"`.
 
 By default each `[source,console]` snippet runs as its own isolated test. You
 can manipulate the test execution in the following ways:

+ 5 - 5
docs/build.gradle

@@ -58,7 +58,7 @@ restResources {
   }
 }
 
-testClusters.matching { it.name == "integTest"}.configureEach {
+testClusters.matching { it.name == "yamlRestTest"}.configureEach {
   if (singleNode().testDistribution == DEFAULT) {
     setting 'xpack.license.self_generated.type', 'trial'
     setting 'indices.lifecycle.history_index_enabled', 'false'
@@ -86,8 +86,8 @@ testClusters.matching { it.name == "integTest"}.configureEach {
   // Whitelist reindexing from the local node so we can test it.
   setting 'reindex.remote.whitelist', '127.0.0.1:*'
 
-  extraConfigFile 'ingest-geoip/GeoLite2-City.mmdb', file("${project.projectDir}/src/test/resources/GeoLite2-City.mmdb")
-  extraConfigFile 'ingest-geoip/GeoLite2-Country.mmdb', file("${project.projectDir}/src/test/resources/GeoLite2-Country.mmdb")
+  extraConfigFile 'ingest-geoip/GeoLite2-City.mmdb', file("src/yamlRestTest/resources/GeoLite2-City.mmdb")
+  extraConfigFile 'ingest-geoip/GeoLite2-Country.mmdb', file("src/yamlRestTest/resources/GeoLite2-Country.mmdb")
 
   // TODO: remove this once cname is prepended to transport.publish_address by default in 8.0
   systemProperty 'es.transport.cname_in_publish_address', 'true'
@@ -108,7 +108,7 @@ testClusters.matching { it.name == "integTest"}.configureEach {
   }
 }
 
-tasks.named("integTest").configure {
+tasks.named("yamlRestTest").configure {
   doFirst {
     delete("${buildDir}/cluster/shared/repo")
   }
@@ -1626,7 +1626,7 @@ setups['setup-snapshots'] = setups['setup-repository'] + '''
   }
 
   /* Load the actual events only if we're going to use them. */
-  File atomicRedRegsvr32File = new File("$projectDir/src/test/resources/normalized-T1117-AtomicRed-regsvr32.json")
+  File atomicRedRegsvr32File = new File("$projectDir/src/yamlRestTest/resources/normalized-T1117-AtomicRed-regsvr32.json")
   inputs.file(atomicRedRegsvr32File)
 
   doFirst {

+ 1 - 1
docs/reference/cluster/health.asciidoc

@@ -181,7 +181,7 @@ with a single index with one shard and one replica:
   "active_shards_percent_as_number": 50.0
 }
 --------------------------------------------------
-// TESTRESPONSE[s/testcluster/integTest/]
+// TESTRESPONSE[s/testcluster/yamlRestTest/]
 // TESTRESPONSE[s/"number_of_pending_tasks" : 0,/"number_of_pending_tasks" : $body.number_of_pending_tasks,/]
 // TESTRESPONSE[s/"task_max_waiting_in_queue_millis": 0/"task_max_waiting_in_queue_millis": $body.task_max_waiting_in_queue_millis/]
 

+ 0 - 0
docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java → docs/src/yamlRestTest/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java


+ 0 - 0
docs/src/test/resources/GeoLite2-City.mmdb → docs/src/yamlRestTest/resources/GeoLite2-City.mmdb


+ 0 - 0
docs/src/test/resources/GeoLite2-Country.mmdb → docs/src/yamlRestTest/resources/GeoLite2-Country.mmdb


+ 0 - 0
docs/src/test/resources/normalized-T1117-AtomicRed-regsvr32.json → docs/src/yamlRestTest/resources/normalized-T1117-AtomicRed-regsvr32.json


+ 3 - 3
x-pack/docs/build.gradle

@@ -20,8 +20,8 @@ tasks.named("buildRestTests").configure {
 }
 
 dependencies {
-  testImplementation(testArtifact(project(xpackModule('core'))))
-  testImplementation(testArtifact(project(xpackProject('plugin').path)))
+  yamlRestTestImplementation(testArtifact(project(xpackModule('core'))))
+  yamlRestTestImplementation(testArtifact(project(xpackProject('plugin').path)))
 }
 
 restResources {
@@ -30,7 +30,7 @@ restResources {
   }
 }
 
-testClusters.matching { it.name == "integTest" }.configureEach {
+testClusters.matching { it.name == "yamlRestTest" }.configureEach {
   extraConfigFile 'op-jwks.json', xpackProject('test:idp-fixture').file("oidc/op-jwks.json")
   extraConfigFile 'idp-docs-metadata.xml', xpackProject('test:idp-fixture').file("idp/shibboleth-idp/metadata/idp-docs-metadata.xml")
   extraConfigFile 'testClient.crt', xpackProject('plugin:security').file("src/test/resources/org/elasticsearch/xpack/security/action/pki_delegation/testClient.crt")

+ 0 - 0
x-pack/docs/src/test/java/org/elasticsearch/smoketest/XDocsClientYamlTestSuiteIT.java → x-pack/docs/src/yamlRestTest/java/org/elasticsearch/smoketest/XDocsClientYamlTestSuiteIT.java