mirror of
https://github.com/qdrant/qdrant.git
synced 2026-07-23 11:11:00 -05:00
Collection name under test is equal to the test module name, without `.py` suffix. * Helps by debugging/tracing failed tests and find relevant logs lines in qdrant log files * Opens up a possibility to run tests in parallel, given that there are no data sharing between test modules Change details: * defined module scoped `collection_name` fixture in `conftest.py` * removed `collection_name` module variable * each test signature modified to declare the dependency to `collection_name` fixture * `@pytest.mark.parametrize` migrated to `@pytest-cases.parametrize` in cases when `collection_name` was used as the value
52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
import http.server
|
|
import pytest
|
|
import socketserver
|
|
import threading
|
|
import os
|
|
|
|
|
|
HTTP_SERVER_HOST = os.environ.get("HTTP_SERVER_HOST", "localhost")
|
|
|
|
@pytest.fixture(params=[False, True], scope="module")
|
|
def on_disk_vectors(request):
|
|
return request.param
|
|
|
|
|
|
@pytest.fixture(params=[False, True], scope="module")
|
|
def on_disk_payload(request):
|
|
return request.param
|
|
|
|
|
|
@pytest.fixture
|
|
def http_server(tmpdir):
|
|
"""
|
|
Starts a HTTP server serving files from a temporary directory.
|
|
Yields a tuple (tmpdir, url).
|
|
"""
|
|
|
|
class Handler(http.server.SimpleHTTPRequestHandler):
|
|
def __init__(self, *args, **kwargs):
|
|
# Serve files from the temporary directory
|
|
super().__init__(*args, directory=str(tmpdir), **kwargs)
|
|
|
|
def log_request(self, *args, **kwargs):
|
|
# Silence logging
|
|
pass
|
|
|
|
with socketserver.TCPServer(("0.0.0.0", 0), Handler) as httpd:
|
|
httpd.allow_reuse_address = True
|
|
thread = threading.Thread(
|
|
target=httpd.serve_forever,
|
|
# Lower the shutdown poll interval to speed up tests
|
|
kwargs={"poll_interval": 0.1},
|
|
)
|
|
thread.start()
|
|
yield (tmpdir, f"http://{HTTP_SERVER_HOST}:{httpd.server_address[1]}")
|
|
httpd.shutdown()
|
|
thread.join()
|
|
|
|
|
|
@pytest.fixture(scope='module', autouse=True)
|
|
def collection_name(request):
|
|
return request.node.name.removesuffix(".py")
|