diff --git a/.ci/test-matrix.yml b/.ci/test-matrix.yml index 5a2fd52a..8f307dbe 100755 --- a/.ci/test-matrix.yml +++ b/.ci/test-matrix.yml @@ -1,5 +1,5 @@ ELASTICSEARCH_VERSION: - - 7.5-SNAPSHOT + - 7.x-SNAPSHOT TEST_SUITE: - oss diff --git a/elasticsearch/helpers/test.py b/elasticsearch/helpers/test.py index 4d120c47..ebf11c25 100644 --- a/elasticsearch/helpers/test.py +++ b/elasticsearch/helpers/test.py @@ -1,11 +1,6 @@ import time import os - -try: - # python 2.6 - from unittest2 import TestCase, SkipTest -except ImportError: - from unittest import TestCase, SkipTest +from unittest import TestCase, SkipTest from elasticsearch import Elasticsearch from elasticsearch.exceptions import ConnectionError @@ -13,7 +8,7 @@ from elasticsearch.exceptions import ConnectionError def get_test_client(nowait=False, **kwargs): # construct kwargs from the environment - kw = {"timeout": 30} + kw = {"timeout": 30, "ca_certs": ".ci/certs/ca.pem"} if "PYTHON_CONNECTION_CLASS" in os.environ: from elasticsearch import connection @@ -55,6 +50,7 @@ class ElasticsearchTestCase(TestCase): super(ElasticsearchTestCase, self).tearDown() self.client.indices.delete(index="*", ignore=404) self.client.indices.delete_template(name="*", ignore=404) + self.client.indices.delete_alias(index="_all", name="_all", ignore=404) @property def es_version(self): diff --git a/test_elasticsearch/test_server/test_common.py b/test_elasticsearch/test_server/test_common.py index ae7ceed0..fdf7b448 100644 --- a/test_elasticsearch/test_server/test_common.py +++ b/test_elasticsearch/test_server/test_common.py @@ -24,31 +24,19 @@ PARAMS_RENAMES = {"type": "doc_type", "from": "from_"} CATCH_CODES = {"missing": 404, "conflict": 409, "unauthorized": 401} # test features we have implemented -IMPLEMENTED_FEATURES = ("gtelte", "stash_in_path", "headers", "catch_unauthorized") +IMPLEMENTED_FEATURES = {"gtelte", "stash_in_path", "headers", "catch_unauthorized", "default_shards"} # broken YAML tests on some releases SKIP_TESTS = { - "*": set( - ( - # missing skip for transform_and_set feature - "TestApiKey10Basic", - # invalid license - "TestLicense20PutLicense", - "TestXpack15Basic", - # timeouts - "TestMlSetUpgradeMode", - # doesn't account for security index - "TestSnapshot10Basic", - # wrong exception, also body should be marked as required - "TestWatcherPutWatch10Basic", - # weird issue with SET cmd: - "TestUsers10Basic", - "TestWatcherExecuteWatch60HttpInput", - "TestSecurityHidden-Index13Security-TokensRead", - "TestSecurityHidden-Index14Security-Tokens-7Read", - "TestToken10Basic", - ) - ) + "*": { + # Can't figure out the get_alias(expand_wildcards=open) failure. + "TestIndicesGetAlias10Basic", + # Scripts are 7.6+ + "TestScripts20GetScriptContext", + "TestScripts25GetScriptLanguages", + # Disallowing expensive queries is 7.7+ + "TestSearch320DisallowQueries" + } } XPACK_FEATURES = None @@ -61,11 +49,6 @@ class InvalidActionType(Exception): class YamlTestCase(ElasticsearchTestCase): def setUp(self): super(YamlTestCase, self).setUp() - if self._feature_enabled("security"): - self.client.security.put_user( - username="x_pack_rest_user", - body={"password": "x-pack-test-password", "roles": ["superuser"]}, - ) if hasattr(self, "_setup_code"): self.run_code(self._setup_code) self.last_response = None @@ -106,13 +89,15 @@ class YamlTestCase(ElasticsearchTestCase): super(YamlTestCase, self).tearDown() def _feature_enabled(self, name): - global XPACK_FEATURES + global XPACK_FEATURES, IMPLEMENTED_FEATURES + if XPACK_FEATURES is None: try: xinfo = self.client.xpack.info() XPACK_FEATURES = set( f for f in xinfo["features"] if xinfo["features"][f]["enabled"] ) + IMPLEMENTED_FEATURES.add("xpack") 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 @@ -121,6 +106,7 @@ class YamlTestCase(ElasticsearchTestCase): raise XPACK_FEATURES = set() + IMPLEMENTED_FEATURES.add("no_xpack") return name in XPACK_FEATURES