trustgraph/tests/unit
V.Sreeram d4723566cb fix: prevent duplicate dispatcher creation race condition in invoke_global_service (#715)
* fix: prevent duplicate dispatcher creation race condition in invoke_global_service

Concurrent coroutines could all pass the `if key in self.dispatchers` check
before any of them wrote the result back, because `await dispatcher.start()`
yields to the event loop. This caused multiple Pulsar consumers to be created
on the same shared subscription, distributing responses round-robin and
dropping ~2/3 of them — manifesting as a permanent spinner in the Workbench UI.

Apply a double-checked asyncio.Lock in both `invoke_global_service` and
`invoke_flow_service` so only one dispatcher is ever created per service key.

* test: add concurrent-dispatch tests for race condition fix

Add asyncio.gather-based tests that verify invoke_global_service and
invoke_flow_service create exactly one dispatcher under concurrent calls,
preventing the duplicate Pulsar consumer bug.
2026-04-06 11:14:32 +01:00
..
test_agent Additional agent DAG tests (#750) 2026-04-01 13:59:58 +01:00
test_base Embeddings API scores (#671) 2026-03-09 10:53:44 +00:00
test_chunking RabbitMQ pub/sub backend with topic exchange architecture (#752) 2026-04-02 12:47:16 +01:00
test_cli Fix/tests (#647) 2026-02-23 22:01:47 +00:00
test_clients Pub/sub abstraction: decouple from Pulsar (#751) 2026-04-01 20:16:53 +01:00
test_concurrency RabbitMQ pub/sub backend with topic exchange architecture (#752) 2026-04-02 12:47:16 +01:00
test_config Structure data mvp (#452) 2025-08-07 20:47:20 +01:00
test_cores Remove redundant metadata (#685) 2026-03-11 10:51:39 +00:00
test_decoding RabbitMQ pub/sub backend with topic exchange architecture (#752) 2026-04-02 12:47:16 +01:00
test_direct Updated test suite for explainability & provenance (#696) 2026-03-13 14:27:42 +00:00
test_embeddings Updated test suite for explainability & provenance (#696) 2026-03-13 14:27:42 +00:00
test_extract Updated test suite for explainability & provenance (#696) 2026-03-13 14:27:42 +00:00
test_gateway fix: prevent duplicate dispatcher creation race condition in invoke_global_service (#715) 2026-04-06 11:14:32 +01:00
test_knowledge_graph Remove schema:subjectOf edges from KG extraction (#695) 2026-03-13 12:11:21 +00:00
test_librarian Add universal document decoder with multi-format support (#705) 2026-03-23 12:56:35 +00:00
test_provenance Additional agent DAG tests (#750) 2026-04-01 13:59:58 +01:00
test_pubsub RabbitMQ pub/sub backend with topic exchange architecture (#752) 2026-04-02 12:47:16 +01:00
test_query SPARQL query service (#754) 2026-04-02 17:21:39 +01:00
test_rdf Pub/sub abstraction: decouple from Pulsar (#751) 2026-04-01 20:16:53 +01:00
test_reliability Pub/sub abstraction: decouple from Pulsar (#751) 2026-04-01 20:16:53 +01:00
test_retrieval Pub/sub abstraction: decouple from Pulsar (#751) 2026-04-01 20:16:53 +01:00
test_rev_gateway Fix tests (#593) 2025-12-19 08:53:21 +00:00
test_storage Remove redundant metadata (#685) 2026-03-11 10:51:39 +00:00
test_structured_data Updated test suite for explainability & provenance (#696) 2026-03-13 14:27:42 +00:00
test_text_completion Feat: Auto-pull missing Ollama models (#757) 2026-04-06 11:10:53 +01:00
__init__.py Test suite executed from CI pipeline (#433) 2025-07-14 14:57:44 +01:00
test_prompt_manager.py Feature/prompts jsonl (#619) 2026-01-26 17:38:00 +00:00
test_prompt_manager_edge_cases.py Update to enable knowledge extraction using the agent framework (#439) 2025-07-21 14:31:57 +01:00
test_python_api_client.py Structured data 2 (#645) 2026-02-23 15:56:29 +00:00