Some checks are pending
CI / Build og unit tests (push) Waiting to run
CI / Integration (mcr.microsoft.com/mssql/server:2017-latest) (push) Blocked by required conditions
CI / Integration (mcr.microsoft.com/mssql/server:2019-latest) (push) Blocked by required conditions
CI / Integration (mcr.microsoft.com/mssql/server:2022-latest) (push) Blocked by required conditions
CI / Integration (mcr.microsoft.com/mssql/server:2025-latest) (push) Blocked by required conditions
- .NET 10 solution with Core, Connectivity, Rules, Contracts, Agent, Web and Hub - Capability model gating collectors and rules by SQL Server version (2000 and later); rules that cannot run are reported as not measurable, never as passed - Connectivity via Microsoft.Data.SqlClient with ODBC fallback for legacy instances, hardened monitoring session settings valid back to SQL Server 2000 - Support lifecycle rule (SQLI-VER-001) with lifecycle data shipped as a rule pack - Version-aware least-privilege permissions script, verified by integration tests against SQL Server in Docker (reads monitoring sources, cannot read customer data) - Forgejo Actions CI, contributing guide, code of conduct, issue templates, legacy version notes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E3EExwndy8Z22EK2Qpt6BK
48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using Microsoft.Data.SqlClient;
|
|
using Testcontainers.MsSql;
|
|
|
|
namespace SQLInsight.IntegrationTests;
|
|
|
|
/// <summary>
|
|
/// One SQL Server container for the test run. The image is chosen with <c>SQLINSIGHT_MSSQL_IMAGE</c> so CI can run
|
|
/// the same tests against 2017, 2019, 2022 and 2025.
|
|
/// </summary>
|
|
public sealed class SqlServerFixture : IAsyncLifetime
|
|
{
|
|
public const string DefaultImage = "mcr.microsoft.com/mssql/server:2022-latest";
|
|
|
|
public static string Image => Environment.GetEnvironmentVariable("SQLINSIGHT_MSSQL_IMAGE") ?? DefaultImage;
|
|
|
|
private readonly MsSqlContainer _container = new MsSqlBuilder(Image).Build();
|
|
|
|
public string SaConnectionString => _container.GetConnectionString();
|
|
|
|
public string Server
|
|
{
|
|
get
|
|
{
|
|
var builder = new SqlConnectionStringBuilder(SaConnectionString);
|
|
return builder.DataSource;
|
|
}
|
|
}
|
|
|
|
public Task InitializeAsync() => _container.StartAsync();
|
|
|
|
public Task DisposeAsync() => _container.DisposeAsync().AsTask();
|
|
|
|
public async Task ExecuteAsSaAsync(string sql)
|
|
{
|
|
await using var connection = new SqlConnection(SaConnectionString);
|
|
await connection.OpenAsync();
|
|
await using var command = connection.CreateCommand();
|
|
command.CommandText = sql;
|
|
command.CommandTimeout = 120;
|
|
await command.ExecuteNonQueryAsync();
|
|
}
|
|
}
|
|
|
|
[CollectionDefinition(Name)]
|
|
public sealed class SqlServerTestGroup : ICollectionFixture<SqlServerFixture>
|
|
{
|
|
public const string Name = "SQL Server";
|
|
}
|