Skip to content

Commit

Permalink
PP 49 - Unify tests (#161)
Browse files Browse the repository at this point in the history
* Add bash utility functions

* Fix tests running locally and remove useless echo

* Remove old unused circle ci jobs

* Remove useless comments

* Apply PR suggestions

* Add circle CI job names
  • Loading branch information
antomor authored Sep 8, 2021
1 parent e09bffc commit e16b53c
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 213 deletions.
155 changes: 29 additions & 126 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,6 @@ commands:
- run:
name: Prettier
command: npm run prettier
run_rskj_test:
description: 'Execute the parameter test against RSKj node'
parameters:
test:
type: string
steps:
- run:
name: 'Execute << parameters.test >>'
command: |
java -Dminer.client.autoMine=true -Drpc.providers.web.ws.enabled=true -Drsk.conf.file=~/gls/rsknode/node.conf -Dminer.minGasPrice=1 << pipeline.parameters.hardfork >> -cp ~/rsksmart/rskj/rskj-core/build/libs/rskj-core-<< pipeline.parameters.version >>-all.jar co.rsk.Start --regtest --reset nohup &
until nc -z 127.0.0.1 4444
do
echo "Waiting for RskJ..."
sleep 1
done
cp -r node_modules/@rsksmart/rif-relay-contracts/contracts .
cp -r node_modules/@rsksmart/rif-relay-contracts/migrations .
npx truffle test --network regtest << parameters.test >>
rm -rf contracts
rm -rf migrations
rm -rf contract-addresses.json
jobs: # a collection of steps
CodeStyle Checks: # Lint and other pre-checks thread
working_directory: ~/gls # directory where steps will run
Expand All @@ -100,149 +79,74 @@ jobs: # a collection of steps
steps: # a collection of executable commands
- prepare
- run:
name: Tests without DB reset Set B
name: Tests Thread 1
command: |
java -Dminer.client.autoMine=true -Drsk.conf.file=~/gls/rsknode/node.conf -Dminer.minGasPrice=1 << pipeline.parameters.hardfork >> -cp ~/rsksmart/rskj/rskj-core/build/libs/rskj-core-<< pipeline.parameters.version >>-all.jar co.rsk.Start --regtest --reset nohup &
until nc -z 127.0.0.1 4444
do
echo "Waiting for RskJ..."
sleep 1
done
cp -r node_modules/@rsksmart/rif-relay-contracts/contracts .
cp -r node_modules/@rsksmart/rif-relay-contracts/migrations .
npx truffle test --network regtest test/Verifiers.test.ts
npx truffle test --network regtest test/RelayHubPenalizations.test.ts
npx truffle test --network regtest test/RelayHubRegistrationsManagement.test.ts
npx truffle test --network regtest test/TxStoreManager.test.ts
npx truffle test --network regtest test/Utils.test.ts
npx truffle test --network regtest test/common/VersionManager.test.ts
npx truffle test --network regtest test/regressions/PayableWithEmit.test.ts
npx truffle test --network regtest test/relayclient/AccountManager.test.ts
npx truffle test --network regtest test/relayclient/ContractInteractor.test.ts
npx truffle test --network regtest test/relayclient/Configurator.test.ts
rm -rf contracts
rm -rf migrations
rm -rf contract-addresses.json
RSKJ_HARD_FORK="<<pipeline.parameters.hardfork>>"
RSKJ_VERSION="<<pipeline.parameters.version>>"
source "scripts/utils.sh"
run_test_suite_on_ci $TEST_SUITE_1
- store_artifacts:
path: ~/gls/logs

Test Thread 2: # Test thread
working_directory: ~/gls # directory where steps will run
docker: # run the steps with Docker
- image: cimg/openjdk:8.0-node
steps: # a collection of executable commands
- prepare
- run_rskj_test:
test: 'test/relayclient/RelaySelectionManager.test.ts'
- run_rskj_test:
test: 'test/relayserver/RelayServerRequestsProfiling.test.ts'
- run_rskj_test:
test: 'test/relayserver/ServerConfigParams.test.ts'
- run_rskj_test:
test: 'test/relayserver/TransactionManager.test.ts'
- run_rskj_test:
test: 'test/relayclient/KnownRelaysManager.test.ts'
- run_rskj_test:
test: 'test/smartwallet/SmartWallet.test.ts'
- run_rskj_test:
test: 'test/smartwallet/CustomSmartWallet.test.ts'
- run:
name: Tests Thread 2
command: |
RSKJ_HARD_FORK="<<pipeline.parameters.hardfork>>"
RSKJ_VERSION="<<pipeline.parameters.version>>"
source "scripts/utils.sh"
run_test_suite_on_ci $TEST_SUITE_2
- store_artifacts:
path: ~/gls/logs

Test Thread 3: # Test thread
working_directory: ~/gls # directory where steps will run
docker: # run the steps with Docker
- image: cimg/openjdk:8.0-node

steps: # a collection of executable commands
- prepare
- run_rskj_test:
test: 'test/SampleRecipient.test.ts'
- run_rskj_test:
test: 'test/StakeManagement.test.ts'
- run_rskj_test:
test: 'test/RSKAddressValidator.test.ts'
- run_rskj_test:
test: 'test/EnvelopingUtils.test.ts'
- run_rskj_test:
test: 'test/relayclient/SmartWalletDiscovery.test.ts'
- run:
name: Tests Thread 3
command: |
RSKJ_HARD_FORK="<<pipeline.parameters.hardfork>>"
RSKJ_VERSION="<<pipeline.parameters.version>>"
source "scripts/utils.sh"
run_test_suite_on_ci $TEST_SUITE_3
- store_artifacts:
path: ~/gls/logs

Test Thread 4: # Test thread
working_directory: ~/gls # directory where steps will run
docker: # run the steps with Docker
- image: cimg/openjdk:8.0-node
steps: # a collection of executable commands
- prepare
- run:
name: Tests without DB reset Set A
name: Tests Thread 4
command: |
java -Dminer.client.autoMine=true -Drsk.conf.file=~/gls/rsknode/node.conf -Dminer.minGasPrice=1 << pipeline.parameters.hardfork >> -cp ~/rsksmart/rskj/rskj-core/build/libs/rskj-core-<< pipeline.parameters.version >>-all.jar co.rsk.Start --regtest --reset nohup &
until nc -z 127.0.0.1 4444
do
echo "Waiting for RskJ..."
sleep 1
done
cp -r node_modules/@rsksmart/rif-relay-contracts/contracts .
cp -r node_modules/@rsksmart/rif-relay-contracts/migrations .
npx truffle test --network regtest test/Flows.test.ts
npx truffle test --network regtest test/TestEnvironment.test.ts
npx truffle test --network regtest test/HttpWrapper.test.ts
npx truffle test --network regtest test/KeyManager.test.ts
npx truffle test --network regtest test/WalletFactory.test.ts
rm -rf contracts
rm -rf migrations
rm -rf contract-addresses.json
RSKJ_HARD_FORK="<<pipeline.parameters.hardfork>>"
RSKJ_VERSION="<<pipeline.parameters.version>>"
source "scripts/utils.sh"
run_test_suite_on_ci $TEST_SUITE_4
- store_artifacts:
path: ~/gls/logs

Test Thread 5: # Test thread
working_directory: ~/gls # directory where steps will run
docker: # run the steps with Docker
- image: cimg/openjdk:8.0-node
steps: # a collection of executable commands
- prepare
- run:
name: Tests without DB reset Set C
name: Tests Thread 5
command: |
java -Dminer.client.autoMine=true -Drpc.providers.web.ws.enabled=true -Drsk.conf.file=~/gls/rsknode/node.conf -Dminer.minGasPrice=1 << pipeline.parameters.hardfork >> -cp ~/rsksmart/rskj/rskj-core/build/libs/rskj-core-<< pipeline.parameters.version >>-all.jar co.rsk.Start --regtest --reset nohup &
until nc -z 127.0.0.1 4444
do
echo "Waiting for RskJ..."
sleep 1
done
cp -r node_modules/@rsksmart/rif-relay-contracts/contracts .
cp -r node_modules/@rsksmart/rif-relay-contracts/migrations .
npx truffle test --network regtest test/relayclient/RelayClient.test.ts
npx truffle test --network regtest test/relayserver/NetworkSimulation.test.ts
npx truffle test --network regtest test/relayserver/RegistrationManager.test.ts
npx truffle test --network regtest test/relayserver/RelayServer.test.ts
rm -rf contracts
rm -rf migrations
rm -rf contract-addresses.json
- store_artifacts:
path: ~/gls/logs

Test Thread 6: # Test thread
working_directory: ~/gls # directory where steps will run
docker: # run the steps with Docker
- image: cimg/openjdk:8.0-node
steps: # a collection of executable commands
- prepare
- run_rskj_test:
test: 'test/RelayHub.test.ts'
- run_rskj_test:
test: 'test/VersionRegistry.test.ts'
- run_rskj_test:
test: 'test/relayclient/RelayProvider.test.ts'
- run_rskj_test:
test: 'test/relayclient/RelaySelectionManager.test.ts'
RSKJ_HARD_FORK="<<pipeline.parameters.hardfork>>"
RSKJ_VERSION="<<pipeline.parameters.version>>"
source "scripts/utils.sh"
run_test_suite_on_ci $TEST_SUITE_5
- store_artifacts:
path: ~/gls/logs
- store_artifacts:
path: ~/rsksmart/rskj/rskj-core/build/libs/logs
destination: ~/rskj/logs
workflows:
commit:
jobs:
Expand All @@ -252,4 +156,3 @@ workflows:
- Test Thread 3
- Test Thread 4
- Test Thread 5
- Test Thread 6
94 changes: 7 additions & 87 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#trap 'exec 2>&4 1>&3' 0 1 2 3
#exec 1>${TEST_LOG} 2>&1

source "scripts/utils.sh"

trap ctrl_c INT

function ctrl_c() {
Expand All @@ -19,90 +21,8 @@ if [ -z "${NETWORK}" ]; then
docker network create rif-relay-testing
fi

function run_batch() {
TESTS=("$@")
unset TESTS[0]
BATCH_NAME=$1
echo "#################################################################################### Starting Batch ${BATCH_NAME} ####################################################################################"
docker-compose -f docker/docker-compose.yml build
docker-compose -f docker/docker-compose.yml up -d
cp -r node_modules/@rsksmart/rif-relay-contracts/contracts .
cp -r node_modules/@rsksmart/rif-relay-contracts/migrations .

_i=0
while [ $_i -lt 30 ]; do
curl -Ss -H "Content-type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","id":"boot-test"}' \
http://127.0.0.1:4444/ 2>/dev/null | grep -q result && break
sleep 1
_i=$((_i + 1))
done
if [ $_i -eq 30 ]; then
echo "No response from rskj after 30 seconds; aborting..." >&2
exit 1
fi
sleep 5

echo "#################################################################################### START BATCH TESTS ####################################################################################"
TEST_FAIL=0
npx truffle test --network regtest "${TESTS[@]}" || TEST_FAIL=1
echo "#################################################################################### END BATCH TESTS ####################################################################################"
rm -rf contracts
rm -rf migrations
rm -rf contract-addresses.json

docker-compose -f docker/docker-compose.yml down
echo "#################################################################################### Ending Batch ${BATCH_NAME} ####################################################################################"

if [ "${TEST_FAIL}" == "1" ]; then
exit 1
fi
}

# Test_Group_1
run_batch Test_Group_1 \
test/Verifiers.test.ts \
test/RelayHubPenalizations.test.ts \
test/RelayHubRegistrationsManagement.test.ts \
test/TxStoreManager.test.ts \
test/Utils.test.ts \
test/common/VersionManager.test.ts \
test/regressions/PayableWithEmit.test.ts \
test/relayclient/AccountManager.test.ts \
test/relayclient/ContractInteractor.test.ts \
test/relayclient/Configurator.test.ts

# Test_Group_2
run_batch RelaySelectionManager test/relayclient/RelaySelectionManager.test.ts
run_batch RelayServerRequestsProfiling test/relayserver/RelayServerRequestsProfiling.test.ts
run_batch ServerConfigParams test/relayserver/ServerConfigParams.test.ts
run_batch TransactionManager test/relayserver/TransactionManager.test.ts
run_batch KnownRelaysManager test/relayclient/KnownRelaysManager.test.ts
run_batch SmartWallet test/smartwallet/SmartWallet.test.ts
run_batch SampleRecipient test/SampleRecipient.test.ts
run_batch StakeManagement test/StakeManagement.test.ts
run_batch RSKAddressValidator test/RSKAddressValidator.test.ts
run_batch EnvelopingUtils test/EnvelopingUtils.test.ts
run_batch SmartWalletDiscovery test/relayclient/SmartWalletDiscovery.test.ts
run_batch CustomSmartWallet test/smartwallet/CustomSmartWallet.test.ts

# Test_Group_3
run_batch Test_Group_3 \
test/Flows.test.ts \
test/TestEnvironment.test.ts \
test/HttpWrapper.test.ts \
test/KeyManager.test.ts \
test/WalletFactory.test.ts

# Test_Group_4
run_batch Test_Group_4 \
test/relayclient/RelayClient.test.ts \
test/relayserver/NetworkSimulation.test.ts \
test/relayserver/RegistrationManager.test.ts \
test/relayserver/RelayServer.test.ts

# Test_Group_5
run_batch RelayHub test/RelayHub.test.ts
run_batch VersionRegistry test/VersionRegistry.test.ts
run_batch RelayProvider test/relayclient/RelayProvider.test.ts
run_batch RelaySelectionManager test/relayclient/RelaySelectionManager.test.ts
run_test_suite_against_docker $TEST_SUITE_1
run_test_suite_against_docker $TEST_SUITE_2
run_test_suite_against_docker $TEST_SUITE_3
run_test_suite_against_docker $TEST_SUITE_4
run_test_suite_against_docker $TEST_SUITE_5
Loading

0 comments on commit e16b53c

Please sign in to comment.