@@ -609,7 +609,7 @@ function e2e::worktree_cleanup() {
609609}
610610
611611# #############################################
612- # Test worktree- unexpected- removal
612+ # Test worktree unexpected removal
613613# #############################################
614614function e2e::worktree_unexpected_removal() {
615615 GIT_SYNC \
@@ -635,7 +635,52 @@ function e2e::worktree_unexpected_removal() {
635635
636636 # make a unexpected removal
637637 WT=$( git -C " $REPO " rev-list -n1 HEAD)
638- rm -r " $ROOT /.worktrees/$WT "
638+ rm -r " $ROOT /.worktrees/$WT "
639+
640+ # resume time
641+ docker ps --filter label=" git-sync-e2e=$RUNID " --format=" {{.ID}}" \
642+ | while read CTR; do
643+ docker unpause " $CTR " > /dev/null
644+ done
645+
646+ echo " $METRIC_GOOD_SYNC_COUNT "
647+
648+ wait_for_sync " ${MAXWAIT} "
649+ assert_link_exists " $ROOT /link"
650+ assert_file_exists " $ROOT /link/file"
651+ assert_file_eq " $ROOT /link/file" " $FUNCNAME "
652+ assert_metric_eq " ${METRIC_GOOD_SYNC_COUNT} " 2
653+ assert_metric_eq " ${METRIC_FETCH_COUNT} " 2
654+ }
655+
656+ # #############################################
657+ # Test syncing when the worktree is wrong hash
658+ # #############################################
659+ function e2e::sync_recover_wrong_worktree_hash() {
660+ GIT_SYNC \
661+ --period=100ms \
662+ --repo=" file://$REPO " \
663+ --root=" $ROOT " \
664+ --link=" link" \
665+ &
666+
667+ # wait for first sync
668+ wait_for_sync " ${MAXWAIT} "
669+ assert_link_exists " $ROOT /link"
670+ assert_file_exists " $ROOT /link/file"
671+ assert_file_eq " $ROOT /link/file" " $FUNCNAME "
672+ assert_metric_eq " ${METRIC_GOOD_SYNC_COUNT} " 1
673+ assert_metric_eq " ${METRIC_FETCH_COUNT} " 1
674+
675+ # suspend time so we can fake corruption
676+ docker ps --filter label=" git-sync-e2e=$RUNID " --format=" {{.ID}}" \
677+ | while read CTR; do
678+ docker pause " $CTR " > /dev/null
679+ done
680+
681+ # Corrupt it
682+ echo " unexpected" > " $ROOT /link/file"
683+ git -C " $ROOT /link" commit -qam " corrupt it"
639684
640685 # resume time
641686 docker ps --filter label=" git-sync-e2e=$RUNID " --format=" {{.ID}}" \
@@ -1294,17 +1339,14 @@ function e2e::sync_sha_once_sync_different_sha_unknown() {
12941339# #############################################
12951340function e2e::sync_crash_no_link_cleanup_retry() {
12961341 # First sync
1297- echo " $FUNCNAME 1" > " $REPO /file"
1298- git -C " $REPO " commit -qam " $FUNCNAME 1"
1299-
13001342 GIT_SYNC \
13011343 --one-time \
13021344 --repo=" file://$REPO " \
13031345 --root=" $ROOT " \
13041346 --link=" link"
13051347 assert_link_exists " $ROOT /link"
13061348 assert_file_exists " $ROOT /link/file"
1307- assert_file_eq " $ROOT /link/file" " $FUNCNAME 1 "
1349+ assert_file_eq " $ROOT /link/file" " $FUNCNAME "
13081350
13091351 # Corrupt it
13101352 rm -f " $ROOT /link"
@@ -1317,25 +1359,22 @@ function e2e::sync_crash_no_link_cleanup_retry() {
13171359 --link=" link"
13181360 assert_link_exists " $ROOT /link"
13191361 assert_file_exists " $ROOT /link/file"
1320- assert_file_eq " $ROOT /link/file" " $FUNCNAME 1 "
1362+ assert_file_eq " $ROOT /link/file" " $FUNCNAME "
13211363}
13221364
13231365# #############################################
13241366# Test syncing after a crash
13251367# #############################################
13261368function e2e::sync_crash_no_worktree_cleanup_retry() {
13271369 # First sync
1328- echo " $FUNCNAME 1" > " $REPO /file"
1329- git -C " $REPO " commit -qam " $FUNCNAME 1"
1330-
13311370 GIT_SYNC \
13321371 --one-time \
13331372 --repo=" file://$REPO " \
13341373 --root=" $ROOT " \
13351374 --link=" link"
13361375 assert_link_exists " $ROOT /link"
13371376 assert_file_exists " $ROOT /link/file"
1338- assert_file_eq " $ROOT /link/file" " $FUNCNAME 1 "
1377+ assert_file_eq " $ROOT /link/file" " $FUNCNAME "
13391378
13401379 # Corrupt it
13411380 rm -rf " $ROOT /.worktrees/"
@@ -1348,7 +1387,7 @@ function e2e::sync_crash_no_worktree_cleanup_retry() {
13481387 --link=" link"
13491388 assert_link_exists " $ROOT /link"
13501389 assert_file_exists " $ROOT /link/file"
1351- assert_file_eq " $ROOT /link/file" " $FUNCNAME 1 "
1390+ assert_file_eq " $ROOT /link/file" " $FUNCNAME "
13521391}
13531392
13541393# #############################################
0 commit comments