Cover per-row reads on a page of Duo Workflows with a query-count spec
What does this MR do and why?
Adds ee/spec/requests/api/graphql/ai/duo_workflows/workflows_page_reads_spec.rb: a request spec that lists a page of
sessions through duoWorkflowWorkflows, half of them on the incremental checkpoint path (headers and blobs) and half
with a legacy checkpoint row, selects one group of per-row fields at a time, and asserts per table that six rows cost
no more queries than two (exceed_all_query_limit(control).for_query(...)). The checkpoint examples run with the
duo_workflow_read_incremental_checkpoints gate on and off.
Both production incidents on the session list pages shipped because no request-count spec covered the fields involved
(#628080 (closed)). Since that issue was filed, duoMessages,
lastDuoMessage, latestTodoDuoMessage, firstCheckpoint { threadTs }, stalled, aiCatalogItem,
checkpointWrites and the authorization path gained examples in workflows_spec.rb, and the Pipeline.duoWorkflows,
MergeRequest.duoWorkflows and *Links.workflow entry points get theirs in
!267259 (merged). This spec covers what is left. Fields that still read
per row are pending: on the issue that batches them, so the example fails loudly once that fix lands and the
pending: has to be removed:
| Selection | Queries for 2 rows | 6 rows | State |
|---|---|---|---|
latestCheckpoint { threadTs } firstCheckpoint { threadTs }, header and blob tables |
2 | 2 | passes |
mcpEnabled, namespaces and namespace_ai_settings |
flat | flat | passes |
latestCheckpoint { threadTs } firstCheckpoint { threadTs }, p_duo_workflows_checkpoints |
2 | 6 | pending on #637904 |
| the same with the read gate disabled | 4 | 12 | pending on #637904 |
latestCheckpoint { checkpoint compressedCheckpoint }, header and blob tables |
3 | 7 | pending on #637904 |
latestCheckpoint { executionStatus }, all checkpoint tables |
4 | 10 | pending on #628075 |
lastExecutorLogsUrl allExecutorLogsUrls, workload tables |
4 | 12 | pending on #628076 |
#637904 is new: the legacy-row and blob reads it describes had no sibling in the umbrella, so it was filed from this spec's numbers.
Left out on purpose: auditEvents (the governance follow-up of
#628077 decides how that field is bounded) and
duoWorkflowEvents(first: N), which is a root query rather than a per-row field.
No production code changes.
How to reproduce (on master)
Apply the spec and delete its five pending: lines, then:
bin/rspec ee/spec/requests/api/graphql/ai/duo_workflows/workflows_page_reads_spec.rbExpected: 7 examples, 5 failures, each a query-count diff, for example:
loads the checkpoint rows of the legacy sessions in page-level queries
Expected a maximum of 2 queries, got 6:
SELECT "p_duo_workflows_checkpoints".* FROM "p_duo_workflows_checkpoints"...
-- (expected: 0, got: 1)
WHERE "p_duo_workflows_checkpoints"."workflow_id" = 1633 AND ... ORDER BY "p_duo_workflows_checkpoints"."thread_ts" DESC LIMIT 1
loads the workloads of every row in page-level queries
Expected a maximum of 4 queries, got 12:
SELECT "duo_workflows_workloads"."workload_id" FROM "duo_workflows_workloads"...
-- (expected: 0, got: 2)
WHERE "duo_workflows_workloads"."workflow_id" = 1597How to verify (on this branch)
bin/rspec ee/spec/requests/api/graphql/ai/duo_workflows/workflows_page_reads_spec.rb
# 7 examples, 0 failures, 5 pending
bundle exec rubocop ee/spec/requests/api/graphql/ai/duo_workflows/workflows_page_reads_spec.rb
# 1 file inspected, no offenses detectedReferences
Related to #628080 (closed) Related to #637904 Related to gitlab-org#23509