From ae9322c15386a96c72c9c9a06e1dbffddb364eaa Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Mon, 13 Apr 2026 16:38:42 +0800 Subject: [PATCH 1/2] tests: adding "error_message" and "training_state" fields for the vector index --- arango/formatter.py | 4 ++++ tests/static/cluster-3.12.conf | 1 + tests/static/single-3.12.conf | 1 + tests/test_index.py | 20 ++++++++++++++++++++ 4 files changed, 26 insertions(+) diff --git a/arango/formatter.py b/arango/formatter.py index e159c23f..568be244 100644 --- a/arango/formatter.py +++ b/arango/formatter.py @@ -119,6 +119,10 @@ def format_index(body: Json, formatter: bool = True) -> Json: # Introduced via Vector Index in 3.12.6 if "params" in body: result["params"] = body["params"] + if "errorMessage" in body: + result["error_message"] = body["errorMessage"] + if "trainingState" in body: + result["training_state"] = body["trainingState"] return verify_format(body, result) diff --git a/tests/static/cluster-3.12.conf b/tests/static/cluster-3.12.conf index 37737111..6e325cc3 100644 --- a/tests/static/cluster-3.12.conf +++ b/tests/static/cluster-3.12.conf @@ -9,6 +9,7 @@ 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 diff --git a/tests/static/single-3.12.conf b/tests/static/single-3.12.conf index 3c438832..185ff7e5 100644 --- a/tests/static/single-3.12.conf +++ b/tests/static/single-3.12.conf @@ -8,6 +8,7 @@ jwt-secret = /tests/static/keyfile [args] all.database.password = passwd +all.vector-index = true all.database.extended-names = true all.javascript.allow-admin-execute = true all.server.options-api = admin diff --git a/tests/test_index.py b/tests/test_index.py index 04708d9d..b4e4954a 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -350,6 +350,26 @@ def test_add_mdi_index(icol, db_version): icol.delete_index(result["id"]) +def test_add_vector_index(col): + docs = [] + for i in range(100): + docs.append({"x": [1] * 128}) + col.insert_many(docs) + result = col.add_index( + { + "type": "vector", + "fields": ["x"], + "name": "vector_index", + "params": { + "metric": "cosine", + "dimension": 128, + "nLists": 2, + }, + } + ) + assert result["name"] == "vector_index" + + def test_delete_index(icol, bad_col): old_indexes = set(extract("id", icol.indexes())) hash_index = {"type": "hash", "fields": ["attr1", "attr2"], "unique": True} From 35e79a730d23897cd8286eb082bdcc6cb4299087 Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Mon, 13 Apr 2026 16:54:57 +0800 Subject: [PATCH 2/2] test fix --- tests/test_index.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_index.py b/tests/test_index.py index b4e4954a..c756b1e9 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -8,7 +8,7 @@ IndexListError, IndexLoadError, ) -from tests.helpers import assert_raises, extract +from tests.helpers import assert_raises, extract, generate_doc_key def test_list_indexes(icol, bad_col): @@ -353,7 +353,7 @@ def test_add_mdi_index(icol, db_version): def test_add_vector_index(col): docs = [] for i in range(100): - docs.append({"x": [1] * 128}) + docs.append({"_key": generate_doc_key(), "x": [1] * 128}) col.insert_many(docs) result = col.add_index( { @@ -368,6 +368,7 @@ def test_add_vector_index(col): } ) assert result["name"] == "vector_index" + col.delete_index(result["id"]) def test_delete_index(icol, bad_col):