Commit e71383aa authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4e16e489
......@@ -510,12 +510,15 @@ def Restructure(ztree, newStructure):
zstate += (node.next_bucket.Z,)
#print('%s %x: ZSTATE: %r' % ('T' if _zclassify(node.Z).is_ztree else 'B', id(node.Z), zstate,))
node.Z.__setstate__(zstate)
zstate2 = node.Z.__getstate__()
if zstate2 != zstate:
panic("BUG: node.__getstate__ returns not what "
"we passed into node.__setstate__.\nnode: %r\n"
"__setstate__ <- %r\n__getstate__ -> %r" % (node.Z, zstate, zstate2))
zstate_old = node.Z.__getstate__()
if zstate_old != zstate:
node.Z.__setstate__(zstate)
node.Z._p_changed = True
zstate2 = node.Z.__getstate__()
if zstate2 != zstate:
panic("BUG: node.__getstate__ returns not what "
"we passed into node.__setstate__.\nnode: %r\n"
"__setstate__ <- %r\n__getstate__ -> %r" % (node.Z, zstate, zstate2))
assert tnew.Z is ztree
......
......@@ -491,7 +491,8 @@ def test_restructure():
return ztree
# R restructures ztree to have specified new topology.
def R(ztree, newtopo):
# Unless dontcommit=Y is specified, the result is committed.
def R(ztree, newtopo, dontcommit=False):
# verify ztree consistency
items = list(ztree.items())
for (k,v) in items:
......@@ -504,7 +505,8 @@ def test_restructure():
newStructure = newtopo
xbtree.Restructure(ztree, newStructure)
transaction.commit()
if not dontcommit:
transaction.commit()
# force objects state to be reloaded from storage.
# this leads further checks to also verify if Restructure modified a
# node, but did not marked it as changed. If this bug is indeed there -
......@@ -567,14 +569,14 @@ def test_restructure():
# tree with 1 k->v (not yet committed bucket)
z = Z(1)
assert crack_btree(z) == (BTREE_ONE, ((1, X[1]),), None)
R(z, 'T/B1')
R(z, 'T/B1', dontcommit=True)
assert crack_btree(z) == (BTREE_ONE, ((1, X[1]),), None)
R(z, 'T/T/B1')
R(z, 'T/T/B1', dontcommit=True)
t, = assertT(z, [], 'T')
b1, = assertT(t, [], 'B')
assertB(b1, 1)
assert b1._p_oid is not None
R(z, 'T/B1')
R(z, 'T/B1', dontcommit=True)
assertT(z, [], b1)
assertB(b1, 1)
......@@ -582,7 +584,7 @@ def test_restructure():
# tree with 2 k->v (not-yet committed bucket)
z = Z(1,3)
assert crack_btree(z) == (BTREE_ONE, ((1, X[1], 3, X[3]),), None)
R(z, 'T2/B1-B3')
R(z, 'T2/B1-B3', dontcommit=True)
b1, b3 = assertT(z, [2], 'B','B')
assert b1._p_oid is None
assert b3._p_oid is None
......@@ -592,7 +594,7 @@ def test_restructure():
# buckets were not yet assigned oid -> collapsed back into T
assert crack_btree(z) == (BTREE_ONE, ((1, X[1], 3, X[3]),), None)
R(z, 'T3/B1-B3')
R(z, 'T3/B1-B3', dontcommit=True)
b1, b3 = assertT(z, [3], 'B','B')
assert b1._p_oid is None
assert b3._p_oid is None
......
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