Skip to content
Snippets Groups Projects
Commit 80fc2309 authored by jgatt's avatar jgatt
Browse files

added monolithic behavior test to ensure that "red_prob_behavior" do the right behavior assigned

parent bdc42eda
No related branches found
No related tags found
1 merge request!12Merge Request multibehavior
Pipeline #5477 passed
from helper import * from helper import *
from test_users import run_user, assert_exec_time_equals_profile from test_users import run_user, assert_exec_time_equals_profile
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')
users = [ users = [
...@@ -15,6 +17,32 @@ users = [ ...@@ -15,6 +17,32 @@ users = [
"dm_user_multi_behavior_C_you_later_only" "dm_user_multi_behavior_C_you_later_only"
] ]
def make_monolithic_file(user_name, input_json, probability_name, seed=None, red_windows=None, yellow_windows=None):
assert len(user_name) == len(input_json), "The three lists should be of the same size"
schedconf_file = 'test-instances/user_description_file.json'
error_file = {
"users": [
{
"name": name,
"category": "dm_user_multi_behavior",
"param": {
"input_json": json,
probability_name : 1.0
}
}
for name, json in zip(user_name, input_json)
]
}
if seed :
error_file["seed"] =seed
if red_windows :
error_file["red_windows"] = red_windows
if yellow_windows :
error_file["yellow_windows"] = yellow_windows
with open(schedconf_file, 'w+') as error_description_file :
json.dump(error_file,error_description_file)
def test_dm_user_delay(platform_multiC): def test_dm_user_delay(platform_multiC):
out_dir = run_user("dm_user_delay", platform_multiC) out_dir = run_user("dm_user_delay", platform_multiC)
assert_exec_time_equals_profile(out_dir) assert_exec_time_equals_profile(out_dir)
...@@ -33,9 +61,9 @@ def test_speedup(): ...@@ -33,9 +61,9 @@ def test_speedup():
run_user("reconfig_alpha", two_machine_platform) run_user("reconfig_alpha", two_machine_platform)
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)
out_dir_3 = run_user("dm_user_multi_behavior_many_windows_wrong_order",platform_multiC) out_dir_3 = run_user("dm_user_multi_behavior_many_windows_wrong_order", platform_multiC)
content_1 = open(out_dir_1 + "/_jobs.csv").readlines() content_1 = open(out_dir_1 + "/_jobs.csv").readlines()
content_2 = open(out_dir_2 + "/_jobs.csv").readlines() content_2 = open(out_dir_2 + "/_jobs.csv").readlines()
content_3 = open(out_dir_3+ "/_jobs.csv").readlines() content_3 = open(out_dir_3+ "/_jobs.csv").readlines()
...@@ -47,3 +75,21 @@ def test_dm_user_multi_behavior_yellow(platform_multiC) : ...@@ -47,3 +75,21 @@ def test_dm_user_multi_behavior_yellow(platform_multiC) :
def test_dm_user_multi_behavior_C_you_later_only(platform_multiC) : def test_dm_user_multi_behavior_C_you_later_only(platform_multiC) :
run_user("dm_user_multi_behavior_C_you_later_only", platform_multiC) run_user("dm_user_multi_behavior_C_you_later_only", platform_multiC)
run_user("dm_user_multi_behavior_C_you_later_only_two_jobs", platform_multiC) run_user("dm_user_multi_behavior_C_you_later_only_two_jobs", platform_multiC)
def test_dm_user_multi_behavior_monobehavior(platform_multiC) :
schedconf_file = 'test-instances/user_description_file.json'
proba_names= ["red_prob_degrad", "red_prob_rigid", "red_prob_reconfig", "red_prob_renonce"]
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"]
for proba_name in proba_names :
make_monolithic_file(names, input_json, proba_name,seed=3, red_windows=[[200000, 300000]])
test_file_name=f'dm_user_multi_behavior_{proba_name[9:]}_only'
out_dir = run_user(test_file_name, two_machine_platform,
test_name=test_file_name, schedconf = schedconf_file)
if not("comm" in out_dir):
content_job = open(out_dir + "/_jobs.csv").readlines()
if not("rigid" in out_dir):
expected_log = open(f"test/expected_log/dm_user_{proba_name[9:]}-2machines_jobs.csv").readlines()
else :
expected_log = open(f"test/expected_log/replay_user_rigid-2machines_jobs.csv").readlines()
assert content_job == expected_log
\ 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