@@ -609,7 +609,7 @@ function e2e::worktree_cleanup() {
609
609
}
610
610
611
611
# #############################################
612
- # Test worktree- unexpected- removal
612
+ # Test worktree unexpected removal
613
613
# #############################################
614
614
function e2e::worktree_unexpected_removal() {
615
615
GIT_SYNC \
@@ -635,7 +635,52 @@ function e2e::worktree_unexpected_removal() {
635
635
636
636
# make a unexpected removal
637
637
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"
639
684
640
685
# resume time
641
686
docker ps --filter label=" git-sync-e2e=$RUNID " --format=" {{.ID}}" \
@@ -1294,17 +1339,14 @@ function e2e::sync_sha_once_sync_different_sha_unknown() {
1294
1339
# #############################################
1295
1340
function e2e::sync_crash_no_link_cleanup_retry() {
1296
1341
# First sync
1297
- echo " $FUNCNAME 1" > " $REPO /file"
1298
- git -C " $REPO " commit -qam " $FUNCNAME 1"
1299
-
1300
1342
GIT_SYNC \
1301
1343
--one-time \
1302
1344
--repo=" file://$REPO " \
1303
1345
--root=" $ROOT " \
1304
1346
--link=" link"
1305
1347
assert_link_exists " $ROOT /link"
1306
1348
assert_file_exists " $ROOT /link/file"
1307
- assert_file_eq " $ROOT /link/file" " $FUNCNAME 1 "
1349
+ assert_file_eq " $ROOT /link/file" " $FUNCNAME "
1308
1350
1309
1351
# Corrupt it
1310
1352
rm -f " $ROOT /link"
@@ -1317,25 +1359,22 @@ function e2e::sync_crash_no_link_cleanup_retry() {
1317
1359
--link=" link"
1318
1360
assert_link_exists " $ROOT /link"
1319
1361
assert_file_exists " $ROOT /link/file"
1320
- assert_file_eq " $ROOT /link/file" " $FUNCNAME 1 "
1362
+ assert_file_eq " $ROOT /link/file" " $FUNCNAME "
1321
1363
}
1322
1364
1323
1365
# #############################################
1324
1366
# Test syncing after a crash
1325
1367
# #############################################
1326
1368
function e2e::sync_crash_no_worktree_cleanup_retry() {
1327
1369
# First sync
1328
- echo " $FUNCNAME 1" > " $REPO /file"
1329
- git -C " $REPO " commit -qam " $FUNCNAME 1"
1330
-
1331
1370
GIT_SYNC \
1332
1371
--one-time \
1333
1372
--repo=" file://$REPO " \
1334
1373
--root=" $ROOT " \
1335
1374
--link=" link"
1336
1375
assert_link_exists " $ROOT /link"
1337
1376
assert_file_exists " $ROOT /link/file"
1338
- assert_file_eq " $ROOT /link/file" " $FUNCNAME 1 "
1377
+ assert_file_eq " $ROOT /link/file" " $FUNCNAME "
1339
1378
1340
1379
# Corrupt it
1341
1380
rm -rf " $ROOT /.worktrees/"
@@ -1348,7 +1387,7 @@ function e2e::sync_crash_no_worktree_cleanup_retry() {
1348
1387
--link=" link"
1349
1388
assert_link_exists " $ROOT /link"
1350
1389
assert_file_exists " $ROOT /link/file"
1351
- assert_file_eq " $ROOT /link/file" " $FUNCNAME 1 "
1390
+ assert_file_eq " $ROOT /link/file" " $FUNCNAME "
1352
1391
}
1353
1392
1354
1393
# #############################################
0 commit comments