solana/system-test/stability-testcases/gossip-dos-test.sh

64 lines
1.4 KiB
Bash
Raw Normal View History

2020-02-14 20:58:03 -08:00
#!/usr/bin/env bash
set -e
cd "$(dirname "$0")"
SOLANA_ROOT="$(cd ../..; pwd)"
logDir="$PWD"/logs
rm -rf "$logDir"
mkdir "$logDir"
solanaInstallDataDir=$PWD/releases
solanaInstallGlobalOpts=(
--data-dir "$solanaInstallDataDir"
--config "$solanaInstallDataDir"/config.yml
--no-modify-path
)
# Install all the solana versions
bootstrapInstall() {
declare v=$1
if [[ ! -h $solanaInstallDataDir/active_release ]]; then
sh "$SOLANA_ROOT"/install/solana-install-init.sh "$v" "${solanaInstallGlobalOpts[@]}"
fi
export PATH="$solanaInstallDataDir/active_release/bin/:$PATH"
}
bootstrapInstall "edge"
solana-install-init --version
solana-install-init edge
solana-gossip --version
solana-dos --version
2020-02-14 20:58:03 -08:00
killall solana-gossip || true
solana-gossip spy --gossip-port 8001 > "$logDir"/gossip.log 2>&1 &
solanaGossipPid=$!
echo "solana-gossip pid: $solanaGossipPid"
sleep 5
solana-dos --mode gossip --data-type random --data-size 1232 &
dosPid=$!
echo "solana-dos pid: $dosPid"
2020-02-14 20:58:03 -08:00
pass=true
SECONDS=
while ((SECONDS < 600)); do
if ! kill -0 $solanaGossipPid; then
echo "solana-gossip is no longer running after $SECONDS seconds"
pass=false
break
fi
if ! kill -0 $dosPid; then
echo "solana-dos is no longer running after $SECONDS seconds"
2020-02-14 20:58:03 -08:00
pass=false
break
fi
sleep 1
done
kill $solanaGossipPid || true
kill $dosPid || true
2020-02-14 20:58:03 -08:00
wait || true
$pass && echo Pass