tests: add sp_QuickieStore assertion harness (134 assertions) and wire into CI - #838
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
@sort_ordervalues — each a differentORDER BY; the wait sorts also joinquery_store_wait_stats@wait_filter, 4@execution_type_desc, 4@query_type@expert_mode×@format_outputgrid, plus sort orders combined with expert modeBidirectional filter checks
So the filters can't be silently ignored:
@query_text_searchknown-string vs nonsense,@query_typepartitioning proc from ad hoc,@top,@execution_countimpossibly 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_testdatabase 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 afinallyblock. 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 = 1runs 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 inASYNC_NETWORK_IOand 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