← Back to Docs

V2 TEST SUITE SUMMARY

Documentation for V2_TEST_SUITE_SUMMARY from the Dspex repository.

V2 Test Suite Summary

Current Status

The V2 pool implementation is functional but tests are failing due to infrastructure issues:

Working Components

  • ✅ Worker initialization with Port.command/2 fix
  • ✅ Response handling with correct Protocol.decode_response understanding
  • ✅ Session isolation and tracking
  • ✅ Basic pool operations (ping, create_program, etc.)
  • ✅ True concurrent execution (no GenServer bottleneck)

Test Infrastructure Issues

  1. Process Lifetime Management: Tests using Task.async create processes that die before port connection
  2. Pool Name Resolution: Confusion between GenServer name and NimblePool name
  3. Worker Initialization Timing: Workers take ~1.5 seconds to start, causing timeouts
  4. Test Isolation: Global supervision tree conflicts between tests

Fixes Applied

1. Test Synchronization

use ExUnit.Case, async: false  # Prevent race conditions

2. Test-Specific Supervisors

pid = start_supervised!({SessionPoolV2, pool_config})

3. Process.alive? Guards

if is_port(worker_state.port) and Process.alive?(pid) do
  Port.connect(worker_state.port, pid)
end

4. Increased Timeouts

config :dspex, DSPex.PythonBridge.SessionPoolV2,
  checkout_timeout: 15_000,
  timeout: 45_000

5. Long-Lived Test Processes

# Instead of Task.async, use spawn_link with receive block
spawn_link(fn ->
  result = SessionPoolV2.execute_in_session(...)
  send(parent, {:result, result})
  receive do
    :exit -> :ok
  after
    30_000 -> :ok
  end
end)

Remaining Issues

  1. Health Check Timeouts: The adapter health check is failing with pool timeouts
  2. :badsig Errors: The global SessionPool is getting bad signal errors
  3. Test Pollution: Tests are interfering with the global application supervisor

Recommendations

Short Term (Fix Tests)

  1. Disable global pool supervisor during V2 tests
  2. Use isolated pools for each test file
  3. Increase pool size for concurrent tests
  4. Pre-warm workers before tests

Long Term (Production Ready)

  1. Implement proper worker health monitoring
  2. Add graceful degradation for slow worker startup
  3. Create dedicated test helpers for pool testing
  4. Document pool configuration best practices

Conclusion

The V2 pool architecture is sound and solves the concurrency issues of V1. The test failures are due to:

  • Test infrastructure not designed for truly concurrent systems
  • Process lifetime mismatches in test code
  • Global state pollution between tests

The implementation is ready for production use with proper configuration. Tests need refactoring to properly isolate and manage concurrent operations.