Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testnet-deploy: add support for a client node running continuous transactions on the net #724

Merged
merged 2 commits into from
Jul 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion ci/testnet-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ findVms "name=$leaderName"
exit 1
}

echo "Client node:"
findVms "name=$leaderName-client"
clientVm=
if [[ ${#vmlist[@]} = 2 ]]; then
clientVm=${vmlist[1]}
unset 'vmlist[1]'
fi

echo "Validator nodes:"
findVms "name~^$leaderName-validator-"

Expand All @@ -96,7 +104,7 @@ if ! $ROLLING_UPDATE; then
echo "--- Shutting down $vmName in zone $vmZone $nodePosition"
gcloud compute ssh "$vmName" --zone "$vmZone" \
--ssh-flag="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" \
--command="echo sudo snap remove solana" &
--command="sudo snap remove solana" &

if [[ $((count % 5)) = 0 ]]; then
# Slow down deployment to avoid triggering GCP login
Expand All @@ -110,6 +118,29 @@ if ! $ROLLING_UPDATE; then
wait
fi


client_run() {
declare message=$1
declare cmd=$2
[[ -n $clientVm ]] || return 0;
vmName=${clientVm%:*}
vmZone=${clientVm#*:}
echo "--- $message $vmName in zone $vmZone"
gcloud compute ssh "$vmName" --zone "$vmZone" \
--ssh-flag="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" \
--command="$cmd"
}

client_run \
"Shutting down" \
"\
set -x;
tmux list-sessions; \
tmux capture-pane -t solana -p; \
tmux kill-session -t solana; \
sudo snap remove solana; \
"

echo "--- Refreshing leader"
leader=true
pids=()
Expand Down Expand Up @@ -188,4 +219,19 @@ echo "--- $publicUrl sanity test"
USE_SNAP=1 ci/testnet-sanity.sh $publicUrl ${#vmlist[@]}
)

client_run \
"Starting client on " \
"\
set -x;
sudo snap install solana --$SOLANA_SNAP_CHANNEL --devmode; \
snap info solana; \
tmux new -s solana -d \" \
/snap/bin/solana.client-demo $SOLANA_NET_URL ${#vmlist[@]} --loop; \
echo Error: client-demo should never exit; \
bash \
\"; \
sleep 2; \
tmux capture-pane -t solana -p -S -100 \
"

exit 0
54 changes: 40 additions & 14 deletions multinode-demo/client.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,60 @@
#!/bin/bash
#!/bin/bash -e
#
# usage: $0 <rsync network path to solana repo on leader machine> <number of nodes in the network>"
# usage: $0 [leader_url] [num_nodes] [--loop] [extra args]
#
# leader_url URL to the leader (defaults to ..)
# num_nodes Minimum number of nodes to look for while converging
# --loop Add this flag to cause the program to loop infinitely
# "extra args" Any additional arguments are pass along to solana-client-demo
#

here=$(dirname "$0")
# shellcheck source=multinode-demo/common.sh
source "$here"/common.sh

leader=$1
shift
if [[ -z $leader ]]; then
if [[ -d "$SNAP" ]]; then
leader=testnet.solana.com # Default to testnet when running as a Snap
else
leader=$here/.. # Default to local solana repo
fi
fi
count=${2:-1}
shift 2

count=$1
shift
if [[ -z $count ]]; then
count=-1
fi

loop=
if [[ $1 = --loop ]]; then
loop=1
shift
fi

rsync_leader_url=$(rsync_url "$leader")

set -ex
mkdir -p "$SOLANA_CONFIG_CLIENT_DIR"
$rsync -vPz "$rsync_leader_url"/config/leader.json "$SOLANA_CONFIG_CLIENT_DIR"/
iteration=0
while true; do
(
set -x
mkdir -p "$SOLANA_CONFIG_CLIENT_DIR"
$rsync -vPz "$rsync_leader_url"/config/leader.json "$SOLANA_CONFIG_CLIENT_DIR"/

client_json="$SOLANA_CONFIG_CLIENT_DIR"/client.json
[[ -r $client_json ]] || $solana_keygen -o "$client_json"
client_json="$SOLANA_CONFIG_CLIENT_DIR"/client.json
[[ -r $client_json ]] || $solana_keygen -o "$client_json"

$solana_client_demo \
-n "$count" \
-l "$SOLANA_CONFIG_CLIENT_DIR"/leader.json \
-k "$SOLANA_CONFIG_CLIENT_DIR"/client.json \
"$@"
$solana_client_demo \
-n "$count" \
-l "$SOLANA_CONFIG_CLIENT_DIR"/leader.json \
-k "$SOLANA_CONFIG_CLIENT_DIR"/client.json \
"$@"
)
[[ -n $loop ]] || exit 0
iteration=$((iteration + 1))
echo ------------------------------------------------------------------------
echo "Iteration: $iteration"
echo ------------------------------------------------------------------------
done