Skip to content

Commit 842adde

Browse files
larsxschneiderpeff
authored andcommitted
git-p4: add p4d timeout in tests
In rare cases p4d seems to hang. This watchdog will kill the p4d process after 300s in any case. That means each individual git p4 test needs to finish before 300s or it will fail. Signed-off-by: Lars Schneider <[email protected]> Acked-by: Luke Diamand <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent 23aee41 commit 842adde

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

t/lib-git-p4.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ TEST_NO_CREATE_REPO=NoThanks
1010
# here the maximal retry timeout in seconds.
1111
RETRY_TIMEOUT=60
1212

13+
# Sometimes p4d seems to hang. Terminate the p4d process automatically after
14+
# the defined timeout in seconds.
15+
P4D_TIMEOUT=300
16+
1317
. ./test-lib.sh
1418

1519
if ! test_have_prereq PYTHON
@@ -94,6 +98,19 @@ start_p4d() {
9498
# will be caught with the "kill -0" check below.
9599
i=${P4D_START_PATIENCE:-300}
96100
pid=$(cat "$pidfile")
101+
102+
timeout=$(($(time_in_seconds) + $P4D_TIMEOUT))
103+
while true
104+
do
105+
if test $(time_in_seconds) -gt $timeout
106+
then
107+
kill -9 $pid
108+
exit 1
109+
fi
110+
sleep 1
111+
done &
112+
watchdog_pid=$!
113+
97114
ready=
98115
while test $i -gt 0
99116
do
@@ -156,7 +173,8 @@ kill_p4d() {
156173
retry_until_fail kill -9 $pid
157174
# complain if it would not die
158175
test_must_fail kill $pid >/dev/null 2>&1 &&
159-
rm -rf "$db" "$cli" "$pidfile"
176+
rm -rf "$db" "$cli" "$pidfile" &&
177+
retry_until_fail kill -9 $watchdog_pid
160178
}
161179

162180
cleanup_git() {

0 commit comments

Comments
 (0)