def test_primary_stepdown(self): c = ReplicaSetConnection(self.seed, replicaSet=self.name) self.assertTrue(bool(len(c.secondaries))) primary = c.primary secondaries = c.secondaries def primary_changed(): for _ in xrange(30): if c.primary != primary: return True time.sleep(1) return False replset_tools.stepdown_primary() self.assertTrue(primary_changed()) self.assertTrue(secondaries != c.secondaries)
def test_primary_stepdown(self): c = ReplicaSetConnection( self.seed, replicaSet=self.name, use_greenlets=use_greenlets) self.assertTrue(bool(len(c.secondaries))) primary = c.primary secondaries = c.secondaries.copy() def primary_changed(): for _ in xrange(30): if c.primary != primary: return True sleep(1) return False replset_tools.stepdown_primary() self.assertTrue(primary_changed()) # There can be a delay between finding the primary and updating # secondaries sleep(5) self.assertNotEqual(secondaries, c.secondaries)