Skip to content

Commit

Permalink
t5799: explicitly test gvfs-helper --fallback and --no-fallback
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jeffhostetler authored and dscho committed Sep 18, 2024
1 parent 92da944 commit 3234bdc
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions t/t5799-gvfs-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,70 @@ test_expect_success 'successful retry after http-error: origin get' '
verify_connection_count 2
'

#################################################################
# So far we have confirmed that gvfs-helper can recover from a network
# error (with retries, since the cache-server was disabled in all of
# the above tests). Try again with fallback turned on.
#
# With mayhem "http_503" turned on both the cache and origin server
# will always throw a 503 error.
#
# Confirm that we tried to make six connections: we should hit the
# cache-server 3 times (one initial attempt and two retries) and then
# try the origin server 3 times.
#
#################################################################

test_expect_success 'http-error: 503 Service Unavailable (with retry and fallback)' '
test_when_finished "per_test_cleanup" &&
start_gvfs_protocol_server_with_mayhem http_503 &&
test_expect_code $GH__ERROR_CODE__HTTP_503 \
git -C "$REPO_T1" gvfs-helper \
--cache-server=trust \
--remote=origin \
--fallback \
get \
--max-retries=2 \
<"$OIDS_FILE" >OUT.output 2>OUT.stderr &&
stop_gvfs_protocol_server &&
grep -q "error: get: (http:503)" OUT.stderr &&
verify_connection_count 6
'

#################################################################
# Now repeat the above, but explicitly turn off fallback.
#
# Again, we use mayhem "http_503". However, with fallback turned
# off, we will only attempt the 3 connections to the cache server.
# We will not try to hit the origin server.
#
# So we should only see a total of 3 connections rather than the
# six in the previous test.
#
#################################################################

test_expect_success 'http-error: 503 Service Unavailable (with retry and no-fallback)' '
test_when_finished "per_test_cleanup" &&
start_gvfs_protocol_server_with_mayhem http_503 &&
test_expect_code $GH__ERROR_CODE__HTTP_503 \
git -C "$REPO_T1" gvfs-helper \
--cache-server=trust \
--remote=origin \
--no-fallback \
get \
--max-retries=2 \
<"$OIDS_FILE" >OUT.output 2>OUT.stderr &&
stop_gvfs_protocol_server &&
grep -q "error: get: (http:503)" OUT.stderr &&
verify_connection_count 3
'

#################################################################
# Test HTTP Auth
#
Expand Down

0 comments on commit 3234bdc

Please sign in to comment.