forked from vmware/concord-bft
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from evdzhurov/utt-test-automation
Utt test automation
- Loading branch information
Showing
10 changed files
with
324 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
#!/bin/bash | ||
echo "" | ||
echo "Killing all services..." | ||
killall utt_replica | ||
killall payment_service | ||
echo "Done." | ||
|
||
echo "" | ||
echo "Cleaning files..." | ||
rm -rf logs/* core.* rocksdb/* | ||
rm -rf logs/* core.* rocksdb/* automation/* | ||
echo "Done." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/bash | ||
|
||
set +x | ||
|
||
if [[ -z $1 ]]; then | ||
echo "Usage: specify the automation commands to be used." | ||
exit 1 | ||
fi | ||
|
||
# Reset the state | ||
./reset.sh | ||
|
||
# Start replicas and payment services (and keep them running in the background) | ||
. startServices.sh | ||
|
||
mkdir -p automation | ||
|
||
# Summarize the initial state of each wallet | ||
echo "" | ||
echo "Gather the initial state of the system..." | ||
WALLET_PIDS=() | ||
for id in {1..9} | ||
do | ||
../UTTClient/utt_client -n config/net_localhost.txt -i $id -s automation/init_$id.txt > /dev/null & | ||
WALLET_PIDS+=" $!" | ||
done | ||
echo "Waiting wallet pids (${WALLET_PIDS}) to finish..." | ||
wait ${WALLET_PIDS} | ||
echo "Done." | ||
|
||
echo "" | ||
echo "WalledId | LastBlockId | PublicBalance | UttBalance | UttBudget" | ||
cat automation/init_* | ||
|
||
# Export variables describing the initial state | ||
NUM_WALLETS=9 | ||
INIT_BLOCK_ID=$(awk 'BEGIN {value=0} {if(NR==1) value=$2; else if(value != $2) value="error: inconsistent initial value"} END {print value}' automation/init_*) | ||
INIT_PUBLIC_BALANCE=$(awk 'BEGIN {value=0} {if(NR==1) value=$3; else if(value != $3) value="error: inconsistent initial value"} END {print value}' automation/init_*) | ||
INIT_UTT_BALANCE=$(awk 'BEGIN {value=0} {if(NR==1) value=$4; else if(value != $4) value="error: inconsistent initial value"} END {print value}' automation/init_*) | ||
INIT_UTT_BUDGET=$(awk 'BEGIN {value=0} {if(NR==1) value=$5; else if(value != $5) value="error: inconsistent initial value"} END {print value}' automation/init_*) | ||
|
||
# Run automation on each wallet | ||
echo "" | ||
echo "Run automation..." | ||
WALLET_PIDS=() | ||
for id in {1..9} | ||
do | ||
echo -e $1 | ../UTTClient/utt_client -n config/net_localhost.txt -i $id &> automation/run_$id.txt & | ||
WALLET_PIDS+=" $!" | ||
done | ||
echo "Waiting wallet pids (${WALLET_PIDS}) to finish..." | ||
wait ${WALLET_PIDS} | ||
echo "Done." | ||
|
||
# Summarize the final state of each wallet | ||
echo "" | ||
echo "Gather the final state of the system..." | ||
WALLET_PIDS=() | ||
for id in {1..9} | ||
do | ||
../UTTClient/utt_client -n config/net_localhost.txt -i $id -s automation/final_$id.txt > /dev/null & | ||
WALLET_PIDS+=" $!" | ||
done | ||
echo "Waiting wallet pids (${WALLET_PIDS}) to finish..." | ||
wait ${WALLET_PIDS} | ||
echo "Done." | ||
|
||
echo "" | ||
echo "WalledId | LastBlockId | PublicBalance | UttBalance | UttBudget" | ||
cat automation/final_* | ||
|
||
# Stop replicas and payment services | ||
. stopServices.sh | ||
|
||
wait # Wait all services to terminate | ||
echo "" | ||
echo "Automation completed." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#!/bin/bash | ||
echo "" | ||
echo "Killing all services..." | ||
killall utt_replica | ||
killall payment_service | ||
|
||
echo "Finished!" | ||
killall payment_service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
echo "" | ||
echo "###############################################################" | ||
echo "# This test concurrently runs randomized public and utt" | ||
echo "# transafers between random wallets. At the end we check" | ||
echo "# that the total public and utt balance remain the same." | ||
echo "# You can obtain the random seeds from automation/run_ files." | ||
echo "###############################################################" | ||
|
||
# Each wallet executes random transfers and quits | ||
. runAutomation.sh "random 50\nq" | ||
|
||
# Total balances must be conserved | ||
EXPECTED_TOTAL_PUBLIC_BALANCE=$((NUM_WALLETS * INIT_PUBLIC_BALANCE)) | ||
EXPECTED_TOTAL_UTT_BALANCE=$((NUM_WALLETS * INIT_UTT_BALANCE)) | ||
|
||
echo "Expected total public balance: ${EXPECTED_TOTAL_PUBLIC_BALANCE}" | ||
echo "Expected total utt balance: ${EXPECTED_TOTAL_UTT_BALANCE}" | ||
|
||
# Validate | ||
awk -v x=${EXPECTED_TOTAL_PUBLIC_BALANCE} '{ sum += $3 } END {if(sum != x) print "Error: unexpected total public balance!",sum; else print "Total public balance Ok."}' automation/final_* | ||
awk -v x=${EXPECTED_TOTAL_UTT_BALANCE} '{ sum += $4 } END {if(sum != x) print "Error: unexpected total UTT balance!",sum; else print "Total UTT balance Ok."}' automation/final_* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
echo "" | ||
echo "###########################################################" | ||
echo "# This test concurrently runs deposits of \$1 for each" | ||
echo "# wallet. At the end we check that all deposits have been" | ||
echo "# made and that each wallet has the expected amount of" | ||
echo "# additional public money added to its balance." | ||
echo "###########################################################" | ||
|
||
# Each wallet executes 150 additions of $1 to its balance (defined by the checkpoint command) | ||
. runAutomation.sh "checkpoint\nq" | ||
|
||
# We expect all deposits to succeed and that each wallet adds the expected | ||
# value to its public balance | ||
EXPECTED_BLOCK_ID=$((INIT_BLOCK_ID + NUM_WALLETS * 150)) | ||
EXPECTED_PUBLIC_BALANCE=$((INIT_PUBLIC_BALANCE + 150)) | ||
|
||
echo "Expected block id: ${EXPECTED_BLOCK_ID}" | ||
echo "Expected public balance per wallet: ${EXPECTED_PUBLIC_BALANCE}" | ||
|
||
# Validate | ||
awk -v x=${EXPECTED_BLOCK_ID} 'BEGIN {err=0} $2 != x {print "Error: unexpected block id!",$0; err=1} END {if (!err) print "All block ids are Ok."}' automation/final_* | ||
awk -v x=${EXPECTED_PUBLIC_BALANCE} 'BEGIN {err=0} $3 != x {print "Error: unexpected public balance!",$0; err=1} END {if (!err) print "All public balances are Ok."}' automation/final_* |