Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions quickwit/rest-api-tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,31 @@
from os import mkdir
from os import path as osp

# Simple !include constructor for YAML to allow reusing fragments across files.
# Usage examples:
# - !include path/to/file.yaml -> includes full file content
# - !include path/to/file.yaml::doc_mapping -> includes the 'doc_mapping' key
# - !include path/to/file.yaml::a.b.c -> includes nested key a -> b -> c
def _yaml_include(loader, node):
value = loader.construct_scalar(node)
if "::" in value:
filepath, subpath = value.split("::", 1)
else:
filepath, subpath = value, None
with open(filepath, "r") as f:
included = yaml.load(f, Loader=yaml.Loader)
if subpath:
cur = included
for seg in filter(None, subpath.split(".")):
if not isinstance(cur, dict) or seg not in cur:
raise KeyError(f"!include path '{subpath}' not found in {filepath}")
cur = cur[seg]
return cur
return included

# Register the constructor on the default Loader used by this script.
yaml.Loader.add_constructor("!include", _yaml_include)

def debug_http():
old_send = http.client.HTTPConnection.send
def new_send(self, data):
Expand Down