feat: Add additional test annotations (#8272)
* Annotate api,proxy_util,blockstore_badger, policy tests
* Annotate splitstore: bsbadger / markset
* Annotate splitstore feature
* Annotate union/timed blockstore tests
* Annotate openrpc, diff_adt tests
* Annotate error,drand,events tests
* Annotate predicates_test
* Fix annotations
* Annotate tscache, gen tests
* Annotate fundmanager test
* Annotate repub and selection tests
* Annotate statetree_test
* Annotate forks_test
* Annotate searchwait_test.go
* Fix duplicated @@ symbols
* Annotate chain stmgr/store tests
* Annotate more (types) tests
* More tests annotated
* Annotate conformance chaos actor tests
* Annotate more integration tests
* Annotate journal system tests
* Annotate more tests.
* Annotate gas,head buffer behaviors
* Fix markset annotations
* doc: test annotations for the markets dagstore wrapper
* Annotate miner_api test in dagstore
* Annotate more test files
* Remove bad annotations from fsrepo
* Annotate wdpost system
* Remove bad annotations
* Renamce "conformance" to "chaos_actor" tests
* doc: stm annotations for blockheader & election proof tests
* Annotate remaining "A" tests
* annotate: stm for error_test
* memrepo_test.go
* Annotate "b" file tests
* message_test.go
* doc: stm annotate for fsrepo_test
* Annotate "c" file tests
* Annotate "D" test files
* message_test.go
* doc: stm annotate for chain, node/config & client
* docs: stm annotate node_test
* Annotate u,v,wl tests
* doc: stm annotations for various test files
* Annotate "T" test files
* doc: stm annotate for proxy_util_test & policy_test
* doc: stm annotate for various tests
* doc: final few stm annotations
* Add mempool unit tests
* Add two more memPool Add tests
* Update submodules
* Add check function tests
* Add stm annotations, refactor test helper
* Annotate api,proxy_util,blockstore_badger, policy tests
* Annotate splitstore: bsbadger / markset
solving merge conflicts
* Annotate splitstore feature
* Annotate union/timed blockstore tests
* Annotate openrpc, diff_adt tests
* Annotate error,drand,events tests
* Annotate predicates_test
* Fix annotations
* Annotate tscache, gen tests
* Annotate fundmanager test
* Annotate statetree_test
* Annotate forks_test
* Annotate searchwait_test.go
* Fix duplicated @@ symbols
* Annotate chain stmgr/store tests
* Annotate more (types) tests
* More tests annotated
* Annotate conformance chaos actor tests
* Annotate more integration tests
* Annotate journal system tests
* Annotate more tests.
* Annotate gas,head buffer behaviors
solve merge conflict
* Fix markset annotations
* Annotate miner_api test in dagstore
* Annotate more test files
* doc: test annotations for the markets dagstore wrapper
* Annotate wdpost system
* Renamce "conformance" to "chaos_actor" tests
* Annotate remaining "A" tests
* doc: stm annotations for blockheader & election proof tests
* annotate: stm for error_test
* Annotate "b" file tests
* memrepo_test.go
* Annotate "c" file tests
* message_test.go
* Annotate "D" test files
* doc: stm annotate for fsrepo_test
* Annotate u,v,wl tests
* message_test.go
* doc: stm annotate for chain, node/config & client
* docs: stm annotate node_test
* Annotate "T" test files
* doc: stm annotations for various test files
* Add mempool unit tests
solve merge conflict
* doc: stm annotate for proxy_util_test & policy_test
* doc: stm annotate for various tests
* doc: final few stm annotations
* Add two more memPool Add tests
* Update submodules
* Add check function tests
solve conflict
* Add stm annotations, refactor test helper
solve merge conflict
* Change CLI test kinds to "unit"
* Fix double merged test
* Fix ccupgrade_test merge
* Fix lint issues
* Add stm annotation to types_Test
* Test vectors submodule
* Add file annotation to burn_test
Co-authored-by: Nikola Divic <divicnikola@gmail.com>
Co-authored-by: TheMenko <themenkoprojects@gmail.com>
2022-03-16 17:37:34 +00:00
|
|
|
//stm: #unit
|
2020-11-01 12:55:43 +00:00
|
|
|
package badgerbs
|
|
|
|
|
|
|
|
import (
|
2021-07-11 14:51:20 +00:00
|
|
|
"bytes"
|
2021-11-19 01:50:25 +00:00
|
|
|
"context"
|
2021-07-11 14:51:20 +00:00
|
|
|
"fmt"
|
2020-11-01 12:55:43 +00:00
|
|
|
"os"
|
2021-07-11 14:51:20 +00:00
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
2020-11-01 12:55:43 +00:00
|
|
|
"testing"
|
|
|
|
|
2020-11-02 13:32:07 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2021-07-11 14:51:20 +00:00
|
|
|
"golang.org/x/sync/errgroup"
|
|
|
|
|
|
|
|
blocks "github.com/ipfs/go-block-format"
|
|
|
|
cid "github.com/ipfs/go-cid"
|
2021-01-29 20:01:00 +00:00
|
|
|
|
|
|
|
"github.com/filecoin-project/lotus/blockstore"
|
2020-11-01 12:55:43 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestBadgerBlockstore(t *testing.T) {
|
feat: Add additional test annotations (#8272)
* Annotate api,proxy_util,blockstore_badger, policy tests
* Annotate splitstore: bsbadger / markset
* Annotate splitstore feature
* Annotate union/timed blockstore tests
* Annotate openrpc, diff_adt tests
* Annotate error,drand,events tests
* Annotate predicates_test
* Fix annotations
* Annotate tscache, gen tests
* Annotate fundmanager test
* Annotate repub and selection tests
* Annotate statetree_test
* Annotate forks_test
* Annotate searchwait_test.go
* Fix duplicated @@ symbols
* Annotate chain stmgr/store tests
* Annotate more (types) tests
* More tests annotated
* Annotate conformance chaos actor tests
* Annotate more integration tests
* Annotate journal system tests
* Annotate more tests.
* Annotate gas,head buffer behaviors
* Fix markset annotations
* doc: test annotations for the markets dagstore wrapper
* Annotate miner_api test in dagstore
* Annotate more test files
* Remove bad annotations from fsrepo
* Annotate wdpost system
* Remove bad annotations
* Renamce "conformance" to "chaos_actor" tests
* doc: stm annotations for blockheader & election proof tests
* Annotate remaining "A" tests
* annotate: stm for error_test
* memrepo_test.go
* Annotate "b" file tests
* message_test.go
* doc: stm annotate for fsrepo_test
* Annotate "c" file tests
* Annotate "D" test files
* message_test.go
* doc: stm annotate for chain, node/config & client
* docs: stm annotate node_test
* Annotate u,v,wl tests
* doc: stm annotations for various test files
* Annotate "T" test files
* doc: stm annotate for proxy_util_test & policy_test
* doc: stm annotate for various tests
* doc: final few stm annotations
* Add mempool unit tests
* Add two more memPool Add tests
* Update submodules
* Add check function tests
* Add stm annotations, refactor test helper
* Annotate api,proxy_util,blockstore_badger, policy tests
* Annotate splitstore: bsbadger / markset
solving merge conflicts
* Annotate splitstore feature
* Annotate union/timed blockstore tests
* Annotate openrpc, diff_adt tests
* Annotate error,drand,events tests
* Annotate predicates_test
* Fix annotations
* Annotate tscache, gen tests
* Annotate fundmanager test
* Annotate statetree_test
* Annotate forks_test
* Annotate searchwait_test.go
* Fix duplicated @@ symbols
* Annotate chain stmgr/store tests
* Annotate more (types) tests
* More tests annotated
* Annotate conformance chaos actor tests
* Annotate more integration tests
* Annotate journal system tests
* Annotate more tests.
* Annotate gas,head buffer behaviors
solve merge conflict
* Fix markset annotations
* Annotate miner_api test in dagstore
* Annotate more test files
* doc: test annotations for the markets dagstore wrapper
* Annotate wdpost system
* Renamce "conformance" to "chaos_actor" tests
* Annotate remaining "A" tests
* doc: stm annotations for blockheader & election proof tests
* annotate: stm for error_test
* Annotate "b" file tests
* memrepo_test.go
* Annotate "c" file tests
* message_test.go
* Annotate "D" test files
* doc: stm annotate for fsrepo_test
* Annotate u,v,wl tests
* message_test.go
* doc: stm annotate for chain, node/config & client
* docs: stm annotate node_test
* Annotate "T" test files
* doc: stm annotations for various test files
* Add mempool unit tests
solve merge conflict
* doc: stm annotate for proxy_util_test & policy_test
* doc: stm annotate for various tests
* doc: final few stm annotations
* Add two more memPool Add tests
* Update submodules
* Add check function tests
solve conflict
* Add stm annotations, refactor test helper
solve merge conflict
* Change CLI test kinds to "unit"
* Fix double merged test
* Fix ccupgrade_test merge
* Fix lint issues
* Add stm annotation to types_Test
* Test vectors submodule
* Add file annotation to burn_test
Co-authored-by: Nikola Divic <divicnikola@gmail.com>
Co-authored-by: TheMenko <themenkoprojects@gmail.com>
2022-03-16 17:37:34 +00:00
|
|
|
//stm: @SPLITSTORE_BADGER_PUT_001, @SPLITSTORE_BADGER_POOLED_STORAGE_KEY_001
|
|
|
|
//stm: @SPLITSTORE_BADGER_OPEN_001, @SPLITSTORE_BADGER_CLOSE_001
|
2020-11-01 12:55:43 +00:00
|
|
|
(&Suite{
|
|
|
|
NewBlockstore: newBlockstore(DefaultOptions),
|
|
|
|
OpenBlockstore: openBlockstore(DefaultOptions),
|
|
|
|
}).RunTests(t, "non_prefixed")
|
|
|
|
|
|
|
|
prefixed := func(path string) Options {
|
|
|
|
opts := DefaultOptions(path)
|
|
|
|
opts.Prefix = "/prefixed/"
|
|
|
|
return opts
|
|
|
|
}
|
|
|
|
|
|
|
|
(&Suite{
|
|
|
|
NewBlockstore: newBlockstore(prefixed),
|
|
|
|
OpenBlockstore: openBlockstore(prefixed),
|
|
|
|
}).RunTests(t, "prefixed")
|
|
|
|
}
|
|
|
|
|
2020-11-02 13:32:07 +00:00
|
|
|
func TestStorageKey(t *testing.T) {
|
feat: Add additional test annotations (#8272)
* Annotate api,proxy_util,blockstore_badger, policy tests
* Annotate splitstore: bsbadger / markset
* Annotate splitstore feature
* Annotate union/timed blockstore tests
* Annotate openrpc, diff_adt tests
* Annotate error,drand,events tests
* Annotate predicates_test
* Fix annotations
* Annotate tscache, gen tests
* Annotate fundmanager test
* Annotate repub and selection tests
* Annotate statetree_test
* Annotate forks_test
* Annotate searchwait_test.go
* Fix duplicated @@ symbols
* Annotate chain stmgr/store tests
* Annotate more (types) tests
* More tests annotated
* Annotate conformance chaos actor tests
* Annotate more integration tests
* Annotate journal system tests
* Annotate more tests.
* Annotate gas,head buffer behaviors
* Fix markset annotations
* doc: test annotations for the markets dagstore wrapper
* Annotate miner_api test in dagstore
* Annotate more test files
* Remove bad annotations from fsrepo
* Annotate wdpost system
* Remove bad annotations
* Renamce "conformance" to "chaos_actor" tests
* doc: stm annotations for blockheader & election proof tests
* Annotate remaining "A" tests
* annotate: stm for error_test
* memrepo_test.go
* Annotate "b" file tests
* message_test.go
* doc: stm annotate for fsrepo_test
* Annotate "c" file tests
* Annotate "D" test files
* message_test.go
* doc: stm annotate for chain, node/config & client
* docs: stm annotate node_test
* Annotate u,v,wl tests
* doc: stm annotations for various test files
* Annotate "T" test files
* doc: stm annotate for proxy_util_test & policy_test
* doc: stm annotate for various tests
* doc: final few stm annotations
* Add mempool unit tests
* Add two more memPool Add tests
* Update submodules
* Add check function tests
* Add stm annotations, refactor test helper
* Annotate api,proxy_util,blockstore_badger, policy tests
* Annotate splitstore: bsbadger / markset
solving merge conflicts
* Annotate splitstore feature
* Annotate union/timed blockstore tests
* Annotate openrpc, diff_adt tests
* Annotate error,drand,events tests
* Annotate predicates_test
* Fix annotations
* Annotate tscache, gen tests
* Annotate fundmanager test
* Annotate statetree_test
* Annotate forks_test
* Annotate searchwait_test.go
* Fix duplicated @@ symbols
* Annotate chain stmgr/store tests
* Annotate more (types) tests
* More tests annotated
* Annotate conformance chaos actor tests
* Annotate more integration tests
* Annotate journal system tests
* Annotate more tests.
* Annotate gas,head buffer behaviors
solve merge conflict
* Fix markset annotations
* Annotate miner_api test in dagstore
* Annotate more test files
* doc: test annotations for the markets dagstore wrapper
* Annotate wdpost system
* Renamce "conformance" to "chaos_actor" tests
* Annotate remaining "A" tests
* doc: stm annotations for blockheader & election proof tests
* annotate: stm for error_test
* Annotate "b" file tests
* memrepo_test.go
* Annotate "c" file tests
* message_test.go
* Annotate "D" test files
* doc: stm annotate for fsrepo_test
* Annotate u,v,wl tests
* message_test.go
* doc: stm annotate for chain, node/config & client
* docs: stm annotate node_test
* Annotate "T" test files
* doc: stm annotations for various test files
* Add mempool unit tests
solve merge conflict
* doc: stm annotate for proxy_util_test & policy_test
* doc: stm annotate for various tests
* doc: final few stm annotations
* Add two more memPool Add tests
* Update submodules
* Add check function tests
solve conflict
* Add stm annotations, refactor test helper
solve merge conflict
* Change CLI test kinds to "unit"
* Fix double merged test
* Fix ccupgrade_test merge
* Fix lint issues
* Add stm annotation to types_Test
* Test vectors submodule
* Add file annotation to burn_test
Co-authored-by: Nikola Divic <divicnikola@gmail.com>
Co-authored-by: TheMenko <themenkoprojects@gmail.com>
2022-03-16 17:37:34 +00:00
|
|
|
//stm: @SPLITSTORE_BADGER_OPEN_001, @SPLITSTORE_BADGER_CLOSE_001
|
|
|
|
//stm: @SPLITSTORE_BADGER_STORAGE_KEY_001
|
2020-11-02 13:32:07 +00:00
|
|
|
bs, _ := newBlockstore(DefaultOptions)(t)
|
|
|
|
bbs := bs.(*Blockstore)
|
|
|
|
defer bbs.Close() //nolint:errcheck
|
|
|
|
|
|
|
|
cid1 := blocks.NewBlock([]byte("some data")).Cid()
|
|
|
|
cid2 := blocks.NewBlock([]byte("more data")).Cid()
|
|
|
|
cid3 := blocks.NewBlock([]byte("a little more data")).Cid()
|
|
|
|
require.NotEqual(t, cid1, cid2) // sanity check
|
|
|
|
require.NotEqual(t, cid2, cid3) // sanity check
|
|
|
|
|
|
|
|
// nil slice; let StorageKey allocate for us.
|
|
|
|
k1 := bbs.StorageKey(nil, cid1)
|
|
|
|
require.Len(t, k1, 55)
|
|
|
|
require.True(t, cap(k1) == len(k1))
|
|
|
|
|
|
|
|
// k1's backing array is reused.
|
|
|
|
k2 := bbs.StorageKey(k1, cid2)
|
|
|
|
require.Len(t, k2, 55)
|
|
|
|
require.True(t, cap(k2) == len(k1))
|
|
|
|
|
|
|
|
// bring k2 to len=0, and verify that its backing array gets reused
|
|
|
|
// (i.e. k1 and k2 are overwritten)
|
|
|
|
k3 := bbs.StorageKey(k2[:0], cid3)
|
|
|
|
require.Len(t, k3, 55)
|
|
|
|
require.True(t, cap(k3) == len(k3))
|
|
|
|
|
|
|
|
// backing array of k1 and k2 has been modified, i.e. memory is shared.
|
|
|
|
require.Equal(t, k3, k1)
|
|
|
|
require.Equal(t, k3, k2)
|
|
|
|
}
|
|
|
|
|
2021-02-28 23:02:36 +00:00
|
|
|
func newBlockstore(optsSupplier func(path string) Options) func(tb testing.TB) (bs blockstore.BasicBlockstore, path string) {
|
|
|
|
return func(tb testing.TB) (bs blockstore.BasicBlockstore, path string) {
|
2020-11-01 12:55:43 +00:00
|
|
|
tb.Helper()
|
|
|
|
|
2022-03-11 06:27:36 +00:00
|
|
|
path = tb.TempDir()
|
2020-11-01 12:55:43 +00:00
|
|
|
|
|
|
|
db, err := Open(optsSupplier(path))
|
|
|
|
if err != nil {
|
|
|
|
tb.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return db, path
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-28 23:02:36 +00:00
|
|
|
func openBlockstore(optsSupplier func(path string) Options) func(tb testing.TB, path string) (bs blockstore.BasicBlockstore, err error) {
|
|
|
|
return func(tb testing.TB, path string) (bs blockstore.BasicBlockstore, err error) {
|
2020-11-01 12:55:43 +00:00
|
|
|
tb.Helper()
|
|
|
|
return Open(optsSupplier(path))
|
|
|
|
}
|
|
|
|
}
|
2021-07-11 14:51:20 +00:00
|
|
|
|
|
|
|
func testMove(t *testing.T, optsF func(string) Options) {
|
2021-12-17 09:42:09 +00:00
|
|
|
ctx := context.Background()
|
2022-03-11 06:27:36 +00:00
|
|
|
basePath := t.TempDir()
|
2021-07-11 14:51:20 +00:00
|
|
|
|
|
|
|
dbPath := filepath.Join(basePath, "db")
|
|
|
|
|
|
|
|
db, err := Open(optsF(dbPath))
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
defer db.Close() //nolint
|
|
|
|
|
|
|
|
var have []blocks.Block
|
|
|
|
var deleted []cid.Cid
|
|
|
|
|
|
|
|
// add some blocks
|
|
|
|
for i := 0; i < 10; i++ {
|
|
|
|
blk := blocks.NewBlock([]byte(fmt.Sprintf("some data %d", i)))
|
2021-11-19 01:50:25 +00:00
|
|
|
err := db.Put(ctx, blk)
|
2021-07-11 14:51:20 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
have = append(have, blk)
|
|
|
|
}
|
|
|
|
|
|
|
|
// delete some of them
|
|
|
|
for i := 5; i < 10; i++ {
|
|
|
|
c := have[i].Cid()
|
2021-11-19 01:50:25 +00:00
|
|
|
err := db.DeleteBlock(ctx, c)
|
2021-07-11 14:51:20 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
deleted = append(deleted, c)
|
|
|
|
}
|
|
|
|
have = have[:5]
|
|
|
|
|
|
|
|
// start a move concurrent with some more puts
|
|
|
|
g := new(errgroup.Group)
|
|
|
|
g.Go(func() error {
|
|
|
|
for i := 10; i < 1000; i++ {
|
|
|
|
blk := blocks.NewBlock([]byte(fmt.Sprintf("some data %d", i)))
|
2021-11-19 01:50:25 +00:00
|
|
|
err := db.Put(ctx, blk)
|
2021-07-11 14:51:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
have = append(have, blk)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
g.Go(func() error {
|
2021-07-27 06:50:44 +00:00
|
|
|
return db.CollectGarbage(blockstore.WithFullGC(true))
|
2021-07-11 14:51:20 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
err = g.Wait()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// now check that we have all the blocks in have and none in the deleted lists
|
2021-07-27 07:16:50 +00:00
|
|
|
checkBlocks := func() {
|
|
|
|
for _, blk := range have {
|
2021-11-19 01:50:25 +00:00
|
|
|
has, err := db.Has(ctx, blk.Cid())
|
2021-07-27 07:16:50 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2021-07-11 14:51:20 +00:00
|
|
|
|
2021-07-27 07:16:50 +00:00
|
|
|
if !has {
|
|
|
|
t.Fatal("missing block")
|
|
|
|
}
|
2021-07-11 14:51:20 +00:00
|
|
|
|
2021-11-19 01:50:25 +00:00
|
|
|
blk2, err := db.Get(ctx, blk.Cid())
|
2021-07-27 07:16:50 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2021-07-11 14:51:20 +00:00
|
|
|
|
2021-07-27 07:16:50 +00:00
|
|
|
if !bytes.Equal(blk.RawData(), blk2.RawData()) {
|
|
|
|
t.Fatal("data mismatch")
|
|
|
|
}
|
2021-07-11 14:51:20 +00:00
|
|
|
}
|
|
|
|
|
2021-07-27 07:16:50 +00:00
|
|
|
for _, c := range deleted {
|
2021-11-19 01:50:25 +00:00
|
|
|
has, err := db.Has(ctx, c)
|
2021-07-27 07:16:50 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2021-07-11 14:51:20 +00:00
|
|
|
|
2021-07-27 07:16:50 +00:00
|
|
|
if has {
|
|
|
|
t.Fatal("resurrected block")
|
|
|
|
}
|
2021-07-11 14:51:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-27 07:16:50 +00:00
|
|
|
checkBlocks()
|
|
|
|
|
2021-07-11 14:51:20 +00:00
|
|
|
// check the basePath -- it should contain a directory with name db.{timestamp}, soft-linked
|
|
|
|
// to db and nothing else
|
2021-07-27 07:16:50 +00:00
|
|
|
checkPath := func() {
|
|
|
|
entries, err := os.ReadDir(basePath)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2021-07-11 14:51:20 +00:00
|
|
|
|
2021-07-27 07:16:50 +00:00
|
|
|
if len(entries) != 2 {
|
|
|
|
t.Fatalf("too many entries; expected %d but got %d", 2, len(entries))
|
|
|
|
}
|
2021-07-11 14:51:20 +00:00
|
|
|
|
2021-07-27 07:16:50 +00:00
|
|
|
var haveDB, haveDBLink bool
|
|
|
|
for _, e := range entries {
|
|
|
|
if e.Name() == "db" {
|
|
|
|
if (e.Type() & os.ModeSymlink) == 0 {
|
|
|
|
t.Fatal("found db, but it's not a symlink")
|
|
|
|
}
|
|
|
|
haveDBLink = true
|
|
|
|
continue
|
2021-07-11 14:51:20 +00:00
|
|
|
}
|
2021-07-27 07:16:50 +00:00
|
|
|
if strings.HasPrefix(e.Name(), "db.") {
|
|
|
|
if !e.Type().IsDir() {
|
|
|
|
t.Fatal("found db prefix, but it's not a directory")
|
|
|
|
}
|
|
|
|
haveDB = true
|
|
|
|
continue
|
2021-07-11 14:51:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-27 07:16:50 +00:00
|
|
|
if !haveDB {
|
|
|
|
t.Fatal("db directory is missing")
|
|
|
|
}
|
|
|
|
if !haveDBLink {
|
|
|
|
t.Fatal("db link is missing")
|
|
|
|
}
|
2021-07-11 14:51:20 +00:00
|
|
|
}
|
2021-07-27 07:16:50 +00:00
|
|
|
|
|
|
|
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)
|
2021-07-11 14:51:20 +00:00
|
|
|
}
|
2021-07-27 07:16:50 +00:00
|
|
|
|
|
|
|
checkBlocks()
|
|
|
|
checkPath()
|
2021-07-28 08:56:35 +00:00
|
|
|
|
|
|
|
// reopen the db to make sure our relative link works:
|
|
|
|
err = db.Close()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
db, err = Open(optsF(dbPath))
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// db.Close() is already deferred
|
|
|
|
|
|
|
|
checkBlocks()
|
2021-07-11 14:51:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestMoveNoPrefix(t *testing.T) {
|
feat: Add additional test annotations (#8272)
* Annotate api,proxy_util,blockstore_badger, policy tests
* Annotate splitstore: bsbadger / markset
* Annotate splitstore feature
* Annotate union/timed blockstore tests
* Annotate openrpc, diff_adt tests
* Annotate error,drand,events tests
* Annotate predicates_test
* Fix annotations
* Annotate tscache, gen tests
* Annotate fundmanager test
* Annotate repub and selection tests
* Annotate statetree_test
* Annotate forks_test
* Annotate searchwait_test.go
* Fix duplicated @@ symbols
* Annotate chain stmgr/store tests
* Annotate more (types) tests
* More tests annotated
* Annotate conformance chaos actor tests
* Annotate more integration tests
* Annotate journal system tests
* Annotate more tests.
* Annotate gas,head buffer behaviors
* Fix markset annotations
* doc: test annotations for the markets dagstore wrapper
* Annotate miner_api test in dagstore
* Annotate more test files
* Remove bad annotations from fsrepo
* Annotate wdpost system
* Remove bad annotations
* Renamce "conformance" to "chaos_actor" tests
* doc: stm annotations for blockheader & election proof tests
* Annotate remaining "A" tests
* annotate: stm for error_test
* memrepo_test.go
* Annotate "b" file tests
* message_test.go
* doc: stm annotate for fsrepo_test
* Annotate "c" file tests
* Annotate "D" test files
* message_test.go
* doc: stm annotate for chain, node/config & client
* docs: stm annotate node_test
* Annotate u,v,wl tests
* doc: stm annotations for various test files
* Annotate "T" test files
* doc: stm annotate for proxy_util_test & policy_test
* doc: stm annotate for various tests
* doc: final few stm annotations
* Add mempool unit tests
* Add two more memPool Add tests
* Update submodules
* Add check function tests
* Add stm annotations, refactor test helper
* Annotate api,proxy_util,blockstore_badger, policy tests
* Annotate splitstore: bsbadger / markset
solving merge conflicts
* Annotate splitstore feature
* Annotate union/timed blockstore tests
* Annotate openrpc, diff_adt tests
* Annotate error,drand,events tests
* Annotate predicates_test
* Fix annotations
* Annotate tscache, gen tests
* Annotate fundmanager test
* Annotate statetree_test
* Annotate forks_test
* Annotate searchwait_test.go
* Fix duplicated @@ symbols
* Annotate chain stmgr/store tests
* Annotate more (types) tests
* More tests annotated
* Annotate conformance chaos actor tests
* Annotate more integration tests
* Annotate journal system tests
* Annotate more tests.
* Annotate gas,head buffer behaviors
solve merge conflict
* Fix markset annotations
* Annotate miner_api test in dagstore
* Annotate more test files
* doc: test annotations for the markets dagstore wrapper
* Annotate wdpost system
* Renamce "conformance" to "chaos_actor" tests
* Annotate remaining "A" tests
* doc: stm annotations for blockheader & election proof tests
* annotate: stm for error_test
* Annotate "b" file tests
* memrepo_test.go
* Annotate "c" file tests
* message_test.go
* Annotate "D" test files
* doc: stm annotate for fsrepo_test
* Annotate u,v,wl tests
* message_test.go
* doc: stm annotate for chain, node/config & client
* docs: stm annotate node_test
* Annotate "T" test files
* doc: stm annotations for various test files
* Add mempool unit tests
solve merge conflict
* doc: stm annotate for proxy_util_test & policy_test
* doc: stm annotate for various tests
* doc: final few stm annotations
* Add two more memPool Add tests
* Update submodules
* Add check function tests
solve conflict
* Add stm annotations, refactor test helper
solve merge conflict
* Change CLI test kinds to "unit"
* Fix double merged test
* Fix ccupgrade_test merge
* Fix lint issues
* Add stm annotation to types_Test
* Test vectors submodule
* Add file annotation to burn_test
Co-authored-by: Nikola Divic <divicnikola@gmail.com>
Co-authored-by: TheMenko <themenkoprojects@gmail.com>
2022-03-16 17:37:34 +00:00
|
|
|
//stm: @SPLITSTORE_BADGER_OPEN_001, @SPLITSTORE_BADGER_CLOSE_001
|
|
|
|
//stm: @SPLITSTORE_BADGER_PUT_001, @SPLITSTORE_BADGER_POOLED_STORAGE_KEY_001
|
|
|
|
//stm: @SPLITSTORE_BADGER_DELETE_001, @SPLITSTORE_BADGER_COLLECT_GARBAGE_001
|
2021-07-11 14:51:20 +00:00
|
|
|
testMove(t, DefaultOptions)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMoveWithPrefix(t *testing.T) {
|
feat: Add additional test annotations (#8272)
* Annotate api,proxy_util,blockstore_badger, policy tests
* Annotate splitstore: bsbadger / markset
* Annotate splitstore feature
* Annotate union/timed blockstore tests
* Annotate openrpc, diff_adt tests
* Annotate error,drand,events tests
* Annotate predicates_test
* Fix annotations
* Annotate tscache, gen tests
* Annotate fundmanager test
* Annotate repub and selection tests
* Annotate statetree_test
* Annotate forks_test
* Annotate searchwait_test.go
* Fix duplicated @@ symbols
* Annotate chain stmgr/store tests
* Annotate more (types) tests
* More tests annotated
* Annotate conformance chaos actor tests
* Annotate more integration tests
* Annotate journal system tests
* Annotate more tests.
* Annotate gas,head buffer behaviors
* Fix markset annotations
* doc: test annotations for the markets dagstore wrapper
* Annotate miner_api test in dagstore
* Annotate more test files
* Remove bad annotations from fsrepo
* Annotate wdpost system
* Remove bad annotations
* Renamce "conformance" to "chaos_actor" tests
* doc: stm annotations for blockheader & election proof tests
* Annotate remaining "A" tests
* annotate: stm for error_test
* memrepo_test.go
* Annotate "b" file tests
* message_test.go
* doc: stm annotate for fsrepo_test
* Annotate "c" file tests
* Annotate "D" test files
* message_test.go
* doc: stm annotate for chain, node/config & client
* docs: stm annotate node_test
* Annotate u,v,wl tests
* doc: stm annotations for various test files
* Annotate "T" test files
* doc: stm annotate for proxy_util_test & policy_test
* doc: stm annotate for various tests
* doc: final few stm annotations
* Add mempool unit tests
* Add two more memPool Add tests
* Update submodules
* Add check function tests
* Add stm annotations, refactor test helper
* Annotate api,proxy_util,blockstore_badger, policy tests
* Annotate splitstore: bsbadger / markset
solving merge conflicts
* Annotate splitstore feature
* Annotate union/timed blockstore tests
* Annotate openrpc, diff_adt tests
* Annotate error,drand,events tests
* Annotate predicates_test
* Fix annotations
* Annotate tscache, gen tests
* Annotate fundmanager test
* Annotate statetree_test
* Annotate forks_test
* Annotate searchwait_test.go
* Fix duplicated @@ symbols
* Annotate chain stmgr/store tests
* Annotate more (types) tests
* More tests annotated
* Annotate conformance chaos actor tests
* Annotate more integration tests
* Annotate journal system tests
* Annotate more tests.
* Annotate gas,head buffer behaviors
solve merge conflict
* Fix markset annotations
* Annotate miner_api test in dagstore
* Annotate more test files
* doc: test annotations for the markets dagstore wrapper
* Annotate wdpost system
* Renamce "conformance" to "chaos_actor" tests
* Annotate remaining "A" tests
* doc: stm annotations for blockheader & election proof tests
* annotate: stm for error_test
* Annotate "b" file tests
* memrepo_test.go
* Annotate "c" file tests
* message_test.go
* Annotate "D" test files
* doc: stm annotate for fsrepo_test
* Annotate u,v,wl tests
* message_test.go
* doc: stm annotate for chain, node/config & client
* docs: stm annotate node_test
* Annotate "T" test files
* doc: stm annotations for various test files
* Add mempool unit tests
solve merge conflict
* doc: stm annotate for proxy_util_test & policy_test
* doc: stm annotate for various tests
* doc: final few stm annotations
* Add two more memPool Add tests
* Update submodules
* Add check function tests
solve conflict
* Add stm annotations, refactor test helper
solve merge conflict
* Change CLI test kinds to "unit"
* Fix double merged test
* Fix ccupgrade_test merge
* Fix lint issues
* Add stm annotation to types_Test
* Test vectors submodule
* Add file annotation to burn_test
Co-authored-by: Nikola Divic <divicnikola@gmail.com>
Co-authored-by: TheMenko <themenkoprojects@gmail.com>
2022-03-16 17:37:34 +00:00
|
|
|
//stm: @SPLITSTORE_BADGER_OPEN_001, @SPLITSTORE_BADGER_CLOSE_001
|
|
|
|
//stm: @SPLITSTORE_BADGER_PUT_001, @SPLITSTORE_BADGER_POOLED_STORAGE_KEY_001
|
|
|
|
//stm: @SPLITSTORE_BADGER_DELETE_001, @SPLITSTORE_BADGER_COLLECT_GARBAGE_001
|
2021-07-11 14:51:20 +00:00
|
|
|
testMove(t, func(path string) Options {
|
|
|
|
opts := DefaultOptions(path)
|
|
|
|
opts.Prefix = "/prefixed/"
|
|
|
|
return opts
|
|
|
|
})
|
|
|
|
}
|