[localnet] checkpoint

rosetta
Daniel Van Der Maden 4 years ago
parent 046b21b04c
commit e031a8c43f
No known key found for this signature in database
GPG Key ID: AEA215877D53EE19
  1. 15
      localnet/Dockerfile
  2. 14
      localnet/Makefile
  3. 14
      localnet/configs/localnet_rosetta_test_s0.json
  4. 14
      localnet/configs/localnet_rosetta_test_s1.json
  5. 0
      localnet/rpc_tests/conftest.py
  6. 0
      localnet/rpc_tests/test_account.py
  7. 0
      localnet/rpc_tests/test_blockchain.py
  8. 0
      localnet/rpc_tests/test_contract.py
  9. 0
      localnet/rpc_tests/test_staking.py
  10. 0
      localnet/rpc_tests/test_transaction.py
  11. 0
      localnet/rpc_tests/txs.py
  12. 0
      localnet/rpc_tests/utils.py
  13. 70
      localnet/scripts/run.sh

@ -7,11 +7,9 @@ SHELL ["/bin/bash", "-c"]
RUN apt update && apt upgrade -y && apt update -y && apt install unzip \
libgmp-dev libssl-dev curl git jq make gcc g++ bash sudo python3 python3-pip -y
RUN git clone https://github.com/harmony-one/harmony.git
RUN git clone https://github.com/harmony-one/bls.git
RUN git clone https://github.com/harmony-one/mcl.git
RUN git clone https://github.com/harmony-one/harmony.git \
&& git clone https://github.com/harmony-one/bls.git \
&& git clone https://github.com/harmony-one/mcl.git
# Build to fetch all dependencies for faster test builds
RUN cd harmony && go get github.com/pborman/uuid && go get github.com/rjeczalik/notify \
@ -26,17 +24,12 @@ WORKDIR $GOPATH/src/github.com/harmony-one/harmony-tests/localnet
RUN curl -L -o /go/bin/hmy https://harmony.one/hmycli && chmod +x /go/bin/hmy
COPY scripts scripts
COPY tests tests
COPY rpc_tests rpc_tests
COPY configs configs
COPY requirements.txt requirements.txt
RUN python3 -m pip install -r requirements.txt && rm requirements.txt
RUN chmod +x $GOPATH/src/github.com/harmony-one/harmony-tests/localnet/scripts/run.sh
WORKDIR $GOPATH/src/github.com/harmony-one/harmony
ENTRYPOINT ["/go/src/github.com/harmony-one/harmony-tests/localnet/scripts/run.sh"]

@ -6,8 +6,9 @@ help:
@echo "build-cached - build the docker image with cache"
@echo "upload-test - test the docker image before uploading to dockerhub"
@echo "upload - upload the docker image to dockerhub (require credentials)"
@echo "test - run the test suite"
@echo "run - run the localnet tests without docker"
@echo "rosetta-test-run - run the rosetta tests as it would run inside the docker container"
@echo "rpc-test-run - run the localnet rpc tests as it would run inside the docker container"
@echo "rpc-test-debug - run the rpc test suite on a running localnet"
install:
python3 -m pip install -r requirements.txt
@ -24,9 +25,12 @@ upload-test: build
upload: build
docker push harmonyone/localnet-test
run:
rosetta-test-run:
bash ./scripts/run.sh -r
rpc-test-run:
bash ./scripts/run.sh -n
test:
python3 -u -m py.test -v -r s -s tests -x -n 8
rpc-test-debug:
python3 -u -m py.test -v -r s -s rpc_tests -x -n 8

@ -34,7 +34,7 @@
"balance_tracking_disabled": false,
"coin_tracking_disabled": false,
"end_conditions": {
"duration": 60,
"duration": 30,
"reconciliation_coverage": {
"coverage": 0.95,
"from_tip": true
@ -102,7 +102,7 @@
},
{
"name": "create_account",
"concurrency": 1,
"concurrency": 10,
"scenarios": [
{
"name": "create_account",
@ -132,7 +132,7 @@
},
{
"name": "transfer",
"concurrency": 10,
"concurrency": 1,
"scenarios": [
{
"name": "transfer",
@ -310,10 +310,10 @@
}
],
"end_conditions": {
"create_account": 2,
"transfer": 10,
"cross_shard_transfer": 10,
"contract_creation": 10
"create_account": 1,
"transfer": 1,
"cross_shard_transfer": 1,
"contract_creation": 1
}
}
}

@ -34,7 +34,7 @@
"balance_tracking_disabled": false,
"coin_tracking_disabled": false,
"end_conditions": {
"duration": 60,
"duration": 30,
"reconciliation_coverage": {
"coverage": 0.95,
"from_tip": true
@ -102,7 +102,7 @@
},
{
"name": "create_account",
"concurrency": 1,
"concurrency": 10,
"scenarios": [
{
"name": "create_account",
@ -132,7 +132,7 @@
},
{
"name": "transfer",
"concurrency": 10,
"concurrency": 1,
"scenarios": [
{
"name": "transfer",
@ -310,10 +310,10 @@
}
],
"end_conditions": {
"create_account": 2,
"transfer": 10,
"cross_shard_transfer": 10,
"contract_creation": 10
"create_account": 1,
"transfer": 1,
"cross_shard_transfer": 1,
"contract_creation": 1
}
}
}

@ -21,6 +21,7 @@ function setup() {
exit 1
fi
kill_localnet
error=0 # reset error/exit code
}
function build_and_start_localnet() {
@ -49,28 +50,38 @@ function go_tests() {
bash ./scripts/go_executable_build.sh -S
BUILD=False
fi
bash ./scripts/travis_checker.sh
bash ./scripts/travis_checker.sh || error=1
echo -e "\n=== \e[38;5;0;48;5;255mFINISHED GO TESTS\e[0m ===\n"
popd
}
function api_tests() {
echo -e "\n=== \e[38;5;0;48;5;255mSTARTING NODE API TESTS\e[0m ===\n"
function rpc_tests() {
echo -e "\n=== \e[38;5;0;48;5;255mSTARTING RPC TESTS\e[0m ===\n"
build_and_start_localnet || exit 1 &
sleep 20
wait_for_localnet_boot 100 # Timeout at ~300 seconds
echo "Starting test suite..."
sleep 3
error=0
# Use 4 or less threads, high thread count can lead to burst RPC calls, which can lead to some RPC calls being rejected.
cd "$DIR/../" && python3 -u -m py.test -v -r s -s tests -x -n 4 || error=1
echo -e "\n=== \e[38;5;0;48;5;255mFINISHED NODE API TESTS\e[0m ===\n"
cd "$DIR/../" && python3 -u -m py.test -v -r s -s rpc_tests -x -n 4 || error=1
echo -e "\n=== \e[38;5;0;48;5;255mFINISHED RPC TESTS\e[0m ===\n"
}
if [ "$KEEP" == "true" ]; then
tail -f /dev/null
fi
exit "$error"
function rosetta_tests() {
echo -e "\n=== \e[38;5;0;48;5;255mSTARTING ROSETTA API TESTS\e[0m ===\n"
build_and_start_localnet || exit 1 &
sleep 30
wait_for_localnet_boot 100 # Timeout at ~300 seconds
echo "Starting test suite..."
sleep 3
# Run tests sequentially for clear error tracing
rosetta-cli check:construction --configuration-file "$DIR/../configs/localnet_rosetta_test_s0.json" || error=1
rosetta-cli check:data --configuration-file "$DIR/../configs/localnet_rosetta_test_s0.json" || error=1
rosetta-cli check:construction --configuration-file "$DIR/../configs/localnet_rosetta_test_s1.json" || error=1
rosetta-cli check:data --configuration-file "$DIR/../configs/localnet_rosetta_test_s1.json" || error=1
echo -e "\n=== \e[38;5;0;48;5;255mFINISHED ROSETTA API TESTS\e[0m ===\n"
}
function wait_for_localnet_boot() {
@ -117,15 +128,25 @@ trap kill_localnet SIGINT SIGTERM EXIT
BUILD=true
KEEP=false
GOTESTS=true
NODEAPI=true
GO=true
RPC=true
ROSETTA=true
while getopts "Bkgn" option; do
while getopts "Bkgnr" option; do
case ${option} in
B) BUILD=false ;;
k) KEEP=true ;;
g) NODEAPI=false ;;
n) GOTESTS=false ;;
g) RPC=false
ROSETTA=false
;;
n)
GO=false
ROSETTA=false
;;
r)
GO=false
RPC=false
;;
*) echo "
Integration tester for localnet
@ -133,7 +154,8 @@ Option: Help:
-B Do NOT build binray before testing
-k Keep localnet running after Node API tests are finished
-g ONLY run go tests & checks
-n ONLY run the Node API tests
-n ONLY run the RPC tests
-r ONLY run the rosetta API tests
"
exit 0
;;
@ -142,10 +164,20 @@ done
setup
if [ "$GOTESTS" == "true" ]; then
if [ "$GO" == "true" ]; then
go_tests
fi
if [ "$NODEAPI" == "true" ]; then
api_tests
if [ "$RPC" == "true" ]; then
rpc_tests
fi
if [ "$ROSETTA" == "true" ]; then
rosetta_tests
fi
if [ "$KEEP" == "true" ]; then
tail -f /dev/null
fi
exit "$error"

Loading…
Cancel
Save