All of lore.kernel.org
 help / color / mirror / Atom feed
From: Derrick Stolee <stolee@gmail.com>
To: "SZEDER Gábor" <szeder.dev@gmail.com>
Cc: Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org, Derrick Stolee <dstolee@microsoft.com>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 11/11] test-lib: clear watchman watches at test completion
Date: Mon, 9 Dec 2019 20:43:37 -0500	[thread overview]
Message-ID: <76b75c14-96ec-f8a5-a367-fb9b97a1c477@gmail.com> (raw)
In-Reply-To: <20191209234016.GA6527@szeder.dev>

On 12/9/2019 6:40 PM, SZEDER Gábor wrote:
> On Mon, Dec 09, 2019 at 09:12:37AM -0500, Derrick Stolee wrote:
>>>> +		watchman watch-list |
>>>
>>> Then with the above fixed, trying to run 'watchman' triggers another
>>> error if it's not installed:
>>>
>>>   $ GIT_TEST_FSMONITOR="$PWD"/t7519/fsmonitor-none ./t5570-git-daemon.sh 
>>>   [...]
>>>   ok 21 - hostname interpolation works after LF-stripping
>>>   ./t5570-git-daemon.sh: 1484: ./t5570-git-daemon.sh: watchman: not found
>>>   # failed 1 among 21 test(s)
>>>
>>> I think we need an additional condition to run this only if
>>> 't7519/fsmonitor-watchman' is used in the tests.
>>
>> The intention is to enable a test-suite-wide run using GIT_TEST_FSMONITOR,
>> and that can only use watchman (currently).
> 
> I've just run 'GIT_TEST_FSMONITOR=$(pwd)/t7519/fsmonitor-all make',
> and it only failed one test in 't0090-cache-tree.sh', but the fix is
> already in 'pu' in 61eea521fe (fsmonitor: do not compare bitmap size
> with size of split index, 2019-11-13).
> 
> 
>>>> diff --git a/t/test-lib.sh b/t/test-lib.sh
>>>> index 30b07e310f..067a432ea5 100644
>>>> --- a/t/test-lib.sh
>>>> +++ b/t/test-lib.sh
>>>> @@ -1072,6 +1072,8 @@ test_atexit_handler () {
>>>>  	# sure that the registered cleanup commands are run only once.
>>>>  	test : != "$test_atexit_cleanup" || return 0
>>>>  
>>>> +	test_clear_watchman
>>>
>>> I'm not sure where to put this call, but this is definitely not the
>>> right place for it.  See that 'return 0' above in the context?  That's
>>> where the test_atexit_handler function returns early when no atexit
>>> handler commands are set, i.e. in all test scripts that don't involve
>>> some kind of daemons, thus this call is not invoked in the majority of
>>> test scripts.
>>
>> Ah, I misunderstood the point of test_atexit_handler.
>>
>>> Simply moving this call before that early return is not good, because
>>> then it would be invoked twice.
>>>
>>> An option would be to register this call as an atexit command
>>> somewhere late in 'test-lib.sh' (around where GIT_TEST_GETTEXT_POISON
>>> is restored, perhaps).  That way it would be invoked most of the time,
>>> and it would be invoked only once, but I'm not sure how it would work
>>> out with test scripts that unset GIT_TEST_FSMONITOR somewhere in the
>>> middle for the remainder of the test script.  However, register the
>>> atexit command only if GIT_TEST_FSMONITOR is set (to something
>>> watchman-specific), so it won't be invoked at all if
>>> GIT_TEST_FSMONITOR is not set, and thus it won't generate additional
>>> test output and trace.
>>>
>>> I don't have a better idea.
>>
>> Shouldn't it be sufficient to add it into test_done? If the test fails,
>> then we could leave watches open, but that's no worse than we had without
>> this test_clear_watchman method.
> 
> I don't know enough about watchman to have an informed opinion.
> 
> I think the answer mainly depends on what we want to achive and what
> happens when a test script run with GIT_TEST_FSMONITOR exits without
> invoking 'test_done' is re-executed (e.g. after a test case fails with
> '--immediate' or when the user hits ctrl-c or closes the terminal
> window mid-test).
> 
> As far as I understand the commit message of v2 of this patch [1], we
> mainly want two things:
> 
>   - Avoid overloading watchman's watch queue.  For this it might
>     indeed be sufficient to clear watches in 'test_done', because most
>     test scripts tend to succeed most of the time.
> 
>   - Make GIT_TEST_FSMONITOR work reliably on Windows.  For this, I'm
>     afraid it's not enough in general, because a failure with
>     '--immediate' or after a ctrl-c we won't run 'test_done', so we
>     won't clear the watches, and watchman will keep the fd to the
>     trash dir open, and, consequently, will interfere with subsequent
>     executions of the same test script as it can't delete the still
>     existing trash dir left over from the previous run.

You are right. Running an individual test and ending it early would
lead to these leaked handles. This assumes someone is aware of the
GIT_TEST_FSMONITOR environment variable, so they are at least
interacting with the feature directly to some extent.

>     It could still be sufficient for fsmonitor-enabled CI builds,
>     though, because there we don't re-run tests, don't hit ctrl-c, and
>     (at least on Azure Pipelines) don't use '--immediate', and the
>     whole VM/container/whatever is thrown away at end anyway.

This is the hope. It would be nice to get to that point.

> 
>     On Linux/Unix-y systems it probably doesn't matter much, because
>     they can delete open directories, but I wonder what happens with a
>     watch when the directory it is supposed observe gets deleted.  If
>     the watch is removed in this case, great; if it isn't, then...
>     well, then what happens with it?  Will it be overwritten with the
>     next test run, or will there be duplicate watches for the same
>     dir?

When a directory is deleted from under Watchman on Linux, the watch
is removed...eventually. I'm not sure at exactly what point that happens.
At the very least, Watchman will receive and process the signals for all
of the paths being removed inside the directory. Running 'watch-del'
removes that overhead.

Thanks,
-Stolee

  reply	other threads:[~2019-12-10  1:43 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-21 22:20 [PATCH 00/11] Improve testability with GIT_TEST_FSMONITOR Derrick Stolee via GitGitGadget
2019-11-21 22:20 ` [PATCH 01/11] fsmonitor: disable in a bare repo Derrick Stolee via GitGitGadget
2019-11-21 23:18   ` Denton Liu
2019-11-22  1:57     ` Derrick Stolee
2019-11-21 22:20 ` [PATCH 02/11] fsmonitor: do not output to stderr for tests Derrick Stolee via GitGitGadget
2019-11-21 22:20 ` [PATCH 03/11] t1301-shared-repo.sh: disable FSMONITOR Derrick Stolee via GitGitGadget
2019-11-21 22:20 ` [PATCH 04/11] t1510-repo-setup.sh: disable fsmonitor if no .git dir Derrick Stolee via GitGitGadget
2019-11-21 22:20 ` [PATCH 05/11] fsmonitor: disable fsmonitor with worktrees Derrick Stolee via GitGitGadget
2019-11-21 22:20 ` [PATCH 06/11] t3030-merge-recursive.sh: disable fsmonitor when tweaking GIT_WORK_TREE Derrick Stolee via GitGitGadget
2019-11-21 22:20 ` [PATCH 07/11] t3600-rm.sh: disable fsmonitor when deleting populated submodule Derrick Stolee via GitGitGadget
2019-11-21 22:20 ` [PATCH 08/11] tests: disable fsmonitor in submodule tests Derrick Stolee via GitGitGadget
2019-11-21 22:20 ` [PATCH 09/11] t7063: disable fsmonitor with status cache Derrick Stolee via GitGitGadget
2019-11-21 22:20 ` [PATCH 10/11] t7519: disable external GIT_TEST_FSMONITOR variable Derrick Stolee via GitGitGadget
2019-11-21 22:20 ` [PATCH 11/11] test-lib: clear watchman watches at test completion Derrick Stolee via GitGitGadget
2019-11-22  1:06   ` SZEDER Gábor
2019-12-09 14:12     ` Derrick Stolee
2019-12-09 23:40       ` SZEDER Gábor
2019-12-10  1:43         ` Derrick Stolee [this message]
2019-12-09 16:09 ` [PATCH v2 0/8] Improve testability with GIT_TEST_FSMONITOR Derrick Stolee via GitGitGadget
2019-12-09 16:09   ` [PATCH v2 1/8] fsmonitor: disable in a bare repo Derrick Stolee via GitGitGadget
2019-12-10  9:46     ` SZEDER Gábor
2019-12-09 16:09   ` [PATCH v2 2/8] fsmonitor: do not output to stderr for tests Derrick Stolee via GitGitGadget
2019-12-09 16:09   ` [PATCH v2 3/8] t1301-shared-repo.sh: disable FSMONITOR Derrick Stolee via GitGitGadget
2019-12-10  9:43     ` SZEDER Gábor
2019-12-09 16:10   ` [PATCH v2 4/8] t3030-merge-recursive.sh: disable fsmonitor when tweaking GIT_WORK_TREE Derrick Stolee via GitGitGadget
2019-12-10 10:07     ` SZEDER Gábor
2019-12-10 13:45       ` Derrick Stolee
2019-12-10 14:57         ` SZEDER Gábor
2019-12-10 15:07         ` SZEDER Gábor
2020-01-23 15:45           ` Derrick Stolee
2019-12-09 16:10   ` [PATCH v2 5/8] tests: disable fsmonitor in submodule tests Derrick Stolee via GitGitGadget
2019-12-10 10:13     ` SZEDER Gábor
2019-12-10 13:57       ` Derrick Stolee
2019-12-09 16:10   ` [PATCH v2 6/8] t7063: disable fsmonitor with status cache Derrick Stolee via GitGitGadget
2019-12-09 16:10   ` [PATCH v2 7/8] t7519: disable external GIT_TEST_FSMONITOR variable Derrick Stolee via GitGitGadget
2019-12-09 16:10   ` [PATCH v2 8/8] test-lib: clear watchman watches at test completion Derrick Stolee via GitGitGadget
2019-12-09 22:52     ` Junio C Hamano
2019-12-10  1:49       ` Derrick Stolee
2019-12-10  5:20         ` Junio C Hamano
2019-12-10 13:51           ` Derrick Stolee
2019-12-10 14:09           ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=76b75c14-96ec-f8a5-a367-fb9b97a1c477@gmail.com \
    --to=stolee@gmail.com \
    --cc=dstolee@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=szeder.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.