Skip to content

Commit

Permalink
[WIP] feat: allow reusing local test directories
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Stuewe <[email protected]>
  • Loading branch information
HalosGhost committed Aug 15, 2024
1 parent f755482 commit 0337155
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions scripts/native-system-benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ TL=$(git rev-parse --show-toplevel)
RT="${TL:-$CWD}"
BLD="$RT"/build
SEEDDIR="$BLD"/preseeds
TESTDIR="$BLD"/test-$(date +"%s")
TESTID=$(date +"%s")
TESTDIR="$BLD"/test-"$TESTID"

IFS='' read -r -d '' usage <<'EOF'
Usage: %s [options]
Expand All @@ -24,6 +25,8 @@ Options:
-c, --config=PATH use PATH as the test configuration
-s, --samples=TIME run test for TIME seconds (defaults to 30)
(or indefinitely if set to inf, or infinity)
-t, --test-dir=PATH use PATH for conducting the test instead of
generating one based on the current time
Cleanup:
--clean delete all previous test and preseed artifacts
Expand Down Expand Up @@ -51,6 +54,11 @@ fi

_err=0
while [[ $# -gt 0 ]]; do
if [[ "$1" = '--' ]]; then
shift 1
break
fi

optarg=
shft_cnt=1
if [[ "$1" =~ [=] ]]; then
Expand Down Expand Up @@ -86,6 +94,13 @@ while [[ $# -gt 0 ]]; do
*) DBG="$optarg";;
esac
shift "$shft_cnt";;
-t*|--test-dir*)
if [[ "${optarg:0:1}" == '/' ]]; then
TESTDIR="$optarg"
else
TESTDIR="$CWD/$optarg"
fi
shift "$shft_cnt";;
-c*|--config*)
if [[ "$optarg" = /* ]]; then
ORIG_CFG="${optarg}"
Expand All @@ -111,7 +126,7 @@ if [[ -n "$_help" ]]; then
exit "$_err"
fi

if [[ -z "$ORIG_CFG" ]]; then
if [[ -z "$ORIG_CFG" && "$TESTDIR" = "$BLD"/test-"$TESTID" ]]; then
printf '%s\n' 'No config specified; exiting'
exit 0
fi
Expand All @@ -136,7 +151,20 @@ BEGIN {
EOF

CFG="$TESTDIR"/config
awk "$normalize" "$ORIG_CFG" > "$CFG"
if [[ -f "$CFG" ]]; then
printf 'WARNING: Running from a pre-existing test directory\n'
if grep -q 'seed' "$CFG"; then
# loadgens don't currently serialize their wallet state to-disk
# so effectively all funds are orphaned in this case; disabling
# seeding means the new loadgens will mint and be able to send
# new transactions
printf 'Disabling seeding in-favor of minting\n'
grep -v 'seed' "$CFG" > "$TESTDIR"/config."$TESTID"
CFG="$TESTDIR"/config."$TESTID"
fi
else
awk "$normalize" "$ORIG_CFG" > "$CFG"
fi

twophase=$(grep -q '2pc=1' "$CFG" && printf '1\n' || printf '0\n')
arch=
Expand Down

0 comments on commit 0337155

Please sign in to comment.