[skip e2e]Refactor workflow analyse script (#14966)

Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>
pull/14968/head
zhuwenxing 2022-01-06 22:01:21 +08:00 committed by GitHub
parent b4e2109421
commit d5b62973b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 42 deletions

View File

@ -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")