Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
batmen
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sepia-pub
mael
batmen
Commits
e205ccb9
Commit
e205ccb9
authored
2 years ago
by
jgatt
Browse files
Options
Downloads
Patches
Plain Diff
PPK_ASSERT -> PPK_ASSERT_ERROR. Added some error_message
parent
62b9490c
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!12
Merge Request multibehavior
Pipeline
#5496
passed
2 years ago
Stage: build-and-test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/users/broker.cpp
+3
-3
3 additions, 3 deletions
src/users/broker.cpp
src/users/user_windows.cpp
+20
-4
20 additions, 4 deletions
src/users/user_windows.cpp
test/test_assertion_error.py
+29
-7
29 additions, 7 deletions
test/test_assertion_error.py
with
52 additions
and
14 deletions
src/users/broker.cpp
+
3
−
3
View file @
e205ccb9
...
...
@@ -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
();
...
...
This diff is collapsed.
Click to expand it.
src/users/user_windows.cpp
+
20
−
4
View file @
e205ccb9
...
...
@@ -38,13 +38,21 @@ void DMUserMultiBehavior::init_prob(const rapidjson::Value ¶m,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 ¶m,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
);
...
...
This diff is collapsed.
Click to expand it.
test/test_assertion_error.py
+
29
−
7
View file @
e205ccb9
...
...
@@ -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
)):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment