Merge pull request #115 from 0xPolygon/psp-upstream #200
This file contains hidden or 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
| name: QA - RPC Integration Tests (Polygon) | |
| on: | |
| workflow_dispatch: # Run manually | |
| push: | |
| branches: | |
| - main | |
| - 'release/3.*' | |
| pull_request: | |
| branches: | |
| - main | |
| - 'release/3.*' | |
| types: | |
| - opened | |
| - reopened | |
| - synchronize | |
| - ready_for_review | |
| jobs: | |
| bor-mainnet-rpc-integ-tests: | |
| if: false # Temporarily disabled | |
| concurrency: | |
| group: >- | |
| ${{ | |
| (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) && | |
| format('{0}-{1}', github.workflow, github.run_id) || | |
| format('{0}-{1}', github.workflow, github.ref) | |
| }} | |
| cancel-in-progress: true | |
| runs-on: [ self-hosted, qa, Polygon, rpc-integration ] | |
| env: | |
| ERIGON_REFERENCE_DATA_DIR: /opt/erigon-versions/reference-version/datadir | |
| ERIGON_TESTBED_AREA: /opt/erigon-testbed | |
| ERIGON_QA_PATH: /home/qarunner/erigon-qa | |
| ERIGON_ASSERT: true | |
| RPC_PAST_TEST_DIR: /opt/rpc-past-tests | |
| CHAIN: bor-mainnet | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v5 | |
| - name: Clean Erigon Build Directory | |
| run: | | |
| make clean | |
| - name: Build Erigon RPCDaemon and integration | |
| run: | | |
| make rpcdaemon integration | |
| working-directory: ${{ github.workspace }} | |
| - name: Pause the Erigon instance dedicated to db maintenance | |
| run: | | |
| python3 $ERIGON_QA_PATH/test_system/db-producer/pause_production.py || true | |
| - name: Save Erigon Chaindata Directory | |
| id: save_chaindata_step | |
| run: | | |
| rm -rf $ERIGON_TESTBED_AREA/chaindata-prev || true | |
| echo "Backup chaindata" | |
| cp -r $ERIGON_REFERENCE_DATA_DIR/chaindata $ERIGON_TESTBED_AREA/chaindata-prev | |
| - name: Run Migrations | |
| working-directory: ${{ github.workspace }}/build/bin | |
| run: | | |
| echo "Running migrations on datadir..." | |
| ./integration run_migrations --datadir $ERIGON_REFERENCE_DATA_DIR --chain $CHAIN | |
| - name: Run RpcDaemon | |
| working-directory: ${{ github.workspace }}/build/bin | |
| run: | | |
| echo "Starting RpcDaemon..." | |
| ./rpcdaemon --datadir $ERIGON_REFERENCE_DATA_DIR --http.api bor,admin,debug,eth,parity,erigon,trace,web3,txpool,ots,net --ws > erigon.log 2>&1 & | |
| RPC_DAEMON_PID=$! | |
| RPC_DAEMON_EXIT_STATUS=$? | |
| echo "RPC_DAEMON_PID=$RPC_DAEMON_PID" >> $GITHUB_ENV | |
| echo "rpc_daemon_started=true" >> $GITHUB_OUTPUT | |
| sleep 5 | |
| tail erigon.log | |
| if [ $RPC_DAEMON_EXIT_STATUS -ne 0 ]; then | |
| echo "RpcDaemon failed to start" | |
| echo "::error::Error detected during tests: RpcDaemon failed to start" | |
| exit 1 | |
| fi | |
| echo "RpcDaemon started" | |
| - name: Wait for port 8545 to be opened | |
| run: | | |
| for i in {1..30}; do | |
| if nc -z localhost 8545; then | |
| echo "Port 8545 is open" | |
| break | |
| fi | |
| echo "Waiting for port 8545 to open..." | |
| sleep 10 | |
| done | |
| if ! nc -z localhost 8545; then | |
| echo "Port 8545 did not open in time" | |
| echo "::error::Error detected during tests: Port 8545 did not open in time" | |
| exit 1 | |
| fi | |
| - name: Run RPC Integration Tests | |
| id: test_step | |
| run: | | |
| commit=$(git -C ${{runner.workspace}}/erigon rev-parse --short HEAD) | |
| TEST_RESULT_DIR="$RPC_PAST_TEST_DIR/polygon_$(date +%Y%m%d_%H%M%S)_integration_${commit}_http/" | |
| echo "TEST_RESULT_DIR=$TEST_RESULT_DIR" >> $GITHUB_ENV | |
| chmod +x ${{ runner.workspace }}/erigon/.github/workflows/scripts/run_rpc_tests_polygon.sh | |
| set +e # Disable exit on error for test run | |
| ${{ runner.workspace }}/erigon/.github/workflows/scripts/run_rpc_tests_polygon.sh ${{ runner.workspace }} $TEST_RESULT_DIR | |
| test_exit_status=$? # Capture test runner script exit status | |
| set -e # Re-enable exit on error after test run | |
| echo "test_executed=true" >> $GITHUB_OUTPUT | |
| echo | |
| if [ $test_exit_status -eq 0 ]; then | |
| echo "RPC tests completed successfully" | |
| echo "TEST_RESULT=success" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "Error detected during RPC tests" | |
| echo "TEST_RESULT=failure" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Stop Erigon RpcDaemon | |
| if: always() | |
| working-directory: ${{ github.workspace }}/build/bin | |
| run: | | |
| # Clean up rpcdaemon process if it's still running | |
| if [ -n "$RPC_DAEMON_PID" ] && kill -0 $RPC_DAEMON_PID 2> /dev/null; then | |
| echo "RpcDaemon stopping..." | |
| kill $RPC_DAEMON_PID | |
| echo "RpcDaemon stopped" | |
| else | |
| echo "RpcDaemon has already terminated" | |
| fi | |
| - name: Restore Erigon Chaindata Directory | |
| if: ${{ always() }} | |
| run: | | |
| if [ -d "$ERIGON_TESTBED_AREA/chaindata-prev" ] && [ "${{ steps.save_chaindata_step.outcome }}" == "success" ]; then | |
| rm -rf $ERIGON_REFERENCE_DATA_DIR/chaindata | |
| echo "Restore chaindata" | |
| mv $ERIGON_TESTBED_AREA/chaindata-prev $ERIGON_REFERENCE_DATA_DIR/chaindata | |
| fi | |
| - name: Resume the Erigon instance dedicated to db maintenance | |
| if: ${{ always() }} | |
| run: | | |
| python3 $ERIGON_QA_PATH/test_system/db-producer/resume_production.py || true | |
| - name: Upload test results | |
| if: steps.test_step.outputs.test_executed == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results | |
| path: ${{ env.TEST_RESULT_DIR }} | |
| - name: Save test results | |
| if: steps.test_step.outputs.test_executed == 'true' | |
| working-directory: ${{ github.workspace }} | |
| env: | |
| TEST_RESULT: ${{ steps.test_step.outputs.TEST_RESULT }} | |
| run: | | |
| db_version=$(python3 $ERIGON_QA_PATH/test_system/qa-tests/uploads/prod_info.py $ERIGON_REFERENCE_DATA_DIR/../production.ini production erigon_repo_commit) | |
| if [ -z "$db_version" ]; then | |
| db_version="no-version" | |
| fi | |
| python3 $ERIGON_QA_PATH/test_system/qa-tests/uploads/upload_test_results.py --repo erigon --commit $(git rev-parse HEAD) --branch ${{ github.ref_name }} --test_name rpc-integration-tests --chain $CHAIN --runner ${{ runner.name }} --db_version $db_version --outcome $TEST_RESULT #--result_file ${{ github.workspace }}/result-$CHAIN.json | |
| - name: Action to check failure condition | |
| if: failure() | |
| run: | | |
| if [ "${{ steps.test_step.outputs.test_executed }}" != "true" ]; then | |
| echo "::error::Test not executed, workflow failed for infrastructure reasons" | |
| fi | |
| exit 1 | |
| - name: Action for Success | |
| if: steps.test_step.outputs.TEST_RESULT == 'success' | |
| run: echo "::notice::Tests completed successfully" | |
| - name: Action for Failure | |
| if: steps.test_step.outputs.TEST_RESULT != 'success' | |
| run: | | |
| echo "::error::Error detected during tests: some tests failed, check the logs or the artifacts for more details" | |
| exit 1 | |