Skip to content

test-support: add multi_get fault injection hook to TestBackend #369

Description

@coderabbitai

Summary

TestBackend in crates/gossip-scanner-runtime/src/git_persistence.rs currently exposes set_fail_on_get_call which only fires for single-key get calls. The multi_get implementation reads state.kv directly without incrementing get_call_count, so the load_watermarks error path (which goes through multi_get) cannot be fault-injected from downstream crates using the test-support feature.

Proposed change

Add a set_fail_on_multi_get_call(call_no: usize) / clear_fail_on_multi_get_call() pair to TestBackend (with a matching multi_get_call_count: usize and fail_on_multi_get_call: Option<usize> field on TestBackendState) that fires an injected TestBackendError when the internal monotonic counter reaches call_no.

Alternatively, the multi_get override could be removed from TestBackend entirely so it delegates to the default get-loop implementation, sharing the existing fail_on_get_call hook — though this changes observable call-count semantics for tests that already use set_fail_on_get_call.

Motivation

This enables downstream integration tests (e.g., in scanner-engine-integration-tests) to cover the load_watermarks backend-error path deterministically, closing the remaining untestable read branch in GitPersistenceAdapter.

Context

Identified in PR #365 (feature/seen-bitmap-crash-recovery). Deferred from that PR as out of scope — crash-recovery tests for commit_finalize only go through single-key get calls.

Requested by: @ahrav
PR reference: #365 (comment)

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions