2121# DESELECT_FROM_FILE: path to file with tests to deselect
2222# CLUSTERS_COUNT: number of local testnet clusters to launch
2323# FORBID_RESTART: if set to 1, do not restart clusters between tests
24+ # SESSION_TIMEOUT: overall timeout for the test session (e.g. 10800 for 3 hours)
2425#
2526# Notes:
2627# - If PYTEST_ARGS is provided, we disable cleanup and the initial "skip all" pass.
@@ -51,9 +52,15 @@ All targets respect the same env vars as the original Makefile.
5152EOF
5253}
5354
54- pytest_w_echo () {
55- echo " Running: PYTEST_ADDOPTS='${PYTEST_ADDOPTS:- } ' pytest $* "
56- pytest " $@ "
55+ run_pytest () {
56+ if [ -n " ${SESSION_TIMEOUT:- } " ]; then
57+ local -a timeout_arr=( " --signal=INT" " --kill-after=0" " $SESSION_TIMEOUT " )
58+ echo " Running: PYTEST_ADDOPTS='${PYTEST_ADDOPTS:- } ' timeout ${timeout_arr[*]} pytest $* "
59+ timeout " ${timeout_arr[@]} " pytest " $@ "
60+ else
61+ echo " Running: PYTEST_ADDOPTS='${PYTEST_ADDOPTS:- } ' pytest $* "
62+ pytest " $@ "
63+ fi
5764}
5865
5966ensure_dirs () {
@@ -133,7 +140,7 @@ initial_skip_pass() {
133140}
134141
135142run_real_tests () {
136- pytest_w_echo \
143+ run_pytest \
137144 " $TESTS_DIR " \
138145 " ${MARKEXPR_ARR[@]} " \
139146 " ${DESELECT_FROM_FILE_ARR[@]} " \
@@ -157,41 +164,44 @@ ensure_markexpr_default() {
157164target_tests () {
158165 export DbSyncAbortOnPanic=" ${DbSyncAbortOnPanic:- 1} "
159166 TEST_THREADS=" ${TEST_THREADS:- 20} "
167+ SESSION_TIMEOUT=" ${SESSION_TIMEOUT:- 72000} "
160168
161169 ensure_dirs
162170 set_common_env
163171 compute_common_args
164172 cleanup_previous_run
165173 initial_skip_pass
166- run_real_tests --timeout=10800 --session-timeout=72000 " $@ "
174+ run_real_tests --timeout=10800 " $@ "
167175}
168176
169177target_testpr () {
170178 export TESTPR=1
171179 export CLUSTERS_COUNT=" ${CLUSTERS_COUNT:- 5} "
172180 TEST_THREADS=" ${TEST_THREADS:- 20} "
181+ SESSION_TIMEOUT=" ${SESSION_TIMEOUT:- 27000} "
173182 ensure_markexpr_default " smoke"
174183
175184 ensure_dirs
176185 set_common_env
177186 compute_common_args
178187 cleanup_previous_run
179188 initial_skip_pass
180- run_real_tests --timeout=1200 --session-timeout=2700 " $@ "
189+ run_real_tests --timeout=1200 " $@ "
181190}
182191
183192target_testnets () {
184193 export CLUSTERS_COUNT=1
185194 export FORBID_RESTART=1
186195 TEST_THREADS=" ${TEST_THREADS:- 15} "
196+ SESSION_TIMEOUT=" ${SESSION_TIMEOUT:- 10800} "
187197 ensure_markexpr_default " testnets"
188198
189199 ensure_dirs
190200 set_common_env
191201 compute_common_args
192202 cleanup_previous_run
193203 initial_skip_pass
194- run_real_tests --timeout=7200 --session-timeout=10800 " $@ "
204+ run_real_tests --timeout=7200 " $@ "
195205}
196206
197207# Dispatch
0 commit comments