From b13194e43da8d8e312960bcdad2906475a04d868 Mon Sep 17 00:00:00 2001 From: Yutong Zhang Date: Fri, 3 Jan 2025 14:13:24 +0800 Subject: [PATCH 1/2] Add debug log --- .../impacted_area_testing/calculate_instance_number.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.azure-pipelines/impacted_area_testing/calculate_instance_number.py b/.azure-pipelines/impacted_area_testing/calculate_instance_number.py index 259da937f34..32ef797f2f8 100644 --- a/.azure-pipelines/impacted_area_testing/calculate_instance_number.py +++ b/.azure-pipelines/impacted_area_testing/calculate_instance_number.py @@ -1,6 +1,7 @@ import os import argparse import math +import logging from constant import PR_CHECKER_TOPOLOGY_NAME, MAX_INSTANCE_NUMBER, MAX_GET_TOKEN_RETRY_TIMES from azure.kusto.data import KustoConnectionStringBuilder, KustoClient @@ -95,8 +96,8 @@ def main(scripts, topology, branch): "| order by UploadTime desc) on TestPlanId " \ f"| where FilePath == '{script}' " \ "| where Result !in ('failure', 'error') " \ + "| take 5" \ "| summarize ActualCount = count(), TotalRuntime = sum(Runtime)" - try: response = client.execute("SonicTestData", query) except Exception as e: @@ -117,6 +118,8 @@ def main(scripts, topology, branch): total_running_time += average_running_time scripts_running_time[script] = average_running_time + logging.info(f"Time for each test script: {scripts_running_time}") + logging.info(f"Total running time: {total_running_time}") # Total running time is calculated by seconds, divide by 60 to get minutes # For one instance, we plan to assign 90 minutes to run test scripts # Obtain the number of instances by rounding up the calculation. @@ -131,6 +134,8 @@ def main(scripts, topology, branch): parser.add_argument("--branch", help="Test branch", type=str, default="") args = parser.parse_args() + logging.basicConfig(level=logging.INFO) + scripts = args.scripts topology = args.topology branch = args.branch From d6c705e019baf07c9c2aa72874894448a13e038c Mon Sep 17 00:00:00 2001 From: Yutong Zhang Date: Fri, 3 Jan 2025 15:23:46 +0800 Subject: [PATCH 2/2] Modify as comment --- .../impacted_area_testing/calculate_instance_number.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/impacted_area_testing/calculate_instance_number.py b/.azure-pipelines/impacted_area_testing/calculate_instance_number.py index 32ef797f2f8..b5a6296ca70 100644 --- a/.azure-pipelines/impacted_area_testing/calculate_instance_number.py +++ b/.azure-pipelines/impacted_area_testing/calculate_instance_number.py @@ -5,6 +5,8 @@ from constant import PR_CHECKER_TOPOLOGY_NAME, MAX_INSTANCE_NUMBER, MAX_GET_TOKEN_RETRY_TIMES from azure.kusto.data import KustoConnectionStringBuilder, KustoClient +logging.basicConfig(level=logging.INFO) + def parse_list_from_str(s): # Since Azure Pipeline doesn't support to receive an empty parameter, @@ -134,8 +136,6 @@ def main(scripts, topology, branch): parser.add_argument("--branch", help="Test branch", type=str, default="") args = parser.parse_args() - logging.basicConfig(level=logging.INFO) - scripts = args.scripts topology = args.topology branch = args.branch