Skip to content

Commit c6c2bf9

Browse files
authored
fix: wait for finalization with timeout (#202)
* fix: wait for finalization with timeout * fix: don't copy test report from container if local run * fix: run e2d in CD with 1 thread
1 parent 6f51f0e commit c6c2bf9

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

.github/actions/tests/run-e2e-tests/action.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ inputs:
4040
decrypt:
4141
description: 'Decrypt secrets'
4242
required: false
43+
threads:
44+
description: 'Number of threads to use'
45+
required: false
46+
default: '4'
4347

4448
runs:
4549
using: composite
@@ -75,7 +79,7 @@ runs:
7579
--log-cli-level '${{ inputs.log_level }}' \
7680
-k '${{ inputs.keyword }}' \
7781
-m '${{ inputs.markers }}' \
78-
-n 4 \
82+
-n '${{ inputs.threads}}' \
7983
--dist=loadgroup \
8084
--ci-run \
8185
--init-timestamp '${{ inputs.init_timestamp }}' \
@@ -101,7 +105,7 @@ runs:
101105
eval "$pytest_cmd"
102106
fi
103107
- name: Copy .report.json if run with docker exec
104-
if: ${{ inputs.local-environment }} == 'true'
108+
if: ${{ inputs.local-environment == 'true' }}
105109
run: |
106110
echo "Copy test results from docker container"
107111
mkdir -p e2e-tests

.github/workflows/cd.yml

+28-6
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,30 @@ jobs:
189189
xargs -I {} curl -s -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"chain_getHeader","params":["{}"],"id":"1"}' http://$STAGING_PREVIEW_VALIDATOR_1_HOST:$STAGING_PREVIEW_VALIDATOR_1_PORT |
190190
jq -r ".result.number" | xargs printf "%d"
191191
)
192-
if [ "$FINALIZED_NUMBER" -gt 0 ]; then
193-
echo "Blocks are being finalized. Finalized Block Number: $FINALIZED_NUMBER"
194-
else
195-
echo "No blocks are being finalized. Finalized Block Number: $FINALIZED_NUMBER"
196-
exit 1
197-
fi
192+
193+
timeout=300 # Timeout in seconds
194+
interval=10 # Interval in seconds
195+
elapsed=0
196+
197+
while [ "$FINALIZED_NUMBER" -le 0 ]; do
198+
if [ $elapsed -ge $timeout ]; then
199+
echo "Timeout reached: $timeout seconds"
200+
exit 1
201+
fi
202+
203+
echo "Waiting for blocks to be finalized..."
204+
sleep $interval
205+
elapsed=$((elapsed + interval))
206+
207+
FINALIZED_NUMBER=$(
208+
curl -s -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"chain_getFinalizedHead","params":[],"id":"1"}' http://$STAGING_PREVIEW_VALIDATOR_1_HOST:$STAGING_PREVIEW_VALIDATOR_1_PORT |
209+
jq -r ".result" |
210+
xargs -I {} curl -s -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"chain_getHeader","params":["{}"],"id":"1"}' http://$STAGING_PREVIEW_VALIDATOR_1_HOST:$STAGING_PREVIEW_VALIDATOR_1_PORT |
211+
jq -r ".result.number" | xargs printf "%d"
212+
)
213+
done
214+
215+
echo "Blocks are being finalized. Finalized Block Number: $FINALIZED_NUMBER"
198216
shell: bash
199217

200218
run-smoke-tests:
@@ -220,6 +238,7 @@ jobs:
220238
env: staging
221239
decrypt: true
222240
markers: "not active_flow and not passive_flow and (CD or rpc)"
241+
threads: 1
223242

224243
run-all-tests:
225244
permissions:
@@ -247,6 +266,7 @@ jobs:
247266
decrypt: true
248267
markers: "not active_flow and not passive_flow"
249268
deployment_mc_epoch: $DEPLOYMENT_MC_EPOCH
269+
threads: 1
250270

251271
wait-for-n1-epoch:
252272
permissions:
@@ -308,6 +328,7 @@ jobs:
308328
latest_mc_epoch: true
309329
markers: "not active_flow and not passive_flow"
310330
deployment_mc_epoch: $DEPLOYMENT_MC_EPOCH
331+
threads: 1
311332

312333
wait-for-n2-epoch:
313334
permissions:
@@ -369,6 +390,7 @@ jobs:
369390
latest_mc_epoch: true
370391
markers: "not active_flow and not passive_flow"
371392
deployment_mc_epoch: $DEPLOYMENT_MC_EPOCH
393+
threads: 1
372394

373395
publish:
374396
permissions:

0 commit comments

Comments
 (0)