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 f10d83c444
1385 changed files with 69732 additions and 10280 deletions

View File

@@ -2,30 +2,24 @@ 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;
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 +44,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 +81,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 +118,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 +152,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 +188,8 @@ public sealed class RedisSchedulerQueueTests : IAsyncLifetime
plannerDepth.Should().Be(0);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task RunnerQueue_DropWhenDeadLetterDisabled()
{
if (SkipIfUnavailable())
@@ -209,6 +208,7 @@ public sealed class RedisSchedulerQueueTests : IAsyncLifetime
TimeProvider.System,
async config => (IConnectionMultiplexer)await ConnectionMultiplexer.ConnectAsync(config).ConfigureAwait(false));
using StellaOps.TestKit;
var message = TestData.CreateRunnerMessage();
await queue.EnqueueAsync(message);
@@ -234,7 +234,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