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

.

parent dfb82ecc
......@@ -22,7 +22,10 @@ from wendelin.lib.testing import getTestDB
from wendelin.bigfile.file_zodb import ZBigFile
from wendelin.bigfile.tests.test_filezodb import blksize
from wendelin import wcfs
import transaction
from persistent import Persistent
from persistent.timestamp import TimeStamp
import os, os.path, subprocess
from pytest import raises
......@@ -62,6 +65,11 @@ def readfile(path):
with open(path) as f:
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.
def test_zurlstable():
for i in range(10):
......@@ -106,10 +114,18 @@ def test_join_autostart():
def test_bigfile_empty():
root = testdb.dbopen()
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()
tid1 = last._p_serial
root['aaa'] = 'bbb'
last._p_changed = 1
transaction.commit()
tid2 = last._p_serial
assert ttime(tid2) > ttime(tid1)
wc = wcfs.join(testzurl, autostart=True)
......@@ -117,10 +133,11 @@ def test_bigfile_empty():
fpath = "%s/bigfile/%s" % (wc.mountpoint, f._p_oid.encode('hex'))
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
# XXX mtime(head/data) ~= last txn that changed bigdile
assert readfile(fpath + "/head/at") == 'txn2'
# 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