Skip to content

Epic: remove test-only handling from production code #1163

Open
1 of 1 issue completed
Open

Description

@dkropachev

Production code currently accommodates objects and state that exist only because of unit-test fixtures. This adds alternative execution paths to the driver and lets tests exercise weaker contracts than real requests use.

For example, response-future tests supply strings instead of Host instances, while request execution conditionally skips host locking and lifecycle checks for non-Host values:

https://github.com/scylladb/python-driver/blob/41c90067360a2d10d4ac4927c7821ec4611e4598/tests/unit/test_response_future.py#L370-L374

https://github.com/scylladb/python-driver/blob/41c90067360a2d10d4ac4927c7821ec4611e4598/cassandra/cluster.py#L8052-L8062

There are also explicit production fallbacks for tests constructing Session without running its initializer:

https://github.com/scylladb/python-driver/blob/41c90067360a2d10d4ac4927c7821ec4611e4598/cassandra/cluster.py#L4511-L4516

https://github.com/scylladb/python-driver/blob/41c90067360a2d10d4ac4927c7821ec4611e4598/cassandra/cluster.py#L4525-L4530

Scope

Audit cassandra/ for branches, attribute defaults, lazy initialization, and type checks whose only purpose is to accommodate test fixtures, mocks, or partially initialized objects. Remove each confirmed case through focused child issues and update the corresponding fixtures to satisfy the production contract.

Start with:

  • Non-Host handling in ResponseFuture._query() and request selection.
  • Session pool bookkeeping initialized lazily specifically for tests that bypass Session.__init__.
  • An audit of other production accommodations for missing fixture attributes or incomplete mock objects; verify their purpose before scheduling removal.

Acceptance criteria

  • Inventory confirmed test-only accommodations and track their removal in child issues.
  • Refactor fixtures to provide valid object types, ownership, locks, and initialized state.
  • Remove all confirmed test-only production paths identified by the audit.
  • Preserve supported public behavior, including cached Host resolution by ID, and retain endpoint/pool ownership, lifecycle, timeout, retry, and concurrency protections.
  • Preserve legitimate compatibility and runtime fallbacks, including pure-Python implementations; a defensive check alone is not evidence of test-only handling.
  • Keep meaningful behavioral coverage and run the relevant unit suites against pure-Python and rebuilt Cython modules where applicable.

This epic is complete when the audit and its cleanup issues are complete. It does not require a live-cluster reproducer: the initial evidence is the source and test-fixture contracts above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pythonPull requests that update python code

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions