git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] t5551: test usage of chunked encoding explicitly
@ 2019-06-05 19:26 Jonathan Tan
  2019-06-05 19:40 ` Derrick Stolee
  2019-06-05 19:41 ` Jeff King
  0 siblings, 2 replies; 3+ messages in thread
From: Jonathan Tan @ 2019-06-05 19:26 UTC (permalink / raw)
  To: git; +Cc: Jonathan Tan

When run using GIT_TEST_PROTOCOL_VERSION=2, a test in t5551 fails
because 4 POSTs (probe, ls-refs, probe, fetch) are sent instead of 2
(probe, fetch).

One way to resolve this would be to relax the condition (from "= 2" to
greater than 1, say), but upon further inspection, the test probably
shouldn't be counting the number of POSTs. This test states that large
requests are split across POSTs, but this is not correct; the main
change is that chunked transfer encoding is used, but the request is
still contained within one POST. (The test coincidentally works because
Git indeed sends 2 POSTs in the case of a large request, but that is
because, as stated above, the first POST is a probing RPC - see
post_rpc() in remote-curl.c for more information.)

Therefore, instead of counting POSTs, check that chunked transfer
encoding is used. This also has the desirable side effect of passing
with GIT_TEST_PROTOCOL_VERSION=2.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
---
With this change, all tests pass at master with
GIT_TEST_PROTOCOL_VERSION=2.
---
 t/t5551-http-fetch-smart.sh | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh
index ac74626a7b..aed2d9bb05 100755
--- a/t/t5551-http-fetch-smart.sh
+++ b/t/t5551-http-fetch-smart.sh
@@ -301,11 +301,10 @@ test_expect_success CMDLINE_LIMIT \
 	)
 '
 
-test_expect_success 'large fetch-pack requests can be split across POSTs' '
+test_expect_success 'large fetch-pack requests can be sent using chunked encoding' '
 	GIT_TRACE_CURL=true git -c http.postbuffer=65536 \
 		clone --bare "$HTTPD_URL/smart/repo.git" split.git 2>err &&
-	grep "^=> Send header: POST" err >posts &&
-	test_line_count = 2 posts
+	grep "^=> Send header: Transfer-Encoding: chunked" err
 '
 
 test_expect_success 'test allowreachablesha1inwant' '
-- 
2.22.0.rc1.311.g5d7573a151-goog


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

* Re: [PATCH] t5551: test usage of chunked encoding explicitly
  2019-06-05 19:26 [PATCH] t5551: test usage of chunked encoding explicitly Jonathan Tan
@ 2019-06-05 19:40 ` Derrick Stolee
  2019-06-05 19:41 ` Jeff King
  1 sibling, 0 replies; 3+ messages in thread
From: Derrick Stolee @ 2019-06-05 19:40 UTC (permalink / raw)
  To: Jonathan Tan, git

On 6/5/2019 3:26 PM, Jonathan Tan wrote:
> When run using GIT_TEST_PROTOCOL_VERSION=2, a test in t5551 fails
> because 4 POSTs (probe, ls-refs, probe, fetch) are sent instead of 2
> (probe, fetch).
> 
> One way to resolve this would be to relax the condition (from "= 2" to
> greater than 1, say), but upon further inspection, the test probably
> shouldn't be counting the number of POSTs. This test states that large
> requests are split across POSTs, but this is not correct; the main
> change is that chunked transfer encoding is used, but the request is
> still contained within one POST. (The test coincidentally works because
> Git indeed sends 2 POSTs in the case of a large request, but that is
> because, as stated above, the first POST is a probing RPC - see
> post_rpc() in remote-curl.c for more information.)
> 
> Therefore, instead of counting POSTs, check that chunked transfer
> encoding is used. This also has the desirable side effect of passing
> with GIT_TEST_PROTOCOL_VERSION=2.

I'm all for testing the _right_ thing.

> -test_expect_success 'large fetch-pack requests can be split across POSTs' '
> +test_expect_success 'large fetch-pack requests can be sent using chunked encoding' '
>  	GIT_TRACE_CURL=true git -c http.postbuffer=65536 \
>  		clone --bare "$HTTPD_URL/smart/repo.git" split.git 2>err &&
> -	grep "^=> Send header: POST" err >posts &&
> -	test_line_count = 2 posts
> +	grep "^=> Send header: Transfer-Encoding: chunked" err
>  '

And this does seem to be testing what you now claim it tests.

LGTM.
-Stolee


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

* Re: [PATCH] t5551: test usage of chunked encoding explicitly
  2019-06-05 19:26 [PATCH] t5551: test usage of chunked encoding explicitly Jonathan Tan
  2019-06-05 19:40 ` Derrick Stolee
@ 2019-06-05 19:41 ` Jeff King
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff King @ 2019-06-05 19:41 UTC (permalink / raw)
  To: Jonathan Tan; +Cc: git

On Wed, Jun 05, 2019 at 12:26:24PM -0700, Jonathan Tan wrote:

> When run using GIT_TEST_PROTOCOL_VERSION=2, a test in t5551 fails
> because 4 POSTs (probe, ls-refs, probe, fetch) are sent instead of 2
> (probe, fetch).
> 
> One way to resolve this would be to relax the condition (from "= 2" to
> greater than 1, say), but upon further inspection, the test probably
> shouldn't be counting the number of POSTs. This test states that large
> requests are split across POSTs, but this is not correct; the main
> change is that chunked transfer encoding is used, but the request is
> still contained within one POST. (The test coincidentally works because
> Git indeed sends 2 POSTs in the case of a large request, but that is
> because, as stated above, the first POST is a probing RPC - see
> post_rpc() in remote-curl.c for more information.)

That seems reasonable. What I was really going for with this test was
just ensuring that we were actually hitting the "large request" code
path at all. And checking for chunked encoding is another way of doing
that. (And I certainly agree that "split across POSTs" is an inaccurate
way of describing what it was trying for).

> With this change, all tests pass at master with
> GIT_TEST_PROTOCOL_VERSION=2.

Yay. Thanks for your persistence with this.

-Peff

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

end of thread, other threads:[~2019-06-05 19:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-05 19:26 [PATCH] t5551: test usage of chunked encoding explicitly Jonathan Tan
2019-06-05 19:40 ` Derrick Stolee
2019-06-05 19:41 ` Jeff King

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 NNTP newsgroup(s).