Commit e0ecdee0 authored by Millian Poquet's avatar Millian Poquet
Browse files

[code,tests] fix sequence + test

parent 3630ceea
......@@ -248,6 +248,12 @@ add_test(same_submit_time
-bod /tmp/batsim_tests/same_submit_time
-bwd ${CMAKE_SOURCE_DIR})
add_test(sequence_delay
${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
${CMAKE_SOURCE_DIR}/test/test_sequence_delay.yaml
-bod /tmp/batsim_tests/sequence_delay
-bwd ${CMAKE_SOURCE_DIR})
add_test(no_redis
${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
${CMAKE_SOURCE_DIR}/test/test_no_redis.yaml
......
......@@ -155,14 +155,14 @@ int execute_profile(BatsimContext *context,
}
else if (profile->type == ProfileType::SEQUENCE)
{
xbt_die("Unhandled sequence profile type");
SequenceProfileData * data = (SequenceProfileData *) profile->data;
for (int i = 0; i < data->repeat; i++)
{
for (unsigned int j = 0; j < data->sequence.size(); j++)
{
if (execute_profile(context, data->sequence[j], allocation, cleanup_data, remaining_time) == 0)
if (execute_profile(context, data->sequence[j], allocation,
cleanup_data, remaining_time) == 0)
return 0;
}
}
......
......@@ -315,9 +315,11 @@ Profile *Profile::from_json(const std::string & profile_name,
const Value & seq = json_desc["seq"];
xbt_assert(seq.Size() > 0, "%s: profile '%s' has an invalid array 'seq': its size must be "
"strictly positive", error_prefix.c_str(), profile_name.c_str());
data->sequence.reserve(seq.Size());
for (unsigned int i = 0; i < seq.Size(); ++i)
data->sequence.push_back(string(seq[i].GetString()));
profile->data = data;
profile->data = data;
}
else if (profile_type == "msg_par_hg_pfs0")
{
......
# This script should be called from Batsim's root directory
# If needed, the working directory of this script can be specified within this file
#base_working_directory: ~/proj/batsim
# If needed, the output directory of this script can be specified within this file
base_output_directory: /tmp/batsim_tests/sequence_delay
base_variables:
batsim_dir: ${base_working_directory}
implicit_instances:
implicit:
sweep:
platform :
- {"name":"small", "filename":"${batsim_dir}/platforms/small_platform.xml"}
workload :
- {"name":"sequence_delay", "filename":"${batsim_dir}/workload_profiles/test_sequence_delay.json"}
algo:
- {"name":"filler", "algo_name":"filler"}
generic_instance:
timeout: 10
working_directory: ${base_working_directory}
output_directory: ${base_output_directory}/results/${instance_id}
batsim_command: batsim -p ${platform[filename]} -w ${workload[filename]} -e ${output_directory}/out --mmax-workload -vdebug --config-file ${output_directory}/batsim.conf
sched_command: batsched -v ${algo[algo_name]}
commands_before_execution:
# Batsim config file (redis disabled)
- |
#!/bin/bash
cat > ${output_directory}/batsim.conf << EOF
{
"redis": {
"enabled": false
}
}
EOF
commands_after_execution:
# Let's check that Batsim sent the jobs in the right order
- |
#!/usr/bin/env bash
source ${output_directory}/variables.bash
cat > ${output_directory}/jobs_analysis.py <<EOF
#!/usr/bin/env python3
import json
from math import isclose
import pandas as pd
import sys
jobs = pd.read_csv('${output_directory}/out_jobs.csv')
epsilon = 0.1
exit_status = 0
for _,job in jobs.iterrows():
jid, jsuc, jrt = job['job_id'], job['success'], job['execution_time']
if jid in {1,2,3,4}:
if jsuc != 1:
print('Job {} should be successful...'.format(jsuc))
exit_status = 1
if not isclose(jrt, 30, abs_tol=epsilon):
print('Job {} should take {} s (took {})'.format(jid, 30, jrt))
exit_status = 1
elif jid in {11,12,13,14}:
if jsuc != 0:
print('Job {} should NOT be successful...'.format(jsuc))
exit_status = 1
if not isclose(jrt, 20, abs_tol=epsilon):
print('Job {} should take {} s (took {})'.format(jid, 20, jrt))
exit_status = 1
else:
print('Job {} is unknown!'.format(jid))
exit_status = 1
if len(jobs) != 8:
print('There should be {} jobs (got {})'.format(8, len(jobs)))
exit_status = 1
sys.exit(exit_status)
EOF
- chmod +x ${output_directory}/jobs_analysis.py
- ${output_directory}/jobs_analysis.py
commands_before_instances:
- ${batsim_dir}/test/is_batsim_dir.py ${base_working_directory}
- ${batsim_dir}/test/clean_output_dir.py ${base_output_directory}
{
"date": "2017-04-18",
"description": "Tests whether simple sequence profiles work. Jobs 1->4 should finish in time, jobs 11->14 should reach walltime",
"nb_res": 4,
"jobs": [
{"id": 1, "subtime": 0, "walltime": 50, "res": 1, "profile": "seq_3x10"},
{"id": 2, "subtime": 100, "walltime": 50, "res": 2, "profile": "seq_3x10_unrolled"},
{"id": 3, "subtime": 200, "walltime": 50, "res": 3, "profile": "seq_20+10"},
{"id": 4, "subtime": 300, "walltime": 50, "res": 4, "profile": "seq_10+20"},
{"id":11, "subtime":1000, "walltime": 20, "res": 1, "profile": "seq_3x10"},
{"id":12, "subtime":1100, "walltime": 20, "res": 2, "profile": "seq_3x10_unrolled"},
{"id":13, "subtime":1200, "walltime": 20, "res": 3, "profile": "seq_20+10"},
{"id":14, "subtime":1300, "walltime": 20, "res": 4, "profile": "seq_10+20"}
],
"profiles": {
"delay_10": {
"type": "delay",
"delay": 10
},
"delay_20": {
"type": "delay",
"delay": 20
},
"seq_3x10": {
"type": "composed",
"nb" : 3,
"seq": ["delay_10"]
},
"seq_3x10_unrolled": {
"type": "composed",
"nb" : 1,
"seq": ["delay_10", "delay_10", "delay_10"]
},
"seq_20+10": {
"type": "composed",
"nb" : 1,
"seq": ["delay_20", "delay_10"]
},
"seq_10+20": {
"type": "composed",
"nb" : 1,
"seq": ["delay_10", "delay_20"]
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment