Fix transfer tests involving sqlite memory storage

This commit is contained in:
Matt Joiner 2021-01-19 15:10:33 +11:00
parent b69bb34eaf
commit beb9ec8ffe
2 changed files with 23 additions and 13 deletions

View File

@ -147,8 +147,8 @@ func initSchema(conn conn, pageSize int, triggers bool) error {
type NewPiecesStorageOpts struct {
NewPoolOpts
ProvOpts func(*ProviderOpts)
storage.ResourcePiecesOpts
ProvOpts func(*ProviderOpts)
StorageOpts func(*storage.ResourcePiecesOpts)
}
// A convenience function that creates a connection pool, resource provider, and a pieces storage
@ -166,7 +166,13 @@ func NewPiecesStorage(opts NewPiecesStorageOpts) (_ storage.ClientImplCloser, er
conns.Close()
return
}
store := storage.NewResourcePiecesOpts(prov, opts.ResourcePiecesOpts)
storageOpts := storage.ResourcePiecesOpts{
NoSizedPuts: provOpts.NoConcurrentBlobReads,
}
if f := opts.StorageOpts; f != nil {
f(&storageOpts)
}
store := storage.NewResourcePiecesOpts(prov, storageOpts)
return struct {
storage.ClientImpl
io.Closer

View File

@ -278,11 +278,11 @@ func TestClientTransferSmallCacheDefaultReadahead(t *testing.T) {
testClientTransferSmallCache(t, false, -1)
}
func sqliteClientStorageFactory(connOptsMaker func(dataDir string) sqliteStorage.NewPoolOpts) storageFactory {
func sqliteClientStorageFactory(optsMaker func(dataDir string) sqliteStorage.NewPiecesStorageOpts) storageFactory {
return func(dataDir string) storage.ClientImplCloser {
connOpts := connOptsMaker(dataDir)
//log.Printf("opening sqlite db: %#v", connOpts)
ret, err := sqliteStorage.NewPiecesStorage(sqliteStorage.NewPiecesStorageOpts{NewPoolOpts: connOpts})
opts := optsMaker(dataDir)
//log.Printf("opening sqlite db: %#v", opts)
ret, err := sqliteStorage.NewPiecesStorage(opts)
if err != nil {
panic(err)
}
@ -300,14 +300,18 @@ func TestClientTransferVarious(t *testing.T) {
Wrapper: fileCachePieceResourceStorage,
})},
{"Boltdb", storage.NewBoltDB},
{"SqliteFile", sqliteClientStorageFactory(func(dataDir string) sqliteStorage.NewPoolOpts {
return sqliteStorage.NewPoolOpts{
Path: filepath.Join(dataDir, "sqlite.db"),
{"SqliteFile", sqliteClientStorageFactory(func(dataDir string) sqliteStorage.NewPiecesStorageOpts {
return sqliteStorage.NewPiecesStorageOpts{
NewPoolOpts: sqliteStorage.NewPoolOpts{
Path: filepath.Join(dataDir, "sqlite.db"),
},
}
})},
{"SqliteMemory", sqliteClientStorageFactory(func(dataDir string) sqliteStorage.NewPoolOpts {
return sqliteStorage.NewPoolOpts{
Memory: true,
{"SqliteMemory", sqliteClientStorageFactory(func(dataDir string) sqliteStorage.NewPiecesStorageOpts {
return sqliteStorage.NewPiecesStorageOpts{
NewPoolOpts: sqliteStorage.NewPoolOpts{
Memory: true,
},
}
})},
} {