test api: occupancy per ioclass
Occupancy in ioclass config as values in range 0.00 to 1.00 Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
parent
8350ac9e88
commit
d8bc4b8e28
@ -31,7 +31,7 @@ IO_CLASS_CONFIG_HEADER = "IO class id,IO class name,Eviction priority,Allocation
|
|||||||
@functools.total_ordering
|
@functools.total_ordering
|
||||||
class IoClass:
|
class IoClass:
|
||||||
def __init__(self, class_id: int, rule: str = '', priority: int = None,
|
def __init__(self, class_id: int, rule: str = '', priority: int = None,
|
||||||
allocation: bool = True):
|
allocation: str = '1.00'):
|
||||||
self.id = class_id
|
self.id = class_id
|
||||||
self.rule = rule
|
self.rule = rule
|
||||||
self.priority = priority
|
self.priority = priority
|
||||||
@ -39,7 +39,7 @@ class IoClass:
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return (f'{self.id},{self.rule},{"" if self.priority is None else self.priority}'
|
return (f'{self.id},{self.rule},{"" if self.priority is None else self.priority}'
|
||||||
f',{int(self.allocation)}')
|
f',{self.allocation}')
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return ((self.id, self.rule, self.priority, self.allocation)
|
return ((self.id, self.rule, self.priority, self.allocation)
|
||||||
@ -56,7 +56,7 @@ class IoClass:
|
|||||||
class_id=int(parts[0]),
|
class_id=int(parts[0]),
|
||||||
rule=parts[1],
|
rule=parts[1],
|
||||||
priority=int(parts[2]),
|
priority=int(parts[2]),
|
||||||
allocation=parts[3] in ['1', 'YES'])
|
allocation=parts[3])
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def list_to_csv(ioclass_list: [], add_default_rule: bool = True):
|
def list_to_csv(ioclass_list: [], add_default_rule: bool = True):
|
||||||
@ -84,8 +84,8 @@ class IoClass:
|
|||||||
IoClass.list_to_csv(ioclass_list, add_default_rule))
|
IoClass.list_to_csv(ioclass_list, add_default_rule))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default(priority: int = 255, allocation: bool = True):
|
def default(priority=DEFAULT_IO_CLASS_PRIORITY, allocation="1.00"):
|
||||||
return IoClass(0, 'unclassified', priority, allocation)
|
return IoClass(DEFAULT_IO_CLASS_ID, DEFAULT_IO_CLASS_RULE, priority, allocation)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def compare_ioclass_lists(list1: [], list2: []):
|
def compare_ioclass_lists(list1: [], list2: []):
|
||||||
@ -94,10 +94,10 @@ class IoClass:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_random_ioclass_list(count: int, max_priority: int = MAX_IO_CLASS_PRIORITY):
|
def generate_random_ioclass_list(count: int, max_priority: int = MAX_IO_CLASS_PRIORITY):
|
||||||
random_list = [IoClass.default(priority=random.randint(0, max_priority),
|
random_list = [IoClass.default(priority=random.randint(0, max_priority),
|
||||||
allocation=bool(random.randint(0, 1)))]
|
allocation=f"{random.randint(0,100)/100:0.2f}")]
|
||||||
for i in range(1, count):
|
for i in range(1, count):
|
||||||
random_list.append(IoClass(i, priority=random.randint(0, max_priority),
|
random_list.append(IoClass(i, priority=random.randint(0, max_priority),
|
||||||
allocation=bool(random.randint(0, 1)))
|
allocation=f"{random.randint(0,100)/100:0.2f}")
|
||||||
.set_random_rule())
|
.set_random_rule())
|
||||||
return random_list
|
return random_list
|
||||||
|
|
||||||
@ -176,10 +176,10 @@ def add_ioclass(
|
|||||||
ioclass_id: int,
|
ioclass_id: int,
|
||||||
rule: str,
|
rule: str,
|
||||||
eviction_priority: int,
|
eviction_priority: int,
|
||||||
allocation: bool,
|
allocation,
|
||||||
ioclass_config_path: str = default_config_file_path,
|
ioclass_config_path: str = default_config_file_path,
|
||||||
):
|
):
|
||||||
new_ioclass = f"{ioclass_id},{rule},{eviction_priority},{int(allocation)}"
|
new_ioclass = f"{ioclass_id},{rule},{eviction_priority},{allocation}"
|
||||||
TestRun.LOGGER.info(
|
TestRun.LOGGER.info(
|
||||||
f"Adding rule {new_ioclass} " + f"to config file {ioclass_config_path}"
|
f"Adding rule {new_ioclass} " + f"to config file {ioclass_config_path}"
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user