check: allow tests to only verify pack&index integrity

This commit is contained in:
Michael Eischer 2024-04-14 11:42:26 +02:00
parent 4c9a10ca37
commit 7ba5e95a82
3 changed files with 19 additions and 17 deletions

View File

@ -1430,7 +1430,7 @@ func TestArchiverSnapshot(t *testing.T) {
} }
TestEnsureSnapshot(t, repo, snapshotID, want) TestEnsureSnapshot(t, repo, snapshotID, want)
checker.TestCheckRepo(t, repo) checker.TestCheckRepo(t, repo, false)
// check that the snapshot contains the targets with absolute paths // check that the snapshot contains the targets with absolute paths
for i, target := range sn.Paths { for i, target := range sn.Paths {
@ -1590,7 +1590,7 @@ func TestArchiverSnapshotSelect(t *testing.T) {
} }
TestEnsureSnapshot(t, repo, snapshotID, want) TestEnsureSnapshot(t, repo, snapshotID, want)
checker.TestCheckRepo(t, repo) checker.TestCheckRepo(t, repo, false)
}) })
} }
} }
@ -1794,7 +1794,7 @@ func TestArchiverParent(t *testing.T) {
t.Logf("second backup saved as %v", secondSnapshotID.Str()) t.Logf("second backup saved as %v", secondSnapshotID.Str())
t.Logf("testfs: %v", testFS) t.Logf("testfs: %v", testFS)
checker.TestCheckRepo(t, repo) checker.TestCheckRepo(t, repo, false)
}) })
} }
} }
@ -1927,7 +1927,7 @@ func TestArchiverErrorReporting(t *testing.T) {
} }
TestEnsureSnapshot(t, repo, snapshotID, want) TestEnsureSnapshot(t, repo, snapshotID, want)
checker.TestCheckRepo(t, repo) checker.TestCheckRepo(t, repo, false)
}) })
} }
} }
@ -2288,7 +2288,7 @@ func TestMetadataChanged(t *testing.T) {
// make sure the content matches // make sure the content matches
TestEnsureFileContent(context.Background(), t, repo, "testfile", node3, files["testfile"].(TestFile)) TestEnsureFileContent(context.Background(), t, repo, "testfile", node3, files["testfile"].(TestFile))
checker.TestCheckRepo(t, repo) checker.TestCheckRepo(t, repo, false)
} }
func TestRacyFileSwap(t *testing.T) { func TestRacyFileSwap(t *testing.T) {

View File

@ -8,7 +8,7 @@ import (
) )
// TestCheckRepo runs the checker on repo. // TestCheckRepo runs the checker on repo.
func TestCheckRepo(t testing.TB, repo restic.Repository) { func TestCheckRepo(t testing.TB, repo restic.Repository, skipStructure bool) {
chkr := New(repo, true) chkr := New(repo, true)
hints, errs := chkr.LoadIndex(context.TODO(), nil) hints, errs := chkr.LoadIndex(context.TODO(), nil)
@ -33,18 +33,20 @@ func TestCheckRepo(t testing.TB, repo restic.Repository) {
t.Error(err) t.Error(err)
} }
// structure if !skipStructure {
errChan = make(chan error) // structure
go chkr.Structure(context.TODO(), nil, errChan) errChan = make(chan error)
go chkr.Structure(context.TODO(), nil, errChan)
for err := range errChan { for err := range errChan {
t.Error(err) t.Error(err)
} }
// unused blobs // unused blobs
blobs := chkr.UnusedBlobs(context.TODO()) blobs := chkr.UnusedBlobs(context.TODO())
if len(blobs) > 0 { if len(blobs) > 0 {
t.Errorf("unused blobs found: %v", blobs) t.Errorf("unused blobs found: %v", blobs)
}
} }
// read data // read data

View File

@ -45,7 +45,7 @@ func TestCreateSnapshot(t *testing.T) {
t.Fatalf("snapshot has zero tree ID") t.Fatalf("snapshot has zero tree ID")
} }
checker.TestCheckRepo(t, repo) checker.TestCheckRepo(t, repo, false)
} }
func BenchmarkTestCreateSnapshot(t *testing.B) { func BenchmarkTestCreateSnapshot(t *testing.B) {