threads / patch / 27038

patcht3306,t5304: avoid clock skew issues

Subject: [PATCH] t3306,t5304: avoid clock skew issues

## tl;dr

4 messages between Apr 8, 2011 and Apr 14, 2011. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Michael J Gruber· Apr 8, 2011, 17:58 UTC · lore

On systems where the local time and file modification time may be out of sync (e.g. test directory on NFS) t3306 and t5305 can fail because prune compares times such as "now" (client time) with file modification times (server times for remote file systems). I.e., these are spurious test failures.

Avoid this by setting the relevant modification times to the local time.
Noticed on a system with as little as 2s time skew.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
I don't think we can safeguard prune itself properly. A filesystem may be out
of time sync sporadically (and produce incorrect time stamps) but then be in
sync when "git prune" is run so that we can't detect it.
 t/t3306-notes-prune.sh |    4 ++++
 t/t5304-prune.sh       |    3 ++-
 2 files changed, 6 insertions(+), 1 deletions(-)
Show changes to 2 files +6 −1

t/t3306-notes-prune.sh, t/t5304-prune.sh

diff --git a/t/t3306-notes-prune.sh b/t/t3306-notes-prune.sh
index c428217..3114972 100755
--- a/t/t3306-notes-prune.sh
+++ b/t/t3306-notes-prune.sh
@@ -20,6 +20,10 @@ test_expect_success 'setup: create a few commits with notes' '
 	git add file3 &&
 	test_tick &&
 	git commit -m 3rd &&
+	COMMIT=$(git rev-parse HEAD) &&
+	COMMIT_FILE=.git/objects/$(echo $COMMIT | sed "s/^../&\//") &&
+	test -f $COMMIT_FILE &&
+	test-chmtime =+0 $COMMIT_FILE &&
 	git notes add -m "Note #3"
 '
 
diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh
index e2ed13d..d645328 100755
--- a/t/t5304-prune.sh
+++ b/t/t5304-prune.sh
@@ -14,7 +14,8 @@ add_blob() {
 	BLOB=$(echo aleph_0 | git hash-object -w --stdin) &&
 	BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
 	test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
-	test -f $BLOB_FILE
+	test -f $BLOB_FILE &&
+	test-chmtime =+0 $BLOB_FILE
 }
 
 test_expect_success setup '
-- 
1.7.5.rc0.365.g23929a
Junio C Hamano· Apr 8, 2011, 20:20 UTC · re: Michael J Gruber · lore

Re: [PATCH] t3306,t5304: avoid clock skew issues

Michael J Gruber <git@drmicha.warpmail.net> writes:
Show 30 quoted lines
> On systems where the local time and file modification time may be out of
> sync (e.g. test directory on NFS) t3306 and t5305 can fail because prune
> compares times such as "now" (client time) with file modification times
> (server times for remote file systems). I.e., these are spurious test
> failures.
>
> Avoid this by setting the relevant modification times to the local time.
>
> Noticed on a system with as little as 2s time skew.
>
> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
> ---
> I don't think we can safeguard prune itself properly. A filesystem may be out
> of time sync sporadically (and produce incorrect time stamps) but then be in
> sync when "git prune" is run so that we can't detect it.
>
>  t/t3306-notes-prune.sh |    4 ++++
>  t/t5304-prune.sh       |    3 ++-
>  2 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/t/t3306-notes-prune.sh b/t/t3306-notes-prune.sh
> index c428217..3114972 100755
> --- a/t/t3306-notes-prune.sh
> +++ b/t/t3306-notes-prune.sh
> @@ -20,6 +20,10 @@ test_expect_success 'setup: create a few commits with notes' '
>  	git add file3 &&
>  	test_tick &&
>  	git commit -m 3rd &&
> +	COMMIT=$(git rev-parse HEAD) &&
> +	COMMIT_FILE=.git/objects/$(echo $COMMIT | sed "s/^../&\//") &&

Hmm, the remainder of the test script seems to know this commit is 5ee1c35 all over the place. Do the above two lines worth it?

Michael J Gruber· Apr 8, 2011, 20:30 UTC · re: Junio C Hamano · lore

Re: [PATCH] t3306,t5304: avoid clock skew issues

Junio C Hamano venit, vidit, dixit 08.04.2011 22:20:
Show 35 quoted lines
> Michael J Gruber <git@drmicha.warpmail.net> writes:
> 
>> On systems where the local time and file modification time may be out of
>> sync (e.g. test directory on NFS) t3306 and t5305 can fail because prune
>> compares times such as "now" (client time) with file modification times
>> (server times for remote file systems). I.e., these are spurious test
>> failures.
>>
>> Avoid this by setting the relevant modification times to the local time.
>>
>> Noticed on a system with as little as 2s time skew.
>>
>> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
>> ---
>> I don't think we can safeguard prune itself properly. A filesystem may be out
>> of time sync sporadically (and produce incorrect time stamps) but then be in
>> sync when "git prune" is run so that we can't detect it.
>>
>>  t/t3306-notes-prune.sh |    4 ++++
>>  t/t5304-prune.sh       |    3 ++-
>>  2 files changed, 6 insertions(+), 1 deletions(-)
>>
>> diff --git a/t/t3306-notes-prune.sh b/t/t3306-notes-prune.sh
>> index c428217..3114972 100755
>> --- a/t/t3306-notes-prune.sh
>> +++ b/t/t3306-notes-prune.sh
>> @@ -20,6 +20,10 @@ test_expect_success 'setup: create a few commits with notes' '
>>  	git add file3 &&
>>  	test_tick &&
>>  	git commit -m 3rd &&
>> +	COMMIT=$(git rev-parse HEAD) &&
>> +	COMMIT_FILE=.git/objects/$(echo $COMMIT | sed "s/^../&\//") &&
> 
> Hmm, the remainder of the test script seems to know this commit is 5ee1c35
> all over the place.  Do the above two lines worth it?

I found that use of concrete sha1s a bit strange (I didn't run blame...) but have no objection against keeping the new bit in line with the existing test, i.e.

+	COMMIT_FILE=.git/object/5e/e1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
instead of the 2 lines above.
Michael
Michael J Gruber· Apr 14, 2011, 17:38 UTC · re: Michael J Gruber · lore

[PATCHv2] t3306,t5304: avoid clock skew issues

On systems where the local time and file modification time may be out of sync (e.g. test directory on NFS) t3306 and t5305 can fail because prune compares times such as "now" (client time) with file modification times (server times for remote file systems). I.e., these are spurious test failures.

Avoid this by setting the relevant modification times to the local time.
Noticed on a system with as little as 2s time skew.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
I don't think we can safeguard prune itself properly. A filesystem may be out
of time sync sporadically (and produce incorrect time stamps) but then be in
sync when "git prune" is run so that we can't detect it.
v2 uses the known sha1 directly in t3306, just like the rest of the test.
---
 t/t3306-notes-prune.sh |    3 +++
 t/t5304-prune.sh       |    3 ++-
 2 files changed, 5 insertions(+), 1 deletions(-)
Show changes to 2 files +5 −1

t/t3306-notes-prune.sh, t/t5304-prune.sh

diff --git a/t/t3306-notes-prune.sh b/t/t3306-notes-prune.sh
index c428217..86bf909 100755
--- a/t/t3306-notes-prune.sh
+++ b/t/t3306-notes-prune.sh
@@ -20,6 +20,9 @@ test_expect_success 'setup: create a few commits with notes' '
 	git add file3 &&
 	test_tick &&
 	git commit -m 3rd &&
+	COMMIT_FILE=.git/objects/5e/e1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
+	test -f $COMMIT_FILE &&
+	test-chmtime =+0 $COMMIT_FILE &&
 	git notes add -m "Note #3"
 '
 
diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh
index e2ed13d..d645328 100755
--- a/t/t5304-prune.sh
+++ b/t/t5304-prune.sh
@@ -14,7 +14,8 @@ add_blob() {
 	BLOB=$(echo aleph_0 | git hash-object -w --stdin) &&
 	BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
 	test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
-	test -f $BLOB_FILE
+	test -f $BLOB_FILE &&
+	test-chmtime =+0 $BLOB_FILE
 }
 
 test_expect_success setup '
-- 
1.7.5.rc1.312.g1936c

← back to recent threads