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
119 lines
3.9 KiB
Python
119 lines
3.9 KiB
Python
import pytest
|
|
|
|
from .helpers.collection_setup import drop_collection
|
|
from .helpers.helpers import request_with_validation
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def setup(collection_name):
|
|
mix_collection_setup(collection_name=collection_name)
|
|
yield
|
|
drop_collection(collection_name=collection_name)
|
|
|
|
|
|
def mix_collection_setup(
|
|
collection_name='test_collection',
|
|
on_disk_payload=False,
|
|
):
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}',
|
|
method="DELETE",
|
|
path_params={'collection_name': collection_name},
|
|
)
|
|
assert response.ok
|
|
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}',
|
|
method="PUT",
|
|
path_params={'collection_name': collection_name},
|
|
body={
|
|
"vectors": {
|
|
"image": {
|
|
"size": 2,
|
|
"distance": "Euclid"
|
|
}
|
|
},
|
|
"sparse_vectors": {
|
|
"text": {}
|
|
},
|
|
"on_disk_payload": on_disk_payload,
|
|
}
|
|
)
|
|
assert response.ok
|
|
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}',
|
|
method="GET",
|
|
path_params={'collection_name': collection_name},
|
|
)
|
|
assert response.ok
|
|
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}/points',
|
|
method="PUT",
|
|
path_params={'collection_name': collection_name},
|
|
query_params={'wait': 'true'},
|
|
body={
|
|
"points": [
|
|
{
|
|
"id": 1, "vector": {"image": [1, 2], "text": {"indices": [100, 500, 10], "values": [0.9, 0.8, 0.5]}}
|
|
},
|
|
{
|
|
"id": 2, "vector": {"image": [1, 3], "text": {"indices": [10], "values": [0.1]}}
|
|
},
|
|
{
|
|
"id": 3, "vector": {"image": [2, 0], "text": {"indices": [55, 20, 101], "values": [0.4, 0.6, 0.1]}}
|
|
},
|
|
{
|
|
"id": 4, "vector": {"image": [1, 1], "text": {"indices": [66, 12], "values": [0.5, 0.5]}}
|
|
},
|
|
{
|
|
"id": 5, "vector": {"image": [0, 0], "text": {"indices": [1, 2, 3], "values": [0.1, 0.2, 0.3]}}
|
|
}
|
|
]
|
|
}
|
|
)
|
|
assert response.ok
|
|
|
|
|
|
def test_collection_mix_batch_update(collection_name):
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}/points',
|
|
method="PUT",
|
|
path_params={'collection_name': collection_name},
|
|
query_params={'wait': 'true'},
|
|
body={
|
|
"points": [
|
|
{
|
|
"id": 1, "vector": {"image": [1, 1], "text": {"indices": [100, 500, 10], "values": [0.9, 0.8, 0.5]}}
|
|
},
|
|
{
|
|
"id": 2, "vector": {"image": [2, 2], "text": {"indices": [10, 100, 500], "values": [0.1, 0, 0]}}
|
|
},
|
|
{
|
|
"id": 3, "vector": {"image": [3, 3], "text": {"indices": [55, 20, 101], "values": [0.4, 0.6, 0.1]}}
|
|
},
|
|
{
|
|
"id": 4, "vector": {"image": [4, 4], "text": {"indices": [66, 12], "values": [0.5, 0.5]}}
|
|
},
|
|
{
|
|
"id": 5, "vector": {"image": [5, 5], "text": {"indices": [1, 2, 3], "values": [0.1, 0.2, 0.3]}}
|
|
}
|
|
]
|
|
}
|
|
)
|
|
assert response.ok
|
|
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}/points/scroll',
|
|
method="POST",
|
|
path_params={'collection_name': collection_name},
|
|
body={"limit": 10, "with_vector": True}
|
|
)
|
|
assert response.ok
|
|
assert len(response.json()['result']['points']) == 5
|
|
results = response.json()['result']['points']
|
|
|
|
assert results[2]['vector']['image'] == [3, 3]
|
|
assert results[2]['vector']['text']['indices'] == [20, 55, 101]
|