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

Commit 878b22a

Browse files
committed
fix(ta-gql): get testsuites
I made a change previously that made it so the testsuite column in the dataframe returned by get_results became a list[str] instead of str but I didn't update get testsuites to reflect that. This fixes that. also adds a test for the new V1 format that also verifies it populates the testsuites correctly and fixes a bug with that format renaming a column
1 parent 7090578 commit 878b22a

File tree

4 files changed

+48
-4
lines changed

4 files changed

+48
-4
lines changed

graphql_api/tests/test_test_analytics.py

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,41 @@ def test_gql_query_flake_aggregates(self, repository, store_in_redis):
744744
"flakeCount": 1,
745745
}
746746

747-
def test_gql_query_with_new_ta(self, mocker, repository, snapshot):
747+
def test_gql_query_test_suites(self, repository, store_in_redis):
748+
query = base_gql_query % (
749+
repository.author.username,
750+
repository.name,
751+
"""
752+
testSuites
753+
""",
754+
)
755+
756+
result = self.gql_request(query, owner=repository.author)
757+
758+
assert sorted(result["owner"]["repository"]["testAnalytics"]["testSuites"]) == [
759+
"testsuite1",
760+
"testsuite2",
761+
"testsuite3",
762+
"testsuite4",
763+
"testsuite5",
764+
]
765+
766+
def test_gql_query_test_suites_term(self, repository, store_in_redis):
767+
query = base_gql_query % (
768+
repository.author.username,
769+
repository.name,
770+
"""
771+
testSuites(term: "testsuite1")
772+
""",
773+
)
774+
775+
result = self.gql_request(query, owner=repository.author)
776+
777+
assert result["owner"]["repository"]["testAnalytics"]["testSuites"] == [
778+
"testsuite1",
779+
]
780+
781+
def test_gql_query_with_new_ta_v1(self, mocker, repository, snapshot):
748782
# set the feature flag
749783
mocker.patch("rollouts.READ_NEW_TA.check_value", return_value=True)
750784

@@ -757,7 +791,8 @@ def test_gql_query_with_new_ta(self, mocker, repository, snapshot):
757791
storage.write_file(
758792
settings.GCS_BUCKET_NAME,
759793
f"test_analytics/branch_rollups/{repository.repoid}/{repository.branch}.arrow",
760-
test_results_table_no_version.write_ipc(None).getvalue(),
794+
test_results_table_v1.write_ipc(None).getvalue(),
795+
metadata={"version": "1"},
761796
)
762797

763798
# run the GQL query
@@ -784,6 +819,7 @@ def test_gql_query_with_new_ta(self, mocker, repository, snapshot):
784819
}
785820
}
786821
}
822+
testSuites
787823
""",
788824
)
789825

@@ -804,6 +840,14 @@ def test_gql_query_with_new_ta(self, mocker, repository, snapshot):
804840
]
805841
]
806842

843+
assert sorted(result["owner"]["repository"]["testAnalytics"]["testSuites"]) == [
844+
"testsuite0",
845+
"testsuite1",
846+
"testsuite2",
847+
"testsuite3",
848+
"testsuite4",
849+
]
850+
807851
storage.delete_file(
808852
settings.GCS_BUCKET_NAME,
809853
f"test_analytics/branch_rollups/{repository.repoid}/{repository.branch}.arrow",

graphql_api/types/test_analytics/test_analytics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def get_test_suites(
312312
if table is None:
313313
return []
314314

315-
testsuites = table.select(pl.col("testsuite")).unique()
315+
testsuites = table.select(pl.col("testsuite").explode()).unique()
316316

317317
if term:
318318
testsuites = testsuites.filter(pl.col("testsuite").str.starts_with(term))

utils/test_results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def v1_agg_table(table: pl.LazyFrame) -> pl.LazyFrame:
198198
pl.col("avg_duration") * (pl.col("pass_count") + pl.col("fail_count"))
199199
).sum() / (pl.col("pass_count") + pl.col("fail_count")).sum()
200200

201-
table = table.group_by("computed_name").agg(
201+
table = table.group_by(pl.col("computed_name").alias("name")).agg(
202202
pl.col("testsuite").alias(
203203
"testsuite"
204204
), # TODO: filter by this before we aggregate

0 commit comments

Comments
 (0)