Skip to content

Commit a6a58a3

Browse files
jfrancoaclaude
andcommitted
test: handle asynchronous namespace deletion in delete test
test_delete_namespace asserted that get() returns None immediately after delete(), but namespace deletion is asynchronous: delete() returns 202, the server marks the namespace state="deleting", and a background sweep removes it later (NAMESPACE_CLEANUP_INTERVAL, default 30s). Against a real 1.38 cluster get() therefore returned Namespace(state="deleting"), failing the assertion. Poll until the namespace is gone (asserting it stays in "deleting" while present) with a 60s timeout that tolerates the default sweep interval. Also set NAMESPACE_CLEANUP_INTERVAL=2s in the namespaces CI compose so the sweep runs quickly and the test finishes in ~1s instead of ~30s. Verified against a live 1.38.0-rc.0 cluster: all 9 namespace integration tests pass (delete completes in ~0.6s with the shortened interval). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c80ad35 commit a6a58a3

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

ci/docker-compose-namespaces.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ services:
1818
environment:
1919
# Namespaces feature — requires GraphQL disabled
2020
NAMESPACES_ENABLED: "true"
21+
# Sweep deleting namespaces quickly so delete-then-gone tests stay fast
22+
# (defaults to 30s).
23+
NAMESPACE_CLEANUP_INTERVAL: "2s"
2124
REPLICATION_MAXIMUM_FACTOR: "1"
2225
DISABLE_GRAPHQL: "true"
2326
# Static API key auth (operator-level access)

integration/test_namespaces.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import time
2+
13
import pytest
24

35
import weaviate
@@ -107,7 +109,15 @@ def test_delete_namespace(client_factory: ClientFactory) -> None:
107109
client.namespaces.create(name="deletens")
108110
client.namespaces.delete(name="deletens")
109111

112+
# Deletion is asynchronous: delete() returns 202 and the server marks the
113+
# namespace "deleting", then removes it on the background cleanup sweep
114+
# (NAMESPACE_CLEANUP_INTERVAL). Poll until it is gone.
115+
deadline = time.time() + 60
110116
fetched = client.namespaces.get(name="deletens")
117+
while fetched is not None and time.time() < deadline:
118+
assert fetched.state == "deleting"
119+
time.sleep(0.5)
120+
fetched = client.namespaces.get(name="deletens")
111121
assert fetched is None
112122

113123

0 commit comments

Comments
 (0)