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

PPK_ASSERT -> PPK_ASSERT_ERROR. Added some error_message

parent 62b9490c
Branches
Tags
1 merge request!12Merge Request multibehavior
Pipeline #5496 passed
......@@ -65,16 +65,16 @@ Broker::Broker(rapidjson::Document *user_description_file)
//logging info parsing
if(user_description_file->HasMember("log_user_stats")){
PPK_ASSERT((*user_description_file)["log_user_stats"].IsBool(),
PPK_ASSERT_ERROR((*user_description_file)["log_user_stats"].IsBool(),
"Invalid user_description file : field"
"'log_user_stats' should be a boolean");
bool log_user_stats = (*user_description_file)["log_user_stats"].GetBool();
if(log_user_stats){
PPK_ASSERT(user_description_file->HasMember("log_folder"),
PPK_ASSERT_ERROR(user_description_file->HasMember("log_folder"),
"Invalid user_description file : field"
"'log_folder' should be defined with 'log_user_stats' ");
const Value &log_folder_param = (*user_description_file)["log_folder"];
PPK_ASSERT(log_folder_param.IsString(),
PPK_ASSERT_ERROR(log_folder_param.IsString(),
"Invalid user_description file : field"
" 'log_folder' should be a string ");
std::string log_folder = log_folder_param.GetString();
......
......@@ -38,13 +38,21 @@ void DMUserMultiBehavior::init_prob(const rapidjson::Value &param,uint_fast32_t
for (std::vector<double>::size_type i =0 ; i < red_prob.size();i++){
std::string current_prob = red_config[i];
if(param.HasMember(current_prob.c_str())){
PPK_ASSERT(param[current_prob.c_str()].IsDouble()
PPK_ASSERT_ERROR(param[current_prob.c_str()].IsDouble()
&& param[current_prob.c_str()].GetDouble()>=0.0,
"Error every specified red probability should be a non-negative Double");
red_prob[i] = param[current_prob.c_str()].GetDouble();
red_prob_total += red_prob[i];
}
}
/* If we need red_probabilities and
* they are none that are defined and non-zero we raise an error */
std::string error_message = "Error in parameter defined for user ";
error_message += user_name;
error_message += ". The sum of the probability given in parameter sum to 0.0 for red_windows"
"Check that you gave red_prob_behavior parameter to user and at least "
"one non-zero probability";
PPK_ASSERT_ERROR( red_prob_total != 0.0 || !(dm_window || red_windows), error_message.c_str());
//we save the result in the used probability variable
red_prob_degrad = red_prob[0];
red_prob_Cyoulater = red_prob[1] ;
......@@ -61,13 +69,21 @@ void DMUserMultiBehavior::init_prob(const rapidjson::Value &param,uint_fast32_t
for (std::vector<double>::size_type i =0 ; i < yellow_prob.size();i++){
std::string current_prob = yellow_config[i];
if(param.HasMember(current_prob.c_str())){
PPK_ASSERT(param[current_prob.c_str()].IsDouble()
PPK_ASSERT_ERROR(param[current_prob.c_str()].IsDouble()
&& param[current_prob.c_str()].GetDouble()>=0.0,
"Error every specified yellow probability should be a non-negative Double");
yellow_prob[i] = param[current_prob.c_str()].GetDouble();
yellow_prob_total += yellow_prob[i];
}
}
error_message = "Error in parameter defined for user ";
error_message += user_name;
error_message += ". The sum of the probability given in parameter sum to 0.0 for yellow_windows"
" Check that you gave at least one non-zero yellow_prob_behavior parameter to user ";
/* If we need yellow_probabilities,
* and they are none that are defined and non-zero we raise an error */
PPK_ASSERT_ERROR( yellow_prob_total != 0.0 || !(yellow_windows), error_message.c_str());
//we save the result in the used probability variable
yellow_prob_degrad= yellow_prob[0];
yellow_prob_reconfig = yellow_prob[1];
}
......@@ -104,7 +120,7 @@ void DMUserMultiBehavior::jobs_to_submit(
bool DMUserMultiBehavior::C_you_later_job(double date, double next_time,shared_ptr<Job> job)
{
/* Log... */
log_behavior(job,"C_you_later",next_time);
log_behavior(job,"C_you_later",(long) next_time);
dm_stat[2 * DELAYED]++;
dm_stat[2*DELAYED+1]+= job->nb_requested_resources * std::stol(job->profile);
/* Delete original job from queue and update date */
......@@ -211,7 +227,7 @@ bool DMUserMultiBehavior::yellow_window_behavior(shared_ptr<Job> job,Profile *pr
}
}
void DMUserMultiBehavior::log_behavior(shared_ptr<Job> job, std::string behavior_name, long delay_time)
void DMUserMultiBehavior::log_behavior(shared_ptr<Job> job,std::string behavior_name, long delay_time)
{
if(logger){
logger->add_stat(job,behavior_name,delay_time);
......
......@@ -5,17 +5,18 @@ create_dir_rec_if_needed("test-instances")
import json
def make_error_file(seed=None,red_windows=None,yellow_windows=None) :
def make_error_file(seed=None,red_windows=None, probas = [("red_prob_see_you_later",1.0)], yellow_windows=None) :
"""Create a simple user_description_file with the given parameters to check for proper handling of errors"""
param = { "input_json": "test/workloads/dyn/two_jobs.json"}
for proba in probas :
proba_name,proba_value = proba
param[proba_name] = proba_value
error_file = {
"users": [
{
"name": "user14",
"category": "dm_user_multi_behavior",
"param": {
"input_json": "test/workloads/dyn/two_jobs.json",
"red_prob_see_you_later": 1.0
}
"param": param
}
]
}
......@@ -70,11 +71,32 @@ def test_error_no_window(platform_multiC) :
out_dir = error_user("dm_user_multi_behavior_no_windows", platform_multiC, "window")
def test_empty_red_window(platform_multiC) :
make_error_file(3,red_windows=[])
make_error_file(3, red_windows=[])
out_dir = error_user("dm_user_multi_behavior_empty_red_windows", platform_multiC, "red_windows should be a non-empty array")
def test_empty_yellow_window(platform_multiC) :
make_error_file(3,yellow_windows=[])
make_error_file(3, yellow_windows=[])
out_dir = error_user("dm_user_multi_behavior_empty_yellow_windows", platform_multiC, "yellow_windows should be a non-empty array")
def test_invalid_red_prob(platform_multiC) :
invalid_probas = [[], [("red_prob_reconfig",0.0)], [("red_prob_degrad",0.0)], [("red_prob_rigid",0.0)],
[("red_prob_see_you_later",0.0)],[("red_prob_renonce",0.0)],
[("red_prob_reconfig", 0.0), ("red_prob_degrad", 0.0), ("red_prob_rigid", 0.0),
("red_prob_renonce", 0.0), ("red_prob_see_you_later", 0.0)]]
i = 0
for probas in invalid_probas :
make_error_file(3, red_windows=[[0, 1]],probas=probas)
out_dir = error_user("dm_user_multi_behavior_invalid_red_prob_" + str(i), platform_multiC, "red")
i += 1
def test_invalid_yellow_prob(platform_multiC) :
invalid_probas = [[], [("yellow_prob_reconfig",0.0)], [("yellow_prob_degrad",0.0)], [("yellow_prob_rigid",0.0)],
[("yellow_prob_reconfig", 0.0), ("yellow_prob_degrad", 0.0), ("yellow_prob_rigid", 0.0)]]
i = 0
for probas in invalid_probas :
make_error_file(3, yellow_windows=[[0, 1]],probas=probas)
out_dir = error_user("dm_user_multi_behavior_invalid_yellow_prob_" + str(i), platform_multiC, "yellow")
i += 1
def test_error_invalid_window(platform_multiC) :
invalid_windows_list = [[[0]], [[0.0, 1.0]], [[0, 1, 2]], [[0, 1], [1, 2], [3, 4], 5], [[1, 4.0]], [[1.0, 4]]]
for i in range(len(invalid_windows_list)):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment