Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Protect against unsupported configurations to prevent non-obvious err…
Browse files Browse the repository at this point in the history
…ors later
  • Loading branch information
mvines committed Jul 20, 2018
1 parent 1abefb2 commit 9d25d76
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
18 changes: 16 additions & 2 deletions ci/testnet-sanity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,27 @@ fi


echo "--- $NET_URL: wallet sanity"
multinode-demo/test/wallet-sanity.sh $NET_URL
(
set -x
multinode-demo/test/wallet-sanity.sh $NET_URL
)

echo "--- $NET_URL: node count"
if [[ $NET_URL = testnet.solana.com ]]; then
echo "TODO: Remove this block when a release > 0.7.0 is deployed"
else
$solana_client_demo $NET_URL $EXPECTED_NODE_COUNT -c
if [[ -n "$USE_SNAP" ]]; then
# TODO: Merge client.sh functionality into solana-client-demo proper and
# remove this USE_SNAP case
progie=$solana_client_demo
else
progie=multinode-demo/client.sh
fi

(
set -x
$progie $NET_URL $EXPECTED_NODE_COUNT -c
)
fi

exit 0
27 changes: 20 additions & 7 deletions multinode-demo/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,20 @@ leader_logger="cat"
validator_logger="cat"
drone_logger="cat"

if [[ -d "$SNAP" ]]; then # Running inside a Linux Snap?
if [[ $(uname) != Linux ]]; then
# Protect against unsupported configurations to prevent non-obvious errors
# later. Arguably these should be fatal errors but for now prefer tolerance.
if [[ -n $USE_SNAP ]]; then
echo "Warning: Snap is not supported on $(uname)"
USE_SNAP=
fi
if [[ -n $SOLANA_CUDA ]]; then
echo "Warning: CUDA is not supported on $(uname)"
SOLANA_CUDA=
fi
fi

if [[ -d $SNAP ]]; then # Running inside a Linux Snap?
solana_program() {
declare program="$1"
if [[ "$program" = wallet || "$program" = client-demo ]]; then
Expand All @@ -33,12 +46,12 @@ if [[ -d "$SNAP" ]]; then # Running inside a Linux Snap?
SOLANA_CUDA="$(snapctl get enable-cuda)"
RUST_LOG="$(snapctl get rust-log)"

elif [[ -n "$USE_SNAP" ]]; then # Use the Linux Snap binaries
elif [[ -n $USE_SNAP ]]; then # Use the Linux Snap binaries
solana_program() {
declare program="$1"
printf "solana.%s" "$program"
}
elif [[ -n "$USE_INSTALL" ]]; then # Assume |cargo install| was run
elif [[ -n $USE_INSTALL ]]; then # Assume |cargo install| was run
solana_program() {
declare program="$1"
printf "solana-%s" "$program"
Expand All @@ -53,7 +66,7 @@ else
program=${BASH_REMATCH[1]}
features="--features=cuda"
fi
if [[ -z "$DEBUG" ]]; then
if [[ -z $DEBUG ]]; then
maybe_release=--release
fi
printf "cargo run $maybe_release --bin solana-%s %s -- " "$program" "$features"
Expand Down Expand Up @@ -97,7 +110,7 @@ configure_metrics() {
IFS=',' read -r -a metrics_params <<< "$SOLANA_METRICS_CONFIG"
for param in "${metrics_params[@]}"; do
IFS='=' read -r -a pair <<< "$param"
if [[ "${#pair[@]}" != 2 ]]; then
if [[ ${#pair[@]} != 2 ]]; then
echo Error: invalid metrics parameter: "$param" >&2
else
declare name="${pair[0]}"
Expand Down Expand Up @@ -151,13 +164,13 @@ SOLANA_CONFIG_CLIENT_DIR=${SNAP_USER_DATA:-$PWD}/config-client
rsync_url() { # adds the 'rsync://` prefix to URLs that need it
declare url="$1"

if [[ "$url" =~ ^.*:.*$ ]]; then
if [[ $url =~ ^.*:.*$ ]]; then
# assume remote-shell transport when colon is present, use $url unmodified
echo "$url"
return 0
fi

if [[ -d "$url" ]]; then
if [[ -d $url ]]; then
# assume local directory if $url is a valid directory, use $url unmodified
echo "$url"
return 0
Expand Down

0 comments on commit 9d25d76

Please sign in to comment.