Skip to content

Commit 4f2a700

Browse files
jeffhostetlerdscho
authored andcommitted
t5799: explicitly test gvfs-helper --fallback and --no-fallback
Construct 2 new unit tests to explicitly verify the use of `--fallback` and `--no-fallback` arguments to `gvfs-helper`. When a cache-server is enabled, `gvfs-helper` will try to fetch objects from it rather than the origin server. If the cache-server fails (and all cache-server retry attempts have been exhausted), `gvfs-helper` can optionally "fallback" and try to fetch the objects from the origin server. (The retry logic is also applied to the origin server, if the origin server fails on the first request.) Add new unit tests to verify that `gvfs-helper` respects both the `--max-retries` and `--[no-]fallback` arguments. We use the "http_503" mayhem feature of the `test_gvfs_protocol` server to force a 503 response on all requests to the cache-server and the origin server end-points. We can then count the number of connection requests that `gvfs-helper` makes to the server and confirm both the per-server retries and whether fallback was attempted. Signed-off-by: Jeff Hostetler <jeffhostetler@github.com>
1 parent 8b1da54 commit 4f2a700

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

t/t5799-gvfs-helper.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,70 @@ test_expect_success 'successful retry after http-error: origin get' '
10361036
verify_connection_count 2
10371037
'
10381038

1039+
#################################################################
1040+
# So far we have confirmed that gvfs-helper can recover from a network
1041+
# error (with retries, since the cache-server was disabled in all of
1042+
# the above tests). Try again with fallback turned on.
1043+
#
1044+
# With mayhem "http_503" turned on both the cache and origin server
1045+
# will always throw a 503 error.
1046+
#
1047+
# Confirm that we tried to make six connections: we should hit the
1048+
# cache-server 3 times (one initial attempt and two retries) and then
1049+
# try the origin server 3 times.
1050+
#
1051+
#################################################################
1052+
1053+
test_expect_success 'http-error: 503 Service Unavailable (with retry and fallback)' '
1054+
test_when_finished "per_test_cleanup" &&
1055+
start_gvfs_protocol_server_with_mayhem http_503 &&
1056+
1057+
test_expect_code $GH__ERROR_CODE__HTTP_503 \
1058+
git -C "$REPO_T1" gvfs-helper \
1059+
--cache-server=trust \
1060+
--remote=origin \
1061+
--fallback \
1062+
get \
1063+
--max-retries=2 \
1064+
<"$OIDS_FILE" >OUT.output 2>OUT.stderr &&
1065+
1066+
stop_gvfs_protocol_server &&
1067+
1068+
grep -q "error: get: (http:503)" OUT.stderr &&
1069+
verify_connection_count 6
1070+
'
1071+
1072+
#################################################################
1073+
# Now repeat the above, but explicitly turn off fallback.
1074+
#
1075+
# Again, we use mayhem "http_503". However, with fallback turned
1076+
# off, we will only attempt the 3 connections to the cache server.
1077+
# We will not try to hit the origin server.
1078+
#
1079+
# So we should only see a total of 3 connections rather than the
1080+
# six in the previous test.
1081+
#
1082+
#################################################################
1083+
1084+
test_expect_success 'http-error: 503 Service Unavailable (with retry and no-fallback)' '
1085+
test_when_finished "per_test_cleanup" &&
1086+
start_gvfs_protocol_server_with_mayhem http_503 &&
1087+
1088+
test_expect_code $GH__ERROR_CODE__HTTP_503 \
1089+
git -C "$REPO_T1" gvfs-helper \
1090+
--cache-server=trust \
1091+
--remote=origin \
1092+
--no-fallback \
1093+
get \
1094+
--max-retries=2 \
1095+
<"$OIDS_FILE" >OUT.output 2>OUT.stderr &&
1096+
1097+
stop_gvfs_protocol_server &&
1098+
1099+
grep -q "error: get: (http:503)" OUT.stderr &&
1100+
verify_connection_count 3
1101+
'
1102+
10391103
#################################################################
10401104
# Test HTTP Auth
10411105
#

0 commit comments

Comments
 (0)