[7.x] Start using the Elastic Artifacts API for YAML REST tests

This commit is contained in:
Seth Michael Larson
2021-04-22 12:08:05 -05:00
committed by GitHub
parent 1d96f26fab
commit 794a97578f
13 changed files with 205 additions and 91 deletions
@@ -33,7 +33,6 @@ from ...test_server.test_rest_api_spec import (
PARAMS_RENAMES,
RUN_ASYNC_REST_API_TESTS,
YAML_TEST_SPECS,
InvalidActionType,
YamlRunner,
)
@@ -85,7 +84,7 @@ class AsyncYamlRunner(YamlRunner):
if hasattr(self, "run_" + action_type):
await await_if_coro(getattr(self, "run_" + action_type)(action))
else:
raise InvalidActionType(action_type)
raise RuntimeError("Invalid action type %r" % (action_type,))
async def run_do(self, action):
api = self.client
@@ -95,6 +94,16 @@ class AsyncYamlRunner(YamlRunner):
allowed_warnings = action.pop("allowed_warnings", ())
assert len(action) == 1
# Remove the x_pack_rest_user authentication
# if it's given via headers. We're already authenticated
# via the 'elastic' user.
if (
headers
and headers.get("Authorization", None)
== "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
):
headers.pop("Authorization")
method, args = list(action.items())[0]
args["headers"] = headers
@@ -135,6 +144,18 @@ class AsyncYamlRunner(YamlRunner):
and str(w.message) not in allowed_warnings
]
# This warning can show up in many places but isn't accounted for
# in tests, so we remove it to make sure things pass.
include_type_name_warning = (
"[types removal] Using include_type_name in create index requests is deprecated. "
"The parameter will be removed in the next major version."
)
if (
include_type_name_warning in caught_warnings
and include_type_name_warning not in warn
):
caught_warnings.remove(include_type_name_warning)
# Sorting removes the issue with order raised. We only care about
# if all warnings are raised in the single API call.
if warn and sorted(warn) != sorted(caught_warnings):