diff --git a/test/conftest.py b/test/conftest.py index 4183d49f3754d518d75c51eadbc6420e518f8b07..4049b70977ac5ef476bae9cb24680e7953df7dad 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -20,10 +20,14 @@ def pytest_generate_tests(metafunc): metafunc.parametrize('platform_monoC', platforms) if 'workload_static' in metafunc.fixturenames: - workload_files = glob.glob('test/workloads/static/*.json') - workloads = [Workload( - name=basename(workload_file).replace('.json', ''), - filename=abspath(workload_file)) for workload_file in workload_files] + workload_files = [ + "batpaper", + "mixed", + "para_homo" + ] + path = 'test/workloads/static' + workloads = [Workload(name=wl, filename=abspath(f"{path}/{wl}.json")) + for wl in workload_files] metafunc.parametrize('workload_static', workloads) if 'platform_multiC' in metafunc.fixturenames: diff --git a/test/expected_log/easy_bf_small_instance_jobs.csv b/test/expected_log/easy_bf_small_instance_jobs.csv new file mode 100644 index 0000000000000000000000000000000000000000..7a44ad1113fee9fa9988f85d382cd8a782cc11f7 --- /dev/null +++ b/test/expected_log/easy_bf_small_instance_jobs.csv @@ -0,0 +1,7 @@ +job_id,workload_name,profile,submission_time,requested_number_of_resources,requested_time,success,final_state,starting_time,execution_time,finish_time,waiting_time,turnaround_time,stretch,allocated_resources,consumed_energy,metadata +2,w0,10sec,50.000000,1,20.000000,1,COMPLETED_SUCCESSFULLY,50.000000,10.000000,60.000000,0.000000,10.000000,1.000000,1,-1.000000,"" +0,w0,100sec,0.000000,1,110.000000,1,COMPLETED_SUCCESSFULLY,0.000000,100.000000,100.000000,0.000000,100.000000,1.000000,0,-1.000000,"" +1,w0,100sec,10.000000,2,110.000000,1,COMPLETED_SUCCESSFULLY,100.000000,100.000000,200.000000,90.000000,190.000000,1.900000,0-1,-1.000000,"" +3,w0,100sec,300.000000,1,110.000000,1,COMPLETED_SUCCESSFULLY,300.000000,100.000000,400.000000,0.000000,100.000000,1.000000,0,-1.000000,"" +4,w0,100sec,310.000000,2,110.000000,1,COMPLETED_SUCCESSFULLY,400.000000,100.000000,500.000000,90.000000,190.000000,1.900000,0-1,-1.000000,"" +5,w0,10sec,350.000000,1,80.000000,1,COMPLETED_SUCCESSFULLY,500.000000,10.000000,510.000000,150.000000,160.000000,16.000000,0,-1.000000,"" diff --git a/test/test_schedulers_mono.py b/test/test_schedulers_mono.py index d6fc51910788d5a40375c7c872fea31cddab869d..0e85977b01abbef599b45d9a91421073b6f99ed6 100755 --- a/test/test_schedulers_mono.py +++ b/test/test_schedulers_mono.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 from helper import * +import pandas as pd def test_fcfs(platform_monoC, workload_static): """Tests the scheduler fcfs with different platform and workload files""" @@ -19,8 +20,39 @@ def test_fcfs(platform_monoC, workload_static): instance.to_file(robin_filename) ret = run_robin(robin_filename) + + # Checks that there were no execution error + assert ret.returncode == 0 + + # Checks that the jobs have been executed in FCFS order + jobs = pd.read_csv(f"{output_dir}/_jobs.csv") + jobs.sort_values(by="submission_time", inplace=True) + assert jobs[jobs.success==1].starting_time.is_monotonic_increasing + +def test_easy_bf_small_instance(): + """Tests the scheduler easy backfilling on a small instance""" + + test_name = 'easy_bf_small_instance' + output_dir, robin_filename, _ = init_instance(test_name) + + batcmd = gen_batsim_cmd( + abspath("test/platforms/monocore/2machines.xml"), + abspath("test/workloads/static/backfill.json"), output_dir, "") + instance = RobinInstance(output_dir=output_dir, + batcmd=batcmd, + schedcmd="batmen -v 'easy_bf'", + simulation_timeout=30, ready_timeout=5, + success_timeout=10, failure_timeout=0 + ) + instance.to_file(robin_filename) + ret = run_robin(robin_filename) + + # Checks that there were no execution error assert ret.returncode == 0 + # Checks that backfilling did occur in this small example + assert_expected_output(test_name) + def test_easy_bf(platform_monoC, workload_static): """Tests the scheduler easy backfilling with different platform and workload files""" diff --git a/test/workloads/static/backfill.json b/test/workloads/static/backfill.json new file mode 100644 index 0000000000000000000000000000000000000000..f68dae3a9761b4698942699bae8d717a5f579371 --- /dev/null +++ b/test/workloads/static/backfill.json @@ -0,0 +1,17 @@ +{ + "description": "Test easy backfill.", + "nb_res": 2, + "jobs": [ + {"id": "0", "profile": "100sec", "res": 1, "walltime":110, "subtime": 0}, + {"id": "1", "profile": "100sec", "res": 2, "walltime":110, "subtime": 10}, + {"id": "2", "profile": "10sec", "res": 1, "walltime":20, "subtime": 50}, + + {"id": "3", "profile": "100sec", "res": 1, "walltime":110, "subtime": 300}, + {"id": "4", "profile": "100sec", "res": 2, "walltime":110, "subtime": 310}, + {"id": "5", "profile": "10sec", "res": 1, "walltime":80, "subtime": 350} + ], + "profiles": { + "100sec": {"delay": 100,"type": "delay"}, + "10sec": {"delay": 10,"type": "delay"} + } +} \ No newline at end of file