From 56a18ac9b71e54eb16640adf1aaf8798ac275505 Mon Sep 17 00:00:00 2001 From: Alistair Coles Date: Thu, 27 Jul 2017 14:13:08 +0100 Subject: [PATCH] Add unit test for ObjectReconstructor.is_healthy Add a test that verifies that get_all_devices does fetch devices from the ring. Related-Change: I28925a37f3985c9082b5a06e76af4dc3ec813abe Change-Id: Ie2f83694f14f9a614b5276bbb859b9a3c0ec5dcb --- test/unit/obj/test_reconstructor.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/test/unit/obj/test_reconstructor.py b/test/unit/obj/test_reconstructor.py index f71ff2c1be..be705a7a64 100644 --- a/test/unit/obj/test_reconstructor.py +++ b/test/unit/obj/test_reconstructor.py @@ -1597,7 +1597,7 @@ class TestWorkerReconstructor(unittest.TestCase): # and empty self.assertEqual({}, data) - def test_is_healthy_ring_update_next_check(self): + def test_is_healthy(self): reconstructor = object_reconstructor.ObjectReconstructor( {'recon_cache_path': self.recon_cache_path}, logger=self.logger) @@ -1609,6 +1609,25 @@ class TestWorkerReconstructor(unittest.TestCase): 'sdb%d' % p for p in reconstructor.policies} self.assertTrue(reconstructor.is_healthy()) + def test_is_healthy_detects_ring_change(self): + reconstructor = object_reconstructor.ObjectReconstructor( + {'recon_cache_path': self.recon_cache_path, + 'reconstructor_workers': 1, + # bind ip and port will not match any dev in first version of ring + 'bind_ip': '10.0.0.20', 'bind_port': '1020'}, + logger=self.logger) + p = random.choice(reconstructor.policies) + self.assertEqual(14, len(p.object_ring.devs)) # sanity check + worker_args = list(reconstructor.get_worker_args()) + self.assertFalse(worker_args[0]['override_devices']) # no local devs + self.assertTrue(reconstructor.is_healthy()) + # expand ring - now there are local devices + p.object_ring.set_replicas(28) + self.assertEqual(28, len(p.object_ring.devs)) # sanity check + self.assertFalse(reconstructor.is_healthy()) + self.assertNotEqual(worker_args, list(reconstructor.get_worker_args())) + self.assertTrue(reconstructor.is_healthy()) + def test_final_recon_dump(self): reconstructor = object_reconstructor.ObjectReconstructor( {'recon_cache_path': self.recon_cache_path},