git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* t5570 shaky for anyone ?
@ 2018-11-25 20:52 Torsten Bögershausen
  2018-11-25 22:01 ` Thomas Gummerer
  2018-11-25 22:22 ` t5570 shaky for anyone ? SZEDER Gábor
  0 siblings, 2 replies; 12+ messages in thread
From: Torsten Bögershausen @ 2018-11-25 20:52 UTC (permalink / raw)
  To: Git Mailing List, szeder.dev

After running the  "Git 2.20-rc1" testsuite here on a raspi,
the only TC that failed was t5570.
When the "grep" was run on daemon.log, the file was empty (?).
When inspecting it later, it was filled, and grep would have found
the "extended.attribute" it was looking for.

The following fixes it, but I am not sure if this is the ideal
solution.


diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh
index 7466aad111..e259fee0ed 100755
--- a/t/t5570-git-daemon.sh
+++ b/t/t5570-git-daemon.sh
@@ -192,6 +192,7 @@ test_expect_success 'daemon log records all attributes' '
 	GIT_OVERRIDE_VIRTUAL_HOST=localhost \
 		git -c protocol.version=1 \
 			ls-remote "$GIT_DAEMON_URL/interp.git" &&
+	sleep 1 &&
 	grep -i extended.attribute daemon.log | cut -d" " -f2- >actual &&
 	test_cmp expect actual
 '
----------------
A slightly better approach may be to use a "sleep on demand":

+	( grep -i -q extended.attribute daemon.log || sleep 1 ) &&


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: t5570 shaky for anyone ?
  2018-11-25 20:52 t5570 shaky for anyone ? Torsten Bögershausen
@ 2018-11-25 22:01 ` Thomas Gummerer
  2018-11-26 16:42   ` Jeff King
  2018-11-25 22:22 ` t5570 shaky for anyone ? SZEDER Gábor
  1 sibling, 1 reply; 12+ messages in thread
From: Thomas Gummerer @ 2018-11-25 22:01 UTC (permalink / raw)
  To: Torsten Bögershausen; +Cc: Git Mailing List, szeder.dev, Jeff King

On 11/25, Torsten Bögershausen wrote:
> After running the  "Git 2.20-rc1" testsuite here on a raspi,
> the only TC that failed was t5570.
> When the "grep" was run on daemon.log, the file was empty (?).
> When inspecting it later, it was filled, and grep would have found
> the "extended.attribute" it was looking for.

I believe this has been reported before in
https://public-inbox.org/git/1522783990.964448.1325338528.0D49CC15@webmail.messagingengine.com/,
but it seems like the thread never ended with actually fixing it.
Reading the first reply Peff seemed to be fine with just removing the
test completely, which would be the easiest solution ;)  Adding him to
Cc: here.  

> The following fixes it, but I am not sure if this is the ideal
> solution.
> 
> 
> diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh
> index 7466aad111..e259fee0ed 100755
> --- a/t/t5570-git-daemon.sh
> +++ b/t/t5570-git-daemon.sh
> @@ -192,6 +192,7 @@ test_expect_success 'daemon log records all attributes' '
>  	GIT_OVERRIDE_VIRTUAL_HOST=localhost \
>  		git -c protocol.version=1 \
>  			ls-remote "$GIT_DAEMON_URL/interp.git" &&
> +	sleep 1 &&
>  	grep -i extended.attribute daemon.log | cut -d" " -f2- >actual &&
>  	test_cmp expect actual
>  '
> ----------------
> A slightly better approach may be to use a "sleep on demand":
> 
> +	( grep -i -q extended.attribute daemon.log || sleep 1 ) &&
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: t5570 shaky for anyone ?
  2018-11-25 20:52 t5570 shaky for anyone ? Torsten Bögershausen
  2018-11-25 22:01 ` Thomas Gummerer
@ 2018-11-25 22:22 ` SZEDER Gábor
  2018-11-26 16:45   ` Jeff King
  1 sibling, 1 reply; 12+ messages in thread
From: SZEDER Gábor @ 2018-11-25 22:22 UTC (permalink / raw)
  To: Torsten Bögershausen; +Cc: Git Mailing List, Jeff King

On Sun, Nov 25, 2018 at 09:52:23PM +0100, Torsten Bögershausen wrote:
> After running the  "Git 2.20-rc1" testsuite here on a raspi,
> the only TC that failed was t5570.
> When the "grep" was run on daemon.log, the file was empty (?).
> When inspecting it later, it was filled, and grep would have found
> the "extended.attribute" it was looking for.

I think I saw the same failure on Travis CI already before 2.19, so
it's not a new issue.  Here's the test's verbose output:

  + cat
  + 
  + GIT_OVERRIDE_VIRTUAL_HOST=localhost git -c protocol.version=1 ls-remote git://127.0.0.1:5570/interp.git
  b6752e52dd867264d12240028003f21e3e1dccab        HEAD
  b6752e52dd867264d12240028003f21e3e1dccab        refs/heads/master
  + cut -d  -f2-
  + grep -i extended.attribute daemon.log
  + test_cmp expect actual
  + diff -u expect actual
  --- expect      2018-06-12 10:06:50.758357927 +0000
  +++ actual      2018-06-12 10:06:50.774365936 +0000
  @@ -1,2 +0,0 @@
  -Extended attribute "host": localhost
  -Extended attribute "protocol": version=1
  [10579] Connection from 127.0.0.1:45836
  [10579] Extended attribute "host": localhost
  [10579] Extended attribute "protocol": version=1
  error: last command exited with $?=1
  [10579] Request upload-pack for '/interp.git'
  [10579] Interpolated dir '/usr/src/git/t/trash
  dir.t5570/repo/localhost/interp.git'
  [10462] [10579] Disconnected
  not ok 21 - daemon log records all attributes

The thing is that 'git daemon's log is not written to 'daemon.log'
directly, but it goes through a fifo, which is read by a shell loop,
which then sends all log messages both to 'daemon.log' and to the test
script's standard error.  So there is certainly a race between log
messages going through the fifo and the loop before reaching
'daemon.log' and 'git ls-remote' exiting and 'grep' opening
'daemon.log'.

> The following fixes it, but I am not sure if this is the ideal
> solution.

Currently this is the only test that looks at 'daemon.log', but if we
ever going to add another one, then that will be prone to the same
issue.

I wonder whether it's really that useful to have the daemon log in the
test script's output...  if the log was sent directly to daemon log,
then the window for this race would be smaller, but still not
completely closed.

Anyway, I added Peff to Cc, since he added that whole fifo-shell-loop
thing.

> diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh
> index 7466aad111..e259fee0ed 100755
> --- a/t/t5570-git-daemon.sh
> +++ b/t/t5570-git-daemon.sh
> @@ -192,6 +192,7 @@ test_expect_success 'daemon log records all attributes' '
>  	GIT_OVERRIDE_VIRTUAL_HOST=localhost \
>  		git -c protocol.version=1 \
>  			ls-remote "$GIT_DAEMON_URL/interp.git" &&
> +	sleep 1 &&
>  	grep -i extended.attribute daemon.log | cut -d" " -f2- >actual &&
>  	test_cmp expect actual
>  '
> ----------------
> A slightly better approach may be to use a "sleep on demand":
> 
> +	( grep -i -q extended.attribute daemon.log || sleep 1 ) &&
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: t5570 shaky for anyone ?
  2018-11-25 22:01 ` Thomas Gummerer
@ 2018-11-26 16:42   ` Jeff King
  2018-12-20 16:41     ` [PATCH] t5570: drop racy test Thomas Gummerer
  0 siblings, 1 reply; 12+ messages in thread
From: Jeff King @ 2018-11-26 16:42 UTC (permalink / raw)
  To: Thomas Gummerer; +Cc: Torsten Bögershausen, Git Mailing List, szeder.dev

On Sun, Nov 25, 2018 at 10:01:38PM +0000, Thomas Gummerer wrote:

> On 11/25, Torsten Bögershausen wrote:
> > After running the  "Git 2.20-rc1" testsuite here on a raspi,
> > the only TC that failed was t5570.
> > When the "grep" was run on daemon.log, the file was empty (?).
> > When inspecting it later, it was filled, and grep would have found
> > the "extended.attribute" it was looking for.
> 
> I believe this has been reported before in
> https://public-inbox.org/git/1522783990.964448.1325338528.0D49CC15@webmail.messagingengine.com/,
> but it seems like the thread never ended with actually fixing it.
> Reading the first reply Peff seemed to be fine with just removing the
> test completely, which would be the easiest solution ;)  Adding him to
> Cc: here.

Yes, I don't think there is a way to make this race-proof without
somehow convincing "cat" to flush (and let us know when it has). Which
really implies killing the daemon, and wait()ing on cat to process the
EOF and exit.  And that makes the tests a lot more expensive if we have
to start the daemon for each snippet.

So I'm still fine with just dropping this test.

> > diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh
> > index 7466aad111..e259fee0ed 100755
> > --- a/t/t5570-git-daemon.sh
> > +++ b/t/t5570-git-daemon.sh
> > @@ -192,6 +192,7 @@ test_expect_success 'daemon log records all attributes' '
> >  	GIT_OVERRIDE_VIRTUAL_HOST=localhost \
> >  		git -c protocol.version=1 \
> >  			ls-remote "$GIT_DAEMON_URL/interp.git" &&
> > +	sleep 1 &&
> >  	grep -i extended.attribute daemon.log | cut -d" " -f2- >actual &&
> >  	test_cmp expect actual
> >  '
> > ----------------
> > A slightly better approach may be to use a "sleep on demand":
> > 
> > +	( grep -i -q extended.attribute daemon.log || sleep 1 ) &&

That doesn't really fix it, but just broadens the race window. I dunno.
Maybe that is enough in practice. We could do something like:

  repeat_with_timeout () {
	local i=0
	while test $i -lt 10
	do
		"$@" && return 0
		sleep 1
	done
	# no success even after 10 seconds
	return 1
  }

  repeat_with_timeout grep -i extended.attribute daemon.log

to make the pattern a bit more obvious (and make it easy to extend the
window arbitrarily; surely 10s is enough?).

-Peff

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: t5570 shaky for anyone ?
  2018-11-25 22:22 ` t5570 shaky for anyone ? SZEDER Gábor
@ 2018-11-26 16:45   ` Jeff King
  0 siblings, 0 replies; 12+ messages in thread
From: Jeff King @ 2018-11-26 16:45 UTC (permalink / raw)
  To: SZEDER Gábor; +Cc: Torsten Bögershausen, Git Mailing List

On Sun, Nov 25, 2018 at 11:22:47PM +0100, SZEDER Gábor wrote:

> > The following fixes it, but I am not sure if this is the ideal
> > solution.
> 
> Currently this is the only test that looks at 'daemon.log', but if we
> ever going to add another one, then that will be prone to the same
> issue.
> 
> I wonder whether it's really that useful to have the daemon log in the
> test script's output...  if the log was sent directly to daemon log,
> then the window for this race would be smaller, but still not
> completely closed.
> 
> Anyway, I added Peff to Cc, since he added that whole fifo-shell-loop
> thing.

Yeah, see my comments on the other part of the thread. If we did write
directly to a file, I think that would be enough here because git-daemon
writes this entry before running the sub-process. So by the time
ls-remote finishes, we know that it talked to upload-pack, and we know
that before upload-pack was run, git-daemon wrote the log entry. That
assumes git-daemon doesn't buffer its logs (but if it does, we should
probably fix that).

-Peff

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] t5570: drop racy test
  2018-11-26 16:42   ` Jeff King
@ 2018-12-20 16:41     ` Thomas Gummerer
  2018-12-20 17:14       ` Jeff King
  2019-01-06 17:53       ` [PATCH 2/1] Revert "t/lib-git-daemon: record daemon log" Thomas Gummerer
  0 siblings, 2 replies; 12+ messages in thread
From: Thomas Gummerer @ 2018-12-20 16:41 UTC (permalink / raw)
  To: Jeff King
  Cc: Torsten Bögershausen, Git Mailing List, szeder.dev,
	Jan Palus, Johannes Schindelin

On 11/26, Jeff King wrote:
> On Sun, Nov 25, 2018 at 10:01:38PM +0000, Thomas Gummerer wrote:
> 
> > On 11/25, Torsten Bögershausen wrote:
> > > After running the  "Git 2.20-rc1" testsuite here on a raspi,
> > > the only TC that failed was t5570.
> > > When the "grep" was run on daemon.log, the file was empty (?).
> > > When inspecting it later, it was filled, and grep would have found
> > > the "extended.attribute" it was looking for.
> > 
> > I believe this has been reported before in
> > https://public-inbox.org/git/1522783990.964448.1325338528.0D49CC15@webmail.messagingengine.com/,
> > but it seems like the thread never ended with actually fixing it.
> > Reading the first reply Peff seemed to be fine with just removing the
> > test completely, which would be the easiest solution ;)  Adding him to
> > Cc: here.
> 
> Yes, I don't think there is a way to make this race-proof without
> somehow convincing "cat" to flush (and let us know when it has). Which
> really implies killing the daemon, and wait()ing on cat to process the
> EOF and exit.  And that makes the tests a lot more expensive if we have
> to start the daemon for each snippet.
> 
> So I'm still fine with just dropping this test.

Alright since this has come up twice on the mailing list now (and I've
seen this racyness as well), and nobody found the time to write a
patch yet, below is a patch to just remove the test.

> > > diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh
> > > index 7466aad111..e259fee0ed 100755
> > > --- a/t/t5570-git-daemon.sh
> > > +++ b/t/t5570-git-daemon.sh
> > > @@ -192,6 +192,7 @@ test_expect_success 'daemon log records all attributes' '
> > >  	GIT_OVERRIDE_VIRTUAL_HOST=localhost \
> > >  		git -c protocol.version=1 \
> > >  			ls-remote "$GIT_DAEMON_URL/interp.git" &&
> > > +	sleep 1 &&
> > >  	grep -i extended.attribute daemon.log | cut -d" " -f2- >actual &&
> > >  	test_cmp expect actual
> > >  '
> > > ----------------
> > > A slightly better approach may be to use a "sleep on demand":
> > > 
> > > +	( grep -i -q extended.attribute daemon.log || sleep 1 ) &&
> 
> That doesn't really fix it, but just broadens the race window. I dunno.
> Maybe that is enough in practice. We could do something like:
> 
>   repeat_with_timeout () {
> 	local i=0
> 	while test $i -lt 10
> 	do
> 		"$@" && return 0
> 		sleep 1
> 	done
> 	# no success even after 10 seconds
> 	return 1
>   }
> 
>   repeat_with_timeout grep -i extended.attribute daemon.log
> 
> to make the pattern a bit more obvious (and make it easy to extend the
> window arbitrarily; surely 10s is enough?).

I gave this a try, with below patch to lib-git-daemon.sh that you
proposed in the previous thread about this racyness.  That shows
another problem though, namely when truncating 'daemon.log' before
running 'git ls-remote' in this test, we're not sure all 'git deamon'
has flushed everything from previous invocations.  That may be an even
rarer problem in practice, but still something to keep in mind.

diff --git a/t/lib-git-daemon.sh b/t/lib-git-daemon.sh
index edbea2d986..3c7fea169b 100644
--- a/t/lib-git-daemon.sh
+++ b/t/lib-git-daemon.sh
@@ -62,6 +62,7 @@ start_git_daemon() {
 		(
 			while read -r line <&7
 			do
+				sleep 1
 				printf "%s\n" "$line"
 				printf >&4 "%s\n" "$line"
 			done

Dscho also mentioned on #git-devel a while ago that he may have a look
at actually making this test race-proof, but I guess he's been busy
with the 2.20 release.  I'm also not sure it's worth spending a lot of
time trying to fix this test, but I'd definitely be happy if someone
proposes a different solution.

> -Peff

--- >8 ---
Subject: [PATCH] t5570: drop racy test

t5570 being racy has been reported twice separately on the mailing
list [*1*, *2*].

To make the test race proof, we'd either have to introduce another
fifo the test snippet is waiting on, or somehow convincing "cat" to
flush (and let us know when it has).  Which really implies killing the
daemon, and wait()ing on cat to process the EOF and exit.  And that
makes the tests a lot more expensive if we have to start the daemon
for each snippet.

As this is a test for a relatively minor fix (according to the author)
in 19136be3f8 ("daemon: fix off-by-one in logging extended
attributes", 2018-01-24), drop it to avoid this racyness.  It doesn't
seem worth making the test code much more complex, or slowing down all
tests just to keep this one.

*1*: 1522783990.964448.1325338528.0D49CC15@webmail.messagingengine.com/
*2*: 9d4e5224-9ff4-f3f8-519d-7b2a6f1ea7cd@web.de

Reported-by: Jan Palus <jpalus@fastmail.com>
Reported-by: Torsten Bögershausen <tboegi@web.de>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
---
 t/t5570-git-daemon.sh | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh
index 7466aad111..58ee787685 100755
--- a/t/t5570-git-daemon.sh
+++ b/t/t5570-git-daemon.sh
@@ -183,19 +183,6 @@ test_expect_success 'hostname cannot break out of directory' '
 		git ls-remote "$GIT_DAEMON_URL/escape.git"
 '
 
-test_expect_success 'daemon log records all attributes' '
-	cat >expect <<-\EOF &&
-	Extended attribute "host": localhost
-	Extended attribute "protocol": version=1
-	EOF
-	>daemon.log &&
-	GIT_OVERRIDE_VIRTUAL_HOST=localhost \
-		git -c protocol.version=1 \
-			ls-remote "$GIT_DAEMON_URL/interp.git" &&
-	grep -i extended.attribute daemon.log | cut -d" " -f2- >actual &&
-	test_cmp expect actual
-'
-
 test_expect_success FAKENC 'hostname interpolation works after LF-stripping' '
 	{
 		printf "git-upload-pack /interp.git\n\0host=localhost" | packetize
-- 
2.20.1.415.g653613c723


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] t5570: drop racy test
  2018-12-20 16:41     ` [PATCH] t5570: drop racy test Thomas Gummerer
@ 2018-12-20 17:14       ` Jeff King
  2018-12-21 15:48         ` Johannes Schindelin
  2019-01-06 17:53       ` [PATCH 2/1] Revert "t/lib-git-daemon: record daemon log" Thomas Gummerer
  1 sibling, 1 reply; 12+ messages in thread
From: Jeff King @ 2018-12-20 17:14 UTC (permalink / raw)
  To: Thomas Gummerer
  Cc: Torsten Bögershausen, Git Mailing List, szeder.dev,
	Jan Palus, Johannes Schindelin

On Thu, Dec 20, 2018 at 04:41:50PM +0000, Thomas Gummerer wrote:

> > That doesn't really fix it, but just broadens the race window. I dunno.
> > Maybe that is enough in practice. We could do something like:
> > 
> >   repeat_with_timeout () {
> > 	local i=0
> > 	while test $i -lt 10
> > 	do
> > 		"$@" && return 0
> > 		sleep 1
> > 	done
> > 	# no success even after 10 seconds
> > 	return 1
> >   }
> > 
> >   repeat_with_timeout grep -i extended.attribute daemon.log
> > 
> > to make the pattern a bit more obvious (and make it easy to extend the
> > window arbitrarily; surely 10s is enough?).
> 
> I gave this a try, with below patch to lib-git-daemon.sh that you
> proposed in the previous thread about this racyness.  That shows
> another problem though, namely when truncating 'daemon.log' before
> running 'git ls-remote' in this test, we're not sure all 'git deamon'
> has flushed everything from previous invocations.  That may be an even
> rarer problem in practice, but still something to keep in mind.

Right, that makes sense. Making this race-proof really does require a
separate log stream for each test. I guess we'd need to be able to send
git-daemon a signal to re-open the log (which actually is not as
unreasonable as it may seem; lots of daemons have this for log
rotation).

I think getting rid of the "cat" would also help a lot here.
Unfortunately I think we use it not just for its "tee" effect, but also
to avoid startup races by checking the "Ready to rumble" line. So again,
we'd need some cooperation from git-daemon to tell us out-of-band that
it has completed its startup (e.g., by touching another file).

> Dscho also mentioned on #git-devel a while ago that he may have a look
> at actually making this test race-proof, but I guess he's been busy
> with the 2.20 release.  I'm also not sure it's worth spending a lot of
> time trying to fix this test, but I'd definitely be happy if someone
> proposes a different solution.

Yeah. I'm sure it's fixable with enough effort, but I just think there
are more interesting and important things to work on.

> --- >8 ---
> Subject: [PATCH] t5570: drop racy test

So yeah, I'm still fine with this. But...

> ---
>  t/t5570-git-daemon.sh | 13 -------------
>  1 file changed, 13 deletions(-)

This is the only user of daemon.log, so we could drop those bits from
lib-git-daemon.sh, too. That would also prevent people from adding new
tests, thinking that this was somehow not horribly racy). I.e.,
reverting 314a73d658 (t/lib-git-daemon: record daemon log, 2018-01-25).

-Peff

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] t5570: drop racy test
  2018-12-20 17:14       ` Jeff King
@ 2018-12-21 15:48         ` Johannes Schindelin
  2019-01-06 17:59           ` Thomas Gummerer
  0 siblings, 1 reply; 12+ messages in thread
From: Johannes Schindelin @ 2018-12-21 15:48 UTC (permalink / raw)
  To: Jeff King
  Cc: Thomas Gummerer, Torsten Bögershausen, Git Mailing List,
	szeder.dev, Jan Palus

Hi Thomas & Peff,

On Thu, 20 Dec 2018, Jeff King wrote:

> On Thu, Dec 20, 2018 at 04:41:50PM +0000, Thomas Gummerer wrote:
> 
> > > That doesn't really fix it, but just broadens the race window. I dunno.
> > > Maybe that is enough in practice. We could do something like:
> > > 
> > >   repeat_with_timeout () {
> > > 	local i=0
> > > 	while test $i -lt 10
> > > 	do
> > > 		"$@" && return 0
> > > 		sleep 1
> > > 	done
> > > 	# no success even after 10 seconds
> > > 	return 1
> > >   }
> > > 
> > >   repeat_with_timeout grep -i extended.attribute daemon.log
> > > 
> > > to make the pattern a bit more obvious (and make it easy to extend the
> > > window arbitrarily; surely 10s is enough?).
> > 
> > I gave this a try, with below patch to lib-git-daemon.sh that you
> > proposed in the previous thread about this racyness.  That shows
> > another problem though, namely when truncating 'daemon.log' before
> > running 'git ls-remote' in this test, we're not sure all 'git deamon'
> > has flushed everything from previous invocations.  That may be an even
> > rarer problem in practice, but still something to keep in mind.
> 
> Right, that makes sense. Making this race-proof really does require a
> separate log stream for each test. I guess we'd need to be able to send
> git-daemon a signal to re-open the log (which actually is not as
> unreasonable as it may seem; lots of daemons have this for log
> rotation).
> 
> I think getting rid of the "cat" would also help a lot here.
> Unfortunately I think we use it not just for its "tee" effect, but also
> to avoid startup races by checking the "Ready to rumble" line. So again,
> we'd need some cooperation from git-daemon to tell us out-of-band that
> it has completed its startup (e.g., by touching another file).
> 
> > Dscho also mentioned on #git-devel a while ago that he may have a look
> > at actually making this test race-proof, but I guess he's been busy
> > with the 2.20 release.

And GitGitGadget. And working on the Azure Pipelines support. And
mentoring two interns.

This is what I still have in my internal ticket:

	Try to work around occasional t5570 failures in Git's test suite

	Seems that there is a race condition in
	https://github.com/git/git/blob/master/t/lib-git-daemon.sh#L48-L69
	that could possibly be solved by writing to the daemon.log
	directly, and showing the output only via `tail -f` (and only when
	running in verbose mode, as it simply won't make sense otherwise).

However, if the preferred route is to go ahead and just remove that test
altogether, I'm fine with that, too.

The only reason, in my mind, why we still have `git-daemon` is that it
allows for easy standing up your own Git server, e.g. as an ad-hoc way to
collaborate in a small ad-hoc team. If we ever get to the point where we
can stand up a minimal HTTP/HTTPS server with an internal Git command (not
requiring sysadmin privileges), from my point of view `git-daemon` can
even go the way of the Kale Island (but for much better reasons [*1*]).

> > I'm also not sure it's worth spending a lot of time trying to fix this
> > test, but I'd definitely be happy if someone proposes a different
> > solution.
> 
> Yeah. I'm sure it's fixable with enough effort, but I just think there
> are more interesting and important things to work on.
> 
> > --- >8 ---
> > Subject: [PATCH] t5570: drop racy test
> 
> So yeah, I'm still fine with this. But...
> 
> > ---
> >  t/t5570-git-daemon.sh | 13 -------------
> >  1 file changed, 13 deletions(-)
> 
> This is the only user of daemon.log, so we could drop those bits from
> lib-git-daemon.sh, too. That would also prevent people from adding new
> tests, thinking that this was somehow not horribly racy). I.e.,
> reverting 314a73d658 (t/lib-git-daemon: record daemon log, 2018-01-25).

Indeed, that would be good.

The only reason to keep daemon.log that I can think of is to make
debugging easier, but then, if it should become necessary, it is probably
easier to freopen() stdout or stderr into a file in `git daemon`, anyway.

Ciao,
Dscho

Footnote *1*: Kale Island, along with Rapita, Rehana, Kakatina and Zollies
is prominently featured in a scientific article at
http://iopscience.iop.org/article/10.1088/1748-9326/11/5/054011 that is on
my "important papers I read in 2018" list.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 2/1] Revert "t/lib-git-daemon: record daemon log"
  2018-12-20 16:41     ` [PATCH] t5570: drop racy test Thomas Gummerer
  2018-12-20 17:14       ` Jeff King
@ 2019-01-06 17:53       ` Thomas Gummerer
  2019-01-07  8:20         ` Jeff King
  1 sibling, 1 reply; 12+ messages in thread
