From aed24cf328d63aeb3e091a4ecea6a79cad4af474 Mon Sep 17 00:00:00 2001 From: David Goetz Date: Tue, 16 Nov 2010 08:32:03 -0800 Subject: [PATCH] changes from code review --- swift/obj/replicator.py | 6 +++++- test/unit/obj/test_replicator.py | 21 ++------------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/swift/obj/replicator.py b/swift/obj/replicator.py index 0eec1920c8..9b0294627e 100644 --- a/swift/obj/replicator.py +++ b/swift/obj/replicator.py @@ -61,7 +61,7 @@ def hash_suffix(path, reclaim_age): elif files: files.sort(reverse=True) meta = data = tomb = None - for filename in files[:]: + for filename in list(files): if not meta and filename.endswith('.meta'): meta = filename if not data and filename.endswith('.data'): @@ -471,6 +471,10 @@ class ObjectReplicator(Daemon): self.last_replication_count = self.replication_count def collect_jobs(self): + """ + Returns a sorted list of jobs (dictionaries) that specify the + partitions, nodes, etc to be rsynced. + """ jobs = [] ips = whataremyips() for local_dev in [dev for dev in self.object_ring.devs diff --git a/test/unit/obj/test_replicator.py b/test/unit/obj/test_replicator.py index 58b804460b..ec69dc0439 100644 --- a/test/unit/obj/test_replicator.py +++ b/test/unit/obj/test_replicator.py @@ -38,14 +38,6 @@ def _ips(): object_replicator.whataremyips = _ips -class NullHandler(logging.Handler): - - def emit(self, record): - pass -null_logger = logging.getLogger("testing") -null_logger.addHandler(NullHandler()) - - def mock_http_connect(status): class FakeConn(object): @@ -326,15 +318,6 @@ class TestObjectReplicator(unittest.TestCase): self.replicator.replicate() self.assertFalse(os.access(part_path, os.F_OK)) - def test_rsync(self): - jobs = self.replicator.collect_jobs() - job = jobs[0] - node = job['nodes'][0] - ohash = hash_path('a', 'c', 'o') - data_dir = ohash[-3:] - with _mock_process([(0, ''), (0, ''), (0, '')]): - self.replicator.rsync(node, job, [data_dir]) - def test_run_once_recover_from_failure(self): replicator = object_replicator.ObjectReplicator( dict(swift_dir=self.testdir, devices=self.devices, @@ -377,11 +360,11 @@ class TestObjectReplicator(unittest.TestCase): object_replicator.http_connect = was_connector def test_run(self): - with _mock_process([(0, '')]*100): + with _mock_process([(0, '')] * 100): self.replicator.replicate() def test_run_withlog(self): - with _mock_process([(0, "stuff in log")]*100): + with _mock_process([(0, "stuff in log")] * 100): self.replicator.replicate() if __name__ == '__main__':