Commit 0875dbee authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f778db65
...@@ -36,6 +36,10 @@ from golang import func, method, defer ...@@ -36,6 +36,10 @@ from golang import func, method, defer
from zodbtools.util import ashex as h, fromhex from zodbtools.util import ashex as h, fromhex
from pytest import raises from pytest import raises
# setup:
# - create test database, compute zurl and mountpoint for wcfs
# - at every test: make sure wcfs is not running before & after the test.
testdb = None testdb = None
testzurl = None # URL of testdb testzurl = None # URL of testdb
testmntpt = None # wcfs is mounted here testmntpt = None # wcfs is mounted here
...@@ -66,21 +70,7 @@ def teardown_function(f): ...@@ -66,21 +70,7 @@ def teardown_function(f):
os.rmdir(testmntpt) os.rmdir(testmntpt)
# readfile reads file @ path. # ---- tests ----
def readfile(path):
with open(path) as f:
return f.read()
# tidtime converts tid to transaction commit time.
def tidtime(tid):
t = TimeStamp(tid).timeTime()
# ZODB/py vs ZODB/go time resolution is not better than 1µs
# see e.g. https://lab.nexedi.com/kirr/neo/commit/9112f21e
#
# NOTE pytest.approx supports only ==, not e.g. <, so we use plain round.
return round(t, 6)
# 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():
...@@ -90,6 +80,7 @@ def test_zurlstable(): ...@@ -90,6 +80,7 @@ def test_zurlstable():
zstor.close() zstor.close()
assert zurl == testzurl assert zurl == testzurl
# test that join works.
@func @func
def test_join(): def test_join():
zurl = testzurl zurl = testzurl
...@@ -107,6 +98,7 @@ def test_join(): ...@@ -107,6 +98,7 @@ def test_join():
defer(wc2.close) defer(wc2.close)
assert wc2.mountpoint == wc.mountpoint assert wc2.mountpoint == wc.mountpoint
# test that join(autostart=y) works.
@func @func
def test_join_autostart(): def test_join_autostart():
zurl = testzurl zurl = testzurl
...@@ -121,7 +113,8 @@ def test_join_autostart(): ...@@ -121,7 +113,8 @@ def test_join_autostart():
assert os.path.isdir(wc.mountpoint + "/head/bigfile") assert os.path.isdir(wc.mountpoint + "/head/bigfile")
# XXX parametrize zblk0, zblk1 # XXX test
# XXX parametrize zblk0, zblk1 XXX or just rely on tox?
@func @func
def test_wcfs(): def test_wcfs():
root = testdb.dbopen() root = testdb.dbopen()
...@@ -204,8 +197,6 @@ def test_wcfs(): ...@@ -204,8 +197,6 @@ def test_wcfs():
s = b"hello world" s = b"hello world"
memcpy(vma, s) memcpy(vma, s)
print("\n\n\n")
#import time; time.sleep(2)
commit() commit()
wcsync() # sync wcfs to ZODB wcsync() # sync wcfs to ZODB
...@@ -279,3 +270,25 @@ def test_wcfs(): ...@@ -279,3 +270,25 @@ def test_wcfs():
# TODO pagecache state after loading (via mincore) # TODO pagecache state after loading (via mincore)
def test_wcfs_invproto():
# XXX
pass
# ---- misc ---
# readfile reads file @ path.
def readfile(path):
with open(path) as f:
return f.read()
# tidtime converts tid to transaction commit time.
def tidtime(tid):
t = TimeStamp(tid).timeTime()
# ZODB/py vs ZODB/go time resolution is not better than 1µs
# see e.g. https://lab.nexedi.com/kirr/neo/commit/9112f21e
#
# NOTE pytest.approx supports only ==, not e.g. <, so we use plain round.
return round(t, 6)
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