Skip to content

Commit 7033bef

Browse files
authored
Merge pull request #41 from VirtualFlyBrain/feature/add-thumbnails-to-image-queries
Add thumbnail, template and technique columns to image-bearing queries
2 parents b0047f8 + ef2b11b commit 7033bef

2 files changed

Lines changed: 134 additions & 57 deletions

File tree

src/test/term_info_queries_test.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import unittest
23
import time
34
from vfbquery.term_info_queries import deserialize_term_info, deserialize_term_info_from_dict, process
@@ -582,17 +583,31 @@ def test_term_info_performance(self):
582583
self.assertIsNotNone(result_1, "FBbt_00003748 query returned None")
583584
self.assertIsNotNone(result_2, "VFB_00101567 query returned None")
584585

585-
# Performance assertions - fail if queries take too long
586-
# These thresholds are based on observed performance characteristics
587-
max_single_query_time = 10.0 # seconds (increased from 5.0 to account for SOLR cache overhead)
588-
max_total_time = 10.0 # seconds (2 queries * 5 seconds each)
589-
590-
self.assertLess(duration_1, max_single_query_time,
591-
f"FBbt_00003748 query took {duration_1:.4f}s, exceeding {max_single_query_time}s threshold")
586+
# Performance assertions - fail if queries take too long.
587+
# Thresholds depend on whether SOLR result caching is enabled. When
588+
# VFBQUERY_CACHE_ENABLED=false (CI sets this in python-test.yml so the
589+
# test exercises the live path), every call is a fresh Neo4j round-trip
590+
# rather than a cache hit, so timings are roughly an order of magnitude
591+
# higher. The cache-disabled budget below matches the observed
592+
# uncached latency on healthy infra (~10-20s per query for FBbt_00003748
593+
# which has a large neighbourhood).
594+
cache_enabled = os.environ.get("VFBQUERY_CACHE_ENABLED", "true").lower() != "false"
595+
if cache_enabled:
596+
max_single_query_time = 10.0
597+
max_total_time = 10.0
598+
else:
599+
max_single_query_time = 30.0
600+
max_total_time = 45.0
601+
602+
self.assertLess(duration_1, max_single_query_time,
603+
f"FBbt_00003748 query took {duration_1:.4f}s, exceeding {max_single_query_time}s threshold "
604+
f"(cache_enabled={cache_enabled})")
592605
self.assertLess(duration_2, max_single_query_time,
593-
f"VFB_00101567 query took {duration_2:.4f}s, exceeding {max_single_query_time}s threshold")
606+
f"VFB_00101567 query took {duration_2:.4f}s, exceeding {max_single_query_time}s threshold "
607+
f"(cache_enabled={cache_enabled})")
594608
self.assertLess(duration_1 + duration_2, max_total_time,
595-
f"Total query time {duration_1 + duration_2:.4f}s exceeds {max_total_time}s threshold")
609+
f"Total query time {duration_1 + duration_2:.4f}s exceeds {max_total_time}s threshold "
610+
f"(cache_enabled={cache_enabled})")
596611

597612
# Log success
598613
print("Performance test completed successfully!")

0 commit comments

Comments
 (0)