Skip to content

Commit 3c035ee

Browse files
committed
t9210: differentiate origin and cache servers
Now that we are testing the --<verb>-cache-server options in t9210, we need to be more careful about our variable names to ensure those created in t9210-scalar.sh are different from those set in lib-gvfs-helper.sh. For this we: * Rename variables to use ORIGIN_* for those that host Git repo data. * Update server output files to have more specific names. * Avoid using the default test server port when possible, in preference for a positive shift-by-10k. Signed-off-by: Derrick Stolee <stolee@gmail.com>
1 parent 63f25a0 commit 3c035ee

2 files changed

Lines changed: 46 additions & 42 deletions

File tree

t/lib-gvfs-helper.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ SHARED_CACHE_T2="$(pwd)"/shared_cache_t2
5858
# The server will shut down if/when we delete it. (This is a little
5959
# easier than killing it by PID.)
6060
#
61-
PID_FILE="$(pwd)"/pid-file.pid
62-
SERVER_LOG="$(pwd)"/OUT.server.log
61+
PID_FILE="$(pwd)"/pid-file-gvfs.pid
62+
SERVER_LOG="$(pwd)"/OUT.gvfs.server.log
6363

6464
# Helper functions to compute port, pid-file, and log for a given
6565
# port increment. An increment of 0 (or empty) uses the base values.
@@ -294,7 +294,7 @@ stop_gvfs_protocol_server () {
294294
# port before the next test start another instance and it attempts to
295295
# bind to it).
296296
#
297-
for k in 0 1 2 3 4
297+
for k in $(test_seq 5)
298298
do
299299
if grep -q "Starting graceful shutdown" "$log_file"
300300
then
@@ -334,7 +334,7 @@ start_gvfs_protocol_server () {
334334
#
335335
# Give it a few seconds to get started.
336336
#
337-
for k in 0 1 2 3 4
337+
for k in $(test_seq 5)
338338
do
339339
if test -f "$pid_file"
340340
then
@@ -375,7 +375,7 @@ start_gvfs_protocol_server_with_mayhem () {
375375
#
376376
# Give it a few seconds to get started.
377377
#
378-
for k in 0 1 2 3 4
378+
for k in $(test_seq 5)
379379
do
380380
if test -f "$PID_FILE"
381381
then

t/t9210-scalar.sh

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -360,28 +360,28 @@ test_expect_success UNZIP 'scalar diagnose' '
360360
GIT_TEST_ALLOW_GVFS_VIA_HTTP=1
361361
export GIT_TEST_ALLOW_GVFS_VIA_HTTP
362362

363-
test_set_port GIT_TEST_GVFS_PROTOCOL_PORT
364-
HOST_PORT=127.0.0.1:$GIT_TEST_GVFS_PROTOCOL_PORT
365-
PID_FILE="$(pwd)"/pid-file.pid
366-
SERVER_LOG="$(pwd)"/OUT.server.log
363+
test_set_port GIT_TEST_GVFS_PROTOCOL_ORIGIN_PORT
364+
ORIGIN_HOST_PORT=127.0.0.1:$GIT_TEST_GVFS_PROTOCOL_ORIGIN_PORT
365+
ORIGIN_PID_FILE="$(pwd)"/pid-file.$GIT_TEST_GVFS_PROTOCOL_ORIGIN_PORT.pid
366+
ORIGIN_SERVER_LOG="$(pwd)"/OUT.server.$GIT_TEST_GVFS_PROTOCOL_ORIGIN_PORT.log
367367

368368
test_atexit '
369-
test -f "$PID_FILE" || return 0
369+
test -f "$ORIGIN_PID_FILE" || return 0
370370
371371
# The server will shutdown automatically when we delete the pid-file.
372-
rm -f "$PID_FILE"
372+
rm -f "$ORIGIN_PID_FILE"
373373
374374
test -z "$verbose$verbose_log" || {
375375
echo "server log:"
376-
cat "$SERVER_LOG"
376+
cat "$ORIGIN_SERVER_LOG"
377377
}
378378
379379
# Give it a few seconds to shutdown (mainly to completely release the
380380
# port before the next test start another instance and it attempts to
381381
# bind to it).
382382
for k in $(test_seq 5)
383383
do
384-
grep -q "Starting graceful shutdown" "$SERVER_LOG" &&
384+
grep -q "Starting graceful shutdown" "$ORIGIN_SERVER_LOG" &&
385385
return 0 ||
386386
sleep 1
387387
done
@@ -394,14 +394,14 @@ start_gvfs_enabled_http_server () {
394394
GIT_HTTP_EXPORT_ALL=1 \
395395
test-gvfs-protocol --verbose \
396396
--listen=127.0.0.1 \
397-
--port=$GIT_TEST_GVFS_PROTOCOL_PORT \
397+
--port=$GIT_TEST_GVFS_PROTOCOL_ORIGIN_PORT \
398398
--reuseaddr \
399-
--pid-file="$PID_FILE" \
400-
2>"$SERVER_LOG" &
399+
--pid-file="$ORIGIN_PID_FILE" \
400+
2>"$ORIGIN_SERVER_LOG" &
401401

402-
for k in 0 1 2 3 4
402+
for k in $(test_seq 5)
403403
do
404-
if test -f "$PID_FILE"
404+
if test -f "$ORIGIN_PID_FILE"
405405
then
406406
return 0
407407
fi
@@ -426,20 +426,20 @@ test_expect_success '`scalar clone` with GVFS-enabled server' '
426426
GIT_TRACE2_EVENT="$(pwd)/clone-trace-with-gvfs" scalar \
427427
-c credential.interactive=true \
428428
clone --gvfs-protocol \
429-
--single-branch -- http://$HOST_PORT/ using-gvfs &&
429+
--single-branch -- http://$ORIGIN_HOST_PORT/ using-gvfs &&
430430
431431
grep "GET/config(main)" <clone-trace-with-gvfs &&
432432
433433
: verify that the shared cache has been configured &&
434-
cache_key="url_$(printf "%s" http://$HOST_PORT/ |
434+
cache_key="url_$(printf "%s" http://$ORIGIN_HOST_PORT/ |
435435
tr A-Z a-z |
436436
test-tool sha1)" &&
437437
echo "$(pwd)/.scalarCache/$cache_key" >expect &&
438438
git -C using-gvfs/src config gvfs.sharedCache >actual &&
439439
test_cmp expect actual &&
440440
441441
: verify that URL-specific HTTP version setting is configured for GVFS URLs in clone &&
442-
git -C using-gvfs/src config "http.http://$HOST_PORT/.version" >actual &&
442+
git -C using-gvfs/src config "http.http://$ORIGIN_HOST_PORT/.version" >actual &&
443443
echo "HTTP/1.1" >expect &&
444444
test_cmp expect actual &&
445445
@@ -466,37 +466,41 @@ test_expect_success 'scalar clone: all verbs with different servers' '
466466
start_gvfs_protocol_server 1 &&
467467
start_gvfs_protocol_server 2 &&
468468
start_gvfs_protocol_server 3 &&
469+
start_gvfs_protocol_server 4 &&
469470
470471
# Configure each verb to use a different server:
471-
# - server 0: default (unused in this test; not running.)
472-
# - server 1: prefetch
473-
# - server 2: get
474-
# - server 3: post
472+
# - server 1: default (unused in this test; not running.)
473+
# - server 2: prefetch
474+
# - server 3: get
475+
# - server 4: post
475476
scalar -c credential.interactive=true \
476477
clone --full-clone \
477-
--cache-server-url="$(cache_server_url 0)" \
478-
--prefetch-cache-server-url="$(cache_server_url 1)" \
479-
--get-cache-server-url="$(cache_server_url 2)" \
480-
--post-cache-server-url="$(cache_server_url 3)" \
478+
--cache-server-url="$(cache_server_url 1)" \
479+
--prefetch-cache-server-url="$(cache_server_url 2)" \
480+
--get-cache-server-url="$(cache_server_url 3)" \
481+
--post-cache-server-url="$(cache_server_url 4)" \
481482
--gvfs-protocol \
482-
-- "http://$HOST_PORT/" scalar-clone 2>err >out &&
483+
-- "http://$ORIGIN_HOST_PORT/" scalar-clone 2>err >out &&
483484
484-
test_grep "Cache server URL: $(cache_server_url 0)" err &&
485-
test_grep "Prefetch cache server URL: $(cache_server_url 1)" err &&
486-
test_grep "Objects GET cache server URL: $(cache_server_url 2)" err &&
487-
test_grep "Objects POST cache server URL: $(cache_server_url 3)" err &&
485+
test_grep "Cache server URL: $(cache_server_url 1)" err &&
486+
test_grep "Prefetch cache server URL: $(cache_server_url 2)" err &&
487+
test_grep "Objects GET cache server URL: $(cache_server_url 3)" err &&
488+
test_grep "Objects POST cache server URL: $(cache_server_url 4)" err &&
488489
489-
test_cmp_config -C scalar-clone/src "$(cache_server_url 0)" gvfs.cache-server &&
490-
test_cmp_config -C scalar-clone/src "$(cache_server_url 1)" gvfs.prefetch.cache-server &&
491-
test_cmp_config -C scalar-clone/src "$(cache_server_url 2)" gvfs.get.cache-server &&
492-
test_cmp_config -C scalar-clone/src "$(cache_server_url 3)" gvfs.post.cache-server &&
490+
test_cmp_config -C scalar-clone/src "$(cache_server_url 1)" gvfs.cache-server &&
491+
test_cmp_config -C scalar-clone/src "$(cache_server_url 2)" gvfs.prefetch.cache-server &&
492+
test_cmp_config -C scalar-clone/src "$(cache_server_url 3)" gvfs.get.cache-server &&
493+
test_cmp_config -C scalar-clone/src "$(cache_server_url 4)" gvfs.post.cache-server &&
493494
494495
verify_server_was_contacted 1 &&
495496
verify_server_was_contacted 2 &&
496497
verify_server_was_contacted 3
497498
'
498499

499-
test_expect_success 'fetch <non-existent> does not hang in gvfs-helper' '
500+
test_expect_success EXPENSIVE 'fetch <non-existent> does not hang in gvfs-helper' '
501+
# Marked as EXPENSIVE as this will go through multiple rounds of
502+
# exponential backoff, including delays of 8, 16, 32, 64, 128,
503+
# and 256 seconds in two separate instances.
500504
test_must_fail git -C using-gvfs/src fetch origin does-not-exist
501505
'
502506

@@ -510,7 +514,7 @@ test_expect_success '`scalar clone --no-gvfs-protocol` skips gvfs/config' '
510514
GIT_TRACE2_EVENT="$(pwd)/clone-trace-no-gvfs" scalar \
511515
-c credential.interactive=true \
512516
clone --no-gvfs-protocol \
513-
--single-branch -- http://$HOST_PORT/ skipping-gvfs &&
517+
--single-branch -- http://$ORIGIN_HOST_PORT/ skipping-gvfs &&
514518
515519
! grep "GET/config(main)" <clone-trace-no-gvfs &&
516520
! git -C skipping-gvfs/src config core.gvfs &&
@@ -605,11 +609,11 @@ test_expect_success 'scalar cache-server basics' '
605609
test_expect_success 'scalar cache-server list URL' '
606610
repo=with-real-gvfs &&
607611
git init $repo &&
608-
git -C $repo remote add origin http://$HOST_PORT/ &&
612+
git -C $repo remote add origin http://$ORIGIN_HOST_PORT/ &&
609613
scalar cache-server --list origin $repo >out &&
610614
611615
cat >expect <<-EOF &&
612-
#0: http://$HOST_PORT/servertype/cache
616+
#0: http://$ORIGIN_HOST_PORT/servertype/cache
613617
EOF
614618
615619
test_cmp expect out &&

0 commit comments

Comments
 (0)