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

test: modifs in expected outputs

parent a9d7c91a
No related branches found
No related tags found
No related merge requests found
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
}, },
{ {
"id": 6, "id": 6,
"first_submit_time": 2000.0, "first_submit_time": 4000.0,
"preceding_sessions": [1,2,3,4,5], "preceding_sessions": [1,2,3,4,5],
"thinking_time_after_preceding_session": [1000,1000,1000,1000,1000], "thinking_time_after_preceding_session": [1000,1000,1000,1000,1000],
"nb_jobs": 1, "nb_jobs": 1,
......
{
"description": "Empty SABjson.",
"nb_res": 0,
"sessions": []
}
\ No newline at end of file
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
}, },
{ {
"id": 2, "id": 2,
"first_submit_time": 1000.0, "first_submit_time": 2000.0,
"preceding_sessions": [1], "preceding_sessions": [1],
"thinking_time_after_preceding_session": [0], "thinking_time_after_preceding_session": [0],
"nb_jobs": 1, "nb_jobs": 1,
......
"""Checks the validity of the script on instances that have been manually checked""" """Checks the validity of the script on instances that have been manually checked"""
from conftest import run_script from conftest import run_script
import pytest
import json, os import json, os
def load_expected_output(file_name): def load_expected_output(file_name):
...@@ -20,18 +21,28 @@ def compare_with_expected_output(test_name): ...@@ -20,18 +21,28 @@ def compare_with_expected_output(test_name):
assert len(obtained["sessions"]) == len(expected["sessions"]) assert len(obtained["sessions"]) == len(expected["sessions"])
for s_e, s_o in zip(obtained["sessions"], expected["sessions"]): for s_e, s_o in zip(obtained["sessions"], expected["sessions"]):
assert int(s_e["id"]) == int(s_o["id"]) assert int(s_e["id"]) == int(s_o["id"]), f"\
assert float(s_e["first_submit_time"]) == float(s_o["first_submit_time"]) In session {s_e['id']}"
assert s_e["preceding_sessions"] == s_o["preceding_sessions"] assert float(s_e["first_submit_time"]) == float(s_o["first_submit_time"]), f"\
assert s_e["thinking_time_after_preceding_session"] == s_o["thinking_time_after_preceding_session"] In session {s_e['id']}"
assert int(s_e["nb_jobs"]) == int(s_o["nb_jobs"]) assert s_e["preceding_sessions"] == s_o["preceding_sessions"], f"\
In session {s_e['id']}"
assert s_e["thinking_time_after_preceding_session"] == s_o["thinking_time_after_preceding_session"], f"\
In session {s_e['id']}"
assert int(s_e["nb_jobs"]) == int(s_o["nb_jobs"]), f"\
In session {s_e['id']}"
for j_o, j_e in zip(s_o["jobs"], s_e["jobs"]): for j_o, j_e in zip(s_o["jobs"], s_e["jobs"]):
assert int( j_e["id"]) == int(j_o["id"]) assert int( j_e["id"]) == int(j_o["id"]), f"\
assert float(j_e["profile"]) == float(j_o["profile"]) In session {s_e['id']}, job{j_e['id']}"
assert int( j_e["res"]) == int(j_o["res"]) assert float(j_e["profile"]) == float(j_o["profile"]), f"\
assert float(j_e["subtime"]) == float(j_o["subtime"]) In session {s_e['id']}, job{j_e['id']}"
assert float(j_e["walltime"]) == float(j_o["walltime"]) assert int( j_e["res"]) == int(j_o["res"]), f"\
In session {s_e['id']}, job{j_e['id']}"
assert float(j_e["subtime"]) == float(j_o["subtime"]), f"\
In session {s_e['id']}, job{j_e['id']}"
assert float(j_e["walltime"]) == float(j_o["walltime"]), f"\
In session {s_e['id']}, job{j_e['id']}"
def test_example_workload(): def test_example_workload():
...@@ -71,3 +82,24 @@ def test_edge_cases(): ...@@ -71,3 +82,24 @@ def test_edge_cases():
run_script(delim="arrival", threshold=0, run_script(delim="arrival", threshold=0,
input_swf=f"test/workload/{test_name}.swf", test_name=test_name) input_swf=f"test/workload/{test_name}.swf", test_name=test_name)
compare_with_expected_output(test_name) compare_with_expected_output(test_name)
test_name = "many_preceding"
run_script(delim="arrival", threshold=0,
input_swf=f"test/workload/{test_name}.swf", test_name=test_name)
compare_with_expected_output(test_name)
test_name = "no_session"
run_script(delim="max", threshold=42,
input_swf=f"test/workload/{test_name}.swf", test_name=test_name)
with pytest.raises(FileNotFoundError):
load_expected_output(test_name)
test_name = "one_session_many_jobs"
run_script(delim="last", threshold=10,
input_swf=f"test/workload/{test_name}.swf", test_name=test_name)
compare_with_expected_output(test_name)
test_name = "zero_think_time"
run_script(delim="last", threshold=0,
input_swf=f"test/workload/{test_name}.swf", test_name=test_name)
compare_with_expected_output(test_name)
\ No newline at end of file
; Written by hand. ; Written by hand.
; Expected to produce many_preceding.SABjson with last_t0 ; Expected to produce zero_think_time.SABjson with last_t0
1 0 1000 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 1 0 1000 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
2 2000 0 2000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 2 2000 0 2000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment