Skip to content

Commit 1758c18

Browse files
authored
Add a script to stress-test faucets (#4396)
## Motivation On Testnet Babbage, we experienced a faucet failure (rather, DoS) when many people tried to create wallets and chains at the same time. To make sure it doesn't happen again, we'd like to stress-test the faucet with artificial data. ## Proposal Add a small bash script that executes `linera wallet init; linera wallet request-chain` against a faucet many times in parallel, printing timing information on stdout in JSON for analysis. ## Test Plan Run against a local faucet. ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent 268857e commit 1758c18

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

scripts/faucet-stress-test.bash

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
3+
faucet_url=${1-http://localhost:8080}; shift
4+
count=${1-100}; shift
5+
wallet_base_path=${1-$(mktemp -dtu linera-faucet-stress-test.XXXXXX)/wallet}; shift
6+
7+
wallets=()
8+
9+
function cleanup {
10+
rm -rf "${wallets[@]}"
11+
rmdir --ignore-fail-on-non-empty "$wallet_base_path" 2>/dev/null
12+
}
13+
14+
trap cleanup EXIT
15+
16+
function create_wallet_and_claim_chain {
17+
local path=$1; shift
18+
wallets+=("$path")
19+
mkdir -p $path
20+
TIMEFORMAT='{ "operation": "init", "duration": %R, "wallet": "'"$path"'" }'
21+
time {
22+
LINERA_WALLET=$path/wallet.json \
23+
LINERA_KEYSTORE=$path/keystore.json \
24+
LINERA_STORAGE=rocksdb:$path/storage.db \
25+
>/dev/null \
26+
2>&3 \
27+
linera wallet init --faucet $faucet_url
28+
}
29+
TIMEFORMAT='{ "operation": "request-chain", "duration": %R, "wallet": "'"$path"'" }'
30+
time {
31+
LINERA_WALLET=$path/wallet.json \
32+
LINERA_KEYSTORE=$path/keystore.json \
33+
LINERA_STORAGE=rocksdb:$path/storage.db \
34+
>/dev/null \
35+
2>&3 \
36+
linera wallet request-chain --faucet $faucet_url
37+
}
38+
}
39+
40+
TIMEFORMAT='{ "operation": "stress-test", "duration": %R }'
41+
{
42+
time {
43+
for i in $(seq $count)
44+
do
45+
create_wallet_and_claim_chain $wallet_base_path/$i &
46+
done
47+
wait
48+
}
49+
} 3>&2 2>&1

0 commit comments

Comments
 (0)