Refactor code structure and optimize performance across multiple modules

This commit is contained in:
StellaOps Bot
2025-12-26 20:03:22 +02:00
parent c786faae84
commit b4fc66feb6
3353 changed files with 88254 additions and 1590657 deletions

View File

@@ -5,11 +5,13 @@ using FluentAssertions;
using StellaOps.Scheduler.Models;
using Xunit;
using StellaOps.TestKit;
namespace StellaOps.Scheduler.Queue.Tests;
public sealed class PlannerAndRunnerMessageTests
{
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void PlannerMessage_CanonicalSerialization_RoundTrips()
{
var schedule = new Schedule(
@@ -68,7 +70,8 @@ public sealed class PlannerAndRunnerMessageTests
roundTrip.Should().BeEquivalentTo(message, options => options.WithStrictOrdering());
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void RunnerSegmentMessage_RequiresAtLeastOneDigest()
{
var act = () => new RunnerSegmentQueueMessage(
@@ -80,7 +83,8 @@ public sealed class PlannerAndRunnerMessageTests
act.Should().Throw<ArgumentException>();
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void RunnerSegmentMessage_CanonicalSerialization_RoundTrips()
{
var message = new RunnerSegmentQueueMessage(

View File

@@ -2,30 +2,26 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DotNet.Testcontainers.Builders;
using DotNet.Testcontainers.Containers;
using DotNet.Testcontainers.Configurations;
using FluentAssertions;
using Microsoft.Extensions.Logging.Abstractions;
using StackExchange.Redis;
using StellaOps.Scheduler.Models;
using StellaOps.Scheduler.Queue.Redis;
using Testcontainers.Redis;
using Xunit;
using StellaOps.TestKit;
namespace StellaOps.Scheduler.Queue.Tests;
public sealed class RedisSchedulerQueueTests : IAsyncLifetime
{
private readonly RedisTestcontainer _redis;
private readonly RedisContainer _redis;
private string? _skipReason;
public RedisSchedulerQueueTests()
{
var configuration = new RedisTestcontainerConfiguration();
_redis = new TestcontainersBuilder<RedisTestcontainer>()
.WithDatabase(configuration)
.Build();
_redis = new RedisBuilder().Build();
}
public async Task InitializeAsync()
@@ -50,7 +46,8 @@ public sealed class RedisSchedulerQueueTests : IAsyncLifetime
await _redis.DisposeAsync().AsTask();
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task PlannerQueue_EnqueueLeaseAck_RemovesMessage()
{
if (SkipIfUnavailable())
@@ -86,7 +83,8 @@ public sealed class RedisSchedulerQueueTests : IAsyncLifetime
afterAck.Should().BeEmpty();
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task RunnerQueue_Retry_IncrementsDeliveryAttempt()
{
if (SkipIfUnavailable())
@@ -122,7 +120,8 @@ public sealed class RedisSchedulerQueueTests : IAsyncLifetime
secondLease[0].Attempt.Should().Be(2);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task PlannerQueue_ClaimExpired_ReassignsLease()
{
if (SkipIfUnavailable())
@@ -155,7 +154,8 @@ public sealed class RedisSchedulerQueueTests : IAsyncLifetime
await reclaimed[0].AcknowledgeAsync();
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task PlannerQueue_RecordsDepthMetrics()
{
if (SkipIfUnavailable())
@@ -190,7 +190,8 @@ public sealed class RedisSchedulerQueueTests : IAsyncLifetime
plannerDepth.Should().Be(0);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task RunnerQueue_DropWhenDeadLetterDisabled()
{
if (SkipIfUnavailable())
@@ -234,7 +235,7 @@ public sealed class RedisSchedulerQueueTests : IAsyncLifetime
RetryMaxBackoff = TimeSpan.FromMilliseconds(50),
Redis = new SchedulerRedisQueueOptions
{
ConnectionString = _redis.ConnectionString,
ConnectionString = _redis.GetConnectionString(),
Database = 0,
InitializationTimeout = TimeSpan.FromSeconds(10),
Planner = new RedisSchedulerStreamOptions

View File

@@ -14,11 +14,14 @@ using StellaOps.Scheduler.Queue;
using StellaOps.Scheduler.Queue.Nats;
using Xunit;
using StellaOps.TestKit;
namespace StellaOps.Scheduler.Queue.Tests;
public sealed class SchedulerQueueServiceCollectionExtensionsTests
{
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task AddSchedulerQueues_RegistersNatsTransport()
{
var services = new ServiceCollection();
@@ -39,7 +42,8 @@ public sealed class SchedulerQueueServiceCollectionExtensionsTests
runnerQueue.Should().BeOfType<NatsSchedulerRunnerQueue>();
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task SchedulerQueueHealthCheck_ReturnsHealthy_WhenTransportsReachable()
{
var healthCheck = new SchedulerQueueHealthCheck(
@@ -57,7 +61,8 @@ public sealed class SchedulerQueueServiceCollectionExtensionsTests
result.Status.Should().Be(HealthStatus.Healthy);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task SchedulerQueueHealthCheck_ReturnsUnhealthy_WhenRunnerPingFails()
{
var healthCheck = new SchedulerQueueHealthCheck(

View File

@@ -9,7 +9,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="DotNet.Testcontainers" Version="1.7.0-beta.2269" />
<PackageReference Include="Testcontainers" Version="4.4.0" />
<PackageReference Include="Testcontainers.Redis" Version="4.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
@@ -24,5 +25,6 @@
<ItemGroup>
<ProjectReference Include="../../__Libraries/StellaOps.Scheduler.Models/StellaOps.Scheduler.Models.csproj" />
<ProjectReference Include="../../__Libraries/StellaOps.Scheduler.Queue/StellaOps.Scheduler.Queue.csproj" />
<ProjectReference Include="../../../__Libraries/StellaOps.TestKit/StellaOps.TestKit.csproj" />
</ItemGroup>
</Project>