Commit 0fdfd342 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 52157648
// Copyright (C) 2018 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Copyright (C) 2018-2019 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
......@@ -160,6 +160,7 @@ func (txn *transaction) Abort() {
syncv[i].AfterCompletion(txn)
}()
}
wg.Wait()
// XXX return error?
}
......
// Copyright (C) 2018 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Copyright (C) 2018-2019 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
......@@ -98,7 +98,17 @@ func TestAbort(t *testing.T) {
dm.Modify()
// XXX +sync
/* XXX test Abort not waiting for AfterCompletion via tracetest (with injected δt shakes):
txn.RegisterSync(AfterCompletion: {eAfterCompletion})
go func() {
eAbortPre
txn.Abort()
eAbortPost
}()
expect(eAbortPre, eAfterCompletion, eAbortPost)
*/
txn.Abort()
if !(dm.nabort == 1 && txn.Status() == Aborted) {
t.Fatalf("abort: nabort=%d; txn.Status=%v", dm.nabort, txn.Status())
......
......@@ -187,6 +187,9 @@ func (cc *zcacheControl) WantEvict(obj IPersistent) bool {
// Persistent tests with storage.
//
// this test covers everything at application-level: Persistent, DB, Connection, LiveCache.
//
// XXX test for cache=y/n (raw data cache)
// XXX test both txn.Abort() and conn.Resync()
func TestPersistentDB(t *testing.T) {
X := exc.Raiseif
assert := require.New(t)
......@@ -213,6 +216,8 @@ func TestPersistentDB(t *testing.T) {
txn1, ctx1 := transaction.New(ctx)
conn1, err := db.Open(ctx1, &ConnOptions{}); X(err)
assert.Equal(conn1.db, db)
assert.Equal(conn1.txn, txn1)
// do not evict obj2 from live cache. obj1 is ok to be evicted.
zcache1 := conn1.Cache()
......@@ -273,6 +278,8 @@ func TestPersistentDB(t *testing.T) {
// new db connection should see the change
txn2, ctx2 := transaction.New(ctx)
conn2, err := db.Open(ctx2, &ConnOptions{}); X(err)
assert.Equal(conn2.db, db)
assert.Equal(conn2.txn, txn2)
assert.Equal(conn2.At(), at2)
xc2obj1, err := conn2.Get(ctx2, 101); X(err)
......@@ -308,7 +315,13 @@ func TestPersistentDB(t *testing.T) {
checkObj(obj1, conn1, 101, InvalidTid, GHOST, 0, nil)
checkObj(obj2, conn1, 102, at1, UPTODATE, 0, nil)
// txn1 completes - conn1 goes back to db pool
assert.Equal(conn1.txn, txn1)
txn1.Abort()
assert.Equal(conn1.txn, nil)
// XXX conn1.Resync -> c1obj2 invalidated
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment