diff --git a/integration_test.sh b/integration_test.sh index 22305cf..4197cf1 100755 --- a/integration_test.sh +++ b/integration_test.sh @@ -241,7 +241,7 @@ port: 8111 data_dir: "./conflict1_data" seed_nodes: [] log_level: "info" -sync_interval: 8 +sync_interval: 3 EOF cat > conflict2.yaml </dev/null) - local node2_final_msg=$(echo "$node2_final_full" | jq -r '.data.message' 2>/dev/null) + # Wait for conflict resolution with retry logic (up to 60 seconds) + local max_attempts=20 + local attempt=1 + local node1_final_msg="" + local node2_final_msg="" + local node1_final_full="" + local node2_final_full="" + + log_info "Waiting for conflict resolution (checking every 3 seconds, max 60 seconds)..." + + while [ $attempt -le $max_attempts ]; do + sleep 3 + + # Get current data from both nodes + node1_final_full=$(curl -s http://localhost:8111/kv/test/conflict/data) + node2_final_full=$(curl -s http://localhost:8112/kv/test/conflict/data) + + node1_final_msg=$(echo "$node1_final_full" | jq -r '.data.message' 2>/dev/null) + node2_final_msg=$(echo "$node2_final_full" | jq -r '.data.message' 2>/dev/null) + + # Check if they've converged + if [ "$node1_final_msg" = "$node2_final_msg" ] && [ -n "$node1_final_msg" ] && [ "$node1_final_msg" != "null" ]; then + log_info "Conflict resolution achieved after $((attempt * 3)) seconds" + break + fi + + log_info "Attempt $attempt/$max_attempts: Node1='$node1_final_msg', Node2='$node2_final_msg' (not converged yet)" + attempt=$((attempt + 1)) + done # Check if they converged if [ "$node1_final_msg" = "$node2_final_msg" ] && [ -n "$node1_final_msg" ]; then