This document explains the step-by-step logic of the test.sh script, which validates the core distributed features of DynaRust.
The test suite automates the lifecycle of a 3-node cluster, simulating real-world production events like network partitions, node failures, and massive write bursts.
- Cleanup: Kills any lingering
DynaRustprocesses and wipes thedata/andsnapshots/directories to ensure a "Shared Nothing" starting state. - Build: Recompiles the project in
--releasemode to ensure performance-sensitive features (likeDashMapandAES-GCMencryption) are tested at full speed.
- Dynamic Join: Node 2 and Node 3 join the cluster via Node 1.
- SWIM Protocol: The script waits 15 seconds for the SWIM-inspired gossip protocol to propagate membership. It verifies that every node's "view" of the cluster shows 3 active members.
- Registration Replication: Alice registers on Node 1. The test then attempts to log in as Alice on a different node.
- Verification: This confirms that the internal
authtable is being replicated across the cluster, allowing users to authenticate against any entry point.
This is the most complex part of the test suite:
- Isolation: We send a
SIGSTOPto Node 2, effectively freezing it and simulating a network partition (Split Brain). - Divergent Updates: While Node 2 is frozen, we update a key on Node 1.
- Healing: We resume Node 2 (
SIGCONT) and immediately perform a conflicting update on it. - Reconciliation: The test waits for the nodes to communicate. It verifies that Vector Clocks correctly identified the conflict and used Last-Writer-Wins (LWW) to bring both nodes to the same final state.
- Throughput: Fires 1,000 PUT requests across 20 parallel threads using
xargs. - DashMap Validation: Tests if the shard-based locking in
DashMaphandles high-frequency writes without deadlocks or data corruption. - Total Replication: Verifies that after the burst, all 3 nodes report a key count of exactly 1,000.
- Cold Save: The test triggers the periodic persistence task which encrypts the in-memory store into chunked
storage.dbfiles. - Nuclear Option: Kills the entire cluster (simulating a power failure).
- Restoration: Restarts a node and verifies that the data is correctly decrypted and reloaded from disk into memory.
- Real-time Broadcast: Spawns 3 parallel background listeners on the same key.
- Validation: Performs a single write and verifies that all 3 subscribers received the update event in real-time, confirming the
SubscriptionManagerhandles multiplexing correctly.
- Security Check: Verifies that a normal user (Bob) cannot overwrite Alice's data.
- Admin Elevation: Authenticates as an admin and verifies that the admin can overwrite Alice's data, ensuring the "backdoor" management functions work for cluster maintainers.
- Metrics Middleware: Validates that the request counter and latency tracking are active and reporting non-zero values.
chmod +x test.sh
./test.shNote: Ensure jq is installed on your system as it is used to parse JSON responses.