From: Thomas Gummerer @ 2019-01-06 17:53 UTC (permalink / raw)
  To: Jeff King
  Cc: Torsten Bögershausen, Git Mailing List, szeder.dev,
	Jan Palus, Johannes Schindelin

This reverts commit 314a73d658 (t/lib-git-daemon: record daemon log,
2018-01-25), which let tests use the output of git-daemon.

The previous commit removed the last user of deamon.log in the tests,
there's no good way to make checking for output in the log
race-proof.  Revert this commit as well, to make sure others are not
tempted to use daemon.log in tests in the future, which would lead to
racy tests.

The original commit had one change that still makes sense, namely
switching read/echo for "read -r" and "printf", which relays the data
more faithfully.  Don't revert that piece here, as it is still a
useful change.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
---
 t/lib-git-daemon.sh | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/t/lib-git-daemon.sh b/t/lib-git-daemon.sh
index f98de95c15..fd41229a8f 100644
--- a/t/lib-git-daemon.sh
+++ b/t/lib-git-daemon.sh
@@ -54,19 +54,11 @@ start_git_daemon() {
 		"$@" "$GIT_DAEMON_DOCUMENT_ROOT_PATH" \
 		>&3 2>git_daemon_output &
 	GIT_DAEMON_PID=$!
-	>daemon.log
 	{
 		read -r line <&7
-		printf "%s\n" "$line"
-		printf >&4 "%s\n" "$line"
-		(
-			while read -r line <&7
-			do
-				printf "%s\n" "$line"
-				printf >&4 "%s\n" "$line"
-			done
-		) &
-	} 7<git_daemon_output >>"$TRASH_DIRECTORY/daemon.log" &&
+		printf "%s\n" "$line" >&4
+		cat <&7 >&4 &
+	} 7<git_daemon_output &&
 
 	# Check expected output
 	if test x"$(expr "$line" : "\[[0-9]*\] \(.*\)")" != x"Ready to rumble"
-- 
2.20.1.153.gd81d796ee0

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] t5570: drop racy test
  2018-12-21 15:48         ` Johannes Schindelin
@ 2019-01-06 17:59           ` Thomas Gummerer
  0 siblings, 0 replies; 12+ messages in thread
From: Thomas Gummerer @ 2019-01-06 17:59 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: Jeff King, Torsten Bögershausen, Git Mailing List,
	szeder.dev, Jan Palus

On 12/21, Johannes Schindelin wrote:
> Hi Thomas & Peff,
> 
> On Thu, 20 Dec 2018, Jeff King wrote:
> 
> > On Thu, Dec 20, 2018 at 04:41:50PM +0000, Thomas Gummerer wrote:
> > 
> > > Dscho also mentioned on #git-devel a while ago that he may have a look
> > > at actually making this test race-proof, but I guess he's been busy
> > > with the 2.20 release.
> 
> And GitGitGadget. And working on the Azure Pipelines support. And
> mentoring two interns.
> 
> This is what I still have in my internal ticket:
> 
> 	Try to work around occasional t5570 failures in Git's test suite
> 
> 	Seems that there is a race condition in
> 	https://github.com/git/git/blob/master/t/lib-git-daemon.sh#L48-L69
> 	that could possibly be solved by writing to the daemon.log
> 	directly, and showing the output only via `tail -f` (and only when
> 	running in verbose mode, as it simply won't make sense otherwise).
> 
> However, if the preferred route is to go ahead and just remove that test
> altogether, I'm fine with that, too.

Right, I was of course completely unaware of that internal ticket.  If
you still want to go that way there are certainly no objections from
me.  I just want to make sure not more users run into this racyness,
and I guess you also may have more important/interesting things to
work on.

> The only reason, in my mind, why we still have `git-daemon` is that it
> allows for easy standing up your own Git server, e.g. as an ad-hoc way to
> collaborate in a small ad-hoc team. If we ever get to the point where we
> can stand up a minimal HTTP/HTTPS server with an internal Git command (not
> requiring sysadmin privileges), from my point of view `git-daemon` can
> even go the way of the Kale Island (but for much better reasons [*1*]).
> 
> > > I'm also not sure it's worth spending a lot of time trying to fix this
> > > test, but I'd definitely be happy if someone proposes a different
> > > solution.
> > 
> > Yeah. I'm sure it's fixable with enough effort, but I just think there
> > are more interesting and important things to work on.
> > 
> > > --- >8 ---
> > > Subject: [PATCH] t5570: drop racy test
> > 
> > So yeah, I'm still fine with this. But...
> > 
> > > ---
> > >  t/t5570-git-daemon.sh | 13 -------------
> > >  1 file changed, 13 deletions(-)
> > 
> > This is the only user of daemon.log, so we could drop those bits from
> > lib-git-daemon.sh, too. That would also prevent people from adding new
> > tests, thinking that this was somehow not horribly racy). I.e.,
> > reverting 314a73d658 (t/lib-git-daemon: record daemon log, 2018-01-25).

Right that makes sense.  I sent that as patch 2/1, but I'm happy to
squash those into one if that's preferred.

> Indeed, that would be good.
> 
> The only reason to keep daemon.log that I can think of is to make
> debugging easier, but then, if it should become necessary, it is probably
> easier to freopen() stdout or stderr into a file in `git daemon`, anyway.

We do still print the output when tests are run in verbose mode, which
should be just as good as having the log in a separate file in most
cases I suspect.

> Ciao,
> Dscho
> 
> Footnote *1*: Kale Island, along with Rapita, Rehana, Kakatina and Zollies
> is prominently featured in a scientific article at
> http://iopscience.iop.org/article/10.1088/1748-9326/11/5/054011 that is on
> my "important papers I read in 2018" list.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/1] Revert "t/lib-git-daemon: record daemon log"
  2019-01-06 17:53       ` [PATCH 2/1] Revert "t/lib-git-daemon: record daemon log" Thomas Gummerer
@ 2019-01-07  8:20         ` Jeff King
  2019-01-07 15:45           ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Jeff King @ 2019-01-07  8:20 UTC (permalink / raw)
  To: Thomas Gummerer
  Cc: Junio C Hamano, Torsten Bögershausen, Git Mailing List,
	szeder.dev, Jan Palus, Johannes Schindelin

On Sun, Jan 06, 2019 at 05:53:10PM +0000, Thomas Gummerer wrote:

> This reverts commit 314a73d658 (t/lib-git-daemon: record daemon log,
> 2018-01-25), which let tests use the output of git-daemon.
> 
> The previous commit removed the last user of deamon.log in the tests,
> there's no good way to make checking for output in the log
> race-proof.  Revert this commit as well, to make sure others are not
> tempted to use daemon.log in tests in the future, which would lead to
> racy tests.
> 
> The original commit had one change that still makes sense, namely
> switching read/echo for "read -r" and "printf", which relays the data
> more faithfully.  Don't revert that piece here, as it is still a
> useful change.
> 
> Suggested-by: Jeff King <peff@peff.net>
> Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>

Yep, this looks good to me. Thanks for being extra careful with the
read/printf bits!

Looks like Junio already queued a99653a9b6 (Revert "t/lib-git-daemon:
record daemon log", 2018-12-28) on the tip of tg/t5570-drop-racy-test,
but that's a pure revert. I think we can replace it with this.

-Peff

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/1] Revert "t/lib-git-daemon: record daemon log"
  2019-01-07  8:20         ` Jeff King
@ 2019-01-07 15:45           ` Junio C Hamano
  0 siblings, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2019-01-07 15:45 UTC (permalink / raw)
  To: Jeff King
  Cc: Thomas Gummerer, Torsten Bögershausen, Git Mailing List,
	szeder.dev, Jan Palus, Johannes Schindelin

Jeff King <peff@peff.net> writes:

> Yep, this looks good to me. Thanks for being extra careful with the
> read/printf bits!
>
> Looks like Junio already queued a99653a9b6 (Revert "t/lib-git-daemon:
> record daemon log", 2018-12-28) on the tip of tg/t5570-drop-racy-test,
> but that's a pure revert. I think we can replace it with this.

Thanks, both.  Will do.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-01-07 15:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-25 20:52 t5570 shaky for anyone ? Torsten Bögershausen
2018-11-25 22:01 ` Thomas Gummerer
2018-11-26 16:42   ` Jeff King
2018-12-20 16:41     ` [PATCH] t5570: drop racy test Thomas Gummerer
2018-12-20 17:14       ` Jeff King
2018-12-21 15:48         ` Johannes Schindelin
2019-01-06 17:59           ` Thomas Gummerer
2019-01-06 17:53       ` [PATCH 2/1] Revert "t/lib-git-daemon: record daemon log" Thomas Gummerer
2019-01-07  8:20         ` Jeff King
2019-01-07 15:45           ` Junio C Hamano
2018-11-25 22:22 ` t5570 shaky for anyone ? SZEDER Gábor
2018-11-26 16:45   ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).