Cover batched delete retry recovery · Entire
Cover batched delete retry recovery
bf3b784→main·
Soph·3mo ago·4 files·+101 added/-11 removed
Sessions
7938df770894View transcript
[?
Can you take a look at the go code (wasm) in /Users/soph/Work/entire/devenv/entire-io-worktree1 based a bit on that I wonder if something like this can be build:Codex·GPT-5.4·1 step](/content/gh/entireio/git-sync/session/019d6d29-8cf7-7fe3-adc9-8c3e4d9d5603#timeline-7938df770894/index.html)
Changes
4
docs
Mrewrite-issue-list.md+2/-1
internal
strategy/incremental
Mincremental.go+3/-3
Mincremental_test.go-7
syncer
Mintegration_test.go+96
429 unmodified lines
430
431
432
433
433
434
435
436
437
429 unmodified lines
- Basic context cancellation coverage now exists.
- Batched bootstrap resume mismatch and final-tip cutover paths now have direct integration coverage.
- Batched bootstrap reruns now also cover the "target ref already created, temp ref cleanup still pending" recovery path.
- Some harder injected batch-failure paths still remain.
- Injected temp-ref delete failure during batched cutover is now covered end-to-end, including successful recovery on retry.
- Some harder injected pack-transfer failure paths still remain.
### 22. No benchmark coverage for the expensive paths
Mdocs/rewrite-issue-list.md+2/-1
50 unmodified lines
51
52
53
54
55
56
54
55
56
8 unmodified lines
65
66
67
68
69
70
71
72
73
50 unmodified lines
if p.TargetPusher == nil {
return Result{}, fmt.Errorf("incremental strategy requires TargetPusher")
}
if p.CanTagRelay == nil {
return Result{}, fmt.Errorf("incremental strategy requires CanTagRelay")
}
if ok, reason := canRelay(cfg.Force, cfg.Prune, false, p.PushPlans); ok {
desired := convert.DesiredRefs(planner.DesiredSubset(p.DesiredRefs, p.PushPlans))
packReader, err := p.SourceService.FetchPack(ctx, p.SourceConn, desired, p.TargetRefs)
8 unmodified lines
return Result{Relay: true, RelayMode: "incremental", RelayReason: reason}, nil
}
if p.CanTagRelay == nil {
return Result{}, fmt.Errorf("incremental strategy requires CanTagRelay")
}
if ok, reason := p.CanTagRelay(p.PushPlans); ok {
desired := convert.DesiredRefs(planner.DesiredSubset(p.DesiredRefs, p.PushPlans))
packReader, err := p.SourceService.FetchPack(ctx, p.SourceConn, desired, nil)
Minternal/strategy/incremental/incremental.go+3/-3
189 unmodified lines
190
191
192
193
194
195
196
193
194
195
106 unmodified lines
302
303
304
309
310
311
305
306
307
189 unmodified lines
}
return true, "fast-forward"
},
CanTagRelay: func([]planner.BranchPlan) (bool, string) {
t.Fatal("tag relay policy should not be called for incremental branch relay")
return false, ""
},
}
result, err := Execute(context.Background(), params, planner.PlanConfig{})
if err != nil {
106 unmodified lines
CanRelay: func(bool, bool, bool, []planner.BranchPlan) (bool, string) {
return true, "fast-forward"
},
CanTagRelay: func([]planner.BranchPlan) (bool, string) {
return false, ""
},
}, planner.PlanConfig{})
if err == nil || err.Error() != "push target refs: boom" {
t.Fatalf("unexpected error: %v", err)
Minternal/strategy/incremental/incremental_test.go-7
438 unmodified lines
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
830 unmodified lines
1353
1354
1355
1356
1357
1358
1359
395 unmodified lines
1755
1756
1757
1758
1759
1760
1761
1762
1770
1771
1772
1773
1774
1775
1776
1777
438 unmodified lines
}
}
func TestBootstrap_IntegrationBatchedDeleteFailureRecoversOnRetry(t *testing.T) {
sourceRepo, sourceFS := newSourceRepo(t)
makeLargeCommits(t, sourceRepo, sourceFS, 5, 200_000)
sourceHead, err := sourceRepo.Reference(plumbing.NewBranchReferenceName(testBranch), true)
if err != nil {
t.Fatalf("resolve source head: %v", err)
}
targetRepo, err := git.Init(memory.NewStorage(), nil)
if err != nil {
t.Fatalf("init target repo: %v", err)
}
if err := copyRefsAndObjects(sourceRepo.Storer, targetRepo.Storer, nil); err != nil {
t.Fatalf("copy source objects: %v", err)
}
targetRef := plumbing.NewBranchReferenceName(testBranch)
tempRef := planner.BootstrapTempRef(targetRef)
if err := targetRepo.Storer.SetReference(plumbing.NewHashReference(tempRef, sourceHead.Hash())); err != nil {
t.Fatalf("set temp ref: %v", err)
}
sourceServer := newSmartHTTPRepoServerV2(t, sourceRepo)
targetServer := newSmartHTTPRepoServer(t, targetRepo)
defer sourceServer.Close()
defer targetServer.Close()
failDeleteOnce := true
targetServer.commandHook = func(req *packp.ReferenceUpdateRequest) *packp.ReportStatus {
if !failDeleteOnce || len(req.Commands) != 1 {
return nil
}
cmd := req.Commands[0]
if cmd.Name != tempRef || !cmd.New.IsZero() {
return nil
}
failDeleteOnce = false
report := packp.NewReportStatus()
report.UnpackStatus = "ok"
report.CommandStatuses = append(report.CommandStatuses, &packp.CommandStatus{
ReferenceName: cmd.Name,
Status: "ng simulated temp-ref delete failure",
})
return report
}
cfg := Config{
Source: Endpoint{URL: sourceServer.RepoURL()},
Target: Endpoint{URL: targetServer.RepoURL()},
ProtocolMode: protocolModeAuto,
BatchMaxPackBytes: 350_000,
}
if _, err := Bootstrap(context.Background(), cfg); err == nil {
t.Fatal("expected first bootstrap retry to fail on temp-ref delete")
}
targetHead, err := targetRepo.Reference(targetRef, true)
if err != nil {
t.Fatalf("resolve target head after failed delete: %v", err)
}
if targetHead.Hash() != sourceHead.Hash() {
t.Fatalf("expected target head %s after failed delete, got %s", sourceHead.Hash(), targetHead.Hash())
}
if _, err := targetRepo.Reference(tempRef, true); err != nil {
t.Fatalf("expected temp ref %s to remain after failed delete: %v", tempRef, err)
}
result, err := Bootstrap(context.Background(), cfg)
if err != nil {
t.Fatalf("bootstrap retry after delete failure failed: %v", err)
}
if !result.Relay || result.RelayMode != "bootstrap-batch" {
t.Fatalf("expected batched bootstrap result, got %+v", result)
}
if _, err := targetRepo.Reference(tempRef, true); err == nil {
t.Fatalf("expected temp ref %s to be deleted after retry", tempRef)
}
}
func TestBootstrap_IntegrationBatchedLightweightTagCreatesWithoutExtraPack(t *testing.T) {
sourceRepo, sourceFS := newSourceRepo(t)
makeLargeCommits(t, sourceRepo, sourceFS, 5, 200_000)
830 unmodified lines
receivePackBodyLimit int64
receivePackNoThin bool
commandHook func(*packp.ReferenceUpdateRequest) *packp.ReportStatus
mu sync.Mutex
metrics []exchangeMetric
395 unmodified lines
}
if !bytes.Contains(body, []byte("PACK")) {
if s.commandHook != nil {
if report := s.commandHook(req); report != nil {
var buf bytes.Buffer
if err := report.Encode(&buf); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", fmt.Sprintf("application/x-%s-result", serviceReceivePack))
if _, err := w.Write(buf.Bytes()); err != nil {
s.tb.Fatalf("write receive-pack command hook response: %v", err)
}
s.recordMetric(serviceReceivePack, metricPack, int64(len(body)), int64(buf.Len()), 0, 0)
return
}
}
report := packp.NewReportStatus()
report.UnpackStatus = "ok"
for _, cmd := range req.Commands {