Skip to content

Commit 8ebd819

Browse files
committed
fix: resolve integration test issues
1 parent 2df41fa commit 8ebd819

21 files changed

Lines changed: 306 additions & 80 deletions

File tree

.github/workflows/user-management-test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ jobs:
3131
strategy:
3232
matrix:
3333
DRIVING:
34-
- AZURE
35-
#- AGNOSTIC
34+
- AGNOSTIC
35+
#- AZURE
3636
fail-fast: false
3737

3838
services:
@@ -77,8 +77,8 @@ jobs:
7777
strategy:
7878
matrix:
7979
DRIVING:
80-
- AZURE
81-
#- AGNOSTIC
80+
- AGNOSTIC
81+
#- AZURE
8282
fail-fast: false
8383

8484
steps:

docker-compose.yml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ services:
154154
user-management:
155155
build:
156156
context: ./user-management
157-
dockerfile: src/Stickerlandia.UserManagement.AspNet/Dockerfile
157+
dockerfile: src/Stickerlandia.UserManagement.Api/Dockerfile
158158
container_name: user-management
159159
depends_on:
160160
user-management-db:
@@ -163,7 +163,7 @@ services:
163163
condition: service_healthy
164164
environment:
165165
ASPNETCORE_ENVIRONMENT: Development
166-
DRIVING: ASPNET
166+
DRIVING: AGNOSTIC
167167
DRIVEN: AGNOSTIC
168168
ConnectionStrings__messaging: "redpanda:9092"
169169
ConnectionStrings__database: "Host=user-management-db;Port=5432;Database=user_management;Username=user_mgmt_user;Password=user_mgmt_password"
@@ -175,6 +175,44 @@ services:
175175
- "traefik.http.routers.user-management.rule=PathPrefix(`/api/users`)"
176176
- "traefik.http.services.user-management.loadbalancer.server.port=8080"
177177

178+
user-management-worker:
179+
build:
180+
context: ./user-management
181+
dockerfile: src/Stickerlandia.UserManagement.Worker/Dockerfile
182+
container_name: user-management-worker
183+
depends_on:
184+
user-management-db:
185+
condition: service_healthy
186+
redpanda:
187+
condition: service_healthy
188+
environment:
189+
ASPNETCORE_ENVIRONMENT: Development
190+
DRIVING: AGNOSTIC
191+
DRIVEN: AGNOSTIC
192+
ConnectionStrings__messaging: "redpanda:9092"
193+
ConnectionStrings__database: "Host=user-management-db;Port=5432;Database=user_management;Username=user_mgmt_user;Password=user_mgmt_password"
194+
KAFKA__BOOTSTRAPSERVERS: "redpanda:9092"
195+
KAFKA__SCHEMAREGISTRY: "http://redpanda:8082"
196+
KAFKA__GROUPID: "stickerlandia-user-management"
197+
198+
user-management-db-migrations:
199+
build:
200+
context: ./user-management
201+
dockerfile: src/Stickerlandia.UserManagement.MigrationService/Dockerfile
202+
container_name: user-management-migrations
203+
depends_on:
204+
user-management-db:
205+
condition: service_healthy
206+
environment:
207+
ASPNETCORE_ENVIRONMENT: Development
208+
DRIVING: AGNOSTIC
209+
DRIVEN: AGNOSTIC
210+
ConnectionStrings__messaging: "redpanda:9092"
211+
ConnectionStrings__database: "Host=user-management-db;Port=5432;Database=user_management;Username=user_mgmt_user;Password=user_mgmt_password"
212+
KAFKA__BOOTSTRAPSERVERS: "redpanda:9092"
213+
KAFKA__SCHEMAREGISTRY: "http://redpanda:8082"
214+
KAFKA__GROUPID: "stickerlandia-user-management"
215+
178216
volumes:
179217
sticker-award-data:
180218
user-management-data:

user-management/Stickerlandia.UserManagement.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stickerlandia.UserManagemen
3939
EndProject
4040
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stickerlandia.UserManagement.ServiceDefaults", "src\Stickerlandia.UserManagement.ServiceDefaults\Stickerlandia.UserManagement.ServiceDefaults.csproj", "{7C28228C-4B3D-4AAE-95E6-4669413BD06C}"
4141
EndProject
42+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stickerlandia.UserManagement.MigrationService", "src\Stickerlandia.UserManagement.MigrationService\Stickerlandia.UserManagement.MigrationService.csproj", "{91536DB3-CBA5-44DE-943C-76F8577793FE}"
43+
EndProject
4244
Global
4345
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4446
Debug|Any CPU = Debug|Any CPU
@@ -100,6 +102,10 @@ Global
100102
{7C28228C-4B3D-4AAE-95E6-4669413BD06C}.Debug|Any CPU.Build.0 = Debug|Any CPU
101103
{7C28228C-4B3D-4AAE-95E6-4669413BD06C}.Release|Any CPU.ActiveCfg = Release|Any CPU
102104
{7C28228C-4B3D-4AAE-95E6-4669413BD06C}.Release|Any CPU.Build.0 = Release|Any CPU
105+
{91536DB3-CBA5-44DE-943C-76F8577793FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
106+
{91536DB3-CBA5-44DE-943C-76F8577793FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
107+
{91536DB3-CBA5-44DE-943C-76F8577793FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
108+
{91536DB3-CBA5-44DE-943C-76F8577793FE}.Release|Any CPU.Build.0 = Release|Any CPU
103109
EndGlobalSection
104110
GlobalSection(NestedProjects) = preSolution
105111
{4DDC795B-2EA4-4123-B631-F0D8CAA99BA6} = {FE220876-2B87-4095-8BD2-039049503C72}
@@ -117,5 +123,6 @@ Global
117123
{408EFE63-AA9C-46BD-ADD5-AB917BB4E9E6} = {FC9DDF76-8DAC-4498-8926-8883F984709C}
118124
{ED36763B-8971-4CC9-A4FE-16924F1961C0} = {924749FC-98D5-40A6-8F4B-BA9BFDEDDEC3}
119125
{7C28228C-4B3D-4AAE-95E6-4669413BD06C} = {924749FC-98D5-40A6-8F4B-BA9BFDEDDEC3}
126+
{91536DB3-CBA5-44DE-943C-76F8577793FE} = {924749FC-98D5-40A6-8F4B-BA9BFDEDDEC3}
120127
EndGlobalSection
121128
EndGlobal

user-management/src/Stickerlandia.UserManagement.Agnostic/AuthenticationWorker.cs

Lines changed: 0 additions & 60 deletions
This file was deleted.

user-management/src/Stickerlandia.UserManagement.Agnostic/ServiceExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public static IServiceCollection AddPostgresAuthServices(this IServiceCollection
7878
.UseDbContext<UserManagementDbContext>());
7979

8080
services.AddScoped<IAuthService, MicrosoftIdentityAuthService>();
81-
services.AddHostedService<AuthenticationWorker>();
8281

8382
services.AddScoped<IUsers, PostgresUserRepository>();
8483
services.AddScoped<IOutbox, PostgresUserRepository>();

user-management/src/Stickerlandia.UserManagement.Api/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
33
WORKDIR /App
44

55
# Deps
6-
COPY src/Stickerlandia.UserManagement.AspNet/Stickerlandia.UserManagement.AspNet.csproj src/Stickerlandia.UserManagement.AspNet/
7-
RUN dotnet restore src/Stickerlandia.UserManagement.AspNet/Stickerlandia.UserManagement.AspNet.csproj
6+
COPY src/Stickerlandia.UserManagement.Api/Stickerlandia.UserManagement.Api.csproj src/Stickerlandia.UserManagement.Api/
7+
RUN dotnet restore src/Stickerlandia.UserManagement.Api/Stickerlandia.UserManagement.Api.csproj
88

99
# Now copy the rest of the source code
1010
COPY . ./
1111

1212
# Publish the application
13-
RUN dotnet publish src/Stickerlandia.UserManagement.AspNet/Stickerlandia.UserManagement.AspNet.csproj -o out -c Release -r linux-arm64
13+
RUN dotnet publish src/Stickerlandia.UserManagement.Api/Stickerlandia.UserManagement.Api.csproj -o out -c Release -r linux-arm64
1414

1515
FROM mcr.microsoft.com/dotnet/aspnet:8.0-noble-chiseled AS runtime
1616
WORKDIR /App
1717
COPY --from=build /App/out .
1818
EXPOSE 80
19-
ENTRYPOINT [ "dotnet", "Stickerlandia.UserManagement.AspNet.dll" ]
19+
ENTRYPOINT [ "dotnet", "Stickerlandia.UserManagement.Api.dll" ]
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:9.0 as build
1+
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
22

33
WORKDIR /App
4+
5+
# Deps
6+
COPY src/Stickerlandia.UserManagement.Api/Stickerlandia.UserManagement.Api.csproj src/Stickerlandia.UserManagement.Api/
7+
RUN dotnet restore src/Stickerlandia.UserManagement.Api/Stickerlandia.UserManagement.Api.csproj
8+
9+
# Now copy the rest of the source code
410
COPY . ./
5-
RUN dotnet restore PlantBasedPizza.Account/application/PlantBasedPizza.Account.Api/PlantBasedPizza.Account.Api.csproj
6-
RUN dotnet publish PlantBasedPizza.Account/application/PlantBasedPizza.Account.Api/PlantBasedPizza.Account.Api.csproj -o out -c Release -r linux-x64
711

8-
FROM mcr.microsoft.com/dotnet/aspnet:9.0-noble-chiseled as runtime
12+
# Publish the application
13+
RUN dotnet publish src/Stickerlandia.UserManagement.Api/Stickerlandia.UserManagement.Api.csproj -o out -c Release -r linux-x64
14+
15+
FROM mcr.microsoft.com/dotnet/aspnet:8.0-noble-chiseled AS runtime
916
WORKDIR /App
1017
COPY --from=build /App/out .
1118
EXPOSE 80
12-
ENTRYPOINT [ "dotnet", "PlantBasedPizza.Account.Api.dll" ]
19+
ENTRYPOINT [ "dotnet", "Stickerlandia.UserManagement.Api.dll" ]

user-management/src/Stickerlandia.UserManagement.Aspire/AppBuilderExtensions.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public static IDistributedApplicationBuilder WithContainerizedApi(
2727
.WithEnvironment("DRIVING", builder.Configuration["DRIVING"])
2828
.WithEnvironment("DRIVEN", builder.Configuration["DRIVEN"])
2929
.WithHttpsEndpoint(51545)
30+
.WaitForCompletion(resources.MigrationServiceResource)
3031
.WaitFor(resources.MessagingResource)
3132
.WaitFor(resources.DatabaseResource);
3233

@@ -47,8 +48,17 @@ public static InfrastructureResources WithAgnosticServices(
4748
.AddPostgres("database")
4849
.WithLifetime(ContainerLifetime.Persistent)
4950
.AddDatabase("users");
51+
52+
var migrationService = builder.AddProject<Projects.Stickerlandia_UserManagement_MigrationService>("migration-service")
53+
.WithEnvironment("ConnectionStrings__database", agnosticDb)
54+
.WithEnvironment("ConnectionStrings__messaging", kafka)
55+
.WithEnvironment("DRIVING", builder.Configuration["DRIVING"])
56+
.WithEnvironment("DRIVEN", builder.Configuration["DRIVEN"])
57+
.WithHttpsEndpoint(51545)
58+
.WaitFor(agnosticDb)
59+
.WaitFor(kafka);
5060

51-
return new InfrastructureResources(agnosticDb, kafka);
61+
return new InfrastructureResources(agnosticDb, kafka, migrationService);
5262
}
5363

5464
public static IDistributedApplicationBuilder CreateKafkaTopicsOnReady(
@@ -151,8 +161,17 @@ public static InfrastructureResources WithAzureNativeServices(this IDistributedA
151161
.AddPostgres("database")
152162
.WithLifetime(ContainerLifetime.Persistent)
153163
.AddDatabase("users");
164+
165+
var migrationService = builder.AddProject<Projects.Stickerlandia_UserManagement_MigrationService>("migration-service")
166+
.WithEnvironment("ConnectionStrings__database", azurePostgresDb)
167+
.WithEnvironment("ConnectionStrings__messaging", serviceBus)
168+
.WithEnvironment("DRIVING", builder.Configuration["DRIVING"])
169+
.WithEnvironment("DRIVEN", builder.Configuration["DRIVEN"])
170+
.WithHttpsEndpoint(51545)
171+
.WaitFor(azurePostgresDb)
172+
.WaitFor(serviceBus);
154173

155-
return new InfrastructureResources(azurePostgresDb, serviceBus);
174+
return new InfrastructureResources(azurePostgresDb, serviceBus, migrationService);
156175
}
157176

158177
public static IResourceBuilder<AzureServiceBusQueueResource> WithServiceBusTestCommands(
@@ -191,6 +210,7 @@ public static IDistributedApplicationBuilder WithBackgroundWorker(
191210
.WithEnvironment("ConnectionStrings__database", resources.DatabaseResource)
192211
.WithEnvironment("DRIVING", builder.Configuration["DRIVING"])
193212
.WithEnvironment("DRIVEN", builder.Configuration["DRIVEN"])
213+
.WaitForCompletion(resources.MigrationServiceResource)
194214
.WaitFor(resources.MessagingResource)
195215
.WaitFor(resources.DatabaseResource);
196216

@@ -210,6 +230,7 @@ public static IDistributedApplicationBuilder WithAzureFunctions(
210230
.WithEnvironment("ConnectionStrings__database", resources.DatabaseResource)
211231
.WithEnvironment("DRIVING", builder.Configuration["DRIVING"])
212232
.WithEnvironment("DRIVEN", builder.Configuration["DRIVEN"])
233+
.WaitForCompletion(resources.MigrationServiceResource)
213234
.WaitFor(resources.MessagingResource)
214235
.WaitFor(resources.DatabaseResource)
215236
.WithExternalHttpEndpoints();

user-management/src/Stickerlandia.UserManagement.Aspire/InfrastructureResources.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ namespace Stickerlandia.UserManagement.Aspire;
66

77
public record InfrastructureResources(
88
IResourceBuilder<IResourceWithConnectionString>? DatabaseResource,
9-
IResourceBuilder<IResourceWithConnectionString>? MessagingResource);
9+
IResourceBuilder<IResourceWithConnectionString>? MessagingResource,
10+
IResourceBuilder<ProjectResource> MigrationServiceResource);

user-management/src/Stickerlandia.UserManagement.Aspire/Stickerlandia.UserManagement.Aspire.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<ItemGroup>
2626
<ProjectReference Include="..\Stickerlandia.UserManagement.FunctionApp\Stickerlandia.UserManagement.FunctionApp.csproj" />
2727
<ProjectReference Include="..\Stickerlandia.UserManagement.Api\Stickerlandia.UserManagement.Api.csproj" />
28+
<ProjectReference Include="..\Stickerlandia.UserManagement.MigrationService\Stickerlandia.UserManagement.MigrationService.csproj" />
2829
<ProjectReference Include="..\Stickerlandia.UserManagement.Worker\Stickerlandia.UserManagement.Worker.csproj" />
2930
</ItemGroup>
3031

0 commit comments

Comments
 (0)