You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/integration/README.md
+29-7Lines changed: 29 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,8 @@
5
5
Yes.
6
6
7
7
## Background
8
-
Elasticsearch offers its entire API via HTTP REST endpoints. You can find the whole API specification for every version [here](https://github.com/elastic/elasticsearch/tree/master/rest-api-spec/src/main/resources/rest-api-spec/api).<br/>
9
-
To support different languages at the same time, the Elasticsearch team decided to provide a [YAML specification](https://github.com/elastic/elasticsearch/tree/master/rest-api-spec/src/main/resources/rest-api-spec/test) to test every endpoint, body, headers, warning, error and so on.<br/>
8
+
Elasticsearch offers its entire API via HTTP REST endpoints. You can find the whole API specification for every version [here](https://github.com/elastic/elasticsearch/tree/main/rest-api-spec/src/main/resources/rest-api-spec/api).<br/>
9
+
To support different languages at the same time, the Elasticsearch team decided to provide a [YAML specification](https://github.com/elastic/elasticsearch/tree/main/rest-api-spec/src/main/resources/rest-api-spec/test) to test every endpoint, body, headers, warning, error and so on.<br/>
10
10
This testing suite uses that specification to generate the test for the specified version of Elasticsearch on the fly.
11
11
12
12
## Run
@@ -20,20 +20,45 @@ Once the Elasticsearch repository has been cloned, the testing suite will connec
20
20
21
21
The specification does not allow the test to be run in parallel, so it might take a while to run the entire testing suite; on my machine, `MacBookPro15,2 core i7 2.7GHz 16GB of RAM` it takes around four minutes.
22
22
23
+
### Running locally
24
+
25
+
If you want to run the integration tests on your development machine, you must have an Elasticsearch instance running first.
26
+
A local instance can be spun up in a Docker container by running the [`.ci/run-elasticsearch.sh`](/.ci/run-elasticsearch.sh) script.
27
+
This is the same script CI jobs use to run Elasticsearch for integration tests, so your results should be relatively consistent.
28
+
29
+
To simplify the process of starting a container, testing, and cleaning up the container, you can run the `make integration` target:
30
+
31
+
```sh
32
+
# set some parameters
33
+
export STACK_VERSION=8.7.0
34
+
export TEST_SUITE=free # can be `free` or `platinum`
35
+
make integration
36
+
```
37
+
38
+
If Elasticsearch doesn't come up, run `make integration-cleanup` and then `DETACH=false .ci/run-elasticsearch.sh` manually to read the startup logs.
39
+
40
+
If you get an error about `vm.max_map_count` being too low, run `sudo sysctl -w vm.max_map_count=262144` to update the setting until the next reboot, or `sudo sysctl -w vm.max_map_count=262144 | sudo tee -a /etc/sysctl.conf` to update the setting permanently.
41
+
23
42
### Exit on the first failure
24
-
Bu default the suite will run all the test, even if one assertion has failed. If you want to stop the test at the first failure, use the bailout option:
43
+
44
+
By default the suite will run all the tests, even if one assertion has failed. If you want to stop the test at the first failure, use the bailout option:
45
+
25
46
```sh
26
47
npm run test:integration -- --bail
27
48
```
28
49
29
50
### Calculate the code coverage
51
+
30
52
If you want to calculate the code coverage just run the testing suite with the following parameters, once the test ends, it will open a browser window with the results.
53
+
31
54
```sh
32
55
npm run test:integration -- --cov --coverage-report=html
33
56
```
34
57
35
58
## How does this thing work?
59
+
36
60
At first sight, it might seem complicated, but once you understand what the moving parts are, it's quite easy.
61
+
37
62
1. Connects to the given Elasticsearch instance
38
63
1. Gets the ES version and build hash
39
64
1. Checkout to the given hash (and clone the repository if it is not present)
@@ -46,7 +71,4 @@ At first sight, it might seem complicated, but once you understand what the movi
46
71
47
72
Inside the `index.js` file, you will find the connection, cloning, reading and parsing part of the test, while inside the `test-runner.js` file you will find the function to handle the assertions. Inside `test-runner.js`, we use a [queue](https://github.com/delvedor/workq) to be sure that everything is run in the correct order.
48
73
49
-
Checkout the [rest-api-spec readme](https://github.com/elastic/elasticsearch/blob/master/rest-api-spec/src/main/resources/rest-api-spec/test/README.asciidoc) if you want to know more about how the assertions work.
50
-
51
-
#### Why are we running the test with the `--harmony` flag?
52
-
Because on Node v6 the regex lookbehinds are not supported.
74
+
Check out the [rest-api-spec readme](https://github.com/elastic/elasticsearch/blob/main/rest-api-spec/src/main/resources/rest-api-spec/test/README.asciidoc) if you want to know more about how the assertions work.
0 commit comments