Skip to content

Commit b7cdd64

Browse files
authored
Run compatibility tests from the new 'compatTest' distribution
1 parent 6790940 commit b7cdd64

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

.ci/run-repository.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ docker build \
3232
echo -e "\033[1m>>>>> Run [elastic/elasticsearch-py container] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
3333

3434
if [[ "$STACK_VERSION" == "8.0.0-SNAPSHOT" ]]; then
35-
export STACK_VERSION="7.x-SNAPSHOT"
3635
export ELASTIC_CLIENT_APIVERSIONING="true"
3736
fi
3837

test_elasticsearch/test_async/test_server/test_rest_api_spec.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
clients.
2222
"""
2323
import inspect
24+
import re
2425
import warnings
2526

2627
import pytest
@@ -118,6 +119,11 @@ async def run_do(self, action):
118119
catch = action.pop("catch", None)
119120
warn = action.pop("warnings", ())
120121
allowed_warnings = action.pop("allowed_warnings", ())
122+
if isinstance(allowed_warnings, str):
123+
allowed_warnings = (allowed_warnings,)
124+
allowed_warnings_regex = action.pop("allowed_warnings_regex", ())
125+
if isinstance(allowed_warnings_regex, str):
126+
allowed_warnings_regex = (allowed_warnings_regex,)
121127
assert len(action) == 1
122128

123129
# Remove the x_pack_rest_user authentication
@@ -138,6 +144,9 @@ async def run_do(self, action):
138144

139145
# locate api endpoint
140146
for m in method.split("."):
147+
# Some deprecated APIs are prefixed with 'xpack-*'
148+
if m.startswith("xpack-"):
149+
m = m.replace("xpack-", "")
141150
assert hasattr(api, m)
142151
api = getattr(api, m)
143152

@@ -186,7 +195,14 @@ async def run_do(self, action):
186195
str(w.message)
187196
for w in caught_warnings
188197
if w.category == ElasticsearchWarning
189-
and str(w.message) not in allowed_warnings
198+
and (not allowed_warnings or str(w.message) not in allowed_warnings)
199+
and (
200+
not allowed_warnings_regex
201+
or all(
202+
re.search(pattern, str(w.message)) is None
203+
for pattern in allowed_warnings_regex
204+
)
205+
)
190206
]
191207

192208
# This warning can show up in many places but isn't accounted for

test_elasticsearch/test_server/test_rest_api_spec.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"default_shards",
6060
"warnings",
6161
"allowed_warnings",
62+
"allowed_warnings_regex",
6263
"contains",
6364
"arbitrary_key",
6465
"transform_and_set",
@@ -223,6 +224,11 @@ def run_do(self, action):
223224
catch = action.pop("catch", None)
224225
warn = action.pop("warnings", ())
225226
allowed_warnings = action.pop("allowed_warnings", ())
227+
if isinstance(allowed_warnings, str):
228+
allowed_warnings = (allowed_warnings,)
229+
allowed_warnings_regex = action.pop("allowed_warnings_regex", ())
230+
if isinstance(allowed_warnings_regex, str):
231+
allowed_warnings_regex = (allowed_warnings_regex,)
226232
assert len(action) == 1
227233

228234
# Remove the x_pack_rest_user authentication
@@ -243,6 +249,9 @@ def run_do(self, action):
243249

244250
# locate api endpoint
245251
for m in method.split("."):
252+
# Some deprecated APIs are prefixed with 'xpack-*'
253+
if m.startswith("xpack-"):
254+
m = m.replace("xpack-", "")
246255
assert hasattr(api, m)
247256
api = getattr(api, m)
248257

@@ -291,7 +300,14 @@ def run_do(self, action):
291300
str(w.message)
292301
for w in caught_warnings
293302
if w.category == ElasticsearchWarning
294-
and str(w.message) not in allowed_warnings
303+
and (not allowed_warnings or str(w.message) not in allowed_warnings)
304+
and (
305+
not allowed_warnings_regex
306+
or all(
307+
re.search(pattern, str(w.message)) is None
308+
for pattern in allowed_warnings_regex
309+
)
310+
)
295311
]
296312

297313
# This warning can show up in many places but isn't accounted for
@@ -579,7 +595,10 @@ def sync_runner(sync_client):
579595
# Download the zip and start reading YAML from the files in memory
580596
package_zip = zipfile.ZipFile(io.BytesIO(http.request("GET", package_url).data))
581597
for yaml_file in package_zip.namelist():
582-
if not re.match(r"^rest-api-spec/test/.*\.ya?ml$", yaml_file):
598+
yaml_filter_pattern = r"^rest-api-spec/%s/.*\.ya?ml$" % (
599+
"compatTest" if COMPATIBILITY_MODE_ENABLED else "test"
600+
)
601+
if not re.match(yaml_filter_pattern, yaml_file):
583602
continue
584603
yaml_tests = list(yaml.safe_load_all(package_zip.read(yaml_file)))
585604

@@ -608,7 +627,13 @@ def sync_runner(sync_client):
608627
# is to remove most of the file path prefixes and
609628
# the .yml suffix.
610629
pytest_test_name = yaml_file.rpartition(".")[0].replace(".", "/")
611-
for prefix in ("rest-api-spec/", "test/", "free/", "platinum/"):
630+
for prefix in (
631+
"rest-api-spec/",
632+
"compatTest/",
633+
"test/",
634+
"free/",
635+
"platinum/",
636+
):
612637
if pytest_test_name.startswith(prefix):
613638
pytest_test_name = pytest_test_name[len(prefix) :]
614639
pytest_param_id = "%s[%d]" % (pytest_test_name, test_number)

0 commit comments

Comments
 (0)