Commit 4ff147d1 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent dfb82ecc
...@@ -22,7 +22,10 @@ from wendelin.lib.testing import getTestDB ...@@ -22,7 +22,10 @@ from wendelin.lib.testing import getTestDB
from wendelin.bigfile.file_zodb import ZBigFile from wendelin.bigfile.file_zodb import ZBigFile
from wendelin.bigfile.tests.test_filezodb import blksize from wendelin.bigfile.tests.test_filezodb import blksize
from wendelin import wcfs from wendelin import wcfs
import transaction import transaction
from persistent import Persistent
from persistent.timestamp import TimeStamp
import os, os.path, subprocess import os, os.path, subprocess
from pytest import raises from pytest import raises
...@@ -62,6 +65,11 @@ def readfile(path): ...@@ -62,6 +65,11 @@ def readfile(path):
with open(path) as f: with open(path) as f:
return f.read() return f.read()
# ttime converts tid to transaction commit time.
def ttime(tid):
return TimeStamp(tid).timeTime()
# check that zurl does not change from one open to another storage open. # check that zurl does not change from one open to another storage open.
def test_zurlstable(): def test_zurlstable():
for i in range(10): for i in range(10):
...@@ -106,10 +114,18 @@ def test_join_autostart(): ...@@ -106,10 +114,18 @@ def test_join_autostart():
def test_bigfile_empty(): def test_bigfile_empty():
root = testdb.dbopen() root = testdb.dbopen()
root['zfile'] = f = ZBigFile(blksize) root['zfile'] = f = ZBigFile(blksize)
# NOTE there is no clean way to retrieve tid of just committed transaction
# we'll be using last._p_serial as workaround.
root['last'] = last = Persistent()
transaction.commit() transaction.commit()
tid1 = last._p_serial
root['aaa'] = 'bbb' last._p_changed = 1
transaction.commit() transaction.commit()
tid2 = last._p_serial
assert ttime(tid2) > ttime(tid1)
wc = wcfs.join(testzurl, autostart=True) wc = wcfs.join(testzurl, autostart=True)
...@@ -117,10 +133,11 @@ def test_bigfile_empty(): ...@@ -117,10 +133,11 @@ def test_bigfile_empty():
fpath = "%s/bigfile/%s" % (wc.mountpoint, f._p_oid.encode('hex')) fpath = "%s/bigfile/%s" % (wc.mountpoint, f._p_oid.encode('hex'))
os.mkdir(fpath) os.mkdir(fpath)
os.stat(fpath + "/head/data") st = os.stat(fpath + "/head/data")
assert st.st_size == 0
assert st.st_mtime == ttime(tid1)
# XXX size(head/data) = 0 assert readfile(fpath + "/head/at") == 'txn2'
# XXX mtime(head/data) ~= last txn that changed bigdile
# XXX head/at = last txn of whole db # XXX head/at = last txn of whole db
......
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