Skip to content

Commit

Permalink
test: Invariant is now applied only to persisted local segment
Browse files Browse the repository at this point in the history
  • Loading branch information
tazarov committed Apr 17, 2024
1 parent 3651baa commit 3a969a8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 11 additions & 1 deletion chromadb/test/property/invariants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import gc
import math
from time import sleep

import psutil

Expand Down Expand Up @@ -180,8 +181,17 @@ def fd_not_exceeding_threadpool_size(threadpool_size: int) -> None:
"""
current_process = psutil.Process()
open_files = current_process.open_files()
if len([p.path for p in open_files if "sqlite3" in p.path]) - 1 <= threadpool_size:
max_retries = 5
retry_count = 0
# we probably don't need the below but we keep it to avoid flaky tests.
while (
len([p.path for p in open_files if "sqlite3" in p.path]) - 1 > threadpool_size
and retry_count < max_retries
):
gc.collect() # GC to collect the orphaned TLS objects
open_files = current_process.open_files()
retry_count += 1
sleep(1)
assert (
len([p.path for p in open_files if "sqlite3" in p.path]) - 1 <= threadpool_size
)
Expand Down
4 changes: 3 additions & 1 deletion chromadb/test/test_multithreaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ def perform_operation(
exception = future.exception()
if exception is not None:
raise exception
if isinstance(api, SegmentAPI): # we can't check invariants for FastAPI
if (
isinstance(api, SegmentAPI) and api.get_settings().is_persistent is True
): # we can't check invariants for FastAPI
invariants.fd_not_exceeding_threadpool_size(num_workers)
# Check that invariants hold
invariants.count(coll, records_set)
Expand Down

0 comments on commit 3a969a8

Please sign in to comment.