chore(saf): eagerly validate SweepBatchLimit/SweepTargetParallelism (plan R2-02 T9)
This commit is contained in:
@@ -31,5 +31,13 @@ public sealed class StoreAndForwardOptionsValidator : OptionsValidatorBase<Store
|
|||||||
builder.RequireThat(options.DefaultMaxRetries >= 0,
|
builder.RequireThat(options.DefaultMaxRetries >= 0,
|
||||||
$"ScadaBridge:StoreAndForward:DefaultMaxRetries must be >= 0 " +
|
$"ScadaBridge:StoreAndForward:DefaultMaxRetries must be >= 0 " +
|
||||||
$"(was {options.DefaultMaxRetries}).");
|
$"(was {options.DefaultMaxRetries}).");
|
||||||
|
|
||||||
|
builder.RequireThat(options.SweepBatchLimit >= 0,
|
||||||
|
$"ScadaBridge:StoreAndForward:SweepBatchLimit must be >= 0 " +
|
||||||
|
$"(was {options.SweepBatchLimit}); it bounds due rows per retry sweep — 0 means unlimited (legacy).");
|
||||||
|
|
||||||
|
builder.RequireThat(options.SweepTargetParallelism >= 1,
|
||||||
|
$"ScadaBridge:StoreAndForward:SweepTargetParallelism must be >= 1 " +
|
||||||
|
$"(was {options.SweepTargetParallelism}); it caps concurrent (category,target) sweep lanes — 1 means serial.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+29
@@ -47,4 +47,33 @@ public class StoreAndForwardOptionsValidatorTests
|
|||||||
Assert.True(result.Failed);
|
Assert.True(result.Failed);
|
||||||
Assert.Contains("SqliteDbPath", result.FailureMessage);
|
Assert.Contains("SqliteDbPath", result.FailureMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── R2 T9: sweep-tuning eager validation (N4) ──
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData(-1)]
|
||||||
|
[InlineData(-500)]
|
||||||
|
public void Validate_NegativeSweepBatchLimit_Fails(int limit)
|
||||||
|
{
|
||||||
|
var result = Validate(new StoreAndForwardOptions { SweepBatchLimit = limit });
|
||||||
|
Assert.True(result.Failed);
|
||||||
|
Assert.Contains("SweepBatchLimit", result.FailureMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Validate_ZeroSweepBatchLimit_IsValidUnlimitedLegacy()
|
||||||
|
{
|
||||||
|
var result = Validate(new StoreAndForwardOptions { SweepBatchLimit = 0 });
|
||||||
|
Assert.True(result.Succeeded, result.FailureMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData(0)]
|
||||||
|
[InlineData(-4)]
|
||||||
|
public void Validate_NonPositiveSweepTargetParallelism_Fails(int parallelism)
|
||||||
|
{
|
||||||
|
var result = Validate(new StoreAndForwardOptions { SweepTargetParallelism = parallelism });
|
||||||
|
Assert.True(result.Failed);
|
||||||
|
Assert.Contains("SweepTargetParallelism", result.FailureMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user