Skip to content

Commit 3b218a2

Browse files
dcl10claude
andauthored
Fix integration tests failing in CI due to QueueInitializerService (#56)
* Fix QueueInitializerService crashing test host in CI The previous attempt removed QueueInitializerService by ImplementationType, but in .NET 10 factory-registered hosted services have null ImplementationType so the lookup never matched. The correct fix is to prevent the service being registered in the first place: - AddMessageQueues now short-circuits when ConnectionString is empty - ApiFactory overrides MessageQueue:ConnectionString to "" via in-memory config so QueueInitializerService is never registered when tests run Also reverts the now-unnecessary InternalsVisibleTo. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Add Azurite service to CI and revert dead config override ConfigureAppConfiguration in WebApplicationFactory does not apply before WebApplication.CreateBuilder() processes appsettings.Development.json, so the connection-string override added in the previous commit was a no-op. The correct fix: run Azurite as a service container in CI so that QueueInitializerService.StartAsync succeeds, mirroring the local dev environment where Azurite is already expected to be running. Also reverts the non-functional ConfigureAppConfiguration block and its unused using directive from ApiFactory. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix Azurite API version mismatch in CI Azure.Storage.Queues 12.25.0 uses API version 2026-02-06, which the mcr.microsoft.com/azure-storage/azurite image does not yet support. Switched from a service container (which can't receive command arguments) to a docker run step so we can pass --skipApiVersionCheck. This tells Azurite to serve requests regardless of API version, which is fine for the test environment. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2393161 commit 3b218a2

4 files changed

Lines changed: 15 additions & 9 deletions

File tree

.github/workflows/ci-backend.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ jobs:
2727
steps:
2828
- uses: actions/checkout@v4
2929

30+
- name: Start Azurite
31+
run: |
32+
docker run --detach \
33+
--publish 10000:10000 \
34+
--publish 10001:10001 \
35+
--publish 10002:10002 \
36+
mcr.microsoft.com/azure-storage/azurite \
37+
azurite --skipApiVersionCheck \
38+
--blobHost 0.0.0.0 \
39+
--queueHost 0.0.0.0 \
40+
--tableHost 0.0.0.0
41+
3042
- uses: actions/setup-dotnet@v4
3143
with:
3244
dotnet-version: ${{ env.DOTNET_VERSION }}

backend/src/SkillMatrixLlm.Api/Extensions/ServiceCollectionExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public static IServiceCollection AddMessageQueues(this IServiceCollection s, ICo
5252
{
5353
var options = c.GetSection("MessageQueue").Get<MessageQueueOptions>() ?? new MessageQueueOptions();
5454

55+
if (string.IsNullOrEmpty(options.ConnectionString))
56+
return s;
57+
5558
var projectDescClient = CreateQueueClient(options.ConnectionString, options.ProjectDescriptionQueueName);
5659
var skillReqClient = CreateQueueClient(options.ConnectionString, options.SkillRequirementsQueueName);
5760

backend/src/SkillMatrixLlm.Api/SkillMatrixLlm.Api.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
<UserSecretsId>6a7c2c10-7306-41a6-8b41-d1490d650476</UserSecretsId>
1111
</PropertyGroup>
1212

13-
<ItemGroup>
14-
<InternalsVisibleTo Include="SkillMatrixLlm.Api.IntegrationTests" />
15-
</ItemGroup>
16-
1713
<ItemGroup>
1814
<!-- JWT Bearer authentication — validates Keycloak-issued tokens -->
1915
<PackageReference Include="Azure.Storage.Queues" Version="12.25.0" />

backend/tests/SkillMatrixLlm.Api.IntegrationTests/Fixtures/ApiFactory.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ namespace SkillMatrixLlm.Api.Tests.Fixtures;
1414
using Messaging;
1515
using Models.Recommendations;
1616
using Moq;
17-
using Services;
1817
using Services.Contracts;
1918

2019
/// <summary>
@@ -41,10 +40,6 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) =>
4140
services.AddDbContext<AppDbContext>(o =>
4241
o.UseInMemoryDatabase("TestDb").UseInternalServiceProvider(inMemoryProvider));
4342

44-
var queueInitDescriptor = services.SingleOrDefault(d => d.ImplementationType == typeof(QueueInitializerService));
45-
if (queueInitDescriptor is not null)
46-
services.Remove(queueInitDescriptor);
47-
4843
services.AddTransient(_ => Mock.Of<IEmailSender>());
4944
services.AddSingleton(_ => Mock.Of<IKeycloakDataSeeder>());
5045
services.AddSingleton(_ => Mock.Of<IMessageChannel<ProjectDescriptionPayload>>());

0 commit comments

Comments
 (0)