Skip to content

Commit

Permalink
runner.sh: add --external flag for testing external network
Browse files Browse the repository at this point in the history
With --external flag bench will be run locally without docker container.
The `-a` flag should be used with the `-e` flag for specifying the
external RPC address.

Close #160

Signed-off-by: Ekaterina Pavlova <[email protected]>
  • Loading branch information
AliceInHunterland committed May 27, 2024
1 parent c6c6491 commit 08b3a43
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,15 @@ The following default configurations are available:
--msPerBlock Protocol setting specifying the minimal (and targeted for) time interval between blocks. Must be an integer number of milliseconds.
The default value is set in configuration templates and is 1s and 5s for single node and multinode setup respectively.
Example: --msPerBlock 3000
-e, --external Use external network for benchmarking. Default is false. -a flag should be used to specify RPC addresses.
```

## Build options

By default, neo-bench uses released versions of Neo nodes to build Docker images.
However, you can easily test non-released branches or even separate commits for both Go and C# Neo nodes.
However, you can easily test non-released branches or even separate commits for both Go and C# Neo nodes.
Also with `--external` flag benchmark will be build and run locally without docker containers.

### Build Go node image from sources

Expand Down
27 changes: 23 additions & 4 deletions runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
source .env

OUTPUT=""
ARGS=(-i "/dump.txs")
ARGS=()
FILES=()
MODE=""
COUNT=""
IR_TYPE=go
RPC_TYPE=
RPC_ADDR=()
EXTERNAL_NETWORK=false
export NEOBENCH_LOGGER=${NEOBENCH_LOGGER:-none}
export NEOBENCH_TYPE=${NEOBENCH_TYPE:-NEO}
export NEOBENCH_FROM_COUNT=${NEOBENCH_FROM_COUNT:-1}
Expand Down Expand Up @@ -54,6 +55,7 @@ show_help() {
echo " --msPerBlock Protocol setting specifying the minimal (and targeted for) time interval between blocks. Must be an integer number of milliseconds."
echo " The default value is set in configuration templates and is 1s and 5s for single node and multinode setup respectively."
echo " Example: --msPerBlock 1000"
echo " -e, --external Use external network for benchmarking. Default is false. -a flag should be used to specify RPC addresses."
exit 0
}

Expand All @@ -72,6 +74,9 @@ while test $# -gt 0; do

case $_opt in
-h | --help) show_help ;;
-e|--external)
EXTERNAL_NETWORK=true
;;
-l | --log)
if [[ $# -gt 0 && ${1:0:1} != "-" ]]; then
case "$1" in
Expand Down Expand Up @@ -272,8 +277,22 @@ if [ -n "$NEOBENCH_VOTE" ]; then
ARGS+=(--vote)
fi

make prepare
cleanup() {
echo "Cleaning up..."
[ -n "$pid" ] && kill "$pid" && wait "$pid"
exit
}

docker compose "${FILES[@]}" run bench neo-bench -o "$OUTPUT" "${ARGS[@]}"
trap cleanup SIGINT SIGTERM EXIT

make stop
make prepare
if [ "$EXTERNAL_NETWORK" = true ]; then
ARGS+=(-i "./.docker/build/dump.$NEOBENCH_TYPE.$NEOBENCH_FROM_COUNT.$NEOBENCH_TO_COUNT.txs" --disable-stats)
./cmd/bin/bench -o "$OUTPUT" "${ARGS[@]}"&
pid=$!
wait $pid
else
ARGS+=(-i "/dump.txs")
docker compose "${FILES[@]}" run bench neo-bench -o "$OUTPUT" "${ARGS[@]}"
make stop
fi

0 comments on commit 08b3a43

Please sign in to comment.