Skip to content

Commit 4bd6333

Browse files
authored
[7.6] Updates to TESTING.asciidoc for REST testing (#52862) (#52900)
Update documentation for: * restResources config (related #52114) * call out YAML vs. Java based Rest tests * update example to use newer syntax * update example to target a test that is not skipped * provide example for bwcRest test (related #52383)
1 parent 0064736 commit 4bd6333

File tree

1 file changed

+42
-18
lines changed

1 file changed

+42
-18
lines changed

TESTING.asciidoc

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -273,34 +273,49 @@ test fixtures. If it's not present those checks will be skipped automatically.
273273

274274
== Testing the REST layer
275275

276-
The available integration tests make use of the java API to communicate with
277-
the elasticsearch nodes, using the internal binary transport (port 9300 by
278-
default).
279-
The REST layer is tested through specific tests that are shared between all
280-
the elasticsearch official clients and consist of YAML files that describe the
276+
The REST layer is tested through specific tests that are executed against
277+
a cluster that is configured and initialized via Gradle. The tests
278+
themselves can be written in either Java or with a YAML based DSL.
279+
280+
YAML based REST tests should be preferred since these are shared between all
281+
the elasticsearch official clients. The YAML based tests describe the
281282
operations to be executed and the obtained results that need to be tested.
282283

283-
The YAML files support various operators defined in the link:/rest-api-spec/src/main/resources/rest-api-spec/test/README.asciidoc[rest-api-spec] and adhere to the link:/rest-api-spec/README.markdown[Elasticsearch REST API JSON specification]
284+
The YAML tests support various operators defined in the link:/rest-api-spec/src/main/resources/rest-api-spec/test/README.asciidoc[rest-api-spec] and adhere to the link:/rest-api-spec/README.markdown[Elasticsearch REST API JSON specification]
285+
In order to run the the YAML tests, the relevant API specification needs
286+
to be on the test classpath. Any gradle project that has support for REST
287+
tests will get the primary API on it's class path. However, to better support
288+
Gradle incremental builds, it is recommended to explicitly declare which
289+
parts of the API the tests depend upon.
290+
291+
For example:
292+
---------------------------------------------------------------------------
293+
restResources {
294+
restApi {
295+
includeCore '_common', 'indices', 'index', 'cluster', 'nodes', 'get', 'ingest'
296+
}
297+
}
298+
---------------------------------------------------------------------------
299+
300+
YAML tests that include x-pack specific APIs need to explicitly declare
301+
which APIs are required through a similar `includeXpack` configuration.
284302

285303
The REST tests are run automatically when executing the "./gradlew check" command. To run only the
286304
REST tests use the following command:
287305

288306
---------------------------------------------------------------------------
289-
./gradlew :distribution:archives:integ-test-zip:integTest \
290-
-Dtests.class="org.elasticsearch.test.rest.*Yaml*IT"
307+
./gradlew :distribution:archives:integ-test-zip:integTestRunner \
308+
--tests "org.elasticsearch.test.rest.IntegTestZipClientYamlTestSuiteIT"
291309
---------------------------------------------------------------------------
292310

293-
A specific test case can be run with
311+
A specific test case can be run with the following command:
294312

295313
---------------------------------------------------------------------------
296-
./gradlew :distribution:archives:integ-test-zip:integTest \
297-
-Dtests.class="org.elasticsearch.test.rest.*Yaml*IT" \
298-
-Dtests.method="test {p0=cat.shards/10_basic/Help}"
314+
./gradlew ':distribution:archives:integ-test-zip:integTestRunner' \
315+
--tests "org.elasticsearch.test.rest.IntegTestZipClientYamlTestSuiteIT" \
316+
-Dtests.method="test {p0=cat.segments/10_basic/Help}"
299317
---------------------------------------------------------------------------
300318

301-
`*Yaml*IT` are the executable test classes that runs all the
302-
yaml suites available within the `rest-api-spec` folder.
303-
304319
The REST tests support all the options provided by the randomized runner, plus the following:
305320

306321
* `tests.rest[true|false]`: determines whether the REST tests need to be run (default) or not.
@@ -494,6 +509,14 @@ version 5.3.2 run:
494509
./gradlew v5.3.2#bwcTest
495510
-------------------------------------------------
496511

512+
Use -Dtest.class and -Dtests.method to run a specific bwcTest test.
513+
For example to run a specific tests from the x-pack rolling upgrade from 7.7.0:
514+
-------------------------------------------------
515+
./gradlew :x-pack:qa:rolling-upgrade:v7.7.0#bwcTest \
516+
-Dtests.class=org.elasticsearch.upgrades.UpgradeClusterClientYamlTestSuiteIT \
517+
-Dtests.method="test {p0=*/40_ml_datafeed_crud/*}"
518+
-------------------------------------------------
519+
497520
Tests are ran for versions that are not yet released but with which the current version will be compatible with.
498521
These are automatically checked out and built from source.
499522
See link:./buildSrc/src/main/java/org/elasticsearch/gradle/VersionCollection.java[VersionCollection]
@@ -547,8 +570,9 @@ There are multiple base classes for tests:
547570
* **`ESIntegTestCase`**: An integration test case that creates a cluster that
548571
might have multiple nodes.
549572
* **`ESRestTestCase`**: An integration tests that interacts with an external
550-
cluster via the REST API. For instance, YAML tests run via sub classes of
551-
`ESRestTestCase`.
573+
cluster via the REST API. This is used for Java based REST tests.
574+
* **`ESClientYamlSuiteTestCase` **: A subclass of `ESRestTestCase` used to run
575+
YAML based REST tests.
552576

553577
=== Good practices
554578

@@ -678,4 +702,4 @@ please see https://esrally.readthedocs.io/en/stable/[Rally's documentation].
678702

679703
The Elasticsearch docs are in AsciiDoc format. You can test and build the docs
680704
locally using the Elasticsearch documentation build process. See
681-
https://github.com/elastic/docs.
705+
https://github.com/elastic/docs.

0 commit comments

Comments
 (0)