diff --git a/t/t5799-gvfs-helper.sh b/t/t5799-gvfs-helper.sh index 0d7bcbdab21db6..a7c0188b48e760 100755 --- a/t/t5799-gvfs-helper.sh +++ b/t/t5799-gvfs-helper.sh @@ -24,8 +24,12 @@ test_set_port GIT_TEST_GVFS_PROTOCOL_PORT # actually use it). We are only testing explicit object # fetching using gvfs-helper.exe in isolation. # +# repo_t2: +# Another empty repo to use after we contaminate t1. +# REPO_SRC="$(pwd)"/repo_src REPO_T1="$(pwd)"/repo_t1 +REPO_T2="$(pwd)"/repo_t2 # Setup some loopback URLs where test-gvfs-protocol.exe will be # listening. We will spawn it directly inside the repo_src directory, @@ -45,6 +49,7 @@ ORIGIN_URL=http://$HOST_PORT/servertype/origin CACHE_URL=http://$HOST_PORT/servertype/cache SHARED_CACHE_T1="$(pwd)"/shared_cache_t1 +SHARED_CACHE_T2="$(pwd)"/shared_cache_t2 # The pid-file is created by test-gvfs-protocol.exe when it starts. # The server will shut down if/when we delete it. (This is a little @@ -182,6 +187,10 @@ test_expect_success 'setup repos' ' mkdir "$SHARED_CACHE_T1/pack" && mkdir "$SHARED_CACHE_T1/info" && # + mkdir "$SHARED_CACHE_T2" && + mkdir "$SHARED_CACHE_T2/pack" && + mkdir "$SHARED_CACHE_T2/info" && + # # setup repo_t1 and point all of the gvfs.* values to repo_src. # test_create_repo "$REPO_T1" && @@ -191,6 +200,13 @@ test_expect_success 'setup repos' ' git -C "$REPO_T1" config --local gvfs.sharedCache "$SHARED_CACHE_T1" && echo "$SHARED_CACHE_T1" >> "$REPO_T1"/.git/objects/info/alternates && # + test_create_repo "$REPO_T2" && + git -C "$REPO_T2" branch -M main && + git -C "$REPO_T2" remote add origin $ORIGIN_URL && + git -C "$REPO_T2" config --local gvfs.cache-server $CACHE_URL && + git -C "$REPO_T2" config --local gvfs.sharedCache "$SHARED_CACHE_T2" && + echo "$SHARED_CACHE_T2" >> "$REPO_T2"/.git/objects/info/alternates && + # # # cat <<-EOF >creds.txt && @@ -203,6 +219,7 @@ test_expect_success 'setup repos' ' EOF chmod 755 creds.sh && git -C "$REPO_T1" config --local credential.helper "!f() { cat \"$(pwd)\"/creds.txt; }; f" && + git -C "$REPO_T2" config --local credential.helper "!f() { cat \"$(pwd)\"/creds.txt; }; f" && # # Create some test data sets. # @@ -1246,6 +1263,77 @@ test_expect_success 'integration: fully implicit: diff 2 commits' ' >OUT.output 2>OUT.stderr ' +# T1 should be considered contaminated at this point. + +################################################################# +# gvfs-helper.exe defaults to no fallback. +# gvfs-helper-client.c defaults to adding `--fallback` to child process. +# +# `gvfs.fallback` was added to change the default behavior in the +# gvfs-helper-client.c code to add either `--fallback` or `--no-fallback` +# (for origin server load reasons). +# +# When `gvfs.fallback` is unset, we default to TRUE and pass `--fallback`. +# Otherwise, we use the boolean value to decide. +################################################################# + +test_expect_success 'integration: implicit-get: http_503: diff 2 commits' ' + test_when_finished "per_test_cleanup" && + + # Tell both servers to always send 503. + start_gvfs_protocol_server_with_mayhem http_503 && + + # Implicitly demand-load everything without any pre-seeding. + # (We cannot tell from whether fallback was used or not in this + # limited test.) + # + test_must_fail \ + git -C "$REPO_T2" -c core.useGVFSHelper=true \ + diff $(cat m1.branch)..$(cat m3.branch) \ + >OUT.output 2>OUT.stderr && + + stop_gvfs_protocol_server +' + +test_expect_success 'integration: implicit-get: cache_http_503,no-fallback: diff 2 commits' ' + test_when_finished "per_test_cleanup" && + + # Tell cache server to send 503 and origin server to send 200. + start_gvfs_protocol_server_with_mayhem cache_http_503 && + + # Implicitly demand-load everything without any pre-seeding. + # This should fail because we do not allow fallback. + # + test_must_fail \ + git -C "$REPO_T2" \ + -c core.useGVFSHelper=true \ + -c gvfs.fallback=false \ + diff $(cat m1.branch)..$(cat m3.branch) \ + >OUT.output 2>OUT.stderr && + + stop_gvfs_protocol_server +' + +test_expect_success 'integration: implicit-get: cache_http_503,with-fallback: diff 2 commits' ' + test_when_finished "per_test_cleanup" && + + # Tell cache server to send 503 and origin server to send 200. + start_gvfs_protocol_server_with_mayhem cache_http_503 && + + # Implicitly demand-load everything without any pre-seeding. + # + git -C "$REPO_T2" \ + -c core.useGVFSHelper=true \ + -c gvfs.fallback=true \ + diff $(cat m1.branch)..$(cat m3.branch) \ + >OUT.output 2>OUT.stderr && + + stop_gvfs_protocol_server +' + +# T2 should be considered contaminated at this point. + + ################################################################# # Duplicate packfile tests. #