mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 11:28:54 +00:00
Add TestResetRepository and BenchmarkCreateSnapshot
This commit is contained in:
parent
e9cddc0be5
commit
fd6c854a21
@ -184,3 +184,20 @@ func TestCreateSnapshot(t testing.TB, repo *repository.Repository, at time.Time,
|
||||
|
||||
return snapshot
|
||||
}
|
||||
|
||||
// TestResetRepository removes all packs and indexes from the repository.
|
||||
func TestResetRepository(t testing.TB, repo *repository.Repository) {
|
||||
done := make(chan struct{})
|
||||
defer close(done)
|
||||
|
||||
for _, tpe := range []backend.Type{backend.Snapshot, backend.Index, backend.Data} {
|
||||
for id := range repo.Backend().List(tpe, done) {
|
||||
err := repo.Backend().Remove(tpe, id)
|
||||
if err != nil {
|
||||
t.Errorf("removing %v (%v) failed: %v", id[0:12], tpe, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repo.SetIndex(repository.NewMasterIndex())
|
||||
}
|
||||
|
@ -47,3 +47,15 @@ func TestCreateSnapshot(t *testing.T) {
|
||||
|
||||
checker.TestCheckRepo(t, repo)
|
||||
}
|
||||
|
||||
func BenchmarkCreateSnapshot(b *testing.B) {
|
||||
repo, cleanup := repository.TestRepository(b)
|
||||
defer cleanup()
|
||||
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
restic.TestCreateSnapshot(b, repo, testSnapshotTime, testDepth)
|
||||
restic.TestResetRepository(b, repo)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user