Files
git.stella-ops.org/src/StellaOps.Bench/Notify/StellaOps.Bench.Notify.Tests/BenchmarkScenarioReportTests.cs
master 96d52884e8
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
Add Policy DSL Validator, Schema Exporter, and Simulation Smoke tools
- Implemented PolicyDslValidator with command-line options for strict mode and JSON output.
- Created PolicySchemaExporter to generate JSON schemas for policy-related models.
- Developed PolicySimulationSmoke tool to validate policy simulations against expected outcomes.
- Added project files and necessary dependencies for each tool.
- Ensured proper error handling and usage instructions across tools.
2025-10-27 08:00:11 +02:00

86 lines
2.7 KiB
C#

using System.Linq;
using StellaOps.Bench.Notify.Baseline;
using StellaOps.Bench.Notify.Reporting;
using Xunit;
namespace StellaOps.Bench.Notify.Tests;
public sealed class BenchmarkScenarioReportTests
{
[Fact]
public void RegressionDetection_FlagsLatencies()
{
var result = new ScenarioResult(
Id: "scenario",
Label: "Scenario",
Iterations: 3,
TotalEvents: 1000,
TotalRules: 100,
ActionsPerRule: 2,
AverageMatchesPerEvent: 10,
MinMatchesPerEvent: 8,
MaxMatchesPerEvent: 12,
AverageDeliveriesPerEvent: 20,
TotalDeliveries: 20000,
MeanMs: 200,
P95Ms: 250,
MaxMs: 300,
MeanThroughputPerSecond: 50000,
MinThroughputPerSecond: 40000,
MaxAllocatedMb: 100,
ThresholdMs: null,
MinThroughputThresholdPerSecond: null,
MaxAllocatedThresholdMb: null);
var baseline = new BaselineEntry(
ScenarioId: "scenario",
Iterations: 3,
EventCount: 1000,
DeliveryCount: 20000,
MeanMs: 150,
P95Ms: 180,
MaxMs: 200,
MeanThroughputPerSecond: 60000,
MinThroughputPerSecond: 50000,
MaxAllocatedMb: 90);
var report = new BenchmarkScenarioReport(result, baseline, regressionLimit: 1.1);
Assert.True(report.DurationRegressionBreached);
Assert.True(report.ThroughputRegressionBreached);
Assert.Contains(report.BuildRegressionFailureMessages(), message => message.Contains("max duration"));
}
[Fact]
public void RegressionDetection_NoBaseline_NoBreaches()
{
var result = new ScenarioResult(
Id: "scenario",
Label: "Scenario",
Iterations: 3,
TotalEvents: 1000,
TotalRules: 100,
ActionsPerRule: 2,
AverageMatchesPerEvent: 10,
MinMatchesPerEvent: 8,
MaxMatchesPerEvent: 12,
AverageDeliveriesPerEvent: 20,
TotalDeliveries: 20000,
MeanMs: 200,
P95Ms: 250,
MaxMs: 300,
MeanThroughputPerSecond: 50000,
MinThroughputPerSecond: 40000,
MaxAllocatedMb: 100,
ThresholdMs: null,
MinThroughputThresholdPerSecond: null,
MaxAllocatedThresholdMb: null);
var report = new BenchmarkScenarioReport(result, baseline: null, regressionLimit: null);
Assert.False(report.DurationRegressionBreached);
Assert.False(report.ThroughputRegressionBreached);
Assert.Empty(report.BuildRegressionFailureMessages());
}
}