|
|
Testing ADK Parallel Agent Fan-Out and Fan-In
Author: Venkata Sudhakar
ShopMax India's order fulfillment uses ADK parallel agents to simultaneously check warehouse stock in Mumbai, Delhi, and Bangalore while running a fraud score and fetching the customer profile - all at once. Testing parallel agent fan-out ensures every branch executes and returns results, and fan-in tests confirm the aggregator correctly merges all branch outputs into a single final response.
An ADK parallel agent dispatches multiple sub-agents concurrently and waits for all to finish before the fan-in aggregation step. Tests use asyncio.gather() to simulate concurrent execution. You assert that each branch ran, that its output is present in the aggregated result, and that no branch result overwrites another. Timeout tests verify the aggregator fails fast if any branch hangs.
The example below fans out three parallel checks for a ShopMax India order: stock availability, fraud score, and customer tier. The fan-in step merges all three. Tests confirm each branch output is present and the final decision is computed correctly from the merged data.
It gives the following output,
... (3 passed in 0.01s)
In production, ShopMax India should set per-branch timeouts using asyncio.wait_for() so a slow fraud API does not block order confirmation for all customers. Test the timeout path explicitly by injecting a branch that sleeps beyond the deadline. Monitor branch latency percentiles separately so you can identify which parallel check is the bottleneck during Diwali peak traffic.
|
|