From 1bbe5eb8eba66dd9031f3ad6b8c5d8ed11ff7d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Eggert=20Lundsteen=20Olsen?= Date: Fri, 2 Oct 2026 11:14:54 +0200 Subject: [PATCH] Plan analysis test: start from an empty plan cache With the new collectors the full suite fills the plan cache with heavier statements, so the light probe statements could fall outside the 50 heaviest. The test clears the cache first (test only; SQLInsight never does). Co-Authored-By: Claude Opus 5.5 (1M context) --- tests/SQLInsight.IntegrationTests/CollectorTests.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/SQLInsight.IntegrationTests/CollectorTests.cs b/tests/SQLInsight.IntegrationTests/CollectorTests.cs index 5532aa9..9f0cc58 100644 --- a/tests/SQLInsight.IntegrationTests/CollectorTests.cs +++ b/tests/SQLInsight.IntegrationTests/CollectorTests.cs @@ -267,6 +267,10 @@ public class CollectorTests(SqlServerFixture sql) END; EXEC (N'CREATE OR ALTER FUNCTION dbo.fn_PlanProbePrice (@p int) RETURNS int AS BEGIN RETURN @p * DATEPART(ms, GETDATE()); END;'); """); + // The rest of the suite fills the plan cache with heavier statements; start from an empty cache (test only: + // SQLInsight itself never clears it). + await sql.ExecuteAsSaAsync("DBCC FREEPROCCACHE WITH NO_INFOMSGS;"); + // Run in the database (not after USE in a master batch) so the plans belong to it, and put the tags inside the // statements: the statement text ends at the statement, not at a trailing comment. await using (var connection = new Microsoft.Data.SqlClient.SqlConnection(sql.DatabaseConnectionString(SqlServerFixture.TestDatabase)))