diff options
Diffstat (limited to 'designate/tests/test_coordination.py')
-rw-r--r-- | designate/tests/test_coordination.py | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/designate/tests/test_coordination.py b/designate/tests/test_coordination.py index 67fbe149..f9285823 100644 --- a/designate/tests/test_coordination.py +++ b/designate/tests/test_coordination.py @@ -211,111 +211,3 @@ class TestPartitionerWithoutBackend(TestCase): partitioner.start() partitioner.watch_partition_change(cb) cb.assert_called_with(partitions, None, None) - - -class TestLeaderElection(TestCase): - def setUp(self): - super(TestLeaderElection, self).setUp() - - self.coord_fixture = self.useFixture(fixtures.CoordinatorFixture( - 'zake://', b'InsertNameHere')) - - self.election = coordination.LeaderElection( - self.coordinator, 'President') - - @property - def coordinator(self): - """Helper for quick access to the raw coordinator""" - return self.coord_fixture.coordinator - - def test_is_leader(self): - # We should not be leader until after we start the election. - self.assertFalse(self.election.is_leader) - - # Start the election - self.election.start() - self.coordinator.run_watchers() - - # We should now be the leader. - self.assertTrue(self.election.is_leader) - - # Stop the election - self.election.stop() - - # We should no longer be the leader. - self.assertFalse(self.election.is_leader) - - def test_callbacks(self): - # We should not be leader until after we start the election. - self.assertFalse(self.election.is_leader) - - # Create and attach a callback - mock_callback_one = mock.Mock() - self.election.watch_elected_as_leader(mock_callback_one) - - # Ensure the callback has not yet been called. - self.assertFalse(mock_callback_one.called) - - # Start the election - self.election.start() - self.coordinator.run_watchers() - - # Ensure the callback has been called exactly once. - self.assertEqual(1, mock_callback_one.call_count) - - # Create and attach a second callback after we start - mock_callback_two = mock.Mock() - self.election.watch_elected_as_leader(mock_callback_two) - - # Ensure the callback has been called exactly once. - self.assertEqual(1, mock_callback_two.call_count) - - -class TestLeaderElectionWithoutBackend(TestCase): - def setUp(self): - super(TestLeaderElectionWithoutBackend, self).setUp() - - # coordinator = None indicates no coordination backend has been - # configured - coordinator = None - self.election = coordination.LeaderElection(coordinator, 'President') - - def test_is_leader(self): - # We should not be leader until after we start the election. - self.assertFalse(self.election.is_leader) - - # Start the election - self.election.start() - - # We should now be the leader. - self.assertTrue(self.election.is_leader) - - # Stop the election - self.election.stop() - - # We should no longer be the leader. - self.assertFalse(self.election.is_leader) - - def test_callbacks(self): - # We should not be leader until after we start the election. - self.assertFalse(self.election.is_leader) - - # Create and attach a callback - mock_callback_one = mock.Mock() - self.election.watch_elected_as_leader(mock_callback_one) - - # Ensure the callback has not yet been called. - self.assertFalse(mock_callback_one.called) - - # Start the election - self.election.start() - - # Ensure the callback has been called exactly once. - self.assertEqual(1, mock_callback_one.call_count) - - # Create and attach a second callback after we start - mock_callback_two = mock.Mock() - self.election.watch_elected_as_leader(mock_callback_two) - - # Ensure the callback has been called exactly once. - self.assertEqual(1, mock_callback_two.call_count) |