Skip to content

Commit 70a014b

Browse files
jeffhostetlerdscho
authored andcommitted
t5799: add unit tests for new gvfs.fallback config setting
Signed-off-by: Jeff Hostetler <jeffhostetler@github.com>
1 parent af8d9e9 commit 70a014b

1 file changed

Lines changed: 98 additions & 0 deletions

File tree

‎t/t5799-gvfs-helper.sh‎

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ test_set_port GIT_TEST_GVFS_PROTOCOL_PORT
2424
# actually use it). We are only testing explicit object
2525
# fetching using gvfs-helper.exe in isolation.
2626
#
27+
# repo_t2:
28+
# Another empty repo to use after we contaminate t1.
29+
#
2730
REPO_SRC="$(pwd)"/repo_src
2831
REPO_T1="$(pwd)"/repo_t1
32+
REPO_T2="$(pwd)"/repo_t2
2933

3034
# Setup some loopback URLs where test-gvfs-protocol.exe will be
3135
# listening. We will spawn it directly inside the repo_src directory,
@@ -45,6 +49,7 @@ ORIGIN_URL=http://$HOST_PORT/servertype/origin
4549
CACHE_URL=http://$HOST_PORT/servertype/cache
4650

4751
SHARED_CACHE_T1="$(pwd)"/shared_cache_t1
52+
SHARED_CACHE_T2="$(pwd)"/shared_cache_t2
4853

4954
# The pid-file is created by test-gvfs-protocol.exe when it starts.
5055
# The server will shut down if/when we delete it. (This is a little
@@ -182,6 +187,10 @@ test_expect_success 'setup repos' '
182187
mkdir "$SHARED_CACHE_T1/pack" &&
183188
mkdir "$SHARED_CACHE_T1/info" &&
184189
#
190+
mkdir "$SHARED_CACHE_T2" &&
191+
mkdir "$SHARED_CACHE_T2/pack" &&
192+
mkdir "$SHARED_CACHE_T2/info" &&
193+
#
185194
# setup repo_t1 and point all of the gvfs.* values to repo_src.
186195
#
187196
test_create_repo "$REPO_T1" &&
@@ -191,6 +200,13 @@ test_expect_success 'setup repos' '
191200
git -C "$REPO_T1" config --local gvfs.sharedCache "$SHARED_CACHE_T1" &&
192201
echo "$SHARED_CACHE_T1" >> "$REPO_T1"/.git/objects/info/alternates &&
193202
#
203+
test_create_repo "$REPO_T2" &&
204+
git -C "$REPO_T2" branch -M main &&
205+
git -C "$REPO_T2" remote add origin $ORIGIN_URL &&
206+
git -C "$REPO_T2" config --local gvfs.cache-server $CACHE_URL &&
207+
git -C "$REPO_T2" config --local gvfs.sharedCache "$SHARED_CACHE_T2" &&
208+
echo "$SHARED_CACHE_T2" >> "$REPO_T2"/.git/objects/info/alternates &&
209+
#
194210
#
195211
#
196212
cat <<-EOF >creds.txt &&
@@ -203,6 +219,7 @@ test_expect_success 'setup repos' '
203219
EOF
204220
chmod 755 creds.sh &&
205221
git -C "$REPO_T1" config --local credential.helper "!f() { cat \"$(pwd)\"/creds.txt; }; f" &&
222+
git -C "$REPO_T2" config --local credential.helper "!f() { cat \"$(pwd)\"/creds.txt; }; f" &&
206223
#
207224
# Create some test data sets.
208225
#
@@ -1294,6 +1311,87 @@ test_expect_success 'integration: fully implicit: diff 2 commits' '
12941311
! trace_has_immediate_oid $oid <diff-trace.txt
12951312
'
12961313

1314+
# T1 should be considered contaminated at this point.
1315+
1316+
#################################################################
1317+
# gvfs-helper.exe defaults to no fallback.
1318+
# gvfs-helper-client.c defaults to adding `--fallback` to child process.
1319+
#
1320+
# `gvfs.fallback` was added to change the default behavior in the
1321+
# gvfs-helper-client.c code to add either `--fallback` or `--no-fallback`
1322+
# (for origin server load reasons).
1323+
#
1324+
# When `gvfs.fallback` is unset, we default to TRUE and pass `--fallback`.
1325+
# Otherwise, we use the boolean value to decide.
1326+
#
1327+
# NOTE: We DO NOT attempt to count connection requests in the
1328+
# following tests. Since we are using a normal `git` command to drive
1329+
# the `gvfs-helper-client.c` code (and spawn `git-gvfs-helper.exe`) we
1330+
# cannot make assumptions on the number of child processes or
1331+
# reqeusts. The "promisor" logic may drive one or more single-item
1332+
# GETs or a series of bulk POST attempts. Therefore, we must rely
1333+
# only on the result of the command and (implicitly) whether all
1334+
# missing objects were resolved. We use mayhem features to selectively
1335+
# break the cache and origin servers.
1336+
#################################################################
1337+
1338+
test_expect_success 'integration: implicit-get: http_503: diff 2 commits' '
1339+
test_when_finished "per_test_cleanup" &&
1340+
1341+
# Tell both servers to always send 503.
1342+
start_gvfs_protocol_server_with_mayhem http_503 &&
1343+
1344+
# Implicitly demand-load everything without any pre-seeding.
1345+
# (We cannot tell from whether fallback was used or not in this
1346+
# limited test.)
1347+
#
1348+
test_must_fail \
1349+
git -C "$REPO_T2" -c core.useGVFSHelper=true \
1350+
diff $(cat m1.branch)..$(cat m3.branch) \
1351+
>OUT.output 2>OUT.stderr &&
1352+
1353+
stop_gvfs_protocol_server
1354+
'
1355+
1356+
test_expect_success 'integration: implicit-get: cache_http_503,no-fallback: diff 2 commits' '
1357+
test_when_finished "per_test_cleanup" &&
1358+
1359+
# Tell cache server to send 503 and origin server to send 200.
1360+
start_gvfs_protocol_server_with_mayhem cache_http_503 &&
1361+
1362+
# Implicitly demand-load everything without any pre-seeding.
1363+
# This should fail because we do not allow fallback.
1364+
#
1365+
test_must_fail \
1366+
git -C "$REPO_T2" \
1367+
-c core.useGVFSHelper=true \
1368+
-c gvfs.fallback=false \
1369+
diff $(cat m1.branch)..$(cat m3.branch) \
1370+
>OUT.output 2>OUT.stderr &&
1371+
1372+
stop_gvfs_protocol_server
1373+
'
1374+
1375+
test_expect_success 'integration: implicit-get: cache_http_503,with-fallback: diff 2 commits' '
1376+
test_when_finished "per_test_cleanup" &&
1377+
1378+
# Tell cache server to send 503 and origin server to send 200.
1379+
start_gvfs_protocol_server_with_mayhem cache_http_503 &&
1380+
1381+
# Implicitly demand-load everything without any pre-seeding.
1382+
#
1383+
git -C "$REPO_T2" \
1384+
-c core.useGVFSHelper=true \
1385+
-c gvfs.fallback=true \
1386+
diff $(cat m1.branch)..$(cat m3.branch) \
1387+
>OUT.output 2>OUT.stderr &&
1388+
1389+
stop_gvfs_protocol_server
1390+
'
1391+
1392+
# T2 should be considered contaminated at this point.
1393+
1394+
12971395
#################################################################
12981396
# Duplicate packfile tests.
12991397
#

0 commit comments

Comments
 (0)