wip: testing
parent
a3ca69101e
commit
32b0618505
17
database.go
17
database.go
|
@ -62,18 +62,23 @@ func (db *Database) Start() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Database) WALStatus() (ws WALStatus) {
|
func (db *Database) WALStatus() (ws WALStatus) {
|
||||||
ws.MaxID = db.kv.WALMaxSeqNum()
|
ws.MaxSeqNumKV = db.kv.WALMaxSeqNum()
|
||||||
ws.MaxAppliedID = db.kv.MaxSeqNum()
|
ws.MaxSeqNumWAL = db.kv.MaxSeqNum()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Database) Close() {
|
func (db *Database) Close() {
|
||||||
db.kv.Close()
|
if db.kv != nil {
|
||||||
db.lock.Close()
|
db.kv.Close()
|
||||||
|
db.kv = nil
|
||||||
|
}
|
||||||
|
if db.lock != nil {
|
||||||
|
db.lock.Close()
|
||||||
|
db.lock = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------
|
// ----------------------------------------------------------------------------
|
||||||
db.kv = kvstore.NewSecondary(root)-----------------------------------------------------------
|
|
||||||
|
|
||||||
func (db *Database) onStore(collection string, id uint64, data []byte) {
|
func (db *Database) onStore(collection string, id uint64, data []byte) {
|
||||||
c, ok := db.collections[collection]
|
c, ok := db.collections[collection]
|
||||||
|
|
|
@ -5,7 +5,7 @@ import "time"
|
||||||
func (db *Database) waitForWAL() {
|
func (db *Database) waitForWAL() {
|
||||||
for {
|
for {
|
||||||
status := db.WALStatus()
|
status := db.WALStatus()
|
||||||
if status.MaxAppliedID == status.MaxID {
|
if status.MaxSeqNumWAL == status.MaxSeqNumKV {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package mdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math/rand"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
os.Exit(m.Run())
|
||||||
|
}
|
Reference in New Issue