bench-tps/net sanity: add ability to check for unexpected extra nodes

This commit is contained in:
Michael Vines
2018-09-11 20:00:49 -07:00
parent 9ab5692acf
commit f06113500d
6 changed files with 41 additions and 4 deletions

View File

@ -73,7 +73,7 @@ echo "--- Node count"
set -x set -x
client_id=/tmp/client-id.json-$$ client_id=/tmp/client-id.json-$$
$solana_keygen -o $client_id $solana_keygen -o $client_id
$solana_bench_tps --identity $client_id --num-nodes 3 --converge-only $solana_bench_tps --identity $client_id --num-nodes 3 --reject-extra-nodes --converge-only
rm -rf $client_id rm -rf $client_id
) || flag_error ) || flag_error

View File

@ -108,6 +108,11 @@ time net/gce.sh create "${gce_create_args[@]}"
net/init-metrics.sh -e net/init-metrics.sh -e
echo --- net.sh start echo --- net.sh start
time net/net.sh start -s "$snapChannel" maybeRejectExtraNodes=
if ! $publicNetwork; then
maybeRejectExtraNodes="-o rejectExtraNodes"
fi
# shellcheck disable=SC2086 # Don't want to double quote maybeRejectExtraNodes
time net/net.sh start -s "$snapChannel" $maybeRejectExtraNodes
exit 0 exit 0

View File

@ -32,5 +32,6 @@ echo --- net.sh sanity
net/net.sh sanity \ net/net.sh sanity \
${NO_LEDGER_VERIFY:+-o noLedgerVerify} \ ${NO_LEDGER_VERIFY:+-o noLedgerVerify} \
${NO_VALIDATOR_SANITY:+-o noValidatorSanity} \ ${NO_VALIDATOR_SANITY:+-o noValidatorSanity} \
${REJECT_EXTRA_NODES:+-o rejectExtraNodes} \
exit 0 exit 0

View File

@ -34,6 +34,7 @@ Operate a configured testnet
sanity/start-specific options: sanity/start-specific options:
-o noLedgerVerify - Skip ledger verification -o noLedgerVerify - Skip ledger verification
-o noValidatorSanity - Skip validator sanity -o noValidatorSanity - Skip validator sanity
-o rejectExtraNodes - Require the exact number of nodes
stop-specific options: stop-specific options:
none none
@ -78,7 +79,7 @@ while getopts "h?S:s:o:f:" opt; do
;; ;;
o) o)
case $OPTARG in case $OPTARG in
noLedgerVerify|noValidatorSanity) noLedgerVerify|noValidatorSanity|rejectExtraNodes)
sanityExtraArgs="$sanityExtraArgs -o $OPTARG" sanityExtraArgs="$sanityExtraArgs -o $OPTARG"
;; ;;
*) *)

View File

@ -27,6 +27,7 @@ missing() {
ledgerVerify=true ledgerVerify=true
validatorSanity=true validatorSanity=true
rejectExtraNodes=false
while [[ $1 = -o ]]; do while [[ $1 = -o ]]; do
opt="$2" opt="$2"
shift 2 shift 2
@ -37,6 +38,9 @@ while [[ $1 = -o ]]; do
noValidatorSanity) noValidatorSanity)
validatorSanity=false validatorSanity=false
;; ;;
rejectExtraNodes)
rejectExtraNodes=true
;;
*) *)
echo "Error: unknown option: $opt" echo "Error: unknown option: $opt"
exit 1 exit 1
@ -89,7 +93,18 @@ echo "+++ $entrypointIp: node count ($numNodes expected)"
( (
set -x set -x
$solana_keygen -o "$client_id" $solana_keygen -o "$client_id"
$solana_bench_tps --network "$entrypointIp:8001" --identity "$client_id" --num-nodes "$numNodes" --converge-only
maybeRejectExtraNodes=
if $rejectExtraNodes; then
maybeRejectExtraNodes="--reject-extra-nodes"
fi
$solana_bench_tps \
--network "$entrypointIp:8001" \
--identity "$client_id" \
--num-nodes "$numNodes" \
$maybeRejectExtraNodes \
--converge-only
) )
echo "--- $entrypointIp: verify ledger" echo "--- $entrypointIp: verify ledger"

View File

@ -431,6 +431,11 @@ fn main() {
.takes_value(true) .takes_value(true)
.help("wait for NUM nodes to converge"), .help("wait for NUM nodes to converge"),
) )
.arg(
Arg::with_name("reject-extra-nodes")
.long("reject-extra-nodes")
.help("require exactly num-nodes on convergence. Appropriate only for internal networks"),
)
.arg( .arg(
Arg::with_name("threads") Arg::with_name("threads")
.short("t") .short("t")
@ -517,6 +522,16 @@ fn main() {
); );
exit(1); exit(1);
} }
if matches.is_present("reject-extra-nodes") {
if nodes.len() > num_nodes {
println!(
"Error: Extra nodes discovered. Expecting exactly {}",
num_nodes
);
exit(1);
}
}
if leader.is_none() { if leader.is_none() {
println!("no leader"); println!("no leader");
exit(1); exit(1);