changes from code review
This commit is contained in:
@@ -61,7 +61,7 @@ def hash_suffix(path, reclaim_age):
|
|||||||
elif files:
|
elif files:
|
||||||
files.sort(reverse=True)
|
files.sort(reverse=True)
|
||||||
meta = data = tomb = None
|
meta = data = tomb = None
|
||||||
for filename in files[:]:
|
for filename in list(files):
|
||||||
if not meta and filename.endswith('.meta'):
|
if not meta and filename.endswith('.meta'):
|
||||||
meta = filename
|
meta = filename
|
||||||
if not data and filename.endswith('.data'):
|
if not data and filename.endswith('.data'):
|
||||||
@@ -471,6 +471,10 @@ class ObjectReplicator(Daemon):
|
|||||||
self.last_replication_count = self.replication_count
|
self.last_replication_count = self.replication_count
|
||||||
|
|
||||||
def collect_jobs(self):
|
def collect_jobs(self):
|
||||||
|
"""
|
||||||
|
Returns a sorted list of jobs (dictionaries) that specify the
|
||||||
|
partitions, nodes, etc to be rsynced.
|
||||||
|
"""
|
||||||
jobs = []
|
jobs = []
|
||||||
ips = whataremyips()
|
ips = whataremyips()
|
||||||
for local_dev in [dev for dev in self.object_ring.devs
|
for local_dev in [dev for dev in self.object_ring.devs
|
||||||
|
|||||||
@@ -38,14 +38,6 @@ def _ips():
|
|||||||
object_replicator.whataremyips = _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):
|
def mock_http_connect(status):
|
||||||
|
|
||||||
class FakeConn(object):
|
class FakeConn(object):
|
||||||
@@ -326,15 +318,6 @@ class TestObjectReplicator(unittest.TestCase):
|
|||||||
self.replicator.replicate()
|
self.replicator.replicate()
|
||||||
self.assertFalse(os.access(part_path, os.F_OK))
|
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):
|
def test_run_once_recover_from_failure(self):
|
||||||
replicator = object_replicator.ObjectReplicator(
|
replicator = object_replicator.ObjectReplicator(
|
||||||
dict(swift_dir=self.testdir, devices=self.devices,
|
dict(swift_dir=self.testdir, devices=self.devices,
|
||||||
|
|||||||
Reference in New Issue
Block a user