Skip to content

Commit fb2cf1f

Browse files
committed
fix(test): force Virtuoso checkpoint after loading test data
Virtuoso may not fully index inserted data before queries run, causing flaky SELECT failures despite ASK checks passing. Run an explicit checkpoint via isql after data loading and replace ASK verification with SELECT queries that confirm data is queryable.
1 parent e688eb0 commit fb2cf1f

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

tests/load_test_data.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,21 @@ def load_data(data_file, endpoint="http://localhost:9999/sparql"):
8080
_process_chunk(triples[i:i + chunk_size], client, (i // chunk_size) + 1, total_chunks)
8181

8282

83-
def _verify_data_loaded(endpoint="http://localhost:9999/sparql", timeout=30):
84-
"""Wait until a broad sample of test data is queryable in Virtuoso."""
83+
def _verify_data_loaded(endpoint="http://localhost:9999/sparql", timeout=60):
84+
"""Wait until test data is fully queryable in Virtuoso via SELECT."""
8585
checks = [
86-
'ASK { GRAPH <https://github.com/arcangelo7/time_agnostic/br/> { <https://github.com/arcangelo7/time_agnostic/br/2> ?p ?o } }',
87-
'ASK { GRAPH <https://github.com/arcangelo7/time_agnostic/id/> { <https://github.com/arcangelo7/time_agnostic/id/27139> ?p ?o } }',
88-
'ASK { GRAPH <https://github.com/arcangelo7/time_agnostic/ar/> { <https://github.com/arcangelo7/time_agnostic/ar/15519> ?p ?o } }',
86+
('SELECT ?p ?o WHERE { GRAPH ?g { <https://github.com/arcangelo7/time_agnostic/br/31830> ?p ?o } }', 1),
87+
('SELECT ?p ?o WHERE { GRAPH ?g { <https://github.com/arcangelo7/time_agnostic/id/27139> ?p ?o } }', 1),
88+
('SELECT ?p ?o WHERE { GRAPH ?g { <https://github.com/arcangelo7/time_agnostic/ar/15519> ?p ?o } }', 1),
8989
]
9090
start_time = time.time()
9191
with SPARQLClient(endpoint) as client:
92-
for check in checks:
92+
for query, min_results in checks:
9393
while True:
9494
if time.time() - start_time > timeout:
95-
raise TimeoutError(f"Data verification timed out: {check}")
96-
if client.ask(check):
95+
raise TimeoutError(f"Data verification timed out: {query}")
96+
result = client.query(query)
97+
if len(result["results"]["bindings"]) >= min_results:
9798
break
9899
time.sleep(1)
99100
print("Data verification passed.")

tests/start-test-database.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,9 @@ docker exec test-virtuoso /opt/virtuoso-opensource/bin/isql -U dba -P dba exec="
4545
echo "Loading test data..."
4646
uv run python tests/load_test_data.py
4747

48+
# Force Virtuoso to flush transaction log to disk
49+
echo "Running Virtuoso checkpoint..."
50+
docker exec test-virtuoso /opt/virtuoso-opensource/bin/isql -U dba -P dba exec="checkpoint;"
51+
4852
echo "Setup completed."
49-
echo "Virtuoso DB: http://localhost:9999/sparql"
53+
echo "Virtuoso DB: http://localhost:9999/sparql"

0 commit comments

Comments
 (0)