|
1 | 1 | elasticsearch-py test suite |
2 | 2 | =========================== |
3 | 3 |
|
4 | | -Warning - by default the tests will try and connect to `localhost:9200` and |
| 4 | +Warning - by default the tests will try and connect to ``localhost:9200`` and |
5 | 5 | will destroy all contents of given cluster! The tests also rely on a checkout |
6 | | -of `elasticsearch` repository existing on the same level as the |
7 | | -`elasticsearch-py` clone. Before running the tests we will, by default, pull |
8 | | -latest changes for that repo and perform `git reset --hard` to the exact |
| 6 | +of ``elasticsearch`` repository existing on the same level as the |
| 7 | +``elasticsearch-py`` clone. Before running the tests we will, by default, pull |
| 8 | +latest changes for that repo and perform ``git reset --hard`` to the exact |
9 | 9 | version that was used to build the server we are running against. |
10 | 10 |
|
11 | 11 | Running the tests |
12 | 12 | ----------------- |
13 | 13 |
|
14 | | -To simply run the tests just execute the `run_tests.py` script or invoke |
15 | | -`python setup.py test`. The behavior is driven by environmental variables: |
| 14 | +To simply run the tests just execute the ``run_tests.py`` script or invoke |
| 15 | +``python setup.py test``. The behavior is driven by environmental variables: |
16 | 16 |
|
17 | | - * `TEST_ES_SERVER` - can contain "hostname[:port]" of running es cluster |
| 17 | + * ``TEST_ES_SERVER`` - can contain "hostname[:port]" of running es cluster |
18 | 18 |
|
19 | | - * `TEST_ES_CONNECTION` - name of the connection class to use from |
20 | | - `elasticsearch.connection` module. If you want to run completely with your |
| 19 | + * ``TEST_ES_CONNECTION`` - name of the connection class to use from |
| 20 | + ``elasticsearch.connection`` module. If you want to run completely with your |
21 | 21 | own see section on customizing tests. |
22 | 22 |
|
23 | | - * `TEST_ES_YAML_DIR` - path to the yaml test suite contained in the |
24 | | - elasticsearch repo. Defaults to `$TEST_ES_REPO/rest-api-spec/test` |
| 23 | + * ``TEST_ES_YAML_DIR`` - path to the yaml test suite contained in the |
| 24 | + elasticsearch repo. Defaults to ``$TEST_ES_REPO/rest-api-spec/test`` |
25 | 25 |
|
26 | | - * `TEST_ES_REPO` - path to the elasticsearch repo, by default it will look in |
27 | | - the same directory as `elasticsearch-py` is in. It will not be used if |
28 | | - `TEST_ES_YAML_DIR` is specified directly. |
| 26 | + * ``TEST_ES_REPO`` - path to the elasticsearch repo, by default it will look in |
| 27 | + the same directory as ``elasticsearch-py`` is in. It will not be used if |
| 28 | + ``TEST_ES_YAML_DIR`` is specified directly. |
29 | 29 |
|
30 | | - * `TEST_ES_NOFETCH` - controls if we should fetch new updates to elasticsearch |
| 30 | + * ``TEST_ES_NOFETCH`` - controls if we should fetch new updates to elasticsearch |
31 | 31 | repo and reset it's version to the sha used to build the current es server. |
32 | | - Defaults to `False` which means we will fetch the elasticsearch repo and |
33 | | - `git reset --hard` the sha used to build the server. |
| 32 | + Defaults to ``False`` which means we will fetch the elasticsearch repo and |
| 33 | + ``git reset --hard`` the sha used to build the server. |
34 | 34 |
|
35 | 35 | Alternatively, if you wish to control what you are doing you have several additional options: |
36 | 36 |
|
37 | | - * `run_tests.py` will pass any parameters specified to `nosetests` |
| 37 | + * ``run_tests.py`` will pass any parameters specified to ``nosetests`` |
38 | 38 |
|
39 | | - * you can just run your favorite runner in the `test_elasticsearch` directory |
| 39 | + * you can just run your favorite runner in the ``test_elasticsearch`` directory |
40 | 40 | (verified to work with nose and py.test) and bypass the fetch logic entirely. |
41 | 41 |
|
| 42 | +To install all test dependencies you can also run ``pip install -e .[develop]``. |
| 43 | + |
| 44 | +Run Elasticsearch in a Container |
| 45 | +-------------------------------- |
| 46 | + |
| 47 | +To run elasticsearch in a container, optionally set the ``ES_VERSION`` |
| 48 | +environment evariable to either 5.4, 5.3 or 2.4. ``ES_VERSION`` is defaulted to |
| 49 | +``latest``. Then run ./start_elasticsearch.sh:: |
| 50 | + |
| 51 | + export ES_VERSION=5.4 |
| 52 | + ./start_elasticsearch.sh |
| 53 | + |
| 54 | + |
| 55 | +This will run a version for Elasticsearch in a Docker container suitable for |
| 56 | +running the tests. To check that elasticsearch is running first wait for a |
| 57 | +``healthy`` status in ``docker ps``:: |
| 58 | + |
| 59 | + $ docker ps |
| 60 | + CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
| 61 | + 955e57564e53 7d2ad83f8446 "/docker-entrypoin..." 6 minutes ago Up 6 minutes (healthy) 0.0.0.0:9200->9200/tcp, 9300/tcp trusting_brattain |
| 62 | + |
| 63 | +Then you can navigate to ``locahost:9200`` in your browser. |
| 64 | + |
| 65 | + |
42 | 66 | Customizing the tests |
43 | 67 | --------------------- |
44 | 68 |
|
|
0 commit comments