threads / patch / 39188

patchgit-p4: Fix ocasional test failures in kill_p4d

Subject: [PATCH] git-p4: Fix ocasional test failures in kill_p4d

## tl;dr

2 messages between Apr 29, 2015 and Apr 29, 2015. Diffs are folded; open one to read it.

replies: 1people: 1as markdown or json

Luke Diamand· Apr 29, 2015, 21:26 UTC · lore

Running the git-p4 unit tests, I notice that the 'kill_p4d' test occasionally fails. This just terminates the p4d server, so in theory it should always succeed. The problem is especially noticeable when running multiple tests in parallel:

    $ make -C t T=t98*.sh -j50
That's annoying, as it makes it harder to test changes to git-p4.

It looks like p4d is sensitive to being killed ungracefully. Experimentally, I find that starting it with journalling disabled, and using 'p4 admin stop' rather than kill(1) makes the process much more reliable; I no longer see the intermittent failures.

Luke Diamand (1):
  git-p4: fix occasional test failure in kill_p4d
 t/lib-git-p4.sh | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
-- 
2.3.4.48.g223ab37
Luke Diamand· Apr 29, 2015, 21:26 UTC · re: Luke Diamand · lore

[PATCH] git-p4: fix occasional test failure in kill_p4d

The kill_p4d test function used in the test harness fails occasionally, especially if running many of the git-p4 tests in parallel.

It looks like p4d is sensitive to being shutdown ungracefully, so to work around this, use 'p4 admin stop' rather than kill, and start p4d with journalling turned off. This seems to be much more reliable.

Signed-off-by: Luke Diamand <luke@diamand.org>
---
 t/lib-git-p4.sh | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
Show changes to t/lib-git-p4.sh +8 −7
diff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh
index 5aa8adc..3885381 100644
--- a/t/lib-git-p4.sh
+++ b/t/lib-git-p4.sh
@@ -69,7 +69,8 @@ start_p4d() {
 	(
 		cd "$db" &&
 		{
-			p4d -q -p $P4DPORT &
+			# disable journalling: it makes shutdown unreliable
+			p4d -J off -q -p $P4DPORT &
 			echo $! >"$pidfile"
 		}
 	) &&
@@ -122,15 +123,15 @@ p4_add_user() {
 }
 
 kill_p4d() {
-	pid=$(cat "$pidfile")
-	# it had better exist for the first kill
-	kill $pid &&
-	for i in 1 2 3 4 5 ; do
-		kill $pid >/dev/null 2>&1 || break
+	# graceful shutdown
+	p4 admin stop &&
+	for i in 1 2 3 4 5
+	do
+		p4 info >/dev/null 2>&1 || break
 		sleep 1
 	done &&
 	# complain if it would not die
-	test_must_fail kill $pid >/dev/null 2>&1 &&
+	test_must_fail p4 info 2>&1 >/dev/null &&
 	rm -rf "$db" "$cli" "$pidfile"
 }
 
-- 
2.3.4.48.g223ab37

← back to recent threads