nim-datastore/tests/datastore/testthreadproxyds.nim

81 lines
1.8 KiB
Nim
Raw Normal View History

2023-08-24 19:51:04 -07:00
import std/options
import std/sequtils
import std/os
2023-09-13 14:43:25 -06:00
import std/cpuinfo
2023-08-28 21:45:55 -07:00
import std/algorithm
2023-09-14 17:47:37 -06:00
import std/importutils
2023-08-24 19:51:04 -07:00
2023-09-07 17:33:33 -06:00
import pkg/asynctest
2023-08-24 19:51:04 -07:00
import pkg/chronos
import pkg/stew/results
import pkg/stew/byteutils
2023-09-08 15:09:15 -06:00
import pkg/taskpools
2023-09-14 17:47:37 -06:00
import pkg/questionable/results
2023-08-24 19:51:04 -07:00
2023-09-13 14:43:25 -06:00
import pkg/datastore/sql
2023-09-14 17:47:37 -06:00
import pkg/datastore/fsds
import pkg/datastore/threads/threadproxyds {.all.}
2023-08-24 19:51:04 -07:00
import ./dscommontests
2023-09-13 14:43:25 -06:00
import ./querycommontests
2023-08-24 19:51:04 -07:00
2023-09-14 17:47:37 -06:00
suite "Test Basic ThreadDatastore with SQLite":
2023-08-24 19:51:04 -07:00
2023-08-28 21:56:29 -07:00
var
2023-09-14 17:47:37 -06:00
sqlStore: Datastore
2023-09-08 15:09:15 -06:00
ds: ThreadDatastore
2023-09-14 17:47:37 -06:00
taskPool: Taskpool
2023-08-28 21:56:29 -07:00
key = Key.init("/a/b").tryGet()
bytes = "some bytes".toBytes
otherBytes = "some other bytes".toBytes
2023-08-24 19:51:04 -07:00
2023-08-28 21:56:29 -07:00
setupAll:
2023-09-14 17:47:37 -06:00
sqlStore = SQLiteDatastore.new(Memory).tryGet()
2023-09-13 14:43:25 -06:00
taskPool = Taskpool.new(countProcessors() * 2)
2023-09-14 17:47:37 -06:00
ds = ThreadDatastore.new(sqlStore, taskPool).tryGet()
2023-08-24 19:51:04 -07:00
2023-08-28 21:56:29 -07:00
teardownAll:
2023-09-13 14:43:25 -06:00
(await ds.close()).tryGet()
taskPool.shutdown()
2023-08-24 19:51:04 -07:00
2023-08-28 22:18:08 -07:00
basicStoreTests(ds, key, bytes, otherBytes)
2023-09-14 18:08:22 -06:00
suite "Test Query ThreadDatastore with SQLite":
var
sqlStore: Datastore
ds: ThreadDatastore
taskPool: Taskpool
key = Key.init("/a/b").tryGet()
bytes = "some bytes".toBytes
otherBytes = "some other bytes".toBytes
setup:
sqlStore = SQLiteDatastore.new(Memory).tryGet()
taskPool = Taskpool.new(countProcessors() * 2)
ds = ThreadDatastore.new(sqlStore, taskPool).tryGet()
teardown:
(await ds.close()).tryGet()
taskPool.shutdown()
2023-09-14 18:05:58 -06:00
queryTests(ds, true)
2023-08-24 19:51:04 -07:00
2023-09-14 18:25:16 -06:00
# TODO: needs a per key lock to work
2023-09-14 17:47:37 -06:00
# suite "Test Basic ThreadDatastore with fsds":
2023-08-24 19:51:04 -07:00
2023-09-14 17:47:37 -06:00
# let
# path = currentSourcePath() # get this file's name
# basePath = "tests_data"
# basePathAbs = path.parentDir / basePath
# key = Key.init("/a/b").tryGet()
# bytes = "some bytes".toBytes
# otherBytes = "some other bytes".toBytes
2023-08-24 19:51:04 -07:00
2023-09-14 17:47:37 -06:00
# var
# fsStore: FSDatastore
# ds: ThreadDatastore
# taskPool: Taskpool
2023-08-29 17:00:11 -07:00