Bound remote control object reads
This commit is contained in:
@@ -55,11 +55,11 @@ func TestCommittedRestoreReusesVerifiedManifestCandidate(t *testing.T) {
|
||||
if _, err := executeRestorePlan(context.Background(), cfg, current, plan, nil, fake); err != nil {
|
||||
t.Fatalf("executeRestorePlan() error = %v", err)
|
||||
}
|
||||
if got := fakeDownloadCount(fake, current.CurrentManifestKey); got != 1 {
|
||||
t.Fatalf("manifest downloads = %d, want one discovery transfer reused by restore", got)
|
||||
if got := fakeReadCount(fake, current.CurrentManifestKey); got != 1 {
|
||||
t.Fatalf("manifest reads = %d, want one discovery read reused by restore", got)
|
||||
}
|
||||
if got := fakeDownloadBytes(fake, current.CurrentManifestKey); got != int64(len(current.ManifestData)) {
|
||||
t.Fatalf("manifest bytes transferred = %d, want one verified candidate (%d)", got, len(current.ManifestData))
|
||||
if got := fakeDownloadCount(fake, current.CurrentManifestKey); got != 0 {
|
||||
t.Fatalf("manifest downloads = %d, want no temporary download", got)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,8 +77,8 @@ func TestCommittedRestoreRejectsChangedGenerationForVerifiedManifestCandidate(t
|
||||
if err == nil || !strings.Contains(err.Error(), "generation mismatch") {
|
||||
t.Fatalf("executeRestorePlan() error = %v, want generation mismatch", err)
|
||||
}
|
||||
if got := fakeDownloadCount(fake, current.CurrentManifestKey); got != 1 {
|
||||
t.Fatalf("manifest downloads = %d, want no second transfer for rejected candidate", got)
|
||||
if got := fakeReadCount(fake, current.CurrentManifestKey); got != 1 {
|
||||
t.Fatalf("manifest reads = %d, want no second transfer for rejected candidate", got)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,11 +292,11 @@ func remoteRestoreArtifact(fake *storage.FakeBackend, artifactType artifacts.Rem
|
||||
}
|
||||
}
|
||||
|
||||
func fakeDownloadBytes(fake *storage.FakeBackend, key string) int64 {
|
||||
var count int64
|
||||
for _, call := range fake.Downloads {
|
||||
func fakeReadCount(fake *storage.FakeBackend, key string) int {
|
||||
count := 0
|
||||
for _, call := range fake.Reads {
|
||||
if call.Key == key {
|
||||
count += call.Bytes
|
||||
count++
|
||||
}
|
||||
}
|
||||
return count
|
||||
|
||||
Reference in New Issue
Block a user