Files
scadalink-design/tests/ScadaLink.Host.Tests/AkkaBootstrapTests.cs
Joseph Doherty d38356efdb Phase 1 WP-11–22: Host infrastructure, Blazor Server UI, and integration tests
Host infrastructure (WP-11–17):
- StartupValidator with 19 validation rules
- /health/ready endpoint with DB + Akka health checks
- Akka.NET bootstrap via AkkaHostedService (HOCON config, cluster, remoting, SBR)
- Serilog with SiteId/NodeHostname/NodeRole enrichment
- DeadLetterMonitorActor with count tracking
- CoordinatedShutdown wiring (no Environment.Exit)
- Windows Service support (UseWindowsService)

Central UI (WP-18–21):
- Blazor Server shell with Bootstrap 5, role-aware NavMenu
- Login/logout flow (LDAP auth → JWT → HTTP-only cookie)
- CookieAuthenticationStateProvider with idle timeout
- LDAP group mapping CRUD page (Admin role)
- Route guards with Authorize attributes per role
- SignalR reconnection overlay for failover

Integration tests (WP-22):
- Startup validation, auth flow, audit transactions, readiness gating
186 tests pass (1 skipped: LDAP integration), zero warnings.
2026-03-16 19:50:59 -04:00

81 lines
2.0 KiB
C#

using Akka.Actor;
using Akka.Configuration;
namespace ScadaLink.Host.Tests;
/// <summary>
/// WP-13: Tests for Akka.NET actor system bootstrap.
/// </summary>
public class AkkaBootstrapTests : IDisposable
{
private ActorSystem? _actorSystem;
public void Dispose()
{
_actorSystem?.Dispose();
}
[Fact]
public void ActorSystem_CreatesWithClusterConfig()
{
var hocon = @"
akka {
actor {
provider = cluster
}
remote {
dot-netty.tcp {
hostname = ""localhost""
port = 0
}
}
cluster {
seed-nodes = [""akka.tcp://scadalink-test@localhost:0""]
roles = [""Central""]
min-nr-of-members = 1
}
coordinated-shutdown {
run-by-clr-shutdown-hook = on
}
}";
var config = ConfigurationFactory.ParseString(hocon);
_actorSystem = ActorSystem.Create("scadalink-test", config);
Assert.NotNull(_actorSystem);
Assert.Equal("scadalink-test", _actorSystem.Name);
}
[Fact]
public void ActorSystem_HoconConfig_IncludesCoordinatedShutdown()
{
var hocon = @"
akka {
actor {
provider = cluster
}
remote {
dot-netty.tcp {
hostname = ""localhost""
port = 0
}
}
cluster {
seed-nodes = [""akka.tcp://scadalink-test@localhost:0""]
roles = [""Central""]
run-coordinated-shutdown-when-down = on
}
coordinated-shutdown {
run-by-clr-shutdown-hook = on
}
}";
var config = ConfigurationFactory.ParseString(hocon);
_actorSystem = ActorSystem.Create("scadalink-cs-test", config);
var csConfig = _actorSystem.Settings.Config.GetString("akka.coordinated-shutdown.run-by-clr-shutdown-hook");
Assert.Equal("on", csConfig);
var clusterShutdown = _actorSystem.Settings.Config.GetString("akka.cluster.run-coordinated-shutdown-when-down");
Assert.Equal("on", clusterShutdown);
}
}