Skip to content

Commit 6e8cebe

Browse files
[Impacted Area Based PR testing] Fix actually count calculation for test scripts. (#16487)
What is the motivation for this PR? In PR #16437, we addressed the script timing issue by selecting the five most recent test plans. However, this caused an incorrect ActualCount, as it was summarizing the number of test cases instead of the test scripts. Since the number of test scripts matches the number of test plans, this PR updates the query to correctly count the test plans. How did you do it? Since the number of test scripts matches the number of test plans, this PR updates the query to correctly count the test plans.
1 parent bb2c102 commit 6e8cebe

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

.azure-pipelines/impacted_area_testing/calculate_instance_number.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,15 @@ def main(scripts, topology, branch):
8888
# As baseline test is the universal set of PR test
8989
# we get the historical running time of one script here
9090
# We get recent 5 test plans and calculate the average running time
91-
query = "V2TestCases " \
92-
"| join kind=inner" \
93-
"(TestPlans " \
91+
query = "let FilteredTestPlans = TestPlans " \
9492
"| where TestPlanType == 'PR' and Result == 'FINISHED' " \
95-
f"and Topology == '{PR_CHECKER_TOPOLOGY_NAME[topology][0]}' " \
96-
f"and TestBranch == '{branch}' and TestPlanName contains '{PR_CHECKER_TOPOLOGY_NAME[topology][1]}' " \
97-
"and TestPlanName contains '_BaselineTest_'" \
98-
"| order by UploadTime desc" \
99-
"| take 5) on TestPlanId " \
100-
f"| where FilePath == '{script}' " \
101-
"| where Result !in ('failure', 'error') " \
102-
"| summarize ActualCount = count(), TotalRuntime = sum(Runtime)"
93+
f"and Topology == '{PR_CHECKER_TOPOLOGY_NAME[topology][0]}'" \
94+
f"and TestBranch == '{branch}' and TestPlanName contains '{PR_CHECKER_TOPOLOGY_NAME[topology][1]}'" \
95+
"and TestPlanName contains '_BaselineTest_' | order by UploadTime desc | take 5;" \
96+
"let FilteredCount = toscalar(FilteredTestPlans | summarize ActualCount = count());" \
97+
"V2TestCases | join kind=inner( FilteredTestPlans ) on TestPlanId" \
98+
f"| where FilePath == '{script}' | where Result !in ('failure', 'error')" \
99+
"| summarize TotalRuntime = sum(Runtime), ActualCount=FilteredCount"
103100
try:
104101
response = client.execute("SonicTestData", query)
105102
except Exception as e:

0 commit comments

Comments
 (0)