Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 0194300

Browse files
committed
fix(ta-gql): fill_nan on avg_duration in aggregate
it's possible for the avg_duration to be NaN (which is fine) but I wasn't taking this into account in the aggregate calculation which meant that the NaN's were propagating to the total duration and slowest tests duration so we need to replace them with 0 because that's effectively what they are
1 parent 5d59b5c commit 0194300

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

graphql_api/tests/test_test_analytics.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,17 @@ def test_gql_query_with_new_ta_v1(self, mocker, repository, snapshot):
819819
}
820820
}
821821
}
822+
flakeAggregates {
823+
flakeRate
824+
flakeCount
825+
}
826+
testResultsAggregates {
827+
totalDuration
828+
slowestTestsDuration
829+
totalFails
830+
totalSkips
831+
totalSlowTests
832+
}
822833
testSuites
823834
""",
824835
)
@@ -848,6 +859,20 @@ def test_gql_query_with_new_ta_v1(self, mocker, repository, snapshot):
848859
"testsuite4",
849860
]
850861

862+
assert result["owner"]["repository"]["testAnalytics"]["flakeAggregates"] == {
863+
"flakeRate": (1 / 15),
864+
"flakeCount": 1,
865+
}
866+
867+
assert result["owner"]["repository"]["testAnalytics"][
868+
"testResultsAggregates"
869+
] == {
870+
"totalDuration": 7500.0,
871+
"slowestTestsDuration": 2500.0,
872+
"totalFails": 50,
873+
"totalSkips": 25,
874+
"totalSlowTests": 1,
875+
}
851876
storage.delete_file(
852877
settings.GCS_BUCKET_NAME,
853878
f"test_analytics/branch_rollups/{repository.repoid}/{repository.branch}.arrow",

graphql_api/types/test_results_aggregates/test_results_aggregates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class TestResultsAggregates:
2424

2525

2626
def calculate_aggregates(table: pl.DataFrame) -> pl.DataFrame:
27-
return table.select(
27+
return table.with_columns(pl.col("avg_duration").fill_nan(0)).select(
2828
(
2929
pl.col("avg_duration")
3030
* (pl.col("total_pass_count") + pl.col("total_fail_count"))

0 commit comments

Comments
 (0)