Skip to content

test(db): add connection pool concurrency and failure tests #438

Description

@GaspardKirira

Summary

Add automated tests for vix::db::ConnectionPool and vix::db::PooledConn.

The pool is shared by every high-level DB operation and must behave correctly under concurrency, connection failures, invalid factories, and resource exhaustion.

Current behavior

The connection pool:

  • creates connections through a factory;
  • keeps idle connections in a queue;
  • limits the total connection count;
  • waits when the maximum is reached;
  • validates reused connections with ping();
  • releases connections through PooledConn.

No automated tests currently verify these guarantees.

Expected behavior

The tests must use deterministic fake connections and factories so pool behavior can be validated without depending on a real database engine.

Scope

  • Add a fake Connection implementation for testing.
  • Test minimum connection warmup.
  • Test maximum connection enforcement.
  • Test reuse of released connections.
  • Test waiting while all connections are in use.
  • Test wakeup after a connection is released.
  • Test removal of failed connections.
  • Test factory failures.
  • Test invalid factory results.
  • Test PooledConn destruction.
  • Test PooledConn move construction.
  • Test concurrent acquire and release operations.
  • Preserve the existing public DB API.

Suggested files

  • modules/db/tests/fakes/FakeConnection.hpp
  • modules/db/tests/connection_pool_test.cpp
  • modules/db/tests/CMakeLists.txt

Acceptance criteria

  • Tests do not require MySQL or SQLite.
  • Concurrent tests have bounded execution time.
  • Tests do not depend on arbitrary long sleeps.
  • The maximum configured connection count is never exceeded.
  • Waiting callers continue after a release.
  • Failed connections are not returned to callers.
  • Factory errors do not permanently reduce usable pool capacity.
  • Tests pass under ThreadSanitizer where supported.
  • Existing public APIs remain unchanged.

Non-goals

This issue does not include:

  • redesigning the connection pool API;
  • adding asynchronous acquisition;
  • adding pool metrics;
  • database driver benchmarks.

Suggested labels

  • scope:db
  • type:ci
  • tests
  • sanitizers
  • help wanted
  • status:ready

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededsanitizersRuntime and compile-time analysis using sanitizers (ASan, UBSan, TSan).scope:dbDatabase driversstatus:readyIssue is fully specified and ready for implementationtestsTests, CI coverage and validationtype:ciCI, tests, or tooling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions