extend test to do a double move and check symlink following
This commit is contained in:
parent
cbaffab9dd
commit
d6ace68540
@ -291,7 +291,7 @@ func (b *Blockstore) movingGC() error {
|
||||
dir := filepath.Dir(linkPath)
|
||||
path = filepath.Join(dir, name)
|
||||
}
|
||||
path = fmt.Sprintf("%s.%d", path, time.Now().Unix())
|
||||
path = fmt.Sprintf("%s.%d", path, time.Now().UnixNano())
|
||||
|
||||
log.Infof("moving blockstore from %s to %s", b.opts.Dir, path)
|
||||
|
||||
|
@ -163,6 +163,7 @@ func testMove(t *testing.T, optsF func(string) Options) {
|
||||
}
|
||||
|
||||
// now check that we have all the blocks in have and none in the deleted lists
|
||||
checkBlocks := func() {
|
||||
for _, blk := range have {
|
||||
has, err := db.Has(blk.Cid())
|
||||
if err != nil {
|
||||
@ -193,9 +194,13 @@ func testMove(t *testing.T, optsF func(string) Options) {
|
||||
t.Fatal("resurrected block")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
checkBlocks()
|
||||
|
||||
// check the basePath -- it should contain a directory with name db.{timestamp}, soft-linked
|
||||
// to db and nothing else
|
||||
checkPath := func() {
|
||||
entries, err := os.ReadDir(basePath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -231,6 +236,17 @@ func testMove(t *testing.T, optsF func(string) Options) {
|
||||
}
|
||||
}
|
||||
|
||||
checkPath()
|
||||
|
||||
// now do another FullGC to test the double move and following of symlinks
|
||||
if err := db.CollectGarbage(blockstore.WithFullGC(true)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
checkBlocks()
|
||||
checkPath()
|
||||
}
|
||||
|
||||
func TestMoveNoPrefix(t *testing.T) {
|
||||
testMove(t, DefaultOptions)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user