[PATCH] some improvements to the defer-open test

Michael Adam obnox at samba.org
Wed Aug 6 08:46:12 MDT 2014


Hi,

the defer-open tests is one of the prominent causes
of flapping tests. I have discussed with Metze some
possibilites of improving the timing handling in this
test, unifying it with some other timing-critical tests.

This is not done yet, but for a start, attached find
a patchset that improves the defer-open test so that it
hopefully does not create unexpected errors any more
(but accurately fails with torture-assert), and gives
more helpful error messages in that case.

Review/push appreciated!

Michael

-------------- next part --------------
From ab3db51a13f0a2011c5da8758bf2cca213606fa2 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Fri, 25 Jul 2014 00:20:47 +0200
Subject: [PATCH 1/3] s4:torture: remove an unused variable and bogus check
 from the defer_open test

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/torture/basic/base.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index 4f2240e..5e5d6b9 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -649,7 +649,6 @@ test the timing of deferred open requests
 static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli, int dummy)
 {
 	const char *fname = "\\defer_open_test.dat";
-	int retries=4;
 	int i = 0;
 	bool correct = true;
 	int nsec;
@@ -660,11 +659,6 @@ static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli
 	msec = nsec / 1000;
 	sec = ((double)nsec) / ((double) 1000000);
 
-	if (retries <= 0) {
-		torture_comment(tctx, "failed to connect\n");
-		return false;
-	}
-
 	torture_comment(tctx, "Testing deferred open requests.\n");
 
 	while (i < 4) {
-- 
1.9.1


From fb6efe3001bb78dc038bca59701ce864bd697ec9 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Fri, 25 Jul 2014 00:22:17 +0200
Subject: [PATCH 2/3] s4:torture: consistently log "pid %u: ..." in the
 defer_open test

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/torture/basic/base.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index 5e5d6b9..66c6d41 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -659,7 +659,8 @@ static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli
 	msec = nsec / 1000;
 	sec = ((double)nsec) / ((double) 1000000);
 
-	torture_comment(tctx, "Testing deferred open requests.\n");
+	torture_comment(tctx, "pid %u: Testing deferred open requests.\n",
+			(unsigned)getpid());
 
 	while (i < 4) {
 		int fnum = -1;
@@ -690,7 +691,7 @@ static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli
 			return false;
 		}
 
-		torture_comment(tctx, "pid %u open %d\n", (unsigned)getpid(), i);
+		torture_comment(tctx, "pid %u: open %d\n", (unsigned)getpid(), i);
 
 		smb_msleep(10 * msec);
 		i++;
@@ -713,7 +714,8 @@ static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli
 		}
 	}
 
-	torture_comment(tctx, "deferred test finished\n");
+	torture_comment(tctx, "pid %u: deferred test finished\n",
+			(unsigned)getpid());
 	return correct;
 }
 
-- 
1.9.1


From e8b14ca972d77ee635d5e7e802240c6acf87d98c Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Fri, 25 Jul 2014 00:24:56 +0200
Subject: [PATCH 3/3] s4:torture: use torture_assert instead of torture_comment
 and return in defer_open test

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/torture/basic/base.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index 66c6d41..1d04b35 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -686,10 +686,11 @@ static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli
 			}
 		} while (NT_STATUS_EQUAL(smbcli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION));
 
-		if (fnum == -1) {
-			torture_comment(tctx,"Failed to open %s, error=%s\n", fname, smbcli_errstr(cli->tree));
-			return false;
-		}
+		torture_assert(tctx, fnum != -1,
+			       talloc_asprintf(tctx,
+					"pid %u: Failed to open %s, error=%s\n",
+					(unsigned)getpid(), fname,
+					smbcli_errstr(cli->tree)));
 
 		torture_comment(tctx, "pid %u: open %d\n", (unsigned)getpid(), i);
 
-- 
1.9.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20140806/236be93a/attachment.pgp>


More information about the samba-technical mailing list