Migrate CI to Jenkins on 7.x branch (#1114)

This commit is contained in:
Seth Michael Larson
2020-02-27 10:13:49 -06:00
committed by GitHub
parent 1bda6aca8a
commit 2c7ea70201
24 changed files with 594 additions and 161 deletions
+12 -11
View File
@@ -11,12 +11,12 @@ version that was used to build the server we are running against.
Running the tests
-----------------
To simply run the tests just execute the ``run_tests.py`` script or invoke
``python setup.py test``. The behavior is driven by environmental variables:
To simply run the tests just execute ``python setup.py test``.
The behavior is driven by environmental variables:
* ``TEST_ES_SERVER`` - can contain "hostname[:port]" of running es cluster
* ``ELASTICSEARCH_HOST`` - can contain "hostname[:port]" of running es cluster
* ``TEST_ES_CONNECTION`` - name of the connection class to use from
* ``PYTHON_CLASS_CONNECTION`` - name of the connection class to use from
``elasticsearch.connection`` module. If you want to run completely with your
own see section on customizing tests.
@@ -34,8 +34,6 @@ To simply run the tests just execute the ``run_tests.py`` script or invoke
Alternatively, if you wish to control what you are doing you have several additional options:
* ``run_tests.py`` will pass any parameters specified to ``nosetests``
* you can just run your favorite runner in the ``test_elasticsearch`` directory
(verified to work with nose and py.test) and bypass the fetch logic entirely.
@@ -47,13 +45,16 @@ To install all test dependencies you can also run ``pip install -e .[develop]``.
Run Elasticsearch in a Container
--------------------------------
To run elasticsearch in a container, optionally set the ``ES_VERSION``
environment evariable to either 5.4, 5.3 or 2.4. ``ES_VERSION`` is defaulted to
``latest``. Then run ./start_elasticsearch.sh::
To run elasticsearch in a container set the ``ELASTICSEARCH_VERSION``
environment variable to 7.5, 7.5-SNAPSHOT. Then run ./.ci/run_elasticsearch.sh::
export ES_VERSION=5.4
./start_elasticsearch.sh
# Run OSS Elasticsearch v7.5
export ELASTICSEARCH_VERSION=elasticsearch-oss:7.5-SNAPSHOT
./.ci/run_elasticsearch.sh
# Run XPACK Elasticsearch v7.5
export ELASTICSEARCH_VERSION=elasticsearch:7.5-SNAPSHOT
./.ci/run_elasticsearch.sh
This will run a version for Elasticsearch in a Docker container suitable for
running the tests. To check that elasticsearch is running first wait for a
+5 -5
View File
@@ -21,10 +21,10 @@ def fetch_es_repo():
# no repo
if not exists(repo_path) or not exists(join(repo_path, ".git")):
print("No elasticsearch repo found...")
# set YAML DIR to empty to skip yaml tests
environ["TEST_ES_YAML_DIR"] = ""
return
subprocess.check_call(
"git clone https://github.com/elastic/elasticsearch %s" % repo_path,
shell=True,
)
# set YAML test dir
environ["TEST_ES_YAML_DIR"] = join(
@@ -53,7 +53,7 @@ def fetch_es_repo():
% repo_path,
shell=True,
)
# reset to the version fron info()
# reset to the version from info()
subprocess.check_call("cd %s && git fetch" % repo_path, shell=True)
subprocess.check_call("cd %s && git reset --hard %s" % (repo_path, sha), shell=True)
-20
View File
@@ -1,20 +0,0 @@
#!/bin/bash
# Start elasticsearch in a docker container
ES_VERSION=${ES_VERSION:-"7.5.0"}
ES_TEST_SERVER=${ES_TEST_SERVER:-"http://localhost:9200"}
SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
exec docker run -d \
-e path.repo=/tmp \
-e "repositories.url.allowed_urls=http://*" \
-e node.attr.testattr=test \
-e node.name=test \
-e ES_HOST=$ES_TEST_SERVER \
-e cluster.initial_master_nodes=test \
-v $SOURCE_DIR/../elasticsearch:/code/elasticsearch \
-v /tmp:/tmp \
-p "9200:9200" \
docker.elastic.co/elasticsearch/elasticsearch-oss:$ES_VERSION
+16 -8
View File
@@ -9,7 +9,7 @@ from os.path import exists, join, dirname, pardir
import yaml
from shutil import rmtree
from elasticsearch import TransportError
from elasticsearch import TransportError, RequestError
from elasticsearch.compat import string_types
from elasticsearch.helpers.test import _get_version
@@ -108,10 +108,20 @@ class YamlTestCase(ElasticsearchTestCase):
def _feature_enabled(self, name):
global XPACK_FEATURES
if XPACK_FEATURES is None:
xinfo = self.client.xpack.info()
XPACK_FEATURES = set(
f for f in xinfo["features"] if xinfo["features"][f]["enabled"]
)
try:
xinfo = self.client.xpack.info()
XPACK_FEATURES = set(
f for f in xinfo["features"] if xinfo["features"][f]["enabled"]
)
except RequestError as e:
# We receive a 'RequestError' here when using 'oss' because the request
# for xpack.info() looks like this: 'GET /_xpack' which errors on the
# oss container due to having a similar route to 'GET /<index>'.
if "invalid_index_name_exception" not in e.error:
raise
XPACK_FEATURES = set()
return name in XPACK_FEATURES
def _resolve(self, value):
@@ -236,9 +246,7 @@ class YamlTestCase(ElasticsearchTestCase):
elif feature == "benchmark":
if self._get_benchmark_nodes():
continue
raise SkipTest(
skip.get("reason", "Feature %s is not supported" % feature)
)
raise SkipTest("Feature %s is not supported" % feature)
if "version" in skip:
version, reason = skip["version"], skip["reason"]