I'm trying to query our instance of GitLab for flakey tests.
If I navigate to a URL of this format, https://our-gitlab-instance.com/the-group/the-project/-/pipelines/365771/tests/suite.json?build_ids[]=1671439, we get some nice JSON which lists stats about the tests.
I'm specifically looking for flakey test cases which looks something like this:
{
"status": "success",
"name": "The name of the test",
"classname": "the/path/to/the/test.pw.ts",
"file": null,
"execution_time": 77.511,
"system_output": null,
"stack_trace": null,
"recent_failures": {
"count": 18,
"base_branch": "develop"
},
},
Initially, I was trying to use GraphQL:
query {
project(fullPath: "path_to/my_project") {
pipelines {
nodes {
testSuite {
testCases {
nodes {
recentFailures {
baseBranch
count
}
}
}
}
}
}
}
}
GraphQL seems to provide the right fields, however, testSuite requires an argument buildIds of type [ID!]!.
I can get the data I need with this query:
query {
project(fullPath: "path_to/my_project") {
pipeline(iid: "261264") {
testSuite(buildIds: "1671439") {
testCases {
nodes {
recentFailures {
count
baseBranch
}
}
}
}
}
}
}
But this involves creating a separate query for each job. As I'm wanting to enumerate over all builds over a given timeframe, this seems like a lot.
I have not yet found any REST endpoint that provides this information.
Are there any other options I haven't considered?