diff --git a/swift/obj/reconstructor.py b/swift/obj/reconstructor.py index 67b371a27d..0e8d11f966 100644 --- a/swift/obj/reconstructor.py +++ b/swift/obj/reconstructor.py @@ -1034,7 +1034,7 @@ class ObjectReconstructor(Daemon): policy2devices = self.get_policy2devices() return reduce(set.union, ( set(d['device'] for d in devices) - for devices in policy2devices.values())) + for devices in policy2devices.values()), set()) def collect_parts(self, override_devices=None, override_partitions=None): """ diff --git a/test/unit/obj/test_reconstructor.py b/test/unit/obj/test_reconstructor.py index be705a7a64..5fd75dc8d0 100644 --- a/test/unit/obj/test_reconstructor.py +++ b/test/unit/obj/test_reconstructor.py @@ -3856,6 +3856,20 @@ class TestObjectReconstructor(BaseTestObjectReconstructor): # hashpath is still there, but it's empty self.assertEqual([], os.listdir(df._datadir)) + def test_get_local_devices(self): + local_devs = self.reconstructor.get_local_devices() + self.assertEqual({'sda'}, local_devs) + + @patch_policies(legacy_only=True) + def test_get_local_devices_with_no_ec_policy_env(self): + # even no ec_policy found on the server, it runs just like as + # no ec device found + self.policy = POLICIES.default + self._configure_reconstructor() + self.assertEqual([], self.reconstructor.policies) + local_devs = self.reconstructor.get_local_devices() + self.assertEqual(set(), local_devs) + class TestReconstructFragmentArchive(BaseTestObjectReconstructor): obj_path = '/a/c/o' # subclass overrides this