-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add and update tests for the listRecommendations and UpdateRecommendations APIs #981
Conversation
Signed-off-by: saakhan <[email protected]>
Signed-off-by: saakhan <[email protected]>
Signed-off-by: saakhan <[email protected]>
assert data[0]['kubernetes_objects'][0]['containers'][0]['recommendations']['notifications']['112101'][ | ||
'message'] == 'Cost Recommendations Available' | ||
assert data[0]['kubernetes_objects'][0]['containers'][0]['recommendations']['notifications']['111000'][ | ||
'message'] == 'Recommendations Are Available' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please define the expected messages in utils.py and reference it wherever needed.
short_term_recommendation_current = None | ||
if "current" in short_term_recommendation: | ||
short_term_recommendation_current = short_term_recommendation["current"] | ||
if INFO_COST_RECOMMENDATIONS_AVAILABLE_CODE in short_term_recommendation["notifications"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, please include tests and schema changes for medium and long term recommendation validation too
@@ -227,8 +227,8 @@ def test_update_valid_recommendations_just_endtime_input_after_results_after_cre | |||
data = response.json() | |||
assert response.status_code == SUCCESS_STATUS_CODE | |||
assert data[0]['experiment_name'] == experiment_name | |||
assert data[0]['kubernetes_objects'][0]['containers'][0]['recommendations']['notifications']['112101'][ | |||
'message'] == 'Cost Recommendations Available' | |||
assert data[0]['kubernetes_objects'][0]['containers'][0]['recommendations']['notifications']['111000'][ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the codes be replaced with the variables defined in utils.py
"notifications": { | ||
"112101": { | ||
"111000": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see notification codes doc with this code and a few other codes are missing, can you please check and update the doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the doc in mvp_demo is updated, we will need to update the doc in the remote_monitoring branch
@@ -68,7 +68,9 @@ | |||
CRITICAL_MEMORY_LIMIT_NOT_SET_CODE = "524002" | |||
|
|||
INFO_COST_RECOMMENDATIONS_AVAILABLE_CODE = "112101" | |||
INFO_PERFORMANCE_RECOMMENDATIONS_AVAILABLE_CODE = "112102" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this being used anywhere. Please include tests for validating the notification codes.
Signed-off-by: saakhan <[email protected]>
… term Signed-off-by: saakhan <[email protected]>
Signed-off-by: saakhan <[email protected]>
""" | ||
Test Description: This test validates list recommendations for multiple experiments posted using different json files | ||
and query with only the parameter latest and with both latest=true and latest=false | ||
Test Description: This test validates medium term list recommendations for multiple experiments posted using different json files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the description as this tests all terms
@@ -598,8 +606,8 @@ def test_list_recommendations_exp_name_and_monitoring_end_time(test_name, monito | |||
data = response.json() | |||
assert response.status_code == SUCCESS_STATUS_CODE | |||
assert data[0]['experiment_name'] == experiment_name | |||
assert data[0]['kubernetes_objects'][0]['containers'][0]['recommendations']['notifications']['112101'][ | |||
'message'] == 'Cost Recommendations Available' | |||
assert data[0]['kubernetes_objects'][0]['containers'][0]['recommendations']['notifications']['111000'][ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use variable instead of notification code
@@ -448,8 +456,8 @@ def test_list_recommendations_exp_name_and_latest(latest, cluster_type): | |||
data = response.json() | |||
assert response.status_code == SUCCESS_STATUS_CODE | |||
assert data[0]['experiment_name'] == experiment_name | |||
assert data[0]['kubernetes_objects'][0]['containers'][0]['recommendations']['notifications']['112101'][ | |||
'message'] == 'Cost Recommendations Available' | |||
assert data[0]['kubernetes_objects'][0]['containers'][0]['recommendations']['notifications']['111000'][ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use variable instead of notification code
for engine_entry in engines_list: | ||
if engine_entry in terms_obj[term]["recommendation_engines"]: | ||
engine_obj = terms_obj[term]["recommendation_engines"][engine_entry] | ||
validate_config(engine_obj["config"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, include validate_variations here
Merge 0.0.20_rm changes from mvp_demo to master
…per review Signed-off-by: saakhan <[email protected]>
engine_obj = terms_obj[term]["recommendation_engines"][engine_entry] | ||
validate_config(engine_obj["config"]) | ||
current_config = list_reco_container["recommendations"]["data"][interval_end_time]["current"] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@khansaad - For loop to verify all the terms is required as the long term test would have all 3 terms and medium term will have short term as well and it needs to be validated
…ase and other review changes Signed-off-by: saakhan <[email protected]>
experiment_name = None | ||
response = list_recommendations(experiment_name, latest) | ||
|
||
list_reco_json = response.json() | ||
assert response.status_code == SUCCESS_200_STATUS_CODE | ||
|
||
# Validate the json against the json schema | ||
errorMsg = validate_list_reco_json(list_reco_json, list_reco_json_schema) | ||
errorMsg = validate_list_reco_json(list_reco_json, medium_term_list_reco_json_schema) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be reco_json_schema. Have you tested the changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
Also, Ran the complete functional tests, didn't find any issues in that.
Signed-off-by: saakhan <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR fixes #978