forked from TrueCloudLab/restic
Add TestResetRepository and BenchmarkCreateSnapshot
This commit is contained in:
parent
e9cddc0be5
commit
fd6c854a21
2 changed files with 29 additions and 0 deletions
|
@ -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 a new issue