From 203c7ed866bc85b0c30f5abe6994d23aba1791d8 Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Mon, 13 Apr 2026 17:04:10 +0800 Subject: [PATCH 1/2] Avoiding flaky test race --- tests/test_aql.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/test_aql.py b/tests/test_aql.py index 544a73d..43f3e34 100644 --- a/tests/test_aql.py +++ b/tests/test_aql.py @@ -1,5 +1,6 @@ import asyncio import time +import warnings import pytest from packaging import version @@ -138,10 +139,15 @@ async def test_kill_query(db, bad_db, superuser): queries = await aql.queries() if len(queries) > 0: break - - # Kill the query - query_id = queries[0]["id"] - assert await aql.kill(query_id) is True + time.sleep(1) + + if len(queries) > 0: + # Kill the query + query_id = queries[0]["id"] + assert await aql.kill(query_id) is True + else: + # This test is prone to races + warnings.warn("Query not found in the list, skipping!") # Ignore missing assert await aql.kill("fakeid", ignore_missing=True) is False From 749bcbf4508084eb8c7fd37a85a8c0fbac3f5bfe Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Mon, 13 Apr 2026 18:09:41 +0800 Subject: [PATCH 2/2] Adding new vector index fields --- arangoasync/collection.py | 2 +- arangoasync/typings.py | 18 ++++++++++++++++++ arangoasync/version.py | 2 +- tests/static/cluster-3.12.conf | 5 +++++ tests/static/single-3.12.conf | 6 ++++++ tests/test_collection.py | 23 ++++++++++++++++++++++- 6 files changed, 53 insertions(+), 3 deletions(-) diff --git a/arangoasync/collection.py b/arangoasync/collection.py index 3273465..4c228dd 100644 --- a/arangoasync/collection.py +++ b/arangoasync/collection.py @@ -397,7 +397,7 @@ async def add_index( Args: type (str): Type attribute (ex. "persistent", "inverted", "ttl", "mdi", - "geo"). + "geo", "vector"). fields (dict | list): Fields to index. options (dict | None): Additional index options. diff --git a/arangoasync/typings.py b/arangoasync/typings.py index 1ac0705..8918650 100644 --- a/arangoasync/typings.py +++ b/arangoasync/typings.py @@ -727,6 +727,10 @@ def key_options(self) -> KeyOptions: def computed_values(self) -> Optional[Json]: return self._data.get("computedValues") + @property + def supportsRBAC(self) -> Optional[bool]: + return self._data.get("supportsRBAC") + @property def object_id(self) -> str: return self._data["objectId"] # type: ignore[no-any-return] @@ -808,6 +812,8 @@ def compatibility_formatter(data: Json) -> Json: result["computedValues"] = data["computedValues"] if "internalValidatorType" in data: result["internal_validator_type"] = data["internalValidatorType"] + if "supportsRBAC" in data: + result["supportsRBAC"] = data["supportsRBAC"] return result def format(self, formatter: Optional[Formatter] = None) -> Json: @@ -1121,6 +1127,14 @@ def include_all_fields(self) -> Optional[bool]: def features(self) -> Optional[List[str]]: return self._data.get("features") + @property + def error_message(self) -> Optional[str]: + return self._data.get("errorMessage") + + @property + def training_state(self) -> Optional[str]: + return self._data.get("trainingState") + @staticmethod def compatibility_formatter(data: Json) -> Json: """python-arango compatibility formatter.""" @@ -1179,6 +1193,10 @@ def compatibility_formatter(data: Json) -> Json: result["writebuffer_max_size"] = data["writebufferSizeMax"] if "optimizeTopK" in data: result["optimizeTopK"] = data["optimizeTopK"] + if "errorMessage" in data: + result["error_message"] = data["errorMessage"] + if "trainingState" in data: + result["training_state"] = data["trainingState"] return result def format(self, formatter: Optional[Formatter] = None) -> Json: diff --git a/arangoasync/version.py b/arangoasync/version.py index a955fda..bc86c94 100644 --- a/arangoasync/version.py +++ b/arangoasync/version.py @@ -1 +1 @@ -__version__ = "1.2.1" +__version__ = "1.2.2" diff --git a/tests/static/cluster-3.12.conf b/tests/static/cluster-3.12.conf index d33e07a..6e325cc 100644 --- a/tests/static/cluster-3.12.conf +++ b/tests/static/cluster-3.12.conf @@ -9,7 +9,12 @@ jwt-secret = /tests/static/keyfile [args] all.database.password = passwd +all.vector-index = true all.database.extended-names = true all.log.api-enabled = true all.javascript.allow-admin-execute = true all.server.options-api = admin +all.javascript.files-allowlist = ".*"; +all.javascript.environment-variables-allowlist = ".*"; +all.javascript.endpoints-allowlist = ".*"; +all.javascript.startup-options-allowlist = ".*"; diff --git a/tests/static/single-3.12.conf b/tests/static/single-3.12.conf index d5df3aa..28875d2 100644 --- a/tests/static/single-3.12.conf +++ b/tests/static/single-3.12.conf @@ -8,6 +8,12 @@ jwt-secret = /tests/static/keyfile [args] all.database.password = passwd +all.vector-index = true all.database.extended-names = true +all.log.api-enabled = true all.javascript.allow-admin-execute = true all.server.options-api = admin +all.javascript.files-allowlist = ".*"; +all.javascript.environment-variables-allowlist = ".*"; +all.javascript.endpoints-allowlist = ".*"; +all.javascript.startup-options-allowlist = ".*"; diff --git a/tests/test_collection.py b/tests/test_collection.py index b154499..8729626 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -228,15 +228,36 @@ async def test_collection_index(doc_col, bad_col, cluster): await bad_col.load_indexes() assert err.value.error_code == DATA_SOURCE_NOT_FOUND + # Create a vector index + docs = [] + for key in range(100): + docs.append({"_key": f"key_{key}", "embedding": [1] * 128}) + await doc_col.insert_many(docs) + idx4 = await doc_col.add_index( + "vector", + ["embedding"], + { + "name": "vector_index", + "params": { + "metric": "cosine", + "dimension": 128, + "nLists": 2, + }, + }, + ) + assert idx4.name == "vector_index" + # Delete indexes - del1, del2, del3 = await asyncio.gather( + del1, del2, del3, del4 = await asyncio.gather( doc_col.delete_index(idx1.id), doc_col.delete_index(idx2.numeric_id), doc_col.delete_index(str(idx3.numeric_id)), + doc_col.delete_index(idx4.id), ) assert del1 is True assert del2 is True assert del3 is True + assert del4 is True # Now, the indexes should be gone with pytest.raises(IndexDeleteError) as err: