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

[PATCH jn/test-lint-one-shot-export-to-shell-function] fetch test: mark test of "skipping" haves as v0-only

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Dec 26, 2019, 23:12 UTC
Message-ID
<20191226231251.GC186931@google.com>
In-Reply-To
<xmqq7e2ilu1j.fsf@gitster-ct.c.googlers.com>

Since 633a53179e (fetch test: avoid use of "VAR= cmd" with a shell function, 2019-12-26), t5552.5 (do not send "have" with ancestors of commits that server ACKed) fails when run with GIT_TEST_PROTOCOL_VERSION=2.

The cause:

The progression of "have"s sent in negotiation depends on whether we are using a stateless RPC based transport or a stateful bidirectional one (see for example 44d8dc54e7, "Fix potential local deadlock during fetch-pack", 2011-03-29). In protocol v2, all transports are stateless transports, while in protocol v0, transports such as local access and ssh are stateful.

In stateful transports, the number of "have"s to send multiplies by two each round until we reach PIPESAFE_FLUSH (that is, 32), and then it increases by PIPESAFE_FLUSH each round. In stateless transport, the count multiplies by two each round until we reach LARGE_FLUSH (which is 16384) and then multiplies by 1.1 each round after that.

Moreover, in stateful transports, as fetch-pack.c explains:
	We keep one window "ahead" of the other side, and will wait
	for an ACK only on the next one.

This affects t5552.5 because it looks for "have"s from the negotiator that appear in that second window. With protocol version 2, the second window never arrives, and the test fails.

Until 633a53179e (2019-12-26), a previous test in the same file contained

	GIT_TEST_PROTOCOL_VERSION= trace_fetch client origin to_fetch

In many common shells (e.g. bash when run as "sh"), the setting of GIT_TEST_PROTOCOL_VERSION to the empty string lasts beyond the intended duration of the trace_fetch invocation. This causes it to override the GIT_TEST_PROTOCOL_VERSION setting that was passed in to the test during the remainder of the test script, so t5552.5 never got run using protocol v2 on those shells, regardless of the GIT_TEST_PROTOCOL_VERSION setting from the environment. 633a53179e fixed that, revealing the failing test.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Junio C Hamano wrote:
> The tip of "promote proto v2 to default" series fails at 5552.5
> with or without these two patches, though.

Here's the promised fix, against jn/test-lint-one-shot-export-to-shell-function. Thanks again.

 t/t5552-skipping-fetch-negotiator.sh | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/t/t5552-skipping-fetch-negotiator.sh b/t/t5552-skipping-fetch-negotiator.sh
index a452fe32fa..8f25f4b31f 100755
--- a/t/t5552-skipping-fetch-negotiator.sh
+++ b/t/t5552-skipping-fetch-negotiator.sh
@@ -173,7 +173,17 @@ test_expect_success 'do not send "have" with ancestors of commits that server AC
 	test_commit -C server commit-on-b1 &&
 
 	test_config -C client fetch.negotiationalgorithm skipping &&
-	trace_fetch client "$(pwd)/server" to_fetch &&
+
+	# NEEDSWORK: The number of "have"s sent depends on whether the transport
+	# is stateful. If the overspecification of the result were reduced, this
+	# test could be used for both stateful and stateless transports.
+	(
+		# Force protocol v0, in which local transport is stateful (in
+		# protocol v2 it is stateless).
+		GIT_TEST_PROTOCOL_VERSION=0 &&
+		export GIT_TEST_PROTOCOL_VERSION &&
+		trace_fetch client "$(pwd)/server" to_fetch
+	) &&
 	grep "  fetch" trace &&
 
 	# fetch-pack sends 2 requests each containing 16 "have" lines before
-- 
2.24.1.735.g03f4e72817
Previous: Jonathan NiederNext: Eric Sunshine
Message 13 of 17 in “Enable protocol v2 by default”
  1. 0/5 Enable protocol v2 by defaultJonathan Nieder, Dec 24, 2019
  2. 1/5 fetch test: use more robust test for filtered objectsJonathan Nieder, Dec 24, 2019
  3. Derrick StoleeDec 26, 2019
  4. 2/5 config doc: protocol.version is not experimentalJonathan Nieder, Dec 24, 2019
  5. 3/5 test: request GIT_TEST_PROTOCOL_VERSION=0 when appropriateJonathan Nieder, Dec 24, 2019
  6. Junio C HamanoDec 26, 2019
  7. 0/2 avoid use of "VAR= cmd" with a shell function (Re: [PATCH 3/5] test: request GIT_TEST_PROTOCOL_VERSION=0 when appropriate)Jonathan Nieder, Dec 26, 2019
  8. 1/2 fetch test: avoid use of "VAR= cmd" with a shell functionJonathan Nieder, Dec 26, 2019
  9. 2/2 t/check-non-portable-shell: detect "FOO= shell_func", tooJonathan Nieder, Dec 26, 2019
  10. Junio C HamanoDec 26, 2019
  11. Junio C HamanoDec 26, 2019
  12. Jonathan NiederDec 26, 2019
  13. fetch test: mark test of "skipping" haves as v0-onlyJonathan Nieder, Dec 26, 2019
  14. Eric SunshineDec 26, 2019
  15. 4/5 protocol test: let protocol.version override GIT_TEST_PROTOCOL_VERSIONJonathan Nieder, Dec 24, 2019
  16. 5/5 fetch: default to protocol version 2Jonathan Nieder, Dec 24, 2019
  17. Derrick StoleeDec 26, 2019

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.