changes from code review

This commit is contained in:
David Goetz 2010-11-16 08:32:03 -08:00
parent a71164995a
commit aed24cf328
2 changed files with 7 additions and 20 deletions

View File

@ -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

View File

@ -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__':