Unskip API tests, add xpack no_xpack default_shards features

This commit is contained in:
Seth Michael Larson
2020-02-28 11:36:03 -06:00
committed by GitHub
parent 2c7ea70201
commit 024abcfa39
3 changed files with 18 additions and 36 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
ELASTICSEARCH_VERSION: ELASTICSEARCH_VERSION:
- 7.5-SNAPSHOT - 7.x-SNAPSHOT
TEST_SUITE: TEST_SUITE:
- oss - oss
+2 -6
View File
@@ -1,10 +1,5 @@
import time import time
import os 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 import Elasticsearch
@@ -13,7 +8,7 @@ from elasticsearch.exceptions import ConnectionError
def get_test_client(nowait=False, **kwargs): def get_test_client(nowait=False, **kwargs):
# construct kwargs from the environment # construct kwargs from the environment
kw = {"timeout": 30} kw = {"timeout": 30, "ca_certs": ".ci/certs/ca.pem"}
if "PYTHON_CONNECTION_CLASS" in os.environ: if "PYTHON_CONNECTION_CLASS" in os.environ:
from elasticsearch import connection from elasticsearch import connection
@@ -55,6 +50,7 @@ class ElasticsearchTestCase(TestCase):
super(ElasticsearchTestCase, self).tearDown() super(ElasticsearchTestCase, self).tearDown()
self.client.indices.delete(index="*", ignore=404) self.client.indices.delete(index="*", ignore=404)
self.client.indices.delete_template(name="*", ignore=404) self.client.indices.delete_template(name="*", ignore=404)
self.client.indices.delete_alias(index="_all", name="_all", ignore=404)
@property @property
def es_version(self): def es_version(self):
+14 -28
View File
@@ -24,31 +24,19 @@ PARAMS_RENAMES = {"type": "doc_type", "from": "from_"}
CATCH_CODES = {"missing": 404, "conflict": 409, "unauthorized": 401} CATCH_CODES = {"missing": 404, "conflict": 409, "unauthorized": 401}
# test features we have implemented # 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 # broken YAML tests on some releases
SKIP_TESTS = { SKIP_TESTS = {
"*": set( "*": {
( # Can't figure out the get_alias(expand_wildcards=open) failure.
# missing skip for transform_and_set feature "TestIndicesGetAlias10Basic",
"TestApiKey10Basic", # Scripts are 7.6+
# invalid license "TestScripts20GetScriptContext",
"TestLicense20PutLicense", "TestScripts25GetScriptLanguages",
"TestXpack15Basic", # Disallowing expensive queries is 7.7+
# timeouts "TestSearch320DisallowQueries"
"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",
)
)
} }
XPACK_FEATURES = None XPACK_FEATURES = None
@@ -61,11 +49,6 @@ class InvalidActionType(Exception):
class YamlTestCase(ElasticsearchTestCase): class YamlTestCase(ElasticsearchTestCase):
def setUp(self): def setUp(self):
super(YamlTestCase, self).setUp() 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"): if hasattr(self, "_setup_code"):
self.run_code(self._setup_code) self.run_code(self._setup_code)
self.last_response = None self.last_response = None
@@ -106,13 +89,15 @@ class YamlTestCase(ElasticsearchTestCase):
super(YamlTestCase, self).tearDown() super(YamlTestCase, self).tearDown()
def _feature_enabled(self, name): def _feature_enabled(self, name):
global XPACK_FEATURES global XPACK_FEATURES, IMPLEMENTED_FEATURES
if XPACK_FEATURES is None: if XPACK_FEATURES is None:
try: try:
xinfo = self.client.xpack.info() xinfo = self.client.xpack.info()
XPACK_FEATURES = set( XPACK_FEATURES = set(
f for f in xinfo["features"] if xinfo["features"][f]["enabled"] f for f in xinfo["features"] if xinfo["features"][f]["enabled"]
) )
IMPLEMENTED_FEATURES.add("xpack")
except RequestError as e: except RequestError as e:
# We receive a 'RequestError' here when using 'oss' because the request # We receive a 'RequestError' here when using 'oss' because the request
# for xpack.info() looks like this: 'GET /_xpack' which errors on the # for xpack.info() looks like this: 'GET /_xpack' which errors on the
@@ -121,6 +106,7 @@ class YamlTestCase(ElasticsearchTestCase):
raise raise
XPACK_FEATURES = set() XPACK_FEATURES = set()
IMPLEMENTED_FEATURES.add("no_xpack")
return name in XPACK_FEATURES return name in XPACK_FEATURES