Commit 5ae2efd6 authored by Felix Seibert's avatar Felix Seibert
Browse files

add method to calculate the average total folder sizes and a test

parent 0f8f79d0
......@@ -174,6 +174,19 @@ class TestDataDistribution(unittest.TestCase):
self.assertEqual(average, distribution.get_average_osd_load(create_osd_information(num_osds, osd_capacities),
osd_capacity_key))
def test_average_total_folder_size(self):
folder_sizes = [49, 123, 1, 7]
num_folders = 2
num_osds = 4
osd_capacities = [100, 150]
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),
create_osd_information(num_osds, osd_capacities),
osd_capacity_key)
average = (sum(folder_sizes) * num_folders) / (num_osds * len(osd_capacities))
self.assertEqual(average, distribution.get_average_total_folder_size())
def create_test_osd_list(num_osds, osd_capacities):
test_osds = []
......
......@@ -98,6 +98,18 @@ class DataDistribution(object):
total_osd_capacity += osd_information[osd_uuid][capacity]
return total_folder_size / total_osd_capacity
def get_average_total_folder_size(self):
"""
calculate the average total_folder_size of the OSDs.
"""
total_folder_size = 0
num_osds = 0
for osd in self.OSDs.values():
total_folder_size += osd.total_folder_size
num_osds += 1
return total_folder_size / num_osds
def add_folders(self, folders,
osd_information=None, ratio_parameter='', capacity='',
ignore_osd_capacities=True,
......
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