Restructure solution layout by module
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using StellaOps.Bench.LinkNotMerge.Baseline;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Bench.LinkNotMerge.Tests;
|
||||
|
||||
public sealed class BaselineLoaderTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task LoadAsync_ReadsEntries()
|
||||
{
|
||||
var path = Path.GetTempFileName();
|
||||
try
|
||||
{
|
||||
await File.WriteAllTextAsync(
|
||||
path,
|
||||
"scenario,iterations,observations,aliases,linksets,mean_total_ms,p95_total_ms,max_total_ms,mean_insert_ms,mean_correlation_ms,mean_throughput_per_sec,min_throughput_per_sec,mean_mongo_throughput_per_sec,min_mongo_throughput_per_sec,max_allocated_mb\n" +
|
||||
"lnm_ingest_baseline,5,5000,500,450,320.5,340.1,360.9,120.2,210.3,15000.0,13500.0,18000.0,16500.0,96.5\n");
|
||||
|
||||
var baseline = await BaselineLoader.LoadAsync(path, CancellationToken.None);
|
||||
var entry = Assert.Single(baseline);
|
||||
|
||||
Assert.Equal("lnm_ingest_baseline", entry.Key);
|
||||
Assert.Equal(5, entry.Value.Iterations);
|
||||
Assert.Equal(5000, entry.Value.Observations);
|
||||
Assert.Equal(500, entry.Value.Aliases);
|
||||
Assert.Equal(360.9, entry.Value.MaxTotalMs);
|
||||
Assert.Equal(16500.0, entry.Value.MinMongoThroughputPerSecond);
|
||||
Assert.Equal(96.5, entry.Value.MaxAllocatedMb);
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using StellaOps.Bench.LinkNotMerge.Baseline;
|
||||
using StellaOps.Bench.LinkNotMerge.Reporting;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Bench.LinkNotMerge.Tests;
|
||||
|
||||
public sealed class BenchmarkScenarioReportTests
|
||||
{
|
||||
[Fact]
|
||||
public void RegressionDetection_FlagsBreaches()
|
||||
{
|
||||
var result = new ScenarioResult(
|
||||
Id: "scenario",
|
||||
Label: "Scenario",
|
||||
Iterations: 3,
|
||||
ObservationCount: 1000,
|
||||
AliasGroups: 100,
|
||||
LinksetCount: 90,
|
||||
TotalStatistics: new DurationStatistics(200, 240, 260),
|
||||
InsertStatistics: new DurationStatistics(80, 90, 100),
|
||||
CorrelationStatistics: new DurationStatistics(120, 150, 170),
|
||||
TotalThroughputStatistics: new ThroughputStatistics(8000, 7000),
|
||||
InsertThroughputStatistics: new ThroughputStatistics(9000, 8000),
|
||||
AllocationStatistics: new AllocationStatistics(120),
|
||||
ThresholdMs: null,
|
||||
MinThroughputThresholdPerSecond: null,
|
||||
MinMongoThroughputThresholdPerSecond: null,
|
||||
MaxAllocatedThresholdMb: null);
|
||||
|
||||
var baseline = new BaselineEntry(
|
||||
ScenarioId: "scenario",
|
||||
Iterations: 3,
|
||||
Observations: 1000,
|
||||
Aliases: 100,
|
||||
Linksets: 90,
|
||||
MeanTotalMs: 150,
|
||||
P95TotalMs: 170,
|
||||
MaxTotalMs: 180,
|
||||
MeanInsertMs: 60,
|
||||
MeanCorrelationMs: 90,
|
||||
MeanThroughputPerSecond: 9000,
|
||||
MinThroughputPerSecond: 8500,
|
||||
MeanMongoThroughputPerSecond: 10000,
|
||||
MinMongoThroughputPerSecond: 9500,
|
||||
MaxAllocatedMb: 100);
|
||||
|
||||
var report = new BenchmarkScenarioReport(result, baseline, regressionLimit: 1.1);
|
||||
|
||||
Assert.True(report.DurationRegressionBreached);
|
||||
Assert.True(report.ThroughputRegressionBreached);
|
||||
Assert.True(report.MongoThroughputRegressionBreached);
|
||||
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,
|
||||
ObservationCount: 1000,
|
||||
AliasGroups: 100,
|
||||
LinksetCount: 90,
|
||||
TotalStatistics: new DurationStatistics(200, 220, 230),
|
||||
InsertStatistics: new DurationStatistics(90, 100, 110),
|
||||
CorrelationStatistics: new DurationStatistics(110, 120, 130),
|
||||
TotalThroughputStatistics: new ThroughputStatistics(8000, 7900),
|
||||
InsertThroughputStatistics: new ThroughputStatistics(9000, 8900),
|
||||
AllocationStatistics: new AllocationStatistics(64),
|
||||
ThresholdMs: null,
|
||||
MinThroughputThresholdPerSecond: null,
|
||||
MinMongoThroughputThresholdPerSecond: null,
|
||||
MaxAllocatedThresholdMb: null);
|
||||
|
||||
var report = new BenchmarkScenarioReport(result, baseline: null, regressionLimit: null);
|
||||
|
||||
Assert.False(report.RegressionBreached);
|
||||
Assert.Empty(report.BuildRegressionFailureMessages());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using StellaOps.Bench.LinkNotMerge.Baseline;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Bench.LinkNotMerge.Tests;
|
||||
|
||||
public sealed class LinkNotMergeScenarioRunnerTests
|
||||
{
|
||||
[Fact]
|
||||
public void Execute_BuildsDeterministicAggregation()
|
||||
{
|
||||
var config = new LinkNotMergeScenarioConfig
|
||||
{
|
||||
Id = "unit",
|
||||
Observations = 120,
|
||||
AliasGroups = 24,
|
||||
PurlsPerObservation = 3,
|
||||
CpesPerObservation = 2,
|
||||
ReferencesPerObservation = 2,
|
||||
Tenants = 3,
|
||||
BatchSize = 40,
|
||||
Seed = 1337,
|
||||
};
|
||||
|
||||
var runner = new LinkNotMergeScenarioRunner(config);
|
||||
var result = runner.Execute(iterations: 2, CancellationToken.None);
|
||||
|
||||
Assert.Equal(120, result.ObservationCount);
|
||||
Assert.Equal(24, result.AliasGroups);
|
||||
Assert.True(result.TotalDurationsMs.All(value => value > 0));
|
||||
Assert.True(result.InsertThroughputsPerSecond.All(value => value > 0));
|
||||
Assert.True(result.TotalThroughputsPerSecond.All(value => value > 0));
|
||||
Assert.True(result.AllocatedMb.All(value => value >= 0));
|
||||
Assert.Equal(result.AggregationResult.LinksetCount, result.LinksetCount);
|
||||
Assert.Equal(result.AggregationResult.ObservationCount, result.ObservationCount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<LangVersion>preview</LangVersion>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<UseConcelierTestInfra>false</UseConcelierTestInfra>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
|
||||
<PackageReference Include="xunit" Version="2.9.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.4">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="EphemeralMongo" Version="3.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\StellaOps.Bench.LinkNotMerge\StellaOps.Bench.LinkNotMerge.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user