Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user