Skip to content

Commit

Permalink
Updated kruize.py
Browse files Browse the repository at this point in the history
Signed-off-by: Chandrakala Subramanyam <[email protected]>
  • Loading branch information
chandrams committed Dec 9, 2024
1 parent bf0a532 commit 3053305
Showing 1 changed file with 6 additions and 36 deletions.
42 changes: 6 additions & 36 deletions tests/scripts/helpers/kruize.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ def get_kruize_url():

def form_kruize_url(cluster_type, SERVER_IP=None):
global URL
KIND_IP="127.0.0.1"
KRUIZE_PORT=8080

if SERVER_IP != None:
URL = "http://" + str(SERVER_IP)
Expand All @@ -47,8 +45,7 @@ def form_kruize_url(cluster_type, SERVER_IP=None):
ip = subprocess.run(['minikube ip'], shell=True, stdout=subprocess.PIPE)
SERVER_IP = ip.stdout.decode('utf-8').strip('\n')
URL = "http://" + str(SERVER_IP) + ":" + str(AUTOTUNE_PORT)
elif (cluster_type == "kind"):
URL = "http://" + KIND_IP + ":" + str(KRUIZE_PORT)

elif (cluster_type == "openshift"):

subprocess.run(['oc expose svc/kruize -n openshift-tuning'], shell=True, stdout=subprocess.PIPE)
Expand All @@ -63,33 +60,6 @@ def form_kruize_url(cluster_type, SERVER_IP=None):

print("\nKRUIZE AUTOTUNE URL = ", URL)

# Description: This function invokes the Kruize bulk service API
# Input Parameters: bulk json
def bulk(bulk_json_file):
json_file = open(bulk_json_file, "r")
bulk_json = json.loads(json_file.read())

#print("\nInvoking bulk service...")
url = URL + "/bulk"
print("URL = ", url)

response = requests.post(url, json=bulk_json)
return response

# Description: This function invokes the Kruize bulk service API
# Input Parameters: job id returned from bulk service
def get_bulk_job_status(job_id, verbose = None):
#print("\nGet the bulk job status for job id %s " % (job_id))
queryString = "?"
if job_id:
queryString = queryString + "job_id=%s" % (job_id)
if verbose:
queryString = queryString + "&verbose=%s" % (verbose)

url = URL + "/bulk%s" % (queryString)
#print("URL = ", url)
response = requests.get(url, )
return response

# Description: This function validates the input json and posts the experiment using createExperiment API to Kruize Autotune
# Input Parameters: experiment input json
Expand Down Expand Up @@ -204,10 +174,10 @@ def list_recommendations(experiment_name=None, latest=None, monitoring_end_time=
print("PARAMS = ", PARAMS)
response = requests.get(url=url, params=PARAMS)

#print("Response status code = ", response.status_code)
#print("\n************************************************************")
#print(response.text)
#print("\n************************************************************")
print("Response status code = ", response.status_code)
print("\n************************************************************")
print(response.text)
print("\n************************************************************")
return response


Expand Down Expand Up @@ -521,4 +491,4 @@ def get_bulk_job_status(job_id,verbose=False):

print("Verbose GET Response Status Code: ", response.status_code)
print("Verbose GET Response JSON: ", response.json())
return response
return response

0 comments on commit 3053305

Please sign in to comment.