Skip to content

tests: add sp_QuickieStore assertion harness (134 assertions) and wire into CI - #838

Merged
erikdarlingdata merged 1 commit into
devfrom
tests/quickiestore-harness
Jul 18, 2026
Merged

tests: add sp_QuickieStore assertion harness (134 assertions) and wire into CI#838
erikdarlingdata merged 1 commit into
devfrom
tests/quickiestore-harness

Conversation

@erikdarlingdata

Copy link
Copy Markdown
Owner

sp_QuickieStore had no automated coverage, and it's the proc where compiling proves least: ~16,000 lines assembling a large dynamic SQL statement whose shape changes with almost every one of its 59 parameters. The statement that breaks is built at run time from string fragments, so it only fails on execution.

The matrix (the point of it)

Every axis below rewrites the generated statement, and each run executes what it built:

  • All 39 @sort_order values — each a different ORDER BY; the wait sorts also join query_store_wait_stats
  • 9 @wait_filter, 4 @execution_type_desc, 4 @query_type
  • The @expert_mode × @format_output grid, plus sort orders combined with expert mode

Bidirectional filter checks

So the filters can't be silently ignored: @query_text_search known-string vs nonsense, @query_type partitioning proc from ad hoc, @top, @execution_count impossibly high. Every absence assertion is paired with a completion check so an errored or empty run can't pass vacuously.

Fixture

Creates its own quickiestore_test database with Query Store on, runs a varied workload (ad hoc queries at different costs plus a stored procedure), flushes Query Store, and drops it in a finally block. Nothing else is touched.

134 assertions, green on 2017, 2022 and 2025. No defects found in sp_QuickieStore — the matrix passes clean, which is a good result and now it's guarded.

One documented client limitation

@debug = 1 runs against a database with no Query Store data on purpose. With data, debug mode returns the generated SQL as an XML column (clickable in SSMS), and go-sqlcmd renders XML columns slowly enough that the server parks in ASYNC_NETWORK_IO and it looks exactly like a hang. Client limitation, not a proc defect — the same run is instant in SSMS, and a non-debug run at full width returns in under a second. Documented in the tests README so nobody "fixes" it by widening timeouts.

🤖 Generated with Claude Code

sp_QuickieStore had no automated coverage at all, and it is the proc where
compiling proves least: ~16,000 lines that assemble a large dynamic SQL
statement whose shape changes with almost every one of its 59 parameters.
@sort_order alone accepts 39 values, each building a different ORDER BY (the
wait sorts additionally join query_store_wait_stats), and @wait_filter /
@execution_type_desc / @query_type / @expert_mode / @format_output each rewrite
the statement again. A combination nobody has run assembles SQL that fails only
at EXECUTION.

So the harness is a parameter matrix that executes what each combination built:
all 39 sort orders, 9 wait filters, 4 execution types, 4 query types, and the
expert/format grid. On top of that, bidirectional assertions prove the filters
actually filter rather than being ignored (@query_text_search on a known string
vs nonsense, @query_type partitioning proc from ad hoc, @top, @execution_count
set impossibly high), each absence paired with a completion check so an errored
run cannot pass vacuously. 134 assertions; green on 2017, 2022 and 2025.

It builds its own Query Store scratch database with a varied workload and drops
it in a finally block. Nothing outside that database is touched.

@debug = 1 is exercised against a database with no Query Store data on purpose:
with data, debug mode returns the generated SQL as an XML column, and go-sqlcmd
renders XML columns slowly enough that the server parks in ASYNC_NETWORK_IO and
it looks exactly like a hang. That is a client limitation - the same run is
instant in SSMS and a non-debug run at full width returns in under a second.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@erikdarlingdata
erikdarlingdata merged commit e641144 into dev Jul 18, 2026
5 checks passed
@erikdarlingdata
erikdarlingdata deleted the tests/quickiestore-harness branch July 18, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant