Some checks are pending
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 / Build og unit tests (push) Waiting to run
CI / MSI-installer (push) Blocked by required conditions
CI / Integration (mcr.microsoft.com/mssql/server:2017-latest) (push) Blocked by required conditions
CI / Integration (mcr.microsoft.com/mssql/server:2025-latest) (push) Blocked by required conditions
installer/SQLInsight.wxs (WiX 3 syntax) builds on Linux with wixl (installer/build-msi.sh) and in Forgejo CI on every v* tag. Agent and Web are installed self-contained as Windows services under virtual service accounts (or a gMSA), with a settings page in the wizard or MSI properties for silent installs; the values go to sqlinsight.ini, read after appsettings.json. The data folder is locked to SYSTEM, Administrators and the agent account, the event log source is registered, the web port is opened in the firewall, and the automatic update task is an optional feature. Upgrades happen in place, keep edited settings and the chosen features; uninstall keeps the settings. msi-tables.py writes what wixl lacks (component and feature conditions, Permanent/NeverOverwrite, vital services, REG_EXPAND_SZ) and verify-msi.py checks the result (sequencing, deferred actions, ASCII only). test-msi-wine.sh runs install, upgrade and uninstall under Wine. Installations made with the MSI get new versions as MSI packages run by the update task, so Windows Installer stays in charge of the files. The example instance is removed from the shipped appsettings.json, and the CLI writes UTF-8 to the console. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E3EExwndy8Z22EK2Qpt6BK
62 lines
2.4 KiB
C#
62 lines
2.4 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
namespace SQLInsight.Agent.Tests;
|
|
|
|
public sealed class InstallerSettingsTests : IDisposable
|
|
{
|
|
private readonly string _folder = Path.Combine(Path.GetTempPath(), "sqlinsight-ini-" + Guid.NewGuid().ToString("N"));
|
|
|
|
public InstallerSettingsTests()
|
|
{
|
|
Directory.CreateDirectory(_folder);
|
|
File.WriteAllText(Path.Combine(_folder, "appsettings.json"), """
|
|
{ "SQLInsight": { "Repository": { "ConnectionString": "eksempel" }, "Tick": "00:00:15", "MaxParallelInstances": 4 } }
|
|
""");
|
|
File.WriteAllText(Path.Combine(_folder, InstallerSettings.FileName), """
|
|
[SQLInsight:Repository]
|
|
ConnectionString=Server=sqlmon01;Database=SQLInsight;Integrated Security=true
|
|
[SQLInsight:Instances:0]
|
|
Name=sql01
|
|
Server=sql01
|
|
[SQLInsight]
|
|
Tick=00:00:30
|
|
""");
|
|
}
|
|
|
|
public void Dispose() => Directory.Delete(_folder, recursive: true);
|
|
|
|
private HostApplicationBuilder Builder(params string[] args)
|
|
{
|
|
var builder = Host.CreateApplicationBuilder(new HostApplicationBuilderSettings { ContentRootPath = _folder, Args = args, EnvironmentName = "Production" });
|
|
InstallerSettings.Add(builder.Configuration, _folder);
|
|
return builder;
|
|
}
|
|
|
|
[Fact]
|
|
public void Installer_values_override_the_examples_in_appsettings_json()
|
|
{
|
|
var options = Builder().Configuration.GetSection(AgentOptions.SectionName).Get<AgentOptions>()!;
|
|
|
|
Assert.Equal("Server=sqlmon01;Database=SQLInsight;Integrated Security=true", options.Repository.ConnectionString);
|
|
Assert.Equal("sql01", Assert.Single(options.Instances).Server);
|
|
Assert.Equal(TimeSpan.FromSeconds(30), options.Tick);
|
|
Assert.Equal(4, options.MaxParallelInstances);
|
|
}
|
|
|
|
[Fact]
|
|
public void Command_line_still_overrides_the_installer_values()
|
|
{
|
|
var configuration = Builder("--SQLInsight:Repository:ConnectionString=fra-kommandolinjen").Configuration;
|
|
|
|
Assert.Equal("fra-kommandolinjen", configuration["SQLInsight:Repository:ConnectionString"]);
|
|
}
|
|
|
|
[Fact]
|
|
public void Missing_file_is_fine()
|
|
{
|
|
File.Delete(Path.Combine(_folder, InstallerSettings.FileName));
|
|
|
|
Assert.Equal("eksempel", Builder().Configuration["SQLInsight:Repository:ConnectionString"]);
|
|
}
|
|
}
|