Skip to content

Commit

Permalink
Add additional logging to script calculate_instance_number.py (#16331)
Browse files Browse the repository at this point in the history
What is the motivation for this PR?
In this PR, we have added additional logging to the calculate_instance_number.py script to improve tracking and visibility of its operations.

How did you do it?
Add additional logging to the calculate_instance_number.py script.

How did you verify/test it?
  • Loading branch information
yutongzhang-microsoft authored Jan 6, 2025
1 parent f020006 commit 1c79793
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
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

logging.basicConfig(level=logging.INFO)


def parse_list_from_str(s):
# Since Azure Pipeline doesn't support to receive an empty parameter,
Expand Down Expand Up @@ -95,8 +98,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:
Expand All @@ -117,6 +120,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.
Expand Down

0 comments on commit 1c79793

Please sign in to comment.