From: Brandon Williams <bmwill@google.com>
To: git@vger.kernel.org
Cc: jonathantanmy@google.com, gitster@pobox.com, sbeller@google.com,
jrnieder@gmail.com, Brandon Williams <bmwill@google.com>
Subject: [PATCH v6 3/8] upload-pack: test negotiation with changing repository
Date: Wed, 27 Jun 2018 15:30:18 -0700 [thread overview]
Message-ID: <20180627223023.49659-4-bmwill@google.com> (raw)
In-Reply-To: <20180627223023.49659-1-bmwill@google.com>
Add tests to check the behavior of fetching from a repository which
changes between rounds of negotiation (for example, when different
servers in a load-balancing agreement participate in the same stateless
RPC negotiation). This forms a baseline of comparison to the ref-in-want
functionality (which will be introduced to the client in subsequent
commits), and ensures that subsequent commits do not change existing
behavior.
As part of this effort, a mechanism to substitute strings in a single
HTTP response is added.
Signed-off-by: Brandon Williams <bmwill@google.com>
---
t/lib-httpd.sh | 1 +
t/lib-httpd/apache.conf | 8 ++++
t/lib-httpd/apply-one-time-sed.sh | 22 ++++++++++
t/t5703-upload-pack-ref-in-want.sh | 68 ++++++++++++++++++++++++++++++
4 files changed, 99 insertions(+)
create mode 100644 t/lib-httpd/apply-one-time-sed.sh
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index 435a37465..ed41b155a 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -132,6 +132,7 @@ prepare_httpd() {
cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH"
install_script broken-smart-http.sh
install_script error.sh
+ install_script apply-one-time-sed.sh
ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules"
diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf
index 724d9ae46..581c010d8 100644
--- a/t/lib-httpd/apache.conf
+++ b/t/lib-httpd/apache.conf
@@ -111,9 +111,14 @@ Alias /auth/dumb/ www/auth/dumb/
SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
SetEnv GIT_HTTP_EXPORT_ALL
</LocationMatch>
+<LocationMatch /one_time_sed/>
+ SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
+ SetEnv GIT_HTTP_EXPORT_ALL
+</LocationMatch>
ScriptAliasMatch /smart_*[^/]*/(.*) ${GIT_EXEC_PATH}/git-http-backend/$1
ScriptAlias /broken_smart/ broken-smart-http.sh/
ScriptAlias /error/ error.sh/
+ScriptAliasMatch /one_time_sed/(.*) apply-one-time-sed.sh/$1
<Directory ${GIT_EXEC_PATH}>
Options FollowSymlinks
</Directory>
@@ -123,6 +128,9 @@ ScriptAlias /error/ error.sh/
<Files error.sh>
Options ExecCGI
</Files>
+<Files apply-one-time-sed.sh>
+ Options ExecCGI
+</Files>
<Files ${GIT_EXEC_PATH}/git-http-backend>
Options ExecCGI
</Files>
diff --git a/t/lib-httpd/apply-one-time-sed.sh b/t/lib-httpd/apply-one-time-sed.sh
new file mode 100644
index 000000000..fcef72892
--- /dev/null
+++ b/t/lib-httpd/apply-one-time-sed.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# If "one-time-sed" exists in $HTTPD_ROOT_PATH, run sed on the HTTP response,
+# using the contents of "one-time-sed" as the sed command to be run. If the
+# response was modified as a result, delete "one-time-sed" so that subsequent
+# HTTP responses are no longer modified.
+#
+# This can be used to simulate the effects of the repository changing in
+# between HTTP request-response pairs.
+if [ -e one-time-sed ]; then
+ "$GIT_EXEC_PATH/git-http-backend" >out
+ sed "$(cat one-time-sed)" <out >out_modified
+
+ if diff out out_modified >/dev/null; then
+ cat out
+ else
+ cat out_modified
+ rm one-time-sed
+ fi
+else
+ "$GIT_EXEC_PATH/git-http-backend"
+fi
diff --git a/t/t5703-upload-pack-ref-in-want.sh b/t/t5703-upload-pack-ref-in-want.sh
index da86f7cde..32527a59c 100755
--- a/t/t5703-upload-pack-ref-in-want.sh
+++ b/t/t5703-upload-pack-ref-in-want.sh
@@ -157,4 +157,72 @@ test_expect_success 'want-ref with ref we already have commit for' '
check_output
'
+. "$TEST_DIRECTORY"/lib-httpd.sh
+start_httpd
+
+REPO="$HTTPD_DOCUMENT_ROOT_PATH/repo"
+LOCAL_PRISTINE="$(pwd)/local_pristine"
+
+test_expect_success 'setup repos for change-while-negotiating test' '
+ (
+ git init "$REPO" &&
+ cd "$REPO" &&
+ >.git/git-daemon-export-ok &&
+ test_commit m1 &&
+ git tag -d m1 &&
+
+ # Local repo with many commits (so that negotiation will take
+ # more than 1 request/response pair)
+ git clone "http://127.0.0.1:$LIB_HTTPD_PORT/smart/repo" "$LOCAL_PRISTINE" &&
+ cd "$LOCAL_PRISTINE" &&
+ git checkout -b side &&
+ for i in $(seq 1 33); do test_commit s$i; done &&
+
+ # Add novel commits to upstream
+ git checkout master &&
+ cd "$REPO" &&
+ test_commit m2 &&
+ test_commit m3 &&
+ git tag -d m2 m3
+ ) &&
+ git -C "$LOCAL_PRISTINE" remote set-url origin "http://127.0.0.1:$LIB_HTTPD_PORT/one_time_sed/repo" &&
+ git -C "$LOCAL_PRISTINE" config protocol.version 2
+'
+
+inconsistency () {
+ # Simulate that the server initially reports $2 as the ref
+ # corresponding to $1, and after that, $1 as the ref corresponding to
+ # $1. This corresponds to the real-life situation where the server's
+ # repository appears to change during negotiation, for example, when
+ # different servers in a load-balancing arrangement serve (stateless)
+ # RPCs during a single negotiation.
+ printf "s/%s/%s/" \
+ $(git -C "$REPO" rev-parse $1 | tr -d "\n") \
+ $(git -C "$REPO" rev-parse $2 | tr -d "\n") \
+ >"$HTTPD_ROOT_PATH/one-time-sed"
+}
+
+test_expect_success 'server is initially ahead - no ref in want' '
+ git -C "$REPO" config uploadpack.allowRefInWant false &&
+ rm -rf local &&
+ cp -r "$LOCAL_PRISTINE" local &&
+ inconsistency master 1234567890123456789012345678901234567890 &&
+ test_must_fail git -C local fetch 2>err &&
+ grep "ERR upload-pack: not our ref" err
+'
+
+test_expect_success 'server is initially behind - no ref in want' '
+ git -C "$REPO" config uploadpack.allowRefInWant false &&
+ rm -rf local &&
+ cp -r "$LOCAL_PRISTINE" local &&
+ inconsistency master "master^" &&
+ git -C local fetch &&
+
+ git -C "$REPO" rev-parse --verify "master^" >expected &&
+ git -C local rev-parse --verify refs/remotes/origin/master >actual &&
+ test_cmp expected actual
+'
+
+stop_httpd
+
test_done
--
2.18.0.399.gad0ab374a1-goog
next prev parent reply other threads:[~2018-06-27 22:30 UTC|newest]
Thread overview: 122+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-05 17:51 [PATCH 0/8] ref-in-want Brandon Williams
2018-06-05 17:51 ` [PATCH 1/8] test-pkt-line: add unpack-sideband subcommand Brandon Williams
2018-06-05 17:51 ` [PATCH 2/8] upload-pack: implement ref-in-want Brandon Williams
2018-06-05 19:11 ` Ramsay Jones
2018-06-05 20:32 ` Ævar Arnfjörð Bjarmason
2018-06-06 21:32 ` Brandon Williams
2018-06-06 22:42 ` Ævar Arnfjörð Bjarmason
2018-06-06 22:45 ` Brandon Williams
2018-06-05 17:51 ` [PATCH 3/8] upload-pack: test negotiation with changing repository Brandon Williams
2018-06-05 17:51 ` [PATCH 4/8] fetch: refactor the population of peer ref OIDs Brandon Williams
2018-06-05 17:51 ` [PATCH 5/8] fetch: refactor fetch_refs into two functions Brandon Williams
2018-06-05 17:51 ` [PATCH 6/8] fetch: refactor to make function args narrower Brandon Williams
2018-06-05 17:51 ` [PATCH 7/8] fetch-pack: put shallow info in output parameter Brandon Williams
2018-06-05 17:51 ` [PATCH 8/8] fetch-pack: implement ref-in-want Brandon Williams
2018-06-13 21:39 ` [PATCH v2 0/8] ref-in-want Brandon Williams
2018-06-13 21:39 ` [PATCH v2 1/8] test-pkt-line: add unpack-sideband subcommand Brandon Williams
2018-06-14 18:09 ` Stefan Beller
2018-06-14 19:21 ` Brandon Williams
2018-06-13 21:39 ` [PATCH v2 2/8] upload-pack: implement ref-in-want Brandon Williams
2018-06-14 18:40 ` Stefan Beller
2018-06-14 18:52 ` Brandon Williams
2018-06-15 21:08 ` Junio C Hamano
2018-06-15 21:14 ` Junio C Hamano
2018-06-19 18:50 ` Brandon Williams
2018-06-19 20:37 ` Junio C Hamano
2018-06-19 23:14 ` Brandon Williams
2018-06-21 16:38 ` Junio C Hamano
2018-06-13 21:39 ` [PATCH v2 3/8] upload-pack: test negotiation with changing repository Brandon Williams
2018-06-14 19:23 ` Stefan Beller
2018-06-13 21:39 ` [PATCH v2 4/8] fetch: refactor the population of peer ref OIDs Brandon Williams
2018-06-13 21:39 ` [PATCH v2 5/8] fetch: refactor fetch_refs into two functions Brandon Williams
2018-06-13 21:39 ` [PATCH v2 6/8] fetch: refactor to make function args narrower Brandon Williams
2018-06-14 19:32 ` Stefan Beller
2018-06-13 21:39 ` [PATCH v2 7/8] fetch-pack: put shallow info in output parameter Brandon Williams
2018-06-14 19:42 ` Stefan Beller
2018-06-14 23:59 ` Jonathan Tan
2018-06-19 17:41 ` Brandon Williams
2018-06-13 21:39 ` [PATCH v2 8/8] fetch-pack: implement ref-in-want Brandon Williams
2018-06-14 19:56 ` Stefan Beller
2018-06-14 21:18 ` Brandon Williams
2018-06-22 22:29 ` Jonathan Nieder
2018-06-15 21:20 ` [PATCH v2 0/8] ref-in-want Junio C Hamano
2018-06-18 18:05 ` Brandon Williams
2018-06-20 21:32 ` [PATCH v3 " Brandon Williams
2018-06-20 21:32 ` [PATCH v3 1/8] test-pkt-line: add unpack-sideband subcommand Brandon Williams
2018-06-22 21:12 ` Jonathan Nieder
2018-06-20 21:32 ` [PATCH v3 2/8] upload-pack: implement ref-in-want Brandon Williams
2018-06-25 17:40 ` Jonathan Tan
2018-06-25 18:09 ` Jonathan Tan
2018-06-25 18:20 ` Brandon Williams
2018-06-20 21:32 ` [PATCH v3 3/8] upload-pack: test negotiation with changing repository Brandon Williams
2018-06-20 21:32 ` [PATCH v3 4/8] fetch: refactor the population of peer ref OIDs Brandon Williams
2018-06-25 17:45 ` Jonathan Tan
2018-06-20 21:32 ` [PATCH v3 5/8] fetch: refactor fetch_refs into two functions Brandon Williams
2018-06-22 21:26 ` Jonathan Nieder
2018-06-22 21:42 ` Jonathan Nieder
2018-06-20 21:32 ` [PATCH v3 6/8] fetch: refactor to make function args narrower Brandon Williams
2018-06-20 21:32 ` [PATCH v3 7/8] fetch-pack: put shallow info in output parameter Brandon Williams
2018-06-25 18:03 ` Jonathan Tan
2018-06-25 18:18 ` Brandon Williams
2018-06-20 21:32 ` [PATCH v3 8/8] fetch-pack: implement ref-in-want Brandon Williams
2018-06-22 23:01 ` Jonathan Nieder
2018-06-25 18:08 ` Brandon Williams
2018-06-25 18:53 ` [PATCH v4 0/8] ref-in-want Brandon Williams
2018-06-25 18:53 ` [PATCH v4 1/8] test-pkt-line: add unpack-sideband subcommand Brandon Williams
2018-06-25 18:53 ` [PATCH v4 2/8] upload-pack: implement ref-in-want Brandon Williams
2018-06-25 18:53 ` [PATCH v4 3/8] upload-pack: test negotiation with changing repository Brandon Williams
2018-06-25 22:27 ` Jonathan Tan
2018-06-25 18:53 ` [PATCH v4 4/8] fetch: refactor the population of peer ref OIDs Brandon Williams
2018-06-25 18:53 ` [PATCH v4 5/8] fetch: refactor fetch_refs into two functions Brandon Williams
2018-06-25 18:53 ` [PATCH v4 6/8] fetch: refactor to make function args narrower Brandon Williams
2018-06-25 22:36 ` Jonathan Tan
2018-06-25 18:53 ` [PATCH v4 7/8] fetch-pack: put shallow info in output parameter Brandon Williams
2018-06-25 18:53 ` [PATCH v4 8/8] fetch-pack: implement ref-in-want Brandon Williams
2018-06-25 23:03 ` [PATCH v4 0/8] ref-in-want Jonathan Tan
2018-06-26 20:54 ` [PATCH v5 " Brandon Williams
2018-06-26 20:54 ` [PATCH v5 1/8] test-pkt-line: add unpack-sideband subcommand Brandon Williams
2018-06-26 20:54 ` [PATCH v5 2/8] upload-pack: implement ref-in-want Brandon Williams
2018-06-26 21:25 ` Junio C Hamano
2018-06-27 18:05 ` Brandon Williams
2018-06-27 18:53 ` Junio C Hamano
2018-06-27 20:46 ` Brandon Williams
2018-06-27 20:59 ` Stefan Beller
2018-06-27 18:06 ` Jonathan Tan
2018-06-26 20:54 ` [PATCH v5 3/8] upload-pack: test negotiation with changing repository Brandon Williams
2018-06-26 21:34 ` Junio C Hamano
2018-06-27 18:09 ` Brandon Williams
2018-06-27 17:58 ` Jonathan Tan
2018-06-26 20:54 ` [PATCH v5 4/8] fetch: refactor the population of peer ref OIDs Brandon Williams
2018-06-26 20:54 ` [PATCH v5 5/8] fetch: refactor fetch_refs into two functions Brandon Williams
2018-06-26 20:54 ` [PATCH v5 6/8] fetch: refactor to make function args narrower Brandon Williams
2018-06-26 21:40 ` Junio C Hamano
2018-06-26 20:54 ` [PATCH v5 7/8] fetch-pack: put shallow info in output parameter Brandon Williams
2018-06-26 21:42 ` Junio C Hamano
2018-06-27 18:15 ` Brandon Williams
2018-06-26 20:54 ` [PATCH v5 8/8] fetch-pack: implement ref-in-want Brandon Williams
2018-06-27 18:09 ` Jonathan Tan
2018-06-27 18:18 ` Brandon Williams
2018-06-27 22:30 ` [PATCH v6 0/8] ref-in-want Brandon Williams
2018-06-27 22:30 ` [PATCH v6 1/8] test-pkt-line: add unpack-sideband subcommand Brandon Williams
2018-06-27 22:30 ` [PATCH v6 2/8] upload-pack: implement ref-in-want Brandon Williams
2018-06-27 22:30 ` Brandon Williams [this message]
2018-06-27 22:30 ` [PATCH v6 4/8] fetch: refactor the population of peer ref OIDs Brandon Williams
2018-06-27 22:30 ` [PATCH v6 5/8] fetch: refactor fetch_refs into two functions Brandon Williams
2018-06-27 22:30 ` [PATCH v6 6/8] fetch: refactor to make function args narrower Brandon Williams
2018-06-27 22:30 ` [PATCH v6 7/8] fetch-pack: put shallow info in output parameter Brandon Williams
2018-06-27 22:30 ` [PATCH v6 8/8] fetch-pack: implement ref-in-want Brandon Williams
2018-07-22 9:20 ` Duy Nguyen
2018-07-23 17:53 ` Brandon Williams
2018-07-23 18:13 ` Duy Nguyen
2018-07-23 21:28 ` Jonathan Nieder
2018-07-23 17:56 ` [PATCH] fetch-pack: mark die strings for translation Brandon Williams
2018-07-23 18:14 ` Stefan Beller
2018-07-23 21:29 ` Jonathan Nieder
2018-07-23 22:57 ` Junio C Hamano
2018-07-23 22:59 ` Junio C Hamano
2018-07-23 23:00 ` Brandon Williams
2018-06-15 19:04 ` [PATCH 0/8] ref-in-want Jonathan Tan
2018-06-19 17:32 ` Brandon Williams
2018-06-19 19:23 ` Jonathan Tan
2018-06-19 23:16 ` Brandon Williams
2018-06-19 23:38 ` Jonathan Tan
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180627223023.49659-4-bmwill@google.com \
--to=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jonathantanmy@google.com \
--cc=jrnieder@gmail.com \
--cc=sbeller@google.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.
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).