Fixing sorting of ShardReplicationPositions

This commit is contained in:
Alain Jobart 2016-06-07 09:11:22 -07:00
Родитель 0776485d52
Коммит 13fabe6fee
2 изменённых файлов: 8 добавлений и 7 удалений

Просмотреть файл

@ -2185,10 +2185,9 @@ func (rts rTablets) Len() int { return len(rts) }
func (rts rTablets) Swap(i, j int) { rts[i], rts[j] = rts[j], rts[i] }
// Sort for tablet replication.
// master first, then i/o position, then sql position
// Tablet type first (with master first), then replication positions.
func (rts rTablets) Less(i, j int) bool {
// NOTE: Swap order of unpack to reverse sort
l, r := rts[j], rts[i]
l, r := rts[i], rts[j]
// l or r ReplicationStatus would be nil if we failed to get
// the position (put them at the beginning of the list)
if l.Status == nil {

Просмотреть файл

@ -231,7 +231,6 @@ class TestReparent(unittest.TestCase):
self._check_master_tablet(tablet_62344)
# Perform a graceful reparent operation to another cell.
utils.pause('test_reparent_cross_cell PlannedReparentShard')
utils.run_vtctl(['PlannedReparentShard', 'test_keyspace/' + shard_id,
tablet_31981.tablet_alias], auto_log=True)
utils.validate_topology()
@ -296,11 +295,14 @@ class TestReparent(unittest.TestCase):
utils.validate_topology()
# Run this to make sure it succeeds.
utils.run_vtctl(['ShardReplicationPositions', 'test_keyspace/' + shard_id],
stdout=utils.devnull)
stdout, _ = utils.run_vtctl(['ShardReplicationPositions',
'test_keyspace/' + shard_id],
trap_output=True)
lines = stdout.splitlines()
self.assertEqual(len(lines), 4) # one master, three slaves
self.assertIn('master', lines[0]) # master first
# Perform a graceful reparent operation.
utils.pause('_test_reparent_graceful PlannedReparentShard')
utils.run_vtctl(['PlannedReparentShard', 'test_keyspace/' + shard_id,
tablet_62044.tablet_alias], auto_log=True)
utils.validate_topology()