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

add test for lpt and random assignment ignoring folder sizes

parent c782bcb8
......@@ -25,22 +25,22 @@ class TestDataDistribution(unittest.TestCase):
felix_and_farouk_different = False
num_osds = 3
osd_capacity = 100
osds_capacities = [100]
num_folders = 10
folder_size = 20
folder_sizes = [20]
for i in range(0, 100):
distribution_felix = dataDistribution.DataDistribution()
distribution_felix.add_osd_list(create_test_osd_list(num_osds))
distribution_felix.add_folders(create_test_folder_list(num_folders, folder_size),
osd_information=create_osd_information(num_osds, osd_capacity),
distribution_felix.add_osd_list(create_test_osd_list(num_osds, osds_capacities))
distribution_felix.add_folders(create_test_folder_list(num_folders, folder_sizes),
osd_information=create_osd_information(num_osds, osds_capacities),
random_osd_assignment=True,
ignore_osd_capacities=True)
distribution_farouk = dataDistribution.DataDistribution()
distribution_farouk.add_osd_list(create_test_osd_list(num_osds))
distribution_farouk.add_folders(create_test_folder_list(num_folders, folder_size),
osd_information=create_osd_information(num_osds, osd_capacity),
distribution_farouk.add_osd_list(create_test_osd_list(num_osds, osds_capacities))
distribution_farouk.add_folders(create_test_folder_list(num_folders, folder_sizes),
osd_information=create_osd_information(num_osds, osds_capacities),
random_osd_assignment=True,
ignore_osd_capacities=True)
......@@ -61,13 +61,13 @@ class TestDataDistribution(unittest.TestCase):
max_osd_total_folder_size = max(max_osd_total_folder_size, max_felix, max_farouk)
self.assertTrue(felix_and_farouk_different)
self.assertTrue(max_osd_total_folder_size > osd_capacity)
self.assertTrue(max_osd_total_folder_size > osds_capacities[0])
def test_value_error(self):
distribution = dataDistribution.DataDistribution()
distribution.add_osd_list(create_test_osd_list(1))
distribution.add_osd_list(create_test_osd_list(1, [0]))
try:
distribution.add_folders(create_test_folder_list(1, 1),
distribution.add_folders(create_test_folder_list(1, [1]),
random_osd_assignment=True,
ignore_osd_capacities=False)
except ValueError:
......@@ -76,53 +76,115 @@ class TestDataDistribution(unittest.TestCase):
def test_random_distribution_respecting_capacities(self):
# generate some random distributions and check whether they all respect the OSD capacities
max_osd_total_folder_size = 0
num_osds = 3
osd_capacity = 100
osds_capacities = [100]
num_folders = 10
folder_size = 20
folder_size = [20]
max_osd_total_folder_size = 0
for i in range(0, 100):
distribution = dataDistribution.DataDistribution()
distribution.add_osd_list(create_test_osd_list(num_osds))
distribution.add_osd_list(create_test_osd_list(num_osds, osds_capacities))
distribution.add_folders(create_test_folder_list(num_folders, folder_size),
random_osd_assignment=True,
ignore_osd_capacities=False,
osd_information=create_osd_information(num_osds, osd_capacity),
osd_information=create_osd_information(num_osds, osds_capacities),
capacity=osd_capacity_key)
osds = distribution.get_osd_list()
total_folder_sizes = list(map(lambda x: distribution.OSDs[x].total_folder_size, osds))
max_osd_total_folder_size = max(max(total_folder_sizes), max_osd_total_folder_size)
self.assertTrue(max_osd_total_folder_size <= osd_capacity)
self.assertTrue(max_osd_total_folder_size <= osds_capacities[0])
def test_random_round_robin_distribution(self):
# generate some random distributions
# and check whether OSDs are almost-equally loaded and whether they are different
num_osds = 3
osd_capacities = [0]
num_folders = 10
folder_sizes = [1]
a_b_different = False
def test_round_robin_distribution(self):
pass
for i in range(0, 100):
distribution_a = dataDistribution.DataDistribution()
distribution_a.add_osd_list(create_test_osd_list(num_osds, osd_capacities))
distribution_a.add_folders(create_test_folder_list(num_folders, folder_sizes),
random_osd_assignment=True,
ignore_folder_sizes=True)
distribution_b = dataDistribution.DataDistribution()
distribution_b.add_osd_list(create_test_osd_list(num_osds, osd_capacities))
distribution_b.add_folders(create_test_folder_list(num_folders, folder_sizes),
random_osd_assignment=True,
ignore_folder_sizes=True)
osds_a = distribution_a.get_osd_list()
total_folder_sizes_a = list(map(lambda x: distribution_a.OSDs[x].total_folder_size, osds_a))
self.assertTrue(max(total_folder_sizes_a) is not min(total_folder_sizes_a))
osds_b = distribution_b.get_osd_list()
total_folder_sizes_b = list(map(lambda x: distribution_b.OSDs[x].total_folder_size, osds_b))
self.assertTrue(max(total_folder_sizes_b) is not min(total_folder_sizes_b))
if list(list(distribution_a.OSDs.values())[0].folders.keys())[0] \
!= list(list(distribution_b.OSDs.values())[0].folders.keys())[0]:
a_b_different = True
self.assertTrue(a_b_different)
def test_lpt_distribution(self):
pass
folder_sizes = [3, 7, 11]
num_folders = 4
num_osds = 4
osd_capacities = [0]
distribution = dataDistribution.DataDistribution()
distribution.add_osd_list(create_test_osd_list(num_osds, osd_capacities))
distribution.add_folders(create_test_folder_list(num_folders, folder_sizes))
osds = distribution.get_osd_list()
total_folder_sizes = list(map(lambda x: distribution.OSDs[x].total_folder_size, osds))
self.assertTrue(min(total_folder_sizes) == max(total_folder_sizes))
osd_capacities = [10, 20]
folder_sizes = [4, 4, 4]
distribution = dataDistribution.DataDistribution()
distribution.add_osd_list(create_test_osd_list(num_osds, osd_capacities))
distribution.add_folders(create_test_folder_list(num_folders, folder_sizes))
def create_test_osd_list(num_osds):
osds = distribution.get_osd_list()
total_folder_sizes = list(map(lambda x: distribution.OSDs[x].total_folder_size, osds))
self.assertTrue(2 * min(total_folder_sizes) == max(total_folder_sizes))
def create_test_osd_list(num_osds, osd_capacities):
test_osds = []
for i in range(0, num_osds):
test_osds.append(osd_id_prefix + str(i))
for osd_capacity in osd_capacities:
test_osds.append(create_osd_id(osd_capacity, i))
return test_osds
def create_test_folder_list(num_folders, folder_size):
def create_test_folder_list(num_folders, folder_sizes):
test_folders = []
for i in range(0, num_folders):
new_folder = folder.Folder(folder_id_prefix + str(i), folder_size, None)
test_folders.append(new_folder)
for folder_size in folder_sizes:
new_folder = folder.Folder(folder_id_prefix + "_" + str(folder_size) + "_" + str(i), folder_size, None)
test_folders.append(new_folder)
return test_folders
def create_osd_information(num_osds, osd_capacity):
def create_osd_information(num_osds, osd_capacities):
osd_information = {}
for i in range(0, num_osds):
osd_uuid = osd_id_prefix + str(i)
osd_information[osd_uuid] = {}
osd_information[osd_uuid][osd_capacity_key] = osd_capacity
for osd_capacity in osd_capacities:
osd_uuid = create_osd_id(osd_capacity, i)
osd_information[osd_uuid] = {}
osd_information[osd_uuid][osd_capacity_key] = osd_capacity
return osd_information
def create_osd_id(capacity, index):
return osd_id_prefix + "_" + str(capacity) + "_" + str(index)
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