File: leaderless-replication/testdynamotester.py

Date: 2026-05-29

Time: 10:22

Purpose

testdynamotester.py is a QA-level integration test suite for the Dynamo-style leaderless replication module. It sits alongside the developer-written testdynamo.py and serves as an independent validation layer — the "tester" naming convention across this repo (testertest*.py or test*_tester.py) indicates tests generated or curated to verify the implementation against its spec, distinct from the author's own unit tests.

This file exercises the full public API of dynamo.py: cluster formation, quorum reads/writes, node failure handling, read repair, conflict detection, sloppy quorums with hinted handoff, and anti-entropy repair.

Key Components

The file defines 10 test functions, each targeting a specific behavioral contract:

| Test | What it validates |

|------|-------------------|

| testspecexample_full | End-to-end happy path: write, read, node failure, quorum enforcement, read repair, anti-entropy |

| testspecsloppyquorumexample | Sloppy quorum stores hints on live nodes and delivers them when the target recovers |

| testreadnonexistent_key | Reading a missing key returns None/version 0 without conflict |

| testversionrollbackonfailed_write | A failed quorum write must not increment the version counter — the next successful write picks up from the last committed version |

| testnodeunavailablerejectsoperations | ReplicaNode rejects reads/writes when marked unavailable, preserving prior state |

| testmultiplekeys_independent | Version counters are per-key, not global |

| testconflictdetection | When replicas hold the same version number but different values, a read returns is_conflict=True with all conflicting values as a list |

| testlargecluster10kops | N=7 cluster handles 10k writes across 50 keys without error (smoke/perf test) |

| testantientropyfullsync | Anti-entropy repair synchronizes a node that missed all writes while offline |

| testnohintswithoutsloppyquorum | With sloppyquorum=False, no hints are stored or delivered — offline nodes stay empty until anti-entropy runs |

Patterns

Failure injection via setnodeavailable: Every test that exercises fault tolerance follows the same pattern — take nodes down, perform operations, bring nodes back, assert repair behavior. This is a controlled simulation of network partitions.

Direct store manipulation for conflict injection (test 7): Rather than orchestrating a real concurrent-write scenario, the test injects divergent VersionedValue entries directly into _store on each node. This is a pragmatic shortcut — it tests conflict *detection* without requiring the implementation to produce conflicts organically.

Quorum arithmetic as a test parameter: Tests carefully choose writequorum and readquorum values to create the exact failure conditions needed. For instance, testversionrollbackonfailed_write uses W=3, R=1 so that a single node failure guarantees write failure.

Naming convention: The file is testdynamotester.py (not testertestdynamo.py like most other modules), which is a minor inconsistency in the repo's naming scheme.

Dependencies

Imports from dynamo.py:

Nothing imports this file — it's a leaf test module.

Flow

Tests follow a consistent structure:

1. Construct a DynamoCluster with specific quorum parameters

2. Setup — write initial data, optionally take nodes offline

3. Act — perform the operation under test (put, get, repair, deliver hints)

4. Assert — verify return values, side effects on specific nodes, or exception behavior

Test 1 (testspecexample_full) is the most complex, walking through an entire lifecycle: write → read → node failure → write with degraded quorum → node recovery → read repair → quorum failure → anti-entropy.

Invariants

These tests collectively enforce:

Error Handling

Topics to Explore

Beliefs