mirror of https://github.com/milvus-io/milvus.git
[skip e2e]Refactor workflow analyse script (#14966)
Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>pull/14968/head
parent
b4e2109421
commit
d5b62973b1
|
@ -9,47 +9,27 @@ headers = {
|
|||
}
|
||||
|
||||
response = requests.request("GET", url, headers=headers, data=payload)
|
||||
pod_kill_workflow_id = [w["id"] for w in response.json()["workflows"] if "Pod Kill" in w["name"]][0]
|
||||
pod_failure_workflow_id = [w["id"] for w in response.json()["workflows"] if "Pod Failure" in w["name"]][0]
|
||||
|
||||
|
||||
|
||||
response_pod_kill = requests.request("GET", f"https://api.github.com/repos/milvus-io/milvus/actions/workflows/{pod_kill_workflow_id}/runs", headers=headers, data=payload, verify=False)
|
||||
pod_kill_runs = [r["id"] for r in response_pod_kill.json()["workflow_runs"] if r["status"] == "completed" and r["event"] == "schedule"]
|
||||
|
||||
response_pod_failure = requests.request("GET", f"https://api.github.com/repos/milvus-io/milvus/actions/workflows/{pod_failure_workflow_id}/runs", headers=headers, data=payload, verify=False)
|
||||
pod_failure_runs = [r["id"] for r in response_pod_failure.json()["workflow_runs"] if r["status"] == "completed" and r["event"] == "schedule"]
|
||||
|
||||
|
||||
# pod kill analysis
|
||||
pod_kill_result = {}
|
||||
for run in pod_kill_runs:
|
||||
pod_kill_jobs_url = f"https://api.github.com/repos/milvus-io/milvus/actions/runs/{run}/jobs"
|
||||
response_pod_kill = requests.request("GET", pod_kill_jobs_url, headers=headers, data=payload, verify=False)
|
||||
for r in response_pod_kill.json()["jobs"]:
|
||||
if r["name"] not in pod_kill_result:
|
||||
pod_kill_result[r["name"]] = {"success": 0, "failure": 0}
|
||||
if r["status"] == "completed" and r["conclusion"] == "success":
|
||||
pod_kill_result[r["name"]]["success"] += 1
|
||||
elif r["status"] == "completed" and r["conclusion"] != "success":
|
||||
pod_kill_result[r["name"]]["failure"] += 1
|
||||
def analysis_workflow(workflow_name, workflow_response):
|
||||
workflow_id = [w["id"] for w in workflow_response.json()["workflows"] if workflow_name in w["name"]][0]
|
||||
runs_response = requests.request("GET", f"https://api.github.com/repos/milvus-io/milvus/actions/workflows/{workflow_id}/runs", headers=headers, data=payload, verify=False)
|
||||
workflow_runs = [r["id"] for r in runs_response.json()["workflow_runs"] if r["status"] == "completed" and r["event"] == "schedule"]
|
||||
results = {}
|
||||
for run in workflow_runs:
|
||||
job_url = f"https://api.github.com/repos/milvus-io/milvus/actions/runs/{run}/jobs"
|
||||
job_response = requests.request("GET", job_url, headers=headers, data=payload, verify=False)
|
||||
for r in job_response.json()["jobs"]:
|
||||
if r["name"] not in results:
|
||||
results[r["name"]] = {"success": 0, "failure": 0}
|
||||
if r["status"] == "completed" and r["conclusion"] == "success":
|
||||
results[r["name"]]["success"] += 1
|
||||
elif r["status"] == "completed" and r["conclusion"] != "success":
|
||||
results[r["name"]]["failure"] += 1
|
||||
return results
|
||||
|
||||
for k,v in pod_kill_result.items():
|
||||
print(f"{k} success: {v['success']}, failure: {v['failure']}")
|
||||
|
||||
|
||||
# pod failure analysis
|
||||
pod_failure_result = {}
|
||||
for run in pod_failure_runs:
|
||||
pod_failure_jobs_url = f"https://api.github.com/repos/milvus-io/milvus/actions/runs/{run}/jobs"
|
||||
response_pod_failure = requests.request("GET", pod_failure_jobs_url, headers=headers, data=payload, verify=False)
|
||||
for r in response_pod_failure.json()["jobs"]:
|
||||
if r["name"] not in pod_failure_result:
|
||||
pod_failure_result[r["name"]] = {"success": 0, "failure": 0}
|
||||
if r["status"] == "completed" and r["conclusion"] == "success":
|
||||
pod_failure_result[r["name"]]["success"] += 1
|
||||
elif r["status"] == "completed" and r["conclusion"] == "failure":
|
||||
pod_failure_result[r["name"]]["failure"] += 1
|
||||
|
||||
for k,v in pod_failure_result.items():
|
||||
print(f"{k} success: {v['success']}, failure: {v['failure']}")
|
||||
for workflow in ["Pod Kill"]:
|
||||
result = analysis_workflow(workflow, response)
|
||||
print(f"{workflow}:")
|
||||
for k,v in result.items():
|
||||
print(f"{k} success: {v['success']}, failure: {v['failure']}")
|
||||
print("\n")
|
||||
|
|
Loading…
Reference in New Issue