summaryrefslogtreecommitdiff
path: root/scripts/analyze-raft-simulation.sh
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-06-22 11:58:00 +0300
committerPaul Buetow <paul@buetow.org>2025-06-22 11:58:00 +0300
commit0b5afe8839241dec66ba832cf42860ec69b87df8 (patch)
treee100d2d6204f8c04dc33418ae9f193fa6b1a83c2 /scripts/analyze-raft-simulation.sh
parentb0fc02ce45cb51ce7c8d607d4773808cfa9b6c87 (diff)
Fix message delivery in headless test environment
- Fixed HeadlessSimulationEngine to use correct task manager from receiving process - Reduced message delays for testing (10-50ms instead of 500-2000ms) - Fixed process ID method call (getProcessID not getProcessId) - Improved message delivery scheduling to ensure tasks go to the right task manager This resolves message delivery issues where messages were sent but not received. BasicMulticast test now passes, but 12 protocol tests still failing. 🤖 Generated with Claude Code https://claude.ai/code Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'scripts/analyze-raft-simulation.sh')
-rwxr-xr-xscripts/analyze-raft-simulation.sh57
1 files changed, 57 insertions, 0 deletions
diff --git a/scripts/analyze-raft-simulation.sh b/scripts/analyze-raft-simulation.sh
new file mode 100755
index 0000000..7d6d222
--- /dev/null
+++ b/scripts/analyze-raft-simulation.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+#
+# Analyze why raft.dat isn't working properly
+#
+
+echo "=== Analyzing Raft Simulation Issue ==="
+echo
+
+# Check current raft.dat content
+echo "1. Checking raft.dat file..."
+if [ -f "saved-simulations/raft.dat" ]; then
+ echo " ✓ raft.dat exists ($(stat -c%s saved-simulations/raft.dat 2>/dev/null || stat -f%z saved-simulations/raft.dat) bytes)"
+
+ # Try to detect protocol in the file
+ echo
+ echo "2. Detecting protocols in raft.dat..."
+ strings saved-simulations/raft.dat | grep -E "(Protocol|protocol)" | sort | uniq | head -10
+else
+ echo " ✗ raft.dat not found!"
+ exit 1
+fi
+
+echo
+echo "3. Running raft.dat simulation test..."
+echo " (Looking for Raft-specific messages)"
+echo
+
+# Run and check for Raft messages
+java -cp target/classes:target/test-classes \
+ -Djava.awt.headless=true \
+ -Dds.sim.verbose=true \
+ testing.HeadlessProtocolRunner saved-simulations/raft.dat 2>&1 | \
+ grep -E "(FOLLOWER|CANDIDATE|LEADER|REQUEST_VOTE|election|Raft)" | head -20
+
+echo
+echo "=== Analysis Results ==="
+echo
+echo "PROBLEM: The raft.dat file contains Ping-Pong protocol events, not Raft protocol."
+echo
+echo "The file shows these protocols being loaded:"
+strings saved-simulations/raft.dat | grep -E "VSPingPongProtocol|VSRaftProtocol" | head -5
+
+echo
+echo "=== Solution ==="
+echo
+echo "The raft.dat file needs to be recreated with Raft protocol events."
+echo "Since the file uses Java serialization, it must be created via the GUI:"
+echo
+echo "1. Run: java -jar target/ds-sim-1.0.1-SNAPSHOT.jar"
+echo "2. Create a new simulation (File → New)"
+echo "3. Add 3 processes"
+echo "4. For each process:"
+echo " - Right-click → Protocols → Raft Consensus Algorithm → Server"
+echo "5. Save as: saved-simulations/raft.dat"
+echo
+echo "The issue is that the current raft.dat is just a copy of ping-pong.dat"
+echo "and still contains PingPong protocol activation events." \ No newline at end of file