Skip to content

Add Sentinel mode unit tests for Valkey client reconnection #10772

@jopemachine

Description

@jopemachine

Objective

Add unit tests verifying Valkey client behavior in Sentinel mode, covering master failover detection and reconnection scenarios that are not testable with a standalone Redis instance.

Background

Currently, all Valkey client tests use a standalone Redis container. There are no tests for Sentinel-specific behavior such as master address change detection (need_reconnect), Sentinel discovery failure handling, or reconnection after master failover. BA-5577 requires verification in both Standalone and Sentinel modes.

Scope

Mock-based unit tests

  • ValkeySentinelClient.need_reconnect() detects master address change
  • ValkeySentinelClient._get_master_address() handles Sentinel discovery failure
  • MonitoringValkeyClient monitor loop triggers reconnect on master change (via mocked Sentinel)
  • acquire() failure tracking and reconnect with Sentinel client (via mocked Sentinel)

Mock targets

  • Sentinel.discover_master() — control master address returns
  • GlideClient.create() — return mock client without real connection

Future consideration

Integration tests with real Sentinel infrastructure (Docker Compose with master + replica + sentinel) would require CI infrastructure changes and are out of scope for this issue.

Acceptance Criteria

  • Unit tests for ValkeySentinelClient Sentinel-specific behavior (need_reconnect, master discovery failure)
  • Unit tests for MonitoringValkeyClient wrapping a Sentinel client (monitor loop + acquire reconnect)
  • All tests pass in CI

JIRA Issue: BA-5585

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions