Skip to content

Commit

Permalink
Misc Local Install improvements. (#13446)
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-François Gagné <[email protected]>
Signed-off-by: Rohit Nayak <[email protected]>
Co-authored-by: Rohit Nayak <[email protected]>
  • Loading branch information
jfg956 and rohit-nayak-ps authored Sep 4, 2023
1 parent 7636754 commit 2ed24d5
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 7 deletions.
4 changes: 3 additions & 1 deletion examples/common/scripts/etcd-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ source "$(dirname "${BASH_SOURCE[0]:-$0}")/../env.sh"

cell=${CELL:-'test'}

echo "Starting etcd..."

# Check that etcd is not already running
curl "http://${ETCD_SERVER}" > /dev/null 2>&1 && fail "etcd is already running. Exiting."

Expand All @@ -39,6 +41,6 @@ vtctl $TOPOLOGY_FLAGS VtctldCommand AddCellInfo \
$cell
set -e

echo "etcd start done..."
echo "etcd is running!"


2 changes: 2 additions & 0 deletions examples/common/scripts/mysqlctl-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ mysqlctl \
--tablet_uid $uid \
--mysql_port $mysql_port \
$action

echo -e "MySQL for tablet $alias is running!"
3 changes: 1 addition & 2 deletions examples/common/scripts/vtgate-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ grpc_port=15991
mysql_server_port=15306
mysql_server_socket_path="/tmp/mysql.sock"

# Start vtgate.
echo "Starting vtgate..."
# shellcheck disable=SC2086
vtgate \
$TOPOLOGY_FLAGS \
Expand All @@ -46,7 +46,6 @@ vtgate \
# Block waiting for vtgate to be listening
# Not the same as healthy

echo "Waiting for vtgate to be up..."
while true; do
curl -I "http://$hostname:$web_port/debug/status" >/dev/null 2>&1 && break
sleep 0.1
Expand Down
1 change: 1 addition & 0 deletions examples/common/scripts/vtorc-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ source "${script_dir}/../env.sh"
log_dir="${VTDATAROOT}/tmp"
port=16000

echo "Starting vtorc..."
vtorc \
$TOPOLOGY_FLAGS \
--logtostderr \
Expand Down
2 changes: 2 additions & 0 deletions examples/common/scripts/vttablet-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,5 @@ done

# check one last time
curl -I "http://$hostname:$port/debug/status" || fail "tablet could not be started!"

echo -e "vttablet for $alias is running!"
17 changes: 14 additions & 3 deletions examples/local/101_initial_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,29 @@ CELL=zone1 ../common/scripts/vtctld-up.sh

if vtctldclient GetKeyspace commerce > /dev/null 2>&1 ; then
# Keyspace already exists: we could be running this 101 example on an non-empty VTDATAROOT
vtctldclient --server localhost:15999 SetKeyspaceDurabilityPolicy --durability-policy=semi_sync commerce || fail "Failed to set keyspace durability policy on the commerce keyspace"
vtctldclient SetKeyspaceDurabilityPolicy --durability-policy=semi_sync commerce || fail "Failed to set keyspace durability policy on the commerce keyspace"
else
# Create the keyspace with the sidecar database name and set the
# correct durability policy. Please see the comment above for
# more context on using a custom sidecar database name in your
# Vitess clusters.
vtctldclient --server localhost:15999 CreateKeyspace --sidecar-db-name="${SIDECAR_DB_NAME}" --durability-policy=semi_sync commerce || fail "Failed to create and configure the commerce keyspace"
vtctldclient CreateKeyspace --sidecar-db-name="${SIDECAR_DB_NAME}" --durability-policy=semi_sync commerce || fail "Failed to create and configure the commerce keyspace"
fi

# start mysqlctls for keyspace commerce
# because MySQL takes time to start, we do this in parallel
for i in 100 101 102; do
CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh &
done

# without a sleep, we can have below echo happen before the echo of mysqlctl-up.sh
sleep 2
echo "Waiting for mysqlctls to start..."
wait
echo "mysqlctls are running!"

# start vttablets for keyspace commerce
for i in 100 101 102; do
CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh
CELL=zone1 KEYSPACE=commerce TABLET_UID=$i ../common/scripts/vttablet-up.sh
done

Expand Down
9 changes: 8 additions & 1 deletion examples/local/401_teardown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@ for tablet in 100 200 300 400; do
printf -v alias '%s-%010d' 'zone1' $uid
echo "Shutting down tablet $alias"
CELL=zone1 TABLET_UID=$uid ../common/scripts/vttablet-down.sh
CELL=zone1 TABLET_UID=$uid ../common/scripts/mysqlctl-down.sh
# because MySQL takes time to stop, we do this in parallel
CELL=zone1 TABLET_UID=$uid ../common/scripts/mysqlctl-down.sh &
done

# without a sleep below, we can have the echo happen before the echo of mysqlctl-down.sh
sleep 2
echo "Waiting mysqlctl to stop..."
wait
echo "mysqlctls are stopped!"
fi
done

Expand Down

0 comments on commit 2ed24d5

Please sign in to comment.