Make syncer benchmarks use testing.TB fixtures · Entire
Make syncer benchmarks use testing.TB fixtures
f266bff→main·
Soph·3mo ago·2 files·+24 added/-24 removed
Sessions
ccee9163d5b1View transcript
Changes
2
internal/syncer
Mbenchmark_test.go+6/-6
Mintegration_test.go+18/-18
19 unmodified lines
20
21
22
23
23
24
25
26
3 unmodified lines
30
31
32
33
33
34
35
36
29 unmodified lines
66
67
68
69
70
69
70
71
72
73
36 unmodified lines
110
111
112
113
114
113
114
115
116
117
19 unmodified lines
sourceRepo, sourceFS := newBenchRepo(b)
makeBenchCommits(b, sourceRepo, sourceFS, 8)
sourceServer := newSmartHTTPRepoServerV2(&testing.T{}, sourceRepo)
sourceServer := newSmartHTTPRepoServerV2(b, sourceRepo)
defer sourceServer.Close()
b.ResetTimer()
3 unmodified lines
if err != nil {
b.Fatalf("init target repo: %v", err)
}
targetServer := newSmartHTTPRepoServer(&testing.T{}, targetRepo)
targetServer := newSmartHTTPRepoServer(b, targetRepo)
b.StartTimer()
_, err = Run(context.Background(), Config{
29 unmodified lines
makeBenchCommits(b, sourceRepo, sourceFS, 1)
sourceServer := newSmartHTTPRepoServerV2(&testing.T{}, sourceRepo)
targetServer := newSmartHTTPRepoServer(&testing.T{}, targetRepo)
sourceServer := newSmartHTTPRepoServerV2(b, sourceRepo)
targetServer := newSmartHTTPRepoServer(b, targetRepo)
b.StartTimer()
_, err = Run(context.Background(), Config{
36 unmodified lines
b.Fatalf("set source release branch: %v", err)
}
_, err = Run(context.Background(), Config{
Minternal/syncer/benchmark_test.go+6/-6
1047 unmodified lines
1048
1049
1050
1051
1051
1052
1053
1054
8 unmodified lines
1063
1064
1065
1066
1067
1066
1067
1068
1069
1070
1070
1071
1072
1073
1 unmodified line
1075
1076
1077
1078
1079
1078
1079
1080
1081
1081
1082
1083
1084
1085
1086
1087
1086
1087
1088
1089
1089
1090
1091
1092
139 unmodified lines
1232
1233
1234
1235
1235
1236
1237
1238
21 unmodified lines
1260
1261
1262
1263
1263
1264
1265
1266
37 unmodified lines
1304
1305
1306
1307
1307
1308
1309
1310
45 unmodified lines
1356
1357
1358
1359
1359
1360
1361
1362
51 unmodified lines
1414
1415
1416
1417
1417
1418
1419
1420
19 unmodified lines
1440
1441
1442
1443
1443
1444
1445
1446
40 unmodified lines
1487
1488
1489
1490
1490
1491
1492
1493
11 unmodified lines
1505
1506
1507
1508
1508
1509
1510
1511
1047 unmodified lines
}
type smartHTTPRepoServer struct {
t *testing.T
tb testing.TB
server *httptest.Server
repo *git.Repository
repoPath string
8 unmodified lines
metrics []exchangeMetric
}
func newSmartHTTPRepoServer(t *testing.T, repo *git.Repository) *smartHTTPRepoServer {
t.Helper()
func newSmartHTTPRepoServer(tb testing.TB, repo *git.Repository) *smartHTTPRepoServer {
tb.Helper()
[s](
){s}
}
}
func newSmartHTTPRepoServerV2(t *testing.T, repo *git.Repository) *smartHTTPRepoServer {
t.Helper()
func newSmartHTTPRepoServerV2(tb testing.TB, repo *git.Repository) *smartHTTPRepoServer {
tb.Helper()
[s](
){s}
}
func newAuthenticatedSmartHTTPRepoServer(t *testing.T, repo *git.Repository, username, password string) *smartHTTPRepoServer {
t.Helper()
func newAuthenticatedSmartHTTPRepoServer(tb testing.TB, repo *git.Repository, username, password string) *smartHTTPRepoServer {
tb.Helper()
[s](
){s}
}
139 unmodified lines
w.Header().Set("Content-Type", fmt.Sprintf("application/x-%s-advertisement", service))
if _, err := w.Write(buf.Bytes()); err != nil {
s.t.Fatalf("write advertised refs: %v", err)
s.tb.Fatalf("write advertised refs: %v", err)
}
s.recordMetric(service, metricInfoRefs, 0, int64(buf.Len()), 0, 0)
21 unmodified lines
w.Header().Set("Content-Type", fmt.Sprintf("application/x-%s-advertisement", serviceUploadPack))
if _, err := w.Write(buf.Bytes()); err != nil {
s.t.Fatalf("write v2 advertised refs: %v", err)
s.tb.Fatalf("write v2 advertised refs: %v", err)
}
s.recordMetric(serviceUploadPack, metricInfoRefs, 0, int64(buf.Len()), 0, 0)
37 unmodified lines
w.Header().Set("Content-Type", fmt.Sprintf("application/x-%s-result", serviceUploadPack))
if _, err := w.Write(buf.Bytes()); err != nil {
s.t.Fatalf("write upload-pack response: %v", err)
s.tb.Fatalf("write upload-pack response: %v", err)
}
s.recordMetric(serviceUploadPack, metricPack, int64(len(body)), int64(buf.Len()), len(req.Wants), strings.Count(string(body), "have "))
45 unmodified lines
w.Header().Set("Content-Type", fmt.Sprintf("application/x-%s-result", serviceUploadPack))
if _, err := w.Write(buf.Bytes()); err != nil {
s.t.Fatalf("write v2 ls-refs response: %v", err)
s.tb.Fatalf("write v2 ls-refs response: %v", err)
}
s.recordMetric(serviceUploadPack, metricPack, int64(len(body)), int64(buf.Len()), 0, 0)
51 unmodified lines
if isConnectionCloseError(err) {
return
}
s.t.Fatalf("write v2 fetch response: %v", err)
s.tb.Fatalf("write v2 fetch response: %v", err)
}
s.recordMetric(serviceUploadPack, metricPack, int64(len(body)), int64(buf.Len()), len(wants), len(haves))
19 unmodified lines
w.Header().Set("Content-Type", fmt.Sprintf("application/x-%s-result", serviceReceivePack))
if _, err := w.Write(buf.Bytes()); err != nil {
s.t.Fatalf("write receive-pack rejection: %v", err)
s.tb.Fatalf("write receive-pack rejection: %v", err)
}
return
40 unmodified lines
w.Header().Set("Content-Type", fmt.Sprintf("application/x-%s-result", serviceReceivePack))
if _, err := w.Write(buf.Bytes()); err != nil {
s.t.Fatalf("write receive-pack command response: %v", err)
s.tb.Fatalf("write receive-pack command response: %v", err)
}
return
11 unmodified lines
w.Header().Set("Content-Type", fmt.Sprintf("application/x-%s-result", serviceReceivePack))
if _, err := w.Write(buf.Bytes()); err != nil {
s.t.Fatalf("write receive-pack response: %v", err)
s.tb.Fatalf("write receive-pack response: %v", err)
}
if err != nil {
return
Minternal/syncer/integration_test.go+18/-18