git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 3/3] t/lib-httpd: avoid occasional failures when checking access.log

From
Jeff King <peff@peff.net>
Date
Jul 11, 2018, 14:57 UTC
Message-ID
<20180711145730.GB15269@sigill.intra.peff.net>
In-Reply-To
<20180711125647.16512-4-szeder.dev@gmail.com>
On Wed, Jul 11, 2018 at 02:56:47PM +0200, SZEDER Gábor wrote:
Show 11 quoted lines
> +# Requires one argument: the name of a file containing the expected stripped
> +# access log entries.
> +check_access_log() {
> +	sort "$1" >"$1".sorted &&
> +	strip_access_log >access.log.stripped &&
> +	sort access.log.stripped >access.log.sorted &&
> +	if ! test_cmp "$1".sorted access.log.sorted
> +	then
> +		test_cmp "$1" access.log.stripped
> +	fi
> +}

This will generate output showing both the unsorted and sorted differences. Do we want to suppress the sorted ones (e.g., by just using "cmp" directly)? I guess it doesn't matter unless there is an actual test failure, but I just wonder if it would be confusing to see both.

Show 22 quoted lines
> diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh
> index 6cd986797d..a481e3989a 100755
> --- a/t/t5541-http-push-smart.sh
> +++ b/t/t5541-http-push-smart.sh
> @@ -43,15 +43,13 @@ test_expect_success 'no empty path components' '
>  	cd "$ROOT_PATH" &&
>  	git clone $HTTPD_URL/smart/test_repo.git/ test_repo_clone &&
>  
> -	strip_access_log >act &&
> +	check_access_log exp
> +'
>  
> +test_expect_success 'clear access log' '
>  	# Clear the log, so that it does not affect the "used receive-pack
>  	# service" test which reads the log too.
> -	#
> -	# We do this before the actual comparison to ensure the log is cleared.
> -	>"$HTTPD_ROOT_PATH"/access.log &&
> -
> -	test_cmp exp act
> +	>"$HTTPD_ROOT_PATH"/access.log
>  '

This took some head-scratching, mostly because of the original comment. I thought the "before" here was referring to a timing issue (maybe because we're talking about timing ;) ).

But it is really "make sure that a failed test here does not prevent us from doing this cleanup". So the original really should have just dropped that comment and added a test_when_finished. Bumping it into a separate test as you have here accomplishes the same thing.

-Peff
Previous: SZEDER GáborNext: SZEDER Gábor
Message 18 of 26 in “Fix occasional test failures in http tests”
  1. 0/4 Fix occasional test failures in http testsSZEDER Gábor, Jun 14, 2018
  2. 1/4 t5541: avoid empty line when truncating access logSZEDER Gábor, Jun 14, 2018
  3. 2/4 t/lib-httpd: add the strip_access_log() helper functionSZEDER Gábor, Jun 14, 2018
  4. 3/4 t/lib-httpd: add minor and patch version to $HTTPD_VERSIONSZEDER Gábor, Jun 14, 2018
  5. 4/4 t/lib-httpd: sort log based on timestamp to avoid occasional failureSZEDER Gábor, Jun 14, 2018
  6. SZEDER GáborJun 14, 2018
  7. Jeff KingJun 14, 2018
  8. Junio C HamanoJun 14, 2018
  9. Jeff KingJun 15, 2018
  10. SZEDER GáborJul 11, 2018
  11. Jeff KingJul 11, 2018
  12. Junio C HamanoJun 14, 2018
  13. Jeff KingJun 14, 2018
  14. 0/3 Fix occasional test failures in http testsSZEDER Gábor, Jul 11, 2018
  15. 1/3 t5541: avoid empty line when truncating access logSZEDER Gábor, Jul 11, 2018
  16. 2/3 t/lib-httpd: add the strip_access_log() helper functionSZEDER Gábor, Jul 11, 2018
  17. 3/3 t/lib-httpd: avoid occasional failures when checking access.logSZEDER Gábor, Jul 11, 2018
  18. Jeff KingJul 11, 2018
  19. SZEDER GáborJul 11, 2018
  20. Jeff KingJul 11, 2018
  21. Jeff KingJul 11, 2018
  22. 0/3 Fix occasional test failures in http testsSZEDER Gábor, Jul 12, 2018
  23. 1/3 t5541: clean up truncating access logSZEDER Gábor, Jul 12, 2018
  24. Jeff KingJul 12, 2018
  25. 2/3 t/lib-httpd: add the strip_access_log() helper functionSZEDER Gábor, Jul 12, 2018
  26. 3/3 t/lib-httpd: avoid occasional failures when checking access.logSZEDER Gábor, Jul 12, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.