19fa760604
CI / test (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
Thread Safety: - Add lock to BTreeIndex (insert/get/scan/remove/contains) - Add lock to InvertedIndex (addDocument/removeDocument/search/bm25/tfidf/fuzzy/regex) - Add ctxLock to ExecutionContext for DDL/schema metadata, autoIncCounters, sequences - Deep-copy sessionVars in cloneForConnection() to isolate per-connection state - Fix activeConnections check-then-act race with Lock Wire Protocol Hardening: - Fix RangeDefect in deserializeValue for invalid FieldKind bytes - Fix IndexDefect in fkFloat32/fkFloat64 by reusing readUint32/readUint64 - Fix int32/int64 cast from uint32/uint64 to use cast[] instead of constructor - Fix parseHeader to validate MsgKind instead of holey enum cast Property-Based Tests (tests/prop_test.nim): - 8 invariants for evalExprValue: literal types, commutativity, identity, double negation, NULL propagation Wire Protocol Fuzz (tests/fuzz_test.nim): - 7 fuzz tests: random bytes deserialization, truncated buffers, MsgKind casts, parseHeader logic, message roundtrips NimForum Adapter Smoke Test (tests/nimforum_smoke_test.nim): - Full TCP server lifecycle with adapter CRUD and parameterized queries Test Results: 423 tests pass, 0 failures
70 lines
2.0 KiB
Nim
70 lines
2.0 KiB
Nim
## NimForum Adapter Smoke Test
|
|
import std/unittest
|
|
import std/osproc
|
|
import std/os
|
|
import std/strutils
|
|
import std/strtabs
|
|
import std/times
|
|
|
|
import ../adaptors/nim/baradb_sqlite as sqlite
|
|
|
|
suite "NimForum Adapter Smoke Test":
|
|
var serverProcess: Process
|
|
var port: int
|
|
var dataDir: string
|
|
|
|
setup:
|
|
port = 35000 + (getTime().toUnix.int mod 10000)
|
|
dataDir = getTempDir() / "baradb_nimforum_" & $port
|
|
createDir(dataDir)
|
|
var env = newStringTable()
|
|
for key, val in envPairs():
|
|
env[key] = val
|
|
env["BARADB_PORT"] = $port
|
|
env["BARADB_DATA_DIR"] = dataDir
|
|
env["BARADB_LOG_LEVEL"] = "error"
|
|
serverProcess = startProcess("./build/baradadb", env=env, options={poStdErrToStdOut, poDaemon})
|
|
sleep(800)
|
|
|
|
teardown:
|
|
if serverProcess != nil:
|
|
serverProcess.terminate()
|
|
discard serverProcess.waitForExit()
|
|
removeDir(dataDir)
|
|
|
|
test "Adapter basic CRUD over TCP":
|
|
var db = open("127.0.0.1:" & $port, "", "", "default")
|
|
|
|
db.exec(sql"CREATE TABLE nf_test (id INT PRIMARY KEY, name STRING)")
|
|
db.exec(sql"INSERT INTO nf_test (id, name) VALUES (1, 'hello')")
|
|
db.exec(sql"INSERT INTO nf_test (id, name) VALUES (2, 'world')")
|
|
|
|
let rows = db.getAllRows(sql"SELECT * FROM nf_test")
|
|
check rows.len == 2
|
|
|
|
let row = db.getRow(sql"SELECT * FROM nf_test WHERE id = 1")
|
|
check row.len == 2
|
|
check row[0] == "1"
|
|
check row[1] == "hello"
|
|
|
|
let val = db.getValue(sql"SELECT name FROM nf_test WHERE id = 2")
|
|
check val == "world"
|
|
|
|
let cnt = db.getValue(sql"SELECT count(*) FROM nf_test")
|
|
check cnt == "2"
|
|
|
|
db.close()
|
|
|
|
test "Adapter parameterized queries":
|
|
var db = open("127.0.0.1:" & $port, "", "", "default")
|
|
|
|
db.exec(sql"CREATE TABLE nf_params (id INT PRIMARY KEY, val STRING)")
|
|
db.exec(sql"INSERT INTO nf_params (id, val) VALUES (?, ?)", 10, "ten")
|
|
db.exec(sql"INSERT INTO nf_params (id, val) VALUES (?, ?)", 20, "twenty")
|
|
|
|
let row = db.getRow(sql"SELECT val FROM nf_params WHERE id = ?", 10)
|
|
check row.len >= 1
|
|
check row[row.len - 1] == "ten"
|
|
|
|
db.close()
|