Commit 9181c5d9 authored by Kirill Smelkov's avatar Kirill Smelkov

X Restructure; verify that it marks as changed only modifed nodes

parent e71383aa
...@@ -737,12 +737,12 @@ def test_restructure(): ...@@ -737,12 +737,12 @@ def test_restructure():
R(z, 'T4/T2-T/T-T-T6,10/B1-B3-T-T-T/T-B7-B11/B5') R(z, 'T4/T2-T/T-T-T6,10/B1-B3-T-T-T/T-B7-B11/B5')
R(z, 'T/B1,3,5,7,11') R(z, 'T/B1,3,5,7,11')
# make sure changed objects are marked as such and so included into commit # verify changed objects are marked as such and so included into commit
# (just R also partly verifies this on every call) # (just R also partly verifies this on every call)
z = Z(0,2,3) z = Z(0,2,3)
transaction.commit() transaction.commit()
def Rz(newtopo): def Rz(newtopo):
R(z, newtopo) R(z, newtopo, dontcommit=True)
transaction.commit() transaction.commit()
assert Sv(z) == newtopo assert Sv(z) == newtopo
zconn.cacheMinimize() # force z state to be reloaded from storage zconn.cacheMinimize() # force z state to be reloaded from storage
...@@ -755,48 +755,37 @@ def test_restructure(): ...@@ -755,48 +755,37 @@ def test_restructure():
Rz('T3/B0:a,2:c-B3:d') Rz('T3/B0:a,2:c-B3:d')
Rz('T2/T-T3/B0:a-B2:c-B3:d') Rz('T2/T-T3/B0:a-B2:c-B3:d')
# make sure that only modified nodes are marked as changed.
z = Z(0,1,2,3)
""" R(z, 'T1/T-T2/B0-B1-B2,3')
# XXX T/T1/T-T/B0:g-B1:e,2:d,3:h -> T1/T-T3/B0:g-T-T/B1:e,2:d-B3:h tl, tr = assertT(z, [1], 'T','T')
# (commit asserts that nothing is changed) b0, = assertT(tl, [], 'B')
b1, b23 = assertT(tr, [2], 'B','B')
# XXX leads restructure to generate corrupt btrees assertB(b0, 0)
z = Z() assertB(b1, 1)
transaction.commit() assertB(b23, 2,3)
z[0] = xdecode('g') assert z._p_changed == False
z[1] = xdecode('e') assert tl._p_changed == False
z[2] = xdecode('d') assert tr._p_changed == False
z[3] = xdecode('h') assert b0._p_changed == False
R(z, 'T/T1/T-T/B0:g-B1:e,2:d,3:h') assert b1._p_changed == False
transaction.commit() assert b23._p_changed == False
assert Sv(z) == 'T/T1/T-T/B0:g-B1:e,2:d,3:h'
zconn.cacheMinimize() R(z, 'T1/T-T3/B0-B1,2-B3', dontcommit=True) # reflow right arm
assert Sv(z) == 'T/T1/T-T/B0:g-B1:e,2:d,3:h' assertT(z, [1], tl, tr)
xbtree.zcheck(z) assertT(tl, [], b0)
assertT(tr, [3], b1, b23) # changed
z[0] = xdecode('h') assertB(b0, 0)
z[1] = xdecode('b') assertB(b1, 1,2) # changed
del z[2] assertB(b23, 3) # changed
del z[3] assert z._p_changed == False
R(z, 'T1/B0:h-B1:b') assert tl._p_changed == False
transaction.commit() assert tr._p_changed == True
assert Sv(z) == 'T1/B0:h-B1:b' assert b0._p_changed == False
zconn.cacheMinimize() assert b1._p_changed == True
assert Sv(z) == 'T1/B0:h-B1:b' # XXX fails here assert b23._p_changed == True
xbtree.zcheck(z)
z[0] = xdecode('g')
z[1] = xdecode('e')
z[2] = xdecode('d')
z[3] = xdecode('h')
R(z, 'T1/T-T3/B0:g-T-T/B1:e,2:d-B3:h')
transaction.commit() transaction.commit()
assert Sv(z) == 'T1/T-T3/B0:g-T-T/B1:e,2:d-B3:h'
zconn.cacheMinimize()
assert Sv(z) == 'T1/T-T3/B0:g-T-T/B1:e,2:d-B3:h'
xbtree.zcheck(z)
"""
# ---- tests on automatically generated topologies ---- # ---- tests on automatically generated topologies ----
......
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