From b8fd3a1ce57e5f4d64bd35991ab43eee9ac3d3a8 Mon Sep 17 00:00:00 2001 From: KyrinCode Date: Wed, 17 Dec 2025 17:25:12 +0800 Subject: [PATCH] add test for promoting nonvoter sequencer --- devnet/scripts/active-sequencer.sh | 4 +-- devnet/scripts/promote-nonvoter-to-voter.sh | 34 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100755 devnet/scripts/promote-nonvoter-to-voter.sh diff --git a/devnet/scripts/active-sequencer.sh b/devnet/scripts/active-sequencer.sh index 660143a..f233c00 100755 --- a/devnet/scripts/active-sequencer.sh +++ b/devnet/scripts/active-sequencer.sh @@ -80,12 +80,12 @@ echo "Sequencer successfully activated" SERVER_COUNT=$(curl -sS -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"conductor_clusterMembership","params":[],"id":1}' http://localhost:$LEADER_CONDUCTOR_PORT | jq '.result.servers | length') if (( $SERVER_COUNT < 3 )); then curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"conductor_addServerAsVoter","params":["conductor-2", "op-conductor2:50050", 0],"id":1}' http://localhost:$LEADER_CONDUCTOR_PORT - curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"conductor_addServerAsVoter","params":["conductor-3", "op-conductor3:50050", 0],"id":1}' http://localhost:$LEADER_CONDUCTOR_PORT + curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"conductor_addServerAsNonvoter","params":["conductor-3", "op-conductor3:50050", 0],"id":1}' http://localhost:$LEADER_CONDUCTOR_PORT SERVER_COUNT=$(curl -sS -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"conductor_clusterMembership","params":[],"id":1}' http://localhost:$LEADER_CONDUCTOR_PORT | jq '.result.servers | length') if (( $SERVER_COUNT != 3 )); then echo "unexpected server count, expected: 3, real: $SERVER_COUNT" exit 1 fi - echo "add 2 new voters to raft consensus cluster successfully!" + echo "add 1 voter and 1 nonvoter to raft consensus cluster successfully!" fi diff --git a/devnet/scripts/promote-nonvoter-to-voter.sh b/devnet/scripts/promote-nonvoter-to-voter.sh new file mode 100755 index 0000000..32a6848 --- /dev/null +++ b/devnet/scripts/promote-nonvoter-to-voter.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Function to detect leader conductor and set ports +detect_leader() { + echo "Detecting leader conductor..." + + # Check all three conductors to find the leader + for i in 1 2 3; do + CONDUCTOR_PORT=$((8546 + i)) # 8547, 8548, 8549 + SEQUENCER_PORT=$((9544 + i)) # 9545, 9546, 9547 + + IS_LEADER=$(curl -sS -X POST -H "Content-Type: application/json" \ + --data '{"jsonrpc":"2.0","method":"conductor_leader","params":[],"id":1}' \ + http://localhost:$CONDUCTOR_PORT 2>/dev/null | jq -r '.result' 2>/dev/null) + + if [ "$IS_LEADER" = "true" ]; then + LEADER_CONDUCTOR_PORT=$CONDUCTOR_PORT + LEADER_SEQUENCER_PORT=$SEQUENCER_PORT + echo "Found leader: Conductor $i (conductor port: $LEADER_CONDUCTOR_PORT, sequencer port: $LEADER_SEQUENCER_PORT)" + return 0 + else + echo "Conductor $i (port $CONDUCTOR_PORT): not leader (result: $IS_LEADER)" + fi + done + + echo "Error: No leader conductor found!" + exit 1 +} + +# Detect leader conductor and set ports +detect_leader + + +curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"conductor_addServerAsVoter","params":["conductor-3", "op-conductor3:50050", 0],"id":1}' http://localhost:$LEADER_CONDUCTOR_PORT \ No newline at end of file