|
| 1 | +## Jenkins test folder |
| 2 | + |
| 3 | +This `.ci` folder is used by https://clients-ci.elastic.co |
| 4 | + |
| 5 | +Where each Elasticsearch client runs the [rest api spec test](https://github.com/elastic/elasticsearch/tree/master/rest-api-spec/src/main/resources/rest-api-spec/test) |
| 6 | +as defined by the Elasticsearch team. |
| 7 | + |
| 8 | +Each client starts the cluster using the same `.ci/run-elasticsearch` from `run-tests` and then bootstraps there own `rest api test runner`.api |
| 9 | + |
| 10 | +The .NET rest api spec runner lives under `src/Tests/Test.YamlRunner`. This runner takes the test yaml files and turns them into .NET instructions.api |
| 11 | + |
| 12 | +Each `do` section in the yaml is mapped to a low level client method. To aid with assertions the tests ask for `DynamicResponse` which is a great |
| 13 | +way to deal with elasticsearch responses in a semi typed fashion. |
| 14 | + |
| 15 | +These `rest-api-spec` tests are in addition to the unit and integration tests that live under `src/Tests/Tests` which for 90% of the cases focuses |
| 16 | +more on the high level client `NEST` where as these `rest-api-spec` test fully focus on the low level client `Elasticsearch.Net` |
| 17 | + |
| 18 | +The `DockerFile` in this folder sets up this repos inside a docker container ready to run our build. |
| 19 | + |
| 20 | +The `rest-api-spec` runner expects Elasticsearch to be started before invocation and uses the endpoint its passed to discover the current Elasticsearch |
| 21 | +`build hash` that is running and downloads the tests matching that `build hash`. |
| 22 | + |
| 23 | +If you want to run the tests the same that the Jenkins instance on elastic.co does you can call |
| 24 | + |
| 25 | +```bash |
| 26 | +$ ELASTICSEARCH_VERSION=8.0.0-SNAPSHOT ./.ci/run-tests |
| 27 | +``` |
| 28 | + |
| 29 | +| Variable Name | Default | Description | |
| 30 | +|-------------------------|-------------|-------------| |
| 31 | +| `ELASTICSEARCH_VERSION` | `N/A` | The elasticsearch version to target |
| 32 | +| `TEST_SUITE` | `oss` | `oss` or `xpack` sets which test suite to run and which container to run against. | |
| 33 | +| `DOTNET_VERSION` | `3.0.100` | The .NET sdk version used to grab the proper container | |
| 34 | + |
| 35 | + |
| 36 | +If you want to manually spin up elasticsearch for this tests and call the runner afterwards you can use |
| 37 | + |
| 38 | +```bash |
| 39 | +$ ELASTICSEARCH_VERSION=elasticsearch-oss:8.0.0-SNAPSHOT DETACH=true bash .ci/run-elasticsearch.sh |
| 40 | +``` |
| 41 | + |
| 42 | +Note that `ELASTICSEARCH_VERSION` here is the full docker reference, `.ci/run-tests` is smart enough to compose this based on `TEST_SUITE` |
| 43 | + |
| 44 | +Spinning down the cluster can be done by passing `CLEANUP=true` using the same args |
| 45 | + |
| 46 | +```bash |
| 47 | +$ ELASTICSEARCH_VERSION=elasticsearch-oss:8.0.0-SNAPSHOT CLEANUP=true bash .ci/run-elasticsearch.sh |
| 48 | +``` |
| 49 | + |
| 50 | +To kick off the `rest-api-spec` tests manually after starting the cluster manually: |
| 51 | + |
| 52 | +```bash |
| 53 | +$ ./build.sh rest-spec-tests -f create -e http://localhost:9200 -o /sln/build/output/rest-spec-junit.xml |
| 54 | +``` |
| 55 | + |
| 56 | +See `--help` for a full command line reference |
| 57 | + |
| 58 | +```bash |
| 59 | +$ ./build.sh rest-spec-tests -f --help |
| 60 | +``` |
| 61 | + |
| 62 | +Against in most cases running through `./ci/run-tests` is all you need: |
| 63 | + |
| 64 | +```bash |
| 65 | +$ ELASTICSEARCH_VERSION=8.0.0-SNAPSHOT ./.ci/run-tests |
| 66 | +``` |
| 67 | + |
0 commit comments