Skip to content
Snippets Groups Projects
Commit 43dd4b7c authored by Maël Madon's avatar Maël Madon
Browse files

doc: cosmetics on test files

parent 7961ac82
No related branches found
No related tags found
1 merge request!16Merge request multibehavior
Pipeline #5830 passed
from helper import * from helper import *
from test_users import run_user from test_users import run_user
import json import json
Workload = namedtuple('Workload', ['name', 'filename']) Workload = namedtuple('Workload', ['name', 'filename'])
Platform = namedtuple('Platform', ['name', 'filename']) Platform = namedtuple('Platform', ['name', 'filename'])
two_machine_platform = Platform(name='two_machine_platform', filename='test/platforms/multicore/2machines.xml') two_machine_platform = Platform(name='two_machine_platform', filename='test/platforms/multicore/2machines.xml')
def make_monolithic_file(user_name, input_json, probability_name, seed=None, red_windows=None, yellow_windows=None): def make_monolithic_file(user_name, input_json, probability_name, seed=None, red_windows=None, yellow_windows=None):
""" create a user_description where every user with names in user_name and workload in input_json do only the behavior """Utility function to create a user_description file with the given user_names, input_jsons, probability_name etc."""
given in probability_name with the provided seed and red_windows and yellow_windows """
assert len(user_name) == len(input_json), "The three lists should be of the same size" assert len(user_name) == len(input_json), "The three lists should be of the same size"
schedconf_file = 'test-instances/user_description_file.json' schedconf_file = 'test-instances/user_description_file.json'
error_file = { error_file = {
...@@ -33,7 +34,7 @@ def make_monolithic_file(user_name, input_json, probability_name, seed=None, red ...@@ -33,7 +34,7 @@ def make_monolithic_file(user_name, input_json, probability_name, seed=None, red
json.dump(error_file,error_description_file) json.dump(error_file,error_description_file)
def monolithics_test(proba_names,names,input_json,seed=None,red_windows=None,yellow_windows=None) : def monolithics_test(proba_names,names,input_json,seed=None,red_windows=None,yellow_windows=None) :
""" test a monolithic behavior on red_windows or yellow_windows and compare to their dm_user_replay class equivalent""" """Utility function to launch the test with given parameters and compare the output to their dm_user_replay class equivalent"""
schedconf_file = 'test-instances/user_description_file.json' schedconf_file = 'test-instances/user_description_file.json'
for proba_name in proba_names : for proba_name in proba_names :
behavior_name = proba_name.split("_")[-1] behavior_name = proba_name.split("_")[-1]
...@@ -48,6 +49,7 @@ def monolithics_test(proba_names,names,input_json,seed=None,red_windows=None,yel ...@@ -48,6 +49,7 @@ def monolithics_test(proba_names,names,input_json,seed=None,red_windows=None,yel
else : else :
expected_log = open(f"test/expected_log/replay_user_rigid-2machines_jobs.csv").readlines() expected_log = open(f"test/expected_log/replay_user_rigid-2machines_jobs.csv").readlines()
assert content_job == expected_log assert content_job == expected_log
def test_dm_user_multi_behavior(platform_multiC) : def test_dm_user_multi_behavior(platform_multiC) :
out_dir_1 = run_user("dm_user_multi_behavior", platform_multiC) out_dir_1 = run_user("dm_user_multi_behavior", platform_multiC)
out_dir_2 = run_user("dm_user_multi_behavior_many_windows",platform_multiC) out_dir_2 = run_user("dm_user_multi_behavior_many_windows",platform_multiC)
...@@ -56,6 +58,7 @@ def test_dm_user_multi_behavior(platform_multiC) : ...@@ -56,6 +58,7 @@ def test_dm_user_multi_behavior(platform_multiC) :
with open(f"{out_dir_2}/_jobs.csv") as job_file_2 : with open(f"{out_dir_2}/_jobs.csv") as job_file_2 :
job_line_2 = job_file_2.readlines() job_line_2 = job_file_2.readlines()
assert job_line_1 == job_line_2 assert job_line_1 == job_line_2
def test_dm_user_multi_behavior_yellow(platform_multiC) : def test_dm_user_multi_behavior_yellow(platform_multiC) :
run_user("dm_user_multi_behavior_yellow",platform_multiC) run_user("dm_user_multi_behavior_yellow",platform_multiC)
...@@ -70,6 +73,7 @@ def test_dm_user_multi_behavior_monobehavior_red(platform_multiC) : ...@@ -70,6 +73,7 @@ def test_dm_user_multi_behavior_monobehavior_red(platform_multiC) :
names = ["user" + str(i+14) for i in range(3)] + ["user18"] names = ["user" + str(i+14) for i in range(3)] + ["user18"]
input_json = ["test/workloads/dyn/user" + str(i+14) + ".json" for i in range(3)] + ["test/workloads/dyn/user18.json"] input_json = ["test/workloads/dyn/user" + str(i+14) + ".json" for i in range(3)] + ["test/workloads/dyn/user18.json"]
monolithics_test(proba_names, names, input_json, seed=3, red_windows=[[200000, 300000]]) monolithics_test(proba_names, names, input_json, seed=3, red_windows=[[200000, 300000]])
def test_dm_user_multi_behabior_monobehavior_yellow(platform_multiC) : def test_dm_user_multi_behabior_monobehavior_yellow(platform_multiC) :
""" Test users that only do one behavior in yellow_windows""" """ Test users that only do one behavior in yellow_windows"""
proba_names = ["yellow_prob_reconfig", "yellow_prob_degrad","yellow_prob_rigid"] proba_names = ["yellow_prob_reconfig", "yellow_prob_degrad","yellow_prob_rigid"]
...@@ -80,4 +84,4 @@ def test_dm_user_multi_behabior_monobehavior_yellow(platform_multiC) : ...@@ -80,4 +84,4 @@ def test_dm_user_multi_behabior_monobehavior_yellow(platform_multiC) :
def test_dm_user_small_workload(platform_multiC) : def test_dm_user_small_workload(platform_multiC) :
""" test multi_behavior on small workload file (<100 jobs) for human checkable log""" """ test multi_behavior on small workload file (<100 jobs) for human checkable log"""
for i in range(1, 6): for i in range(1, 6):
run_user(f"dm_user_multi_behavior_small_workload_{i}", platform_multiC) run_user(f"dm_user_multi_behavior_small_workload_{i}", platform_multiC)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment