-
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
Fix UpdateResultsAPI duplicate record issue #1051
Conversation
Signed-off-by: Saad Khan <[email protected]>
@khansaad as mentioned we need to add the appropriate negative tests to handle this scenario. @chandrams please review |
Signed-off-by: Saad Khan <[email protected]>
@@ -335,6 +337,34 @@ def validate_reco_json(create_exp_json, update_results_json, list_reco_json, exp | |||
list_reco_kubernetes_obj, expected_duration_in_hours, test_name) | |||
|
|||
|
|||
def validate_list_exp_results_count(update_results_json, list_exp_json): |
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 function should accept expected_results_count as a parameter
print("list_exp_results_count = ", list_exp_results_count) | ||
print("net_count = ", net_count) | ||
|
||
assert net_count == DUPLICATE_RECORDS_COUNT |
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.
Change this to assert list_exp_results_count against expected_results_count
results = container.get("results", {}) | ||
count += len(results) | ||
|
||
return count/container_count |
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.
Should we take only integer part here?
# Description: This function obtains the experiment details including the results from Kruize Autotune using | ||
# listExperiments API | ||
# Input Parameters: experiment_name | ||
def list_experiments_with_results(experiment_name: str): |
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.
We already have a list_experiments function, pass experiment_name, results, recommendations and latest as parameters and accordingly set the PARAMS before calling the API similar to list_recommendations
data = response.json() | ||
assert response.status_code == ERROR_STATUS_CODE | ||
assert data['status'] == ERROR_STATUS | ||
assert data['message'] == UPDATE_RESULTS_FAILED_RECORDS_MSG |
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.
Also validate the failed records data error messages - "An entry for this record already exists!"
Signed-off-by: Saad Khan <[email protected]>
error_messages = [error['message'] for item in data['data'] for error in item['errors']] | ||
error_messages_code = [error['httpcode'] for item in data['data'] for error in item['errors']] | ||
|
||
assert DUPLICATE_RECORDS_MSG in error_messages |
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.
We need to validate each error message or http code and use equals here
assert data['status'] == ERROR_STATUS | ||
assert data['message'] == UPDATE_RESULTS_FAILED_RECORDS_MSG | ||
|
||
response = list_experiments("true", None, "false", experiment_name) |
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.
Assign the values to variables and pass those variables for better readability. Also update any other references to list_experiments in other tests.
…anges Signed-off-by: Saad Khan <[email protected]>
Signed-off-by: Saad Khan <[email protected]>
Signed-off-by: Saad Khan <[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
Signed-off-by: Saad Khan <[email protected]>
This PR fixes the duplicate record mismatch issue after hitting the updateResults API. We were seeing a difference in the number of records getting saved in the DB.