[PATCH] tests: remove seemingly unnecessary "sleep 3"

Jim Meyering jim at meyering.net
Wed Oct 6 13:44:51 UTC 2010


Jeff Darcy wrote:

> On 10/06/2010 04:26 AM, Jim Meyering wrote:
>> Hi Jeff,
>>
>> I noticed the "sleep 3" because this test seemed to be
>> taking too long ;-)  Removing it doesn't cause any problem
>> here: 100 iterations of "make -j2 check" succeeded:
>>
>>     for i in $(seq 100); do echo $i; , check >>& makerr || break; done
>>
>> From what you mentioned a day or two ago, I wonder if on your
>> system, without that sleep, mongod shuts down too slowly and
>> ends up printing a diagnostic when its directory is automatically
>> deleted by init.sh's cleanup function.
>
> Not quite.  What happens is that the test framework gets EPERM on
> .../mongo when it tries to remove the temp directory, and (improperly
> IMO) treats that as a test failure.

Could it have failed with ENOTEMPTY rather than EPERM?
It's not easy (maybe not even possible) to make "rm -rf" fail with
EPERM when all of the things being deleted were created by the same
user running the command.

If you can reproduce that, I'd be very interested in any
details you can provide, since init.sh is used in many projects,
and I'm about to make a coreutils release that includes it.

>> If that's the case, the test could kill mongod with -9 instead,
>> since there is no need to make it perform an orderly shutdown.
>
> That seems fairly reasonable.
>
>> Does this seem ok to you?
>
> If/when I can test that version on my machine and not have it report
> errors after all tests have passed, then yes.  Also, whatever fix we
> decide on also needs to be applied to other tests.

Of course.

Here's a patch that does that:

>From d906ff6097995029d308970118d145b0408c52ff Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Wed, 6 Oct 2010 10:15:54 +0200
Subject: [PATCH] tests: remove seemingly unnecessary "sleep 3"

* t/replication (cleanup_): Don't sleep for 3 seconds.
* t/replication (cleanup_): Kill with -9, to avoid diagnostics
from init.sh's cleanup (rm -rf) process when it takes too long
for mongod to handle the signal.
* t/basic (cleanup_): Likewise.
---
 t/basic       |    4 ++--
 t/replication |    6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/t/basic b/t/basic
index 4170568..17a0c62 100644
--- a/t/basic
+++ b/t/basic
@@ -9,7 +9,7 @@ m_port=$(expr $mongo_base_port + 0)

 mongod --port $m_port --pidfilepath mongod/pid --dbpath mongod > mongod.log 2>&1 &
 mongo_pid=$!
-cleanup_() { kill $mongo_pid; }
+cleanup_() { kill -9 $mongo_pid; }

 # Wait for up to 3 seconds for mongod to begin listening.
 wait_for .1 30 'mongo < /dev/null' \
@@ -123,7 +123,7 @@ printf '[{"path": "FS", "type": "fs", "name": "primary"}]\n' \

 iwhd -v -p $port -c iwhd.cfg -d localhost:$m_port &
 iwhd_pid=$!
-cleanup_() { kill $mongo_pid $iwhd_pid; }
+cleanup_() { kill -9 $mongo_pid $iwhd_pid; }

 # Wait for up to 3 seconds for iwhd to begin listening on $port.
 wait_for .1 30 "curl -s http://localhost:$port" \
diff --git a/t/replication b/t/replication
index 9ce8ab2..429a30b 100644
--- a/t/replication
+++ b/t/replication
@@ -9,7 +9,7 @@ m_port=$(expr $mongo_base_port + 1)

 mongod --port $m_port --pidfilepath mongod/pid --dbpath mongod > mongod.log 2>&1 &
 mongo_pid=$!
-cleanup_() { kill $mongo_pid; sleep 3; }
+cleanup_() { kill -9 $mongo_pid; }

 # Wait for up to 3 seconds for mongod to begin listening.
 wait_for .1 30 'mongo < /dev/null' \
@@ -28,7 +28,7 @@ iwhd -v -p $port -c iwhd_u.cfg -d localhost:$m_port &
 iwhd_pid=$!
 wait_for .1 30 "curl http://localhost:$port" \
 	|| framework_failure_ "iwhd upstream"
-cleanup_() { kill $mongo_pid $iwhd_pid; sleep 3; }
+cleanup_() { kill -9 $mongo_pid $iwhd_pid; }

 cat > iwhd_d.cfg << EOF
 [
@@ -41,7 +41,7 @@ iwhd -v -p $d_port -c iwhd_d.cfg -d localhost:$m_port &
 iwhd_d_pid=$!
 wait_for .1 30 "curl http://localhost:$d_port" \
 	|| framework_failure_ "iwhd downstream"
-cleanup_() { kill $mongo_pid $iwhd_pid $iwhd_d_pid; sleep 3; }
+cleanup_() { kill -9 $mongo_pid $iwhd_pid $iwhd_d_pid; }

 api=http://localhost:$port
 wait_for_repl() {
--
1.7.3.1.50.g1e633


More information about the iwhd-devel mailing list