Merge "Python3: fix test/unit/obj/test_replicator.py"

This commit is contained in:
Zuul 2019-02-05 02:54:18 +00:00 committed by Gerrit Code Review
commit c2179aa657
3 changed files with 25 additions and 24 deletions

View File

@ -90,13 +90,13 @@ class Stats(object):
total.suffix_hash = self.suffix_hash + other.suffix_hash
total.suffix_sync = self.suffix_sync + other.suffix_sync
all_failed_ips = (set(self.failure_nodes.keys() +
other.failure_nodes.keys()))
all_failed_ips = (set(list(self.failure_nodes.keys()) +
list(other.failure_nodes.keys())))
for ip in all_failed_ips:
self_devs = self.failure_nodes.get(ip, {})
other_devs = other.failure_nodes.get(ip, {})
this_ip_failures = {}
for dev in set(self_devs.keys() + other_devs.keys()):
for dev in set(list(self_devs.keys()) + list(other_devs.keys())):
this_ip_failures[dev] = (
self_devs.get(dev, 0) + other_devs.get(dev, 0))
total.failure_nodes[ip] = this_ip_failures

View File

@ -344,7 +344,7 @@ class TestObjectReplicator(unittest.TestCase):
f = open(os.path.join(df._datadir,
normalize_timestamp(time.time()) + '.data'),
'wb')
f.write('1234567890')
f.write(b'1234567890')
f.close()
ohash = hash_path('a', 'c', 'o')
data_dir = ohash[-3:]
@ -408,7 +408,7 @@ class TestObjectReplicator(unittest.TestCase):
f = open(os.path.join(df._datadir,
normalize_timestamp(time.time()) + '.data'),
'wb')
f.write('1234567890')
f.write(b'1234567890')
f.close()
ohash = hash_path('a', 'c', 'o')
data_dir = ohash[-3:]
@ -842,7 +842,7 @@ class TestObjectReplicator(unittest.TestCase):
ts = next(self.ts)
df = self.df_mgr.get_diskfile('sda', '0', 'a', 'c', 'o', policy)
with df.create() as w:
w.write('asdf')
w.write(b'asdf')
w.put({'X-Timestamp': ts.internal})
w.commit(ts)
expected_suffix_paths.append(os.path.dirname(df._datadir))
@ -850,7 +850,7 @@ class TestObjectReplicator(unittest.TestCase):
ts = next(self.ts)
df = self.df_mgr.get_diskfile('sda', '1', 'a', 'c', 'o', policy)
with df.create() as w:
w.write('asdf')
w.write(b'asdf')
w.put({'X-Timestamp': ts.internal})
w.commit(ts)
expected_suffix_paths.append(os.path.dirname(df._datadir))
@ -925,7 +925,7 @@ class TestObjectReplicator(unittest.TestCase):
ts = next(self.ts)
df = self.df_mgr.get_diskfile('sda', '1', 'a', 'c', 'o', policy)
with df.create() as w:
w.write('asdf')
w.write(b'asdf')
w.put({'X-Timestamp': ts.internal})
w.commit(ts)
handoff_suffix_paths.append(os.path.dirname(df._datadir))
@ -1043,7 +1043,7 @@ class TestObjectReplicator(unittest.TestCase):
policy=POLICIES.legacy)
ts = next(self.ts)
with df.create() as w:
w.write('asdf')
w.write(b'asdf')
w.put({'X-Timestamp': ts.internal})
w.commit(ts)
# pre-flight and post sync request for both other primaries
@ -1125,7 +1125,7 @@ class TestObjectReplicator(unittest.TestCase):
f = open(os.path.join(df._datadir,
normalize_timestamp(time.time()) + '.data'),
'wb')
f.write('1234567890')
f.write(b'1234567890')
f.close()
ohash = hash_path('a', 'c', 'o')
data_dir = ohash[-3:]
@ -1155,7 +1155,7 @@ class TestObjectReplicator(unittest.TestCase):
f = open(os.path.join(df._datadir,
normalize_timestamp(time.time()) + '.data'),
'wb')
f.write('1234567890')
f.write(b'1234567890')
f.close()
ohash = hash_path('a', 'c', 'o')
data_dir = ohash[-3:]
@ -1206,7 +1206,7 @@ class TestObjectReplicator(unittest.TestCase):
ts = normalize_timestamp(time.time())
f = open(os.path.join(df._datadir, ts + '.data'),
'wb')
f.write('1234567890')
f.write(b'1234567890')
f.close()
ohash = hash_path('a', 'c', 'o')
whole_path_from = storage_directory(self.objects, 1, ohash)
@ -1232,7 +1232,7 @@ class TestObjectReplicator(unittest.TestCase):
f = open(os.path.join(df._datadir,
normalize_timestamp(time.time()) + '.data'),
'wb')
f.write('1234567890')
f.write(b'1234567890')
f.close()
ohash = hash_path('a', 'c', 'o')
data_dir = ohash[-3:]
@ -1261,7 +1261,7 @@ class TestObjectReplicator(unittest.TestCase):
f = open(os.path.join(df._datadir,
normalize_timestamp(time.time()) + '.data'),
'wb')
f.write('1234567890')
f.write(b'1234567890')
f.close()
ohash = hash_path('a', 'c', 'o')
data_dir = ohash[-3:]
@ -1297,7 +1297,7 @@ class TestObjectReplicator(unittest.TestCase):
f = open(os.path.join(df._datadir,
normalize_timestamp(time.time()) + '.data'),
'wb')
f.write('1234567890')
f.write(b'1234567890')
f.close()
ohash = hash_path('a', 'c', 'o')
data_dir = ohash[-3:]
@ -1332,7 +1332,7 @@ class TestObjectReplicator(unittest.TestCase):
f = open(os.path.join(df._datadir,
normalize_timestamp(time.time()) + '.data'),
'wb')
f.write('1234567890')
f.write(b'1234567890')
f.close()
ohash = hash_path('a', 'c', 'o')
data_dir = ohash[-3:]
@ -1367,7 +1367,7 @@ class TestObjectReplicator(unittest.TestCase):
f = open(os.path.join(df._datadir,
normalize_timestamp(time.time()) + '.data'),
'wb')
f.write('1234567890')
f.write(b'1234567890')
f.close()
ohash = hash_path('a', 'c', 'o')
data_dir = ohash[-3:]
@ -1443,7 +1443,7 @@ class TestObjectReplicator(unittest.TestCase):
ts = normalize_timestamp(time.time())
f = open(os.path.join(df._datadir, ts + '.data'),
'wb')
f.write('0')
f.write(b'0')
f.close()
ohash = hash_path('a', 'c', 'o')
whole_path_from = storage_directory(self.objects, 1, ohash)
@ -1491,7 +1491,7 @@ class TestObjectReplicator(unittest.TestCase):
ts = normalize_timestamp(time.time())
mkdirs(df._datadir)
f = open(os.path.join(df._datadir, ts + '.data'), 'wb')
f.write('0')
f.write(b'0')
f.close()
ohash = hash_path('a', 'c', 'o')
whole_path_from = storage_directory(self.objects, 1, ohash)
@ -1539,7 +1539,7 @@ class TestObjectReplicator(unittest.TestCase):
mkdirs(df._datadir)
ts = normalize_timestamp(time.time())
f = open(os.path.join(df._datadir, ts + '.data'), 'wb')
f.write('0')
f.write(b'0')
f.close()
ohash = hash_path('a', 'c', 'o')
whole_path_from = storage_directory(self.objects, 1, ohash)
@ -1580,7 +1580,7 @@ class TestObjectReplicator(unittest.TestCase):
mkdirs(df._datadir)
ts = normalize_timestamp(time.time())
f = open(os.path.join(df._datadir, ts + '.data'), 'wb')
f.write('0')
f.write(b'0')
f.close()
ohash = hash_path('a', 'c', 'o')
whole_path_from = storage_directory(self.objects, 1, ohash)
@ -1681,7 +1681,7 @@ class TestObjectReplicator(unittest.TestCase):
f = open(os.path.join(df._datadir,
normalize_timestamp(time.time()) + '.data'),
'wb')
f.write('1234567890')
f.write(b'1234567890')
f.close()
ohash = hash_path('a', 'c', 'o')
data_dir = ohash[-3:]
@ -2070,7 +2070,7 @@ class TestObjectReplicator(unittest.TestCase):
f = open(os.path.join(df._datadir,
normalize_timestamp(time.time()) + '.data'),
'wb')
f.write('1234567890')
f.write(b'1234567890')
f.close()
mock_procs = []
@ -2106,7 +2106,7 @@ class TestObjectReplicator(unittest.TestCase):
f = open(os.path.join(df._datadir,
normalize_timestamp(time.time()) + '.data'),
'wb')
f.write('1234567890')
f.write(b'1234567890')
f.close()
mock_procs = []

View File

@ -85,6 +85,7 @@ commands =
test/unit/container/test_auditor.py \
test/unit/container/test_replicator.py \
test/unit/container/test_sync_store.py \
test/unit/obj/test_replicator.py \
test/unit/obj/test_server.py \
test/unit/proxy/controllers/test_info.py}