From 9bcca268a395ac697c7b3770118a5a348062c6dd Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Fri, 14 Feb 2020 21:58:03 -0700 Subject: [PATCH] Add simple gossip DoS test --- .../abi-testcases/mixed-validator-test.sh | 4 +- system-test/stability-testcases/.gitignore | 1 + .../stability-testcases/gossip-dos-test.sh | 65 +++++++++++++++++++ .../stability-testcases/gossip-dos-test.yml | 3 + 4 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 system-test/stability-testcases/.gitignore create mode 100755 system-test/stability-testcases/gossip-dos-test.sh create mode 100644 system-test/stability-testcases/gossip-dos-test.yml diff --git a/system-test/abi-testcases/mixed-validator-test.sh b/system-test/abi-testcases/mixed-validator-test.sh index 89b0615f21..526f45f219 100755 --- a/system-test/abi-testcases/mixed-validator-test.sh +++ b/system-test/abi-testcases/mixed-validator-test.sh @@ -6,6 +6,7 @@ set -e cd "$(dirname "$0")" +SOLANA_ROOT="$(cd ../..; pwd)" logDir="$PWD"/logs ledgerDir="$PWD"/config @@ -29,8 +30,7 @@ solanaInstallGlobalOpts=( bootstrapInstall() { declare v=$1 if [[ ! -h $solanaInstallDataDir/active_release ]]; then - curl -sSf https://raw.githubusercontent.com/solana-labs/solana/v"$v"/install/solana-install-init.sh \ - | sh -s - "$v" "${solanaInstallGlobalOpts[@]}" + sh "$SOLANA_ROOT"/install/solana-install-init.sh "$v" "${solanaInstallGlobalOpts[@]}" fi export PATH="$solanaInstallDataDir/active_release/bin/:$PATH" } diff --git a/system-test/stability-testcases/.gitignore b/system-test/stability-testcases/.gitignore new file mode 100644 index 0000000000..1790fda312 --- /dev/null +++ b/system-test/stability-testcases/.gitignore @@ -0,0 +1 @@ +/releases/ diff --git a/system-test/stability-testcases/gossip-dos-test.sh b/system-test/stability-testcases/gossip-dos-test.sh new file mode 100755 index 0000000000..73c082409b --- /dev/null +++ b/system-test/stability-testcases/gossip-dos-test.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +set -e +cd "$(dirname "$0")" +SOLANA_ROOT="$(cd ../..; pwd)" + + +if [[ $(uname) != Linux ]]; then + echo Error: this test is Linux only + exit 1 +fi + +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" + +killall solana-gossip || true +solana-gossip spy --gossip-port 8001 > "$logDir"/gossip.log 2>&1 & +solanaGossipPid=$! +echo "solana-gossip pid: $solanaGossipPid" +sleep 5 +dd if=/dev/zero bs=1232 > /dev/udp/127.0.0.1/8001 & +ddPid=$! +echo "dd pid: $ddPid" + +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 $ddPid; then + echo "dd is no longer running after $SECONDS seconds" + pass=false + break + fi + sleep 1 +done + +kill $solanaGossipPid || true +kill $ddPid || true +wait || true + +$pass && echo Pass diff --git a/system-test/stability-testcases/gossip-dos-test.yml b/system-test/stability-testcases/gossip-dos-test.yml new file mode 100644 index 0000000000..95ab5dae1d --- /dev/null +++ b/system-test/stability-testcases/gossip-dos-test.yml @@ -0,0 +1,3 @@ +steps: + - command: "system-test/stability-testcases/gossip-dos-test.sh" + label: "Gossip DoS Test"