Phase 3C: Deployment pipeline & Store-and-Forward engine
Deployment Manager (WP-1–8, WP-16): - DeploymentService: full pipeline (flatten→validate→send→track→audit) - OperationLockManager: per-instance concurrency control - StateTransitionValidator: Enabled/Disabled/NotDeployed transition matrix - ArtifactDeploymentService: broadcast to all sites with per-site results - Deployment identity (GUID + revision hash), idempotency, staleness detection - Instance lifecycle commands (disable/enable/delete) with deduplication Store-and-Forward (WP-9–15): - StoreAndForwardStorage: SQLite persistence, 3 categories, no max buffer - StoreAndForwardService: fixed-interval retry, transient-only buffering, parking - ReplicationService: async best-effort to standby (fire-and-forget) - Parked message management (query/retry/discard from central) - Messages survive instance deletion, S&F drains on disable 620 tests pass (+79 new), zero warnings.
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
using ScadaLink.Commons.Types.Enums;
|
||||
|
||||
namespace ScadaLink.DeploymentManager.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// WP-4: Tests for instance state transition matrix.
|
||||
/// </summary>
|
||||
public class StateTransitionValidatorTests
|
||||
{
|
||||
// ── Deploy transitions ──
|
||||
|
||||
[Theory]
|
||||
[InlineData(InstanceState.NotDeployed)]
|
||||
[InlineData(InstanceState.Enabled)]
|
||||
[InlineData(InstanceState.Disabled)]
|
||||
public void CanDeploy_AllStates_ReturnsTrue(InstanceState state)
|
||||
{
|
||||
Assert.True(StateTransitionValidator.CanDeploy(state));
|
||||
}
|
||||
|
||||
// ── Disable transitions ──
|
||||
|
||||
[Fact]
|
||||
public void CanDisable_WhenEnabled_ReturnsTrue()
|
||||
{
|
||||
Assert.True(StateTransitionValidator.CanDisable(InstanceState.Enabled));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanDisable_WhenDisabled_ReturnsFalse()
|
||||
{
|
||||
Assert.False(StateTransitionValidator.CanDisable(InstanceState.Disabled));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanDisable_WhenNotDeployed_ReturnsFalse()
|
||||
{
|
||||
Assert.False(StateTransitionValidator.CanDisable(InstanceState.NotDeployed));
|
||||
}
|
||||
|
||||
// ── Enable transitions ──
|
||||
|
||||
[Fact]
|
||||
public void CanEnable_WhenDisabled_ReturnsTrue()
|
||||
{
|
||||
Assert.True(StateTransitionValidator.CanEnable(InstanceState.Disabled));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanEnable_WhenEnabled_ReturnsFalse()
|
||||
{
|
||||
Assert.False(StateTransitionValidator.CanEnable(InstanceState.Enabled));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanEnable_WhenNotDeployed_ReturnsFalse()
|
||||
{
|
||||
Assert.False(StateTransitionValidator.CanEnable(InstanceState.NotDeployed));
|
||||
}
|
||||
|
||||
// ── Delete transitions ──
|
||||
|
||||
[Fact]
|
||||
public void CanDelete_WhenEnabled_ReturnsTrue()
|
||||
{
|
||||
Assert.True(StateTransitionValidator.CanDelete(InstanceState.Enabled));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanDelete_WhenDisabled_ReturnsTrue()
|
||||
{
|
||||
Assert.True(StateTransitionValidator.CanDelete(InstanceState.Disabled));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanDelete_WhenNotDeployed_ReturnsFalse()
|
||||
{
|
||||
Assert.False(StateTransitionValidator.CanDelete(InstanceState.NotDeployed));
|
||||
}
|
||||
|
||||
// ── ValidateTransition ──
|
||||
|
||||
[Fact]
|
||||
public void ValidateTransition_ValidDeploy_ReturnsNull()
|
||||
{
|
||||
var error = StateTransitionValidator.ValidateTransition(InstanceState.NotDeployed, "deploy");
|
||||
Assert.Null(error);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ValidateTransition_InvalidEnable_ReturnsError()
|
||||
{
|
||||
var error = StateTransitionValidator.ValidateTransition(InstanceState.Enabled, "enable");
|
||||
Assert.NotNull(error);
|
||||
Assert.Contains("not allowed", error);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ValidateTransition_InvalidDisable_ReturnsError()
|
||||
{
|
||||
var error = StateTransitionValidator.ValidateTransition(InstanceState.Disabled, "disable");
|
||||
Assert.NotNull(error);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ValidateTransition_InvalidDeleteOnNotDeployed_ReturnsError()
|
||||
{
|
||||
var error = StateTransitionValidator.ValidateTransition(InstanceState.NotDeployed, "delete");
|
||||
Assert.NotNull(error);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ValidateTransition_UnknownOperation_ReturnsError()
|
||||
{
|
||||
var error = StateTransitionValidator.ValidateTransition(InstanceState.Enabled, "unknown");
|
||||
Assert.NotNull(error);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user