Skip to content

Commit

Permalink
incorporated review comments
Browse files Browse the repository at this point in the history
Signed-off-by: msvinaykumar <[email protected]>
  • Loading branch information
msvinaykumar committed Nov 25, 2024
1 parent bfab21f commit fa2f4c0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion tests/scripts/helpers/kruize.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def post_bulk_api(input_json_file):
def get_bulk_job_status(job_id,verbose=False):
print("\n************************************************************")
url_basic = f"{URL}/bulk?job_id={job_id}"
url_verbose = f"{URL}/bulk?job_id={job_id}&verbose=true"
url_verbose = f"{URL}/bulk?job_id={job_id}&verbose={verbose}"
getJobIDURL = url_basic
if verbose:
getJobIDURL = url_verbose
Expand Down
25 changes: 25 additions & 0 deletions tests/scripts/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import time
import math
import docker
from helpers.kruize import *
from datetime import datetime, timedelta
from kubernetes import client, config
from pathlib import Path
Expand Down Expand Up @@ -1582,6 +1583,30 @@ def validate_accelerator_recommendations_for_container(recommendations_json):
perf_limits_map = term_obj["recommendation_engines"]["performance"]["config"]["limits"]
validate_limits_map_for_accelerator(perf_limits_map)

#@pytest.mark.skip(reason="Not a test function")
def validate_job_status(job_id, base_url, caplog):
# Common keys expected in both responses
common_keys = {
"status", "total_experiments", "processed_experiments", "job_id", "job_start_time", "job_end_time"
}

# Extra keys expected when verbose=true
verbose_keys = {
"experiments"
}

# Make the GET request without verbose
response_basic = get_bulk_job_status(job_id,False)
# Verify common keys in the basic response
assert common_keys.issubset(
response_basic.json().keys()), f"Missing keys in response: {common_keys - response_basic.json().keys()}"

response_verbose = get_bulk_job_status(job_id,True)
# Verify common and verbose keys in the verbose response
assert common_keys.issubset(
response_verbose.json().keys()), f"Missing keys in verbose response: {common_keys - response_verbose.json().keys()}"
assert verbose_keys.issubset(
response_verbose.json().keys()), f"Missing verbose keys in response: {verbose_keys - response_verbose.json().keys()}"



Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ The above tests are developed using pytest framework and the tests are run using
- Runs the above tests using pytest

### **Bulk API tests**
This test script validates the functionality of a bulk POST API and associated GET job status API for a Kubernetes resource optimization service, focusing on the creation and monitoring of job IDs.
This test script validates the functionality of a bulk POST [API](/design/MonitoringModeAPI.md) and associated GET job status API for a Kubernetes resource optimization service, focusing on the creation and monitoring of job IDs.

Here are the test scenarios:
- Validate the bulk POST API's ability to generate a job_id for given payloads.
Expand Down
27 changes: 1 addition & 26 deletions tests/scripts/local_monitoring_tests/rest_apis/test_bulkAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,30 +63,5 @@ def test_bulk_post_request(cluster_type, bulk_request_payload, expected_job_id_p

# If a job_id is generated, run the GET request test
if job_id_present:
get_job_status(response.json()["job_id"], URL, caplog)
validate_job_status(response.json()["job_id"], URL, caplog)

@pytest.mark.skip(reason="Not a test function")
def get_job_status(job_id, base_url, caplog):
# Common keys expected in both responses
common_keys = {
"status", "total_experiments", "processed_experiments", "job_id", "job_start_time", "job_end_time"
}

# Extra keys expected when verbose=true
verbose_keys = {
"experiments"
}

with caplog.at_level(logging.INFO):
# Make the GET request without verbose
response_basic = get_bulk_job_status(job_id,False)
# Verify common keys in the basic response
assert common_keys.issubset(
response_basic.json().keys()), f"Missing keys in response: {common_keys - response_basic.json().keys()}"

response_verbose = get_bulk_job_status(job_id,True)
# Verify common and verbose keys in the verbose response
assert common_keys.issubset(
response_verbose.json().keys()), f"Missing keys in verbose response: {common_keys - response_verbose.json().keys()}"
assert verbose_keys.issubset(
response_verbose.json().keys()), f"Missing verbose keys in response: {verbose_keys - response_verbose.json().keys()}"

0 comments on commit fa2f4c0

Please sign in to comment.