[sheepdog] [PATCH] tests/functional: use kill_zk_session to _kill_sheep with zk

Liu Yuan namei.unix at gmail.com
Tue Jul 23 10:01:08 CEST 2013


- fix kill_zk_session.c that if ZNONODE returns, we simply return success

In this way we don't blind sleep for _kill_sheep with zk driver. This fixes
some false failure of tests with SSD drive and also boost tests a little bit

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 tests/functional/common.rc |    4 ++--
 tools/kill_zk_session.c    |   10 ++++++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/tests/functional/common.rc b/tests/functional/common.rc
index f621261..c9e18f2 100644
--- a/tests/functional/common.rc
+++ b/tests/functional/common.rc
@@ -323,7 +323,7 @@ _kill_sheep()
     _wait_for_sheep_stop $1
 
     if [[ "$DRIVER" == zoo* ]];then
-        sleep 3 # wait for zookeeper ephemeral node to be deleted
+	    _kill_zk_session $1
     fi
 }
 
@@ -476,7 +476,7 @@ _random()
 
 _kill_zk_session()
 {
-	local path="/sheepdog/member/IPv4 ip:127.0.0.1 port:700$1"
+	local path="/sheepdog/member/IPv4 ip:127.0.0.1 port:$((7000+$1))"
 	if [[ "$DRIVER" == zoo* ]]; then
 		../../tools/kill_zk_session "$path"
 		if [ $? -ne 0 ]; then
diff --git a/tools/kill_zk_session.c b/tools/kill_zk_session.c
index dc0e6a8..8d1f671 100644
--- a/tools/kill_zk_session.c
+++ b/tools/kill_zk_session.c
@@ -47,8 +47,14 @@ int main(int argc, char **argv)
 		;
 
 	rc = zoo_get(zh, path, 0, (char *)&cid, &len, NULL);
-	if (rc != ZOK) {
-		fprintf(stderr, "failed to get data, %s\n", zerror(rc));
+	switch (rc) {
+	case ZOK:
+		break;
+	case ZNONODE:
+		return 0;
+	default:
+		fprintf(stderr, "failed to get data for %s, %s\n", path,
+			zerror(rc));
 		exit(1);
 	}
 
-- 
1.7.9.5




More information about the sheepdog mailing list