From e004e5f298aa4c178f7e7f18614ea963ab4be0f9 Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Thu, 17 Nov 2022 11:11:42 +0530 Subject: [PATCH 01/13] init: pos-535 smoke test --- .github/workflows/ci.yml | 3 +- integration-tests/smoke_test.sh | 54 +++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 002752d6aa..8dfd9953fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,7 @@ on: - "master" - "qa" - "develop" + - "raneet10/pos-535" # RMV pull_request: branches: - "**" @@ -154,7 +155,7 @@ jobs: cd matic-cli/devnet/code/contracts npm run truffle exec scripts/deposit.js -- --network development $(jq -r .root.tokens.MaticToken contractAddresses.json) 100000000000000000000 cd - - bash bor/integration-tests/smoke_test.sh + timeout 10m bash bor/integration-tests/smoke_test.sh - name: Upload logs if: always() diff --git a/integration-tests/smoke_test.sh b/integration-tests/smoke_test.sh index 4181f9f20c..d3e422eefe 100644 --- a/integration-tests/smoke_test.sh +++ b/integration-tests/smoke_test.sh @@ -3,33 +3,43 @@ set -e balanceInit=$(docker exec bor0 bash -c "bor attach /root/.bor/data/bor.ipc -exec 'Math.round(web3.fromWei(eth.getBalance(eth.accounts[0])))'") -delay=600 +#delay=600 +#echo "Wait ${delay} seconds for state-sync..." +#sleep $delay +count=0 +while true +do + + balance=$(docker exec bor0 bash -c "bor attach /root/.bor/data/bor.ipc -exec 'Math.round(web3.fromWei(eth.getBalance(eth.accounts[0])))'") -echo "Wait ${delay} seconds for state-sync..." -sleep $delay + if ! [[ "$balance" =~ ^[0-9]+$ ]]; then + echo "Something is wrong! Can't find the balance of first account in bor network." + exit 1 + fi + echo "Found matic balance on account[0]: " $balance -balance=$(docker exec bor0 bash -c "bor attach /root/.bor/data/bor.ipc -exec 'Math.round(web3.fromWei(eth.getBalance(eth.accounts[0])))'") + if (( $balance <= $balanceInit )); then + echo "Balance in bor network has not increased. Waiting for state sync..." + #exit 1 + else + echo "State Sync occured!" + $count=$count+1 + fi -if ! [[ "$balance" =~ ^[0-9]+$ ]]; then - echo "Something is wrong! Can't find the balance of first account in bor network." - exit 1 -fi + checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .result.id) -echo "Found matic balance on account[0]: " $balance + if [ $checkpointID == "null" ]; then + echo "Checkpoint didn't arrive yet! Waiting..." + #exit 1 + else + echo "Found checkpoint ID:" $checkpointID + $count=$count+1 + fi -if (( $balance <= $balanceInit )); then - echo "Balance in bor network has not increased. This indicates that something is wrong with state sync." - exit 1 -fi - -checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .result.id) - -if [ $checkpointID == "null" ]; then - echo "Something is wrong! Could not find any checkpoint." - exit 1 -else - echo "Found checkpoint ID:" $checkpointID -fi + if [ $count -eq 2 ]; then + break + fi +done echo "All tests have passed!" From 5f0fc27fea2fc7b32e6b088959602624ea8ec72c Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Thu, 17 Nov 2022 12:02:00 +0530 Subject: [PATCH 02/13] fix --- integration-tests/smoke_test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/smoke_test.sh b/integration-tests/smoke_test.sh index d3e422eefe..4105057c50 100644 --- a/integration-tests/smoke_test.sh +++ b/integration-tests/smoke_test.sh @@ -24,7 +24,7 @@ do #exit 1 else echo "State Sync occured!" - $count=$count+1 + count=$((count+1)) fi checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .result.id) @@ -34,7 +34,7 @@ do #exit 1 else echo "Found checkpoint ID:" $checkpointID - $count=$count+1 + count=$((count+1)) fi if [ $count -eq 2 ]; then From 6c77efc955cdf4ce0e862678a99d38e633f34429 Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Thu, 17 Nov 2022 12:55:00 +0530 Subject: [PATCH 03/13] fix logic --- integration-tests/smoke_test.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/integration-tests/smoke_test.sh b/integration-tests/smoke_test.sh index 4105057c50..66eefe5f28 100644 --- a/integration-tests/smoke_test.sh +++ b/integration-tests/smoke_test.sh @@ -6,7 +6,9 @@ balanceInit=$(docker exec bor0 bash -c "bor attach /root/.bor/data/bor.ipc -exec #delay=600 #echo "Wait ${delay} seconds for state-sync..." #sleep $delay -count=0 +stateSyncFound=false +checkpointFound=false + while true do @@ -24,7 +26,7 @@ do #exit 1 else echo "State Sync occured!" - count=$((count+1)) + stateSyncFound=true fi checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .result.id) @@ -34,10 +36,10 @@ do #exit 1 else echo "Found checkpoint ID:" $checkpointID - count=$((count+1)) + checkpointFound=true fi - if [ $count -eq 2 ]; then + if [ $stateSyncFound && $checkpointFound ]; then break fi From c6079a4d4e7260f7851221c602b15dcb9e4a1e9a Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Thu, 17 Nov 2022 13:59:07 +0530 Subject: [PATCH 04/13] chg parenthesis --- integration-tests/smoke_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/smoke_test.sh b/integration-tests/smoke_test.sh index 66eefe5f28..333e079641 100644 --- a/integration-tests/smoke_test.sh +++ b/integration-tests/smoke_test.sh @@ -39,7 +39,7 @@ do checkpointFound=true fi - if [ $stateSyncFound && $checkpointFound ]; then + if (( $stateSyncFound && $checkpointFound )); then break fi From 529e81bd92709abec3d02a3474a40f0d4d7d7ff2 Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Thu, 17 Nov 2022 15:01:29 +0530 Subject: [PATCH 05/13] bool types --- integration-tests/smoke_test.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/integration-tests/smoke_test.sh b/integration-tests/smoke_test.sh index 333e079641..397d797e6b 100644 --- a/integration-tests/smoke_test.sh +++ b/integration-tests/smoke_test.sh @@ -6,8 +6,8 @@ balanceInit=$(docker exec bor0 bash -c "bor attach /root/.bor/data/bor.ipc -exec #delay=600 #echo "Wait ${delay} seconds for state-sync..." #sleep $delay -stateSyncFound=false -checkpointFound=false +stateSyncFound="false" +checkpointFound="false" while true do @@ -26,7 +26,7 @@ do #exit 1 else echo "State Sync occured!" - stateSyncFound=true + stateSyncFound="true" fi checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .result.id) @@ -36,10 +36,10 @@ do #exit 1 else echo "Found checkpoint ID:" $checkpointID - checkpointFound=true + checkpointFound="true" fi - if (( $stateSyncFound && $checkpointFound )); then + if (( $stateSyncFound == "true" & $checkpointFound == "true" )); then break fi From ee2009e0c5c8bc41ed918b7ad75f0a0245854ad9 Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Thu, 17 Nov 2022 16:17:35 +0530 Subject: [PATCH 06/13] op --- integration-tests/smoke_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/smoke_test.sh b/integration-tests/smoke_test.sh index 397d797e6b..71482d30de 100644 --- a/integration-tests/smoke_test.sh +++ b/integration-tests/smoke_test.sh @@ -39,7 +39,7 @@ do checkpointFound="true" fi - if (( $stateSyncFound == "true" & $checkpointFound == "true" )); then + if (( $stateSyncFound == "true" && $checkpointFound == "true" )); then break fi From 245b3271296ca9524ef5cafa5745d316e254ced0 Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Thu, 17 Nov 2022 17:13:12 +0530 Subject: [PATCH 07/13] sq paranthesis --- integration-tests/smoke_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/smoke_test.sh b/integration-tests/smoke_test.sh index 71482d30de..5a60eb04fb 100644 --- a/integration-tests/smoke_test.sh +++ b/integration-tests/smoke_test.sh @@ -39,7 +39,7 @@ do checkpointFound="true" fi - if (( $stateSyncFound == "true" && $checkpointFound == "true" )); then + if [ $stateSyncFound == "true" ] && [ $checkpointFound == "true" ]; then break fi From 1b8ef5059f940591e4f0d5ffaad8e847d5d8fff0 Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Thu, 17 Nov 2022 18:20:53 +0530 Subject: [PATCH 08/13] cleanup --- .github/workflows/ci.yml | 1 - integration-tests/smoke_test.sh | 5 ----- 2 files changed, 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8dfd9953fb..9dcddf16c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,6 @@ on: - "master" - "qa" - "develop" - - "raneet10/pos-535" # RMV pull_request: branches: - "**" diff --git a/integration-tests/smoke_test.sh b/integration-tests/smoke_test.sh index 5a60eb04fb..9bd5cebb40 100644 --- a/integration-tests/smoke_test.sh +++ b/integration-tests/smoke_test.sh @@ -3,9 +3,6 @@ set -e balanceInit=$(docker exec bor0 bash -c "bor attach /root/.bor/data/bor.ipc -exec 'Math.round(web3.fromWei(eth.getBalance(eth.accounts[0])))'") -#delay=600 -#echo "Wait ${delay} seconds for state-sync..." -#sleep $delay stateSyncFound="false" checkpointFound="false" @@ -23,7 +20,6 @@ do if (( $balance <= $balanceInit )); then echo "Balance in bor network has not increased. Waiting for state sync..." - #exit 1 else echo "State Sync occured!" stateSyncFound="true" @@ -33,7 +29,6 @@ do if [ $checkpointID == "null" ]; then echo "Checkpoint didn't arrive yet! Waiting..." - #exit 1 else echo "Found checkpoint ID:" $checkpointID checkpointFound="true" From b2a453b115d1bcb4b4a63b291f8ce9c41224e4f0 Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Fri, 18 Nov 2022 14:04:34 +0530 Subject: [PATCH 09/13] chg: increase timeout --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4fef49a2d0..b5bb62a8bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -154,7 +154,7 @@ jobs: cd matic-cli/devnet/code/contracts npm run truffle exec scripts/deposit.js -- --network development $(jq -r .root.tokens.MaticToken contractAddresses.json) 100000000000000000000 cd - - timeout 10m bash bor/integration-tests/smoke_test.sh + timeout 20m bash bor/integration-tests/smoke_test.sh - name: Upload logs if: always() From 87c54fa7bee290b1ee204e17e403dfdbcad6ce2c Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Fri, 18 Nov 2022 15:00:46 +0530 Subject: [PATCH 10/13] chg: remove repetitive logs --- integration-tests/smoke_test.sh | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/integration-tests/smoke_test.sh b/integration-tests/smoke_test.sh index 9bd5cebb40..07a84814fd 100644 --- a/integration-tests/smoke_test.sh +++ b/integration-tests/smoke_test.sh @@ -16,21 +16,13 @@ do exit 1 fi - echo "Found matic balance on account[0]: " $balance - - if (( $balance <= $balanceInit )); then - echo "Balance in bor network has not increased. Waiting for state sync..." - else - echo "State Sync occured!" + if (( $balance > $balanceInit )); then stateSyncFound="true" fi checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .result.id) - if [ $checkpointID == "null" ]; then - echo "Checkpoint didn't arrive yet! Waiting..." - else - echo "Found checkpoint ID:" $checkpointID + if [ $checkpointID != "null" ]; then checkpointFound="true" fi @@ -39,4 +31,4 @@ do fi done -echo "All tests have passed!" +echo "Both state sync and checkpoint went through. All tests have passed!" From 1da5b36da9cdf24c279a59ca8fbe1c2c877cfcc6 Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Fri, 18 Nov 2022 16:18:34 +0530 Subject: [PATCH 11/13] new: timer --- integration-tests/smoke_test.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/integration-tests/smoke_test.sh b/integration-tests/smoke_test.sh index 07a84814fd..ed9ce0e3ef 100644 --- a/integration-tests/smoke_test.sh +++ b/integration-tests/smoke_test.sh @@ -5,6 +5,8 @@ balanceInit=$(docker exec bor0 bash -c "bor attach /root/.bor/data/bor.ipc -exec stateSyncFound="false" checkpointFound="false" +SECONDS=0 +start_time=$SECONDS while true do @@ -17,12 +19,14 @@ do fi if (( $balance > $balanceInit )); then + stateSyncTime=$(( SECONDS - start_time )) stateSyncFound="true" fi checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .result.id) if [ $checkpointID != "null" ]; then + checkpointTime=$(( SECONDS - start_time )) checkpointFound="true" fi @@ -32,3 +36,5 @@ do done echo "Both state sync and checkpoint went through. All tests have passed!" +echo "Time taken for state sync: $(printf '%02dm:%02ds\n' $(($stateSyncTime%3600/60)) $(($stateSyncTime%60)))" +echo "Time taken for checkpoint: $(printf '%02dm:%02ds\n' $(($checkpointTime%3600/60)) $(($checkpointTime%60)))" From f3573f086d771a57062d8ec685794939da4e1c63 Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Fri, 18 Nov 2022 18:38:03 +0530 Subject: [PATCH 12/13] fix: timer condition --- integration-tests/smoke_test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/smoke_test.sh b/integration-tests/smoke_test.sh index ed9ce0e3ef..d4a4ed2763 100644 --- a/integration-tests/smoke_test.sh +++ b/integration-tests/smoke_test.sh @@ -18,14 +18,14 @@ do exit 1 fi - if (( $balance > $balanceInit )); then + if (( $balance > $balanceInit )) && [ $stateSyncFound != "true" ]; then stateSyncTime=$(( SECONDS - start_time )) stateSyncFound="true" fi checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .result.id) - if [ $checkpointID != "null" ]; then + if [ $checkpointID != "null" ] && [ $checkpointFound != "true"]; then checkpointTime=$(( SECONDS - start_time )) checkpointFound="true" fi From 296a9c4ff516c906c7b7b99d8d58306f55b6b4a7 Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Fri, 18 Nov 2022 18:58:52 +0530 Subject: [PATCH 13/13] fix: incorrect condition --- integration-tests/smoke_test.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/integration-tests/smoke_test.sh b/integration-tests/smoke_test.sh index d4a4ed2763..62ca370ee7 100644 --- a/integration-tests/smoke_test.sh +++ b/integration-tests/smoke_test.sh @@ -18,16 +18,20 @@ do exit 1 fi - if (( $balance > $balanceInit )) && [ $stateSyncFound != "true" ]; then - stateSyncTime=$(( SECONDS - start_time )) - stateSyncFound="true" + if (( $balance > $balanceInit )); then + if [ $stateSyncFound != "true" ]; then + stateSyncTime=$(( SECONDS - start_time )) + stateSyncFound="true" + fi fi checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .result.id) - if [ $checkpointID != "null" ] && [ $checkpointFound != "true"]; then - checkpointTime=$(( SECONDS - start_time )) - checkpointFound="true" + if [ $checkpointID != "null" ]; then + if [ $checkpointFound != "true" ]; then + checkpointTime=$(( SECONDS - start_time )) + checkpointFound="true" + fi fi if [ $stateSyncFound == "true" ] && [ $checkpointFound == "true" ]; then