Commit 00ea89c3 authored by Julien Muchembled's avatar Julien Muchembled

qa: do more checks on the partition table in testReplicationBlockedByUnfinished

parent d3cb8888
......@@ -258,30 +258,34 @@ class PartitionTable(object):
partition on the line (here, line length is 11 to keep the docstring
width under 80 column).
"""
node_list = sorted(self.count_dict)
result = ['pt: node %u: %s, %s' % (i, uuid_str(node.getUUID()),
protocol.node_state_prefix_dict[node.getState()])
for i, node in enumerate(node_list)]
for i, node in enumerate(sorted(self.count_dict))]
append = result.append
line = []
max_line_len = 20 # XXX: hardcoded number of partitions per line
cell_state_dict = protocol.cell_state_prefix_dict
prefix = 0
prefix_len = int(math.ceil(math.log10(self.np)))
for offset, row in enumerate(self.partition_list):
for offset, row in enumerate(self.formatRows()):
if len(line) == max_line_len:
append('pt: %0*u: %s' % (prefix_len, prefix, '|'.join(line)))
line = []
prefix = offset
line.append(row)
if line:
append('pt: %0*u: %s' % (prefix_len, prefix, '|'.join(line)))
return result
def formatRows(self):
node_list = sorted(self.count_dict)
cell_state_dict = protocol.cell_state_prefix_dict
for row in self.partition_list:
if row is None:
line.append('X' * len(node_list))
yield 'X' * len(node_list)
else:
cell_dict = {x.getNode(): cell_state_dict[x.getState()]
for x in row}
line.append(''.join(cell_dict.get(x, '.') for x in node_list))
if line:
append('pt: %0*u: %s' % (prefix_len, prefix, '|'.join(line)))
return result
yield ''.join(cell_dict.get(x, '.') for x in node_list)
def operational(self):
if not self.filled():
......
......@@ -929,6 +929,9 @@ class NEOThreadedTest(NeoTestBase):
with Patch(client, _getFinalTID=lambda *_: None):
self.assertRaises(ConnectionClosed, txn.commit)
def assertPartitionTable(self, cluster, stats):
self.assertEqual(stats, '|'.join(cluster.admin.pt.formatRows()))
def predictable_random(seed=None):
# Because we have 2 running threads when client works, we can't
......
......@@ -502,6 +502,7 @@ class ReplicationTests(NEOThreadedTest):
storage = cluster.getZODBStorage()
oid = storage.new_oid()
tid = None
expected = 'UO'
for n in 1, 0:
# On first iteration, the transaction will block replication
# until tpc_finish.
......@@ -517,12 +518,13 @@ class ReplicationTests(NEOThreadedTest):
cluster.enableStorageList((s1,))
cluster.neoctl.tweakPartitionTable()
self.tic()
self.assertEqual(n, len(cluster.getOutdatedCells()))
self.assertPartitionTable(cluster, expected)
storage.tpc_vote(txn)
self.assertEqual(n, len(cluster.getOutdatedCells()))
self.assertPartitionTable(cluster, expected)
tid = storage.tpc_finish(txn)
self.tic() # replication resumes and ends
self.assertFalse(cluster.getOutdatedCells())
expected = 'UU'
self.assertPartitionTable(cluster, expected)
self.assertEqual(cluster.neoctl.getClusterState(),
ClusterStates.RUNNING)
finally:
......
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