Commit b5894bb6 authored by Felix Seibert's avatar Felix Seibert
Browse files

fix erros revealed by tests

parent c01a3cf0
......@@ -43,11 +43,11 @@ class TestXOSDManager(unittest.TestCase):
osd_man = OSDManager.OSDManager(self.absolute_path_to_managed_folder, value_map=self.value_map)
self.assertEqual(os.path.join(self.volume_name, self.path_on_volume, self.some_folder),
osd_man.path_on_volume(
osd_man.get_path_on_volume(
os.path.join(self.path_to_mount, self.path_on_volume, self.some_folder)))
with self.assertRaises(OSDManager.PathNotManagedException):
osd_man.path_on_volume(self.absolute_path_random)
osd_man.get_path_on_volume(self.absolute_path_random)
def test_get_target_dir(self):
osd_man = OSDManager.OSDManager(self.absolute_path_to_managed_folder, value_map=self.value_map)
......@@ -65,6 +65,10 @@ class TestXOSDManagerWithXtreemFS(unittest.TestCase):
# two mount points of the same xtreemfs volume
self.mount_point_1 = '/dev/shm/xfs_mnt_1'
self.mount_point_2 = '/dev/shm/xfs_mnt_2'
self.mount_point_1 = '/home/felix/git/file_placement2/experiments/scripts/local/mnt'
self.mount_point_2 = self.mount_point_1
self.path_on_mount_point = 'x/y/folder'
self.tmp_folder = '/tmp/python-1298324809321934'
......@@ -181,8 +185,8 @@ class TestXOSDManagerWithXtreemFS(unittest.TestCase):
size_source = int(str(du_source.stdout).split()[0])
total_size_in_distribution = 0
for osd in x_man.distribution.osds.values():
total_size_in_distribution += osd.totalFolderSize
for osd in x_man.distribution.OSDs.values():
total_size_in_distribution += osd.total_folder_size
self.assertNotEqual(size_source, total_size_in_distribution)
......@@ -193,8 +197,8 @@ class TestXOSDManagerWithXtreemFS(unittest.TestCase):
size_source = int(str(du_source.stdout).split()[0])
total_size_in_distribution = 0
for osd in x_man.distribution.osds.values():
total_size_in_distribution += osd.totalFolderSize
for osd in x_man.distribution.OSDs.values():
total_size_in_distribution += osd.total_folder_size
self.assertEqual(size_source, total_size_in_distribution)
......@@ -206,15 +210,15 @@ class TestXOSDManagerWithXtreemFS(unittest.TestCase):
x_man_1.copy_folders(self.depth_2_dirs)
total_size_in_distribution_1 = 0
for osd in x_man_1.distribution.osds.values():
total_size_in_distribution_1 += osd.totalFolderSize
for osd in x_man_1.distribution.OSDs.values():
total_size_in_distribution_1 += osd.total_folder_size
managed_folder_2 = os.path.join(self.mount_point_2, self.path_on_mount_point)
x_man_2 = OSDManager.OSDManager(managed_folder_2)
total_size_in_distribution_2 = 0
for osd in x_man_2.distribution.osds.values():
total_size_in_distribution_2 += osd.totalFolderSize
for osd in x_man_2.distribution.OSDs.values():
total_size_in_distribution_2 += osd.total_folder_size
self.assertEqual(total_size_in_distribution_1, total_size_in_distribution_2)
......
......@@ -357,7 +357,7 @@ class OSDManager(object):
tiles = []
for input_folder in folders:
new_tile = folder.Folder(self.path_on_volume(input_folder), average_size, None)
new_tile = folder.Folder(self.get_path_on_volume(input_folder), average_size, None)
tiles.append(new_tile)
new_tiles = self.distribution.add_folders(tiles)
......@@ -585,7 +585,7 @@ class OSDManager(object):
folders = self.get_depth_2_subdirectories()
for folder_for_update in folders:
folder_id = self.path_on_volume(folder_for_update)
folder_id = self.get_path_on_volume(folder_for_update)
command = ["du", "-s", folder_for_update]
if self.debug:
print("executing: " + str(command))
......
......@@ -68,7 +68,7 @@ class DataDistribution(object):
total_size = 0
total_number_of_folders = 0
for one_osd in self.OSDs.values():
total_size += one_osd.totalFolderSize
total_size += one_osd.total_folder_size
total_number_of_folders += len(one_osd.folders)
if total_number_of_folders == 0:
return 0
......@@ -136,8 +136,8 @@ class DataDistribution(object):
least_used_osd = None
for one_osd in self.OSDs.values():
if (least_used_osd is None) or \
one_osd.totalFolderSize / osd_ratios[one_osd.uuid] \
<= least_used_osd.totalFolderSize / osd_ratios[least_used_osd.uuid]:
one_osd.total_folder_size / osd_ratios[one_osd.uuid] \
<= least_used_osd.total_folder_size / osd_ratios[least_used_osd.uuid]:
least_used_osd = one_osd
least_used_osd.add_folder(folder.id, folder.size)
osds_for_new_folders.append((folder.id,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment