diff --git a/.env.example b/.env.example index 22a6131..ba7bc71 100644 --- a/.env.example +++ b/.env.example @@ -1,8 +1,8 @@ # ─── Heimdall — Environment Variables ────────────────────────────── # Copy this file to .env and adjust for your deployment # -# Since the merge of Api + Web into one process, heimdall-web serves -# both the REST API and Blazor UI on the same port (5000). +# The heimdall service serves the Blazor UI, REST API, SignalR hubs, +# and Hangfire background jobs in a single process on port 5000. # Database DATABASE_URL=Host=postgresql;Port=5432;Database=heimdall;Username=heimdall;Password=heimdall @@ -30,7 +30,7 @@ ALARIK_JWT=ChangeMeAtLeast32BytesLongKeyInProd! # SENTRY_DSN=https://key@glitchtip.tordais.cc/6 # Agent (set per agent instance) -Agent__CentralUrl=http://heimdall-web:8080 +Agent__CentralUrl=http://heimdall:8080 Agent__SiteToken=replace-with-actual-token Agent__AgentName=agent-01 Agent__HeartbeatIntervalSeconds=30 diff --git a/Heimdall.slnx b/Heimdall.slnx index 3c206c4..2115356 100644 --- a/Heimdall.slnx +++ b/Heimdall.slnx @@ -7,7 +7,6 @@ - @@ -17,6 +16,5 @@ - diff --git a/Makefile b/Makefile index f40d819..73c28ea 100644 --- a/Makefile +++ b/Makefile @@ -59,11 +59,7 @@ dev-api: ## Run combined API+Web in development mode (API and Blazor UI in one p Cors__AllowedOrigins="*" \ dotnet run --project src/Heimdall.Web -dev-worker: ## Run workers in development mode - DATABASE_URL="Host=localhost;Port=5432;Database=heimdall;Username=heimdall;Password=heimdall" \ - dotnet run --project src/Heimdall.Workers - -dev-web: ## Run combined API+Web in development mode (no separate API needed) +dev-web: ## Run combined API+Web+Jobs in development mode (single process) DATABASE_URL="Host=localhost;Port=5432;Database=heimdall;Username=heimdall;Password=heimdall" \ JWT__Key="ThisIsADevKeyThatIsAtLeast32BytesLong!!" \ ASPNETCORE_ENVIRONMENT=Development \ diff --git a/docker/Dockerfile.central b/docker/Dockerfile similarity index 56% rename from docker/Dockerfile.central rename to docker/Dockerfile index df89d85..2274185 100644 --- a/docker/Dockerfile.central +++ b/docker/Dockerfile @@ -1,3 +1,13 @@ +# ─── Heimdall — Single image (Web API + Blazor UI + Background Jobs) ── +# This image runs the combined Heimdall.Web process which serves: +# - Blazor UI (interactive Server) +# - REST API controllers +# - Hangfire background jobs (heartbeat monitor, agent failover) +# - SignalR hubs (config, events) +# +# Build: docker build -f docker/Dockerfile -t heimdall . +# Run: docker compose -f docker/docker-compose.yml up -d + FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine AS build WORKDIR /src @@ -8,19 +18,15 @@ COPY src/Heimdall.Domain.Primitives/*.csproj src/Heimdall.Domain.Primitives/ COPY src/Heimdall.Domain/*.csproj src/Heimdall.Domain/ COPY src/Heimdall.Application/*.csproj src/Heimdall.Application/ COPY src/Heimdall.Infrastructure/*.csproj src/Heimdall.Infrastructure/ -COPY src/Heimdall.Api/*.csproj src/Heimdall.Api/ COPY src/Heimdall.Web/*.csproj src/Heimdall.Web/ -COPY src/Heimdall.Workers/*.csproj src/Heimdall.Workers/ RUN dotnet restore src/Heimdall.Web/Heimdall.Web.csproj -RUN dotnet restore src/Heimdall.Workers/Heimdall.Workers.csproj # Copy all source COPY src/ src/ -# Build and publish — the Web project now includes both Web UI and REST API -RUN dotnet publish src/Heimdall.Web/Heimdall.Web.csproj -c Release -o /app/web -RUN dotnet publish src/Heimdall.Workers/Heimdall.Workers.csproj -c Release -o /app/workers +# Build and publish — the Web project now includes Web UI, REST API, and background jobs +RUN dotnet publish src/Heimdall.Web/Heimdall.Web.csproj -c Release -o /app FROM mcr.microsoft.com/dotnet/aspnet:10.0-alpine AS runtime WORKDIR /app @@ -30,10 +36,9 @@ RUN apk add --no-cache icu-libs libstdc++ tzdata krb5 ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \ ASPNETCORE_URLS=http://+:8080 -COPY --from=build /app/web ./web -COPY --from=build /app/web/wwwroot ./wwwroot -COPY --from=build /app/workers ./workers +COPY --from=build /app . +COPY --from=build /app/wwwroot ./wwwroot EXPOSE 8080 -ENTRYPOINT ["dotnet", "web/Heimdall.Web.dll"] +ENTRYPOINT ["dotnet", "Heimdall.Web.dll"] diff --git a/docker/docker-compose.prod.yml b/docker/docker-compose.prod.yml index 0ce95c6..8674750 100644 --- a/docker/docker-compose.prod.yml +++ b/docker/docker-compose.prod.yml @@ -4,12 +4,12 @@ # Prerequisite: cp .env.example .env && edit secrets # # Images are published by the CI pipeline on main branch pushes: -# eltruncho/heimdall-web:latest +# eltruncho/heimdall:latest # eltruncho/heimdall-agent:latest # -# Since the merge of Api + Web into one process, the heimdall-web service -# serves both the REST API and the Blazor UI on the same port. -# Agents and external API clients connect to this single endpoint. +# The heimdall service serves the Blazor UI, REST API, SignalR hubs, +# and Hangfire background jobs (heartbeat monitor, agent failover) +# in a single process. x-logging: &default-logging driver: "json-file" @@ -72,8 +72,8 @@ services: networks: - heimdall-net - heimdall-web: - image: eltruncho/heimdall-web:latest + heimdall: + image: eltruncho/heimdall:latest environment: # Database DATABASE_URL: ${DATABASE_URL:?DATABASE_URL is required} @@ -106,27 +106,10 @@ services: networks: - heimdall-net - heimdall-workers: - image: eltruncho/heimdall-web:latest - entrypoint: ["dotnet", "workers/Heimdall.Workers.dll"] - environment: - DATABASE_URL: ${DATABASE_URL:?DATABASE_URL is required} - ASPNETCORE_ENVIRONMENT: ${ASPNETCORE_ENVIRONMENT:-Production} - SENTRY_DSN: ${SENTRY_DSN} - volumes: - - heimdall_data:/var/lib/heimdall - depends_on: - postgresql: - condition: service_healthy - restart: unless-stopped - logging: *default-logging - networks: - - heimdall-net - heimdall-agent: image: eltruncho/heimdall-agent:latest environment: - Agent__CentralUrl: ${HEIMDALL_CENTRAL_URL:-http://heimdall-web:8080} + Agent__CentralUrl: ${HEIMDALL_CENTRAL_URL:-http://heimdall:8080} Agent__SiteToken: ${HEIMDALL_SITE_TOKEN} Agent__AgentName: ${HEIMDALL_AGENT_NAME:-agent-01} Agent__HeartbeatIntervalSeconds: ${HEIMDALL_HEARTBEAT_INTERVAL:-30} @@ -141,7 +124,7 @@ services: volumes: - agent_state:/var/lib/heimdall depends_on: - - heimdall-web + - heimdall restart: unless-stopped logging: *default-logging networks: diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 3c666dc..a07124c 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,12 +1,12 @@ # ─── Heimdall — Development Docker Compose ───────────────────────── -# Builds images from local source. For production with pre-built images, +# Builds image from local source. For production with pre-built images, # use: docker compose -f docker/docker-compose.prod.yml up -d # For development with hot-reload: # docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml up -d # -# Since the merge of Api + Web into one process, the heimdall-web service -# serves both the REST API and the Blazor UI on the same port. -# Agents and external API clients connect to this single endpoint. +# The heimdall service serves the Blazor UI, REST API, SignalR hubs, +# and Hangfire background jobs (heartbeat monitor, agent failover) +# in a single process. x-logging: &default-logging driver: "json-file" @@ -69,11 +69,11 @@ services: networks: - heimdall-net - heimdall-web: + heimdall: build: context: .. - dockerfile: docker/Dockerfile.central - entrypoint: ["dotnet", "web/Heimdall.Web.dll"] + dockerfile: docker/Dockerfile + image: heimdall:latest environment: # Database DATABASE_URL: ${DATABASE_URL:-Host=postgresql;Port=5432;Database=heimdall;Username=heimdall;Password=heimdall} @@ -106,31 +106,12 @@ services: networks: - heimdall-net - heimdall-workers: - build: - context: .. - dockerfile: docker/Dockerfile.central - entrypoint: ["dotnet", "workers/Heimdall.Workers.dll"] - environment: - DATABASE_URL: ${DATABASE_URL:-Host=postgresql;Port=5432;Database=heimdall;Username=heimdall;Password=heimdall} - ASPNETCORE_ENVIRONMENT: ${ASPNETCORE_ENVIRONMENT:-Production} - SENTRY_DSN: ${SENTRY_DSN} - volumes: - - heimdall_data:/var/lib/heimdall - depends_on: - postgresql: - condition: service_healthy - restart: unless-stopped - logging: *default-logging - networks: - - heimdall-net - heimdall-agent: build: context: .. dockerfile: docker/Dockerfile.agent environment: - Agent__CentralUrl: ${HEIMDALL_CENTRAL_URL:-http://heimdall-web:8080} + Agent__CentralUrl: ${HEIMDALL_CENTRAL_URL:-http://heimdall:8080} Agent__SiteToken: ${HEIMDALL_SITE_TOKEN} Agent__AgentName: ${HEIMDALL_AGENT_NAME:-agent-01} Agent__HeartbeatIntervalSeconds: ${HEIMDALL_HEARTBEAT_INTERVAL:-30} @@ -146,7 +127,7 @@ services: retries: 3 start_period: 15s depends_on: - - heimdall-web + - heimdall restart: unless-stopped logging: *default-logging networks: diff --git a/src/Heimdall.Workers/Jobs/AgentFailoverJob.cs b/src/Heimdall.Infrastructure/Jobs/AgentFailoverJob.cs similarity index 98% rename from src/Heimdall.Workers/Jobs/AgentFailoverJob.cs rename to src/Heimdall.Infrastructure/Jobs/AgentFailoverJob.cs index 37c81ca..420be6c 100644 --- a/src/Heimdall.Workers/Jobs/AgentFailoverJob.cs +++ b/src/Heimdall.Infrastructure/Jobs/AgentFailoverJob.cs @@ -1,10 +1,10 @@ +using Heimdall.Application.Services; +using Heimdall.Domain.Enums; using Heimdall.Infrastructure.Data; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; -using Heimdall.Application.Services; -using Heimdall.Domain.Enums; -namespace Heimdall.Workers.Jobs; +namespace Heimdall.Infrastructure.Jobs; /// /// Hangfire recurring job that detects agents whose heartbeat is stale diff --git a/src/Heimdall.Workers/Jobs/HeartbeatMonitorJob.cs b/src/Heimdall.Infrastructure/Jobs/HeartbeatMonitorJob.cs similarity index 94% rename from src/Heimdall.Workers/Jobs/HeartbeatMonitorJob.cs rename to src/Heimdall.Infrastructure/Jobs/HeartbeatMonitorJob.cs index 28ab1d0..319f59d 100644 --- a/src/Heimdall.Workers/Jobs/HeartbeatMonitorJob.cs +++ b/src/Heimdall.Infrastructure/Jobs/HeartbeatMonitorJob.cs @@ -1,8 +1,9 @@ using Heimdall.Domain.Enums; using Heimdall.Infrastructure.Data; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; -namespace Heimdall.Workers.Jobs; +namespace Heimdall.Infrastructure.Jobs; /// /// Marks agents as Offline if no heartbeat received for 90+ seconds. diff --git a/src/Heimdall.Web/Heimdall.Web.csproj b/src/Heimdall.Web/Heimdall.Web.csproj index 6325414..4f264b9 100644 --- a/src/Heimdall.Web/Heimdall.Web.csproj +++ b/src/Heimdall.Web/Heimdall.Web.csproj @@ -6,6 +6,8 @@ + + diff --git a/src/Heimdall.Web/Program.cs b/src/Heimdall.Web/Program.cs index 982be54..88d323a 100644 --- a/src/Heimdall.Web/Program.cs +++ b/src/Heimdall.Web/Program.cs @@ -1,13 +1,19 @@ using System.IdentityModel.Tokens.Jwt; using System.Security.Claims; using System.Text; +using Heimdall.Application; +using Heimdall.Infrastructure; using Heimdall.Infrastructure.Data; +using Heimdall.Infrastructure.Jobs; using Heimdall.Infrastructure.Security; using Heimdall.Web.Components; using Heimdall.Web.Services; +using Hangfire; +using Hangfire.PostgreSql; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.EntityFrameworkCore; using Microsoft.IdentityModel.Tokens; using MudBlazor.Services; @@ -79,6 +85,42 @@ builder.Services.AddMudServices(config => config.SnackbarConfiguration.VisibleStateDuration = 4000; }); +// ── Application layer ───────────────────────────────────────────── +builder.Services.AddApplication(); + +// ── Infrastructure layer ────────────────────────────────────────── +builder.Services.AddInfrastructure(builder.Configuration, + Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")); + +// ── Database connection string (for Hangfire) ───────────────────── +var connectionString = Environment.GetEnvironmentVariable("DATABASE_URL") + ?? builder.Configuration.GetConnectionString("Default") + ?? throw new InvalidOperationException( + "DATABASE_URL is not configured. Set the DATABASE_URL environment variable " + + "or configure a Default connection string in appsettings.json. " + + "Example: Host=host;Port=5432;Database=heimdall;Username=user;Password=password"); + +// ── Hangfire ────────────────────────────────────────────────────── +#pragma warning disable CS0618 +builder.Services.AddHangfire(config => +{ + config.UsePostgreSqlStorage(connectionString, new PostgreSqlStorageOptions + { + SchemaName = "hangfire" + }); +}); +#pragma warning restore CS0618 + +builder.Services.AddHangfireServer(options => +{ + options.WorkerCount = 2; + options.Queues = ["default", "heartbeat"]; +}); + +// ── Jobs ────────────────────────────────────────────────────────── +builder.Services.AddScoped(); +builder.Services.AddScoped(); + // ── HTTP client for Heimdall API ────────────────────────────────── builder.Services.AddScoped(); var apiBaseUrl = builder.Configuration.GetValue("ApiBaseUrl") @@ -224,6 +266,60 @@ app.MapPost("/_auth/signout", async (HttpContext httpContext, ILogger l return Results.Ok(); }); +// ── Apply pending database migrations ──────────────────────────────── +// Retry with exponential backoff to handle container startup races where +// PostgreSQL accepts TCP connections but isn't ready to serve queries yet. +using (var scope = app.Services.CreateScope()) +{ + var logger = scope.ServiceProvider.GetRequiredService>(); + var db = scope.ServiceProvider.GetRequiredService(); + var maxRetries = 5; + var retryDelay = TimeSpan.FromSeconds(2); + + for (var attempt = 1; attempt <= maxRetries; attempt++) + { + try + { + if (db.Database.GetPendingMigrations().Any()) + { + logger.LogInformation("Applying pending database migrations (attempt {Attempt}/{MaxRetries})...", attempt, maxRetries); + db.Database.Migrate(); + logger.LogInformation("Database migrations applied successfully"); + } + break; + } + catch (Exception ex) when (attempt < maxRetries) + { + logger.LogWarning(ex, + "Database migration attempt {Attempt}/{MaxRetries} failed. Retrying in {Delay}s...", + attempt, maxRetries, retryDelay.TotalSeconds); + await Task.Delay(retryDelay); + retryDelay = TimeSpan.FromSeconds(retryDelay.TotalSeconds * 2); + } + catch (Exception ex) + { + logger.LogCritical(ex, "Failed to apply database migrations after {MaxRetries} attempts.", maxRetries); + throw; + } + } +} + +// ── Register recurring Hangfire jobs ───────────────────────────────── +using (var scope = app.Services.CreateScope()) +{ + var manager = scope.ServiceProvider.GetRequiredService(); + + manager.AddOrUpdate( + "heartbeat-monitor", + job => job.ExecuteAsync(CancellationToken.None), + "*/1 * * * *"); // Every minute + + manager.AddOrUpdate( + "agent-failover", + job => job.ExecuteAsync(CancellationToken.None), + "*/1 * * * *"); // Every minute — checks for stale heartbeats +} + app.Run(); // ─── DTO for the cookie sign-in request ─────────────────────────── diff --git a/src/Heimdall.Workers/Heimdall.Workers.csproj b/src/Heimdall.Workers/Heimdall.Workers.csproj deleted file mode 100644 index 286c934..0000000 --- a/src/Heimdall.Workers/Heimdall.Workers.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - net10.0 - enable - enable - dotnet-Heimdall.Workers-b4781e64-bf20-4437-b464-1bf9180d9f14 - - - - - - - - - - - - - - - diff --git a/src/Heimdall.Workers/Program.cs b/src/Heimdall.Workers/Program.cs deleted file mode 100644 index 8ce6d8b..0000000 --- a/src/Heimdall.Workers/Program.cs +++ /dev/null @@ -1,115 +0,0 @@ -using Heimdall.Application; -using Heimdall.Infrastructure; -using Heimdall.Infrastructure.Data; -using Heimdall.Workers.Jobs; -using Hangfire; -using Hangfire.PostgreSql; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Sentry; - -// ── Sentry (GlitchTip) — DSN from env var, no fallback ────────── -var sentryDsn = Environment.GetEnvironmentVariable("SENTRY_DSN"); - -var builder = Host.CreateApplicationBuilder(args); - -// ── Sentry (GlitchTip) ──────────────────────────────────────────── -if (!string.IsNullOrEmpty(sentryDsn)) -{ - builder.Logging.AddSentry(options => - { - options.Dsn = sentryDsn; - options.MinimumBreadcrumbLevel = LogLevel.Debug; - options.MinimumEventLevel = LogLevel.Error; - }); -} - -var connectionString = Environment.GetEnvironmentVariable("DATABASE_URL") - ?? builder.Configuration.GetConnectionString("Default") - ?? throw new InvalidOperationException( - "DATABASE_URL is not configured. Set the DATABASE_URL environment variable " + - "or configure a Default connection string in appsettings.json. " + - "Example: Host=host;Port=5432;Database=heimdall;Username=user;Password=password"); - -// ── Infrastructure ──────────────────────────────────────────────── -builder.Services.AddInfrastructure(builder.Configuration, - Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")); -builder.Services.AddApplication(); - -// ── Hangfire ────────────────────────────────────────────────────── -#pragma warning disable CS0618 -builder.Services.AddHangfire(config => -{ - config.UsePostgreSqlStorage(connectionString, new PostgreSqlStorageOptions - { - SchemaName = "hangfire" - }); -}); -#pragma warning restore CS0618 - -builder.Services.AddHangfireServer(options => -{ - options.WorkerCount = 2; - options.Queues = ["default", "heartbeat"]; -}); - -// ── Jobs ────────────────────────────────────────────────────────── -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -var host = builder.Build(); - -// Apply migrations with retry (handles container startup races) -using (var scope = host.Services.CreateScope()) -{ - var logger = scope.ServiceProvider.GetRequiredService>(); - var db = scope.ServiceProvider.GetRequiredService(); - var maxRetries = 5; - var retryDelay = TimeSpan.FromSeconds(2); - - for (var attempt = 1; attempt <= maxRetries; attempt++) - { - try - { - if (db.Database.GetPendingMigrations().Any()) - { - logger.LogInformation("Applying pending database migrations (attempt {Attempt}/{MaxRetries})...", attempt, maxRetries); - db.Database.Migrate(); - logger.LogInformation("Database migrations applied successfully"); - } - break; - } - catch (Exception ex) when (attempt < maxRetries) - { - logger.LogWarning(ex, - "Database migration attempt {Attempt}/{MaxRetries} failed. Retrying in {Delay}s...", - attempt, maxRetries, retryDelay.TotalSeconds); - await Task.Delay(retryDelay); - retryDelay = TimeSpan.FromSeconds(retryDelay.TotalSeconds * 2); - } - catch (Exception ex) - { - logger.LogCritical(ex, "Failed to apply database migrations after {MaxRetries} attempts.", maxRetries); - throw; - } - } -} - -// Register recurring jobs -using (var scope = host.Services.CreateScope()) -{ - var manager = scope.ServiceProvider.GetRequiredService(); - - manager.AddOrUpdate( - "heartbeat-monitor", - job => job.ExecuteAsync(CancellationToken.None), - "*/1 * * * *"); // Every minute - - manager.AddOrUpdate( - "agent-failover", - job => job.ExecuteAsync(CancellationToken.None), - "*/1 * * * *"); // Every minute — checks for stale heartbeats -} - -host.Run(); diff --git a/src/Heimdall.Workers/Properties/launchSettings.json b/src/Heimdall.Workers/Properties/launchSettings.json deleted file mode 100644 index aab5c9d..0000000 --- a/src/Heimdall.Workers/Properties/launchSettings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/launchsettings.json", - "profiles": { - "Heimdall.Workers": { - "commandName": "Project", - "dotnetRunMessages": true, - "environmentVariables": { - "DOTNET_ENVIRONMENT": "Development" - } - } - } -} diff --git a/src/Heimdall.Workers/Worker.cs b/src/Heimdall.Workers/Worker.cs deleted file mode 100644 index 2b9146b..0000000 --- a/src/Heimdall.Workers/Worker.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Heimdall.Workers; - -public class Worker(ILogger logger) : BackgroundService -{ - protected override async Task ExecuteAsync(CancellationToken stoppingToken) - { - while (!stoppingToken.IsCancellationRequested) - { - if (logger.IsEnabled(LogLevel.Information)) - { - logger.LogInformation("Worker running at: {time}", DateTimeOffset.UtcNow); - } - await Task.Delay(1000, stoppingToken); - } - } -} diff --git a/src/Heimdall.Workers/appsettings.Development.json b/src/Heimdall.Workers/appsettings.Development.json deleted file mode 100644 index b2dcdb6..0000000 --- a/src/Heimdall.Workers/appsettings.Development.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} diff --git a/src/Heimdall.Workers/appsettings.json b/src/Heimdall.Workers/appsettings.json deleted file mode 100644 index b2dcdb6..0000000 --- a/src/Heimdall.Workers/appsettings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} diff --git a/tests/Heimdall.Workers.Tests/Heimdall.Workers.Tests.csproj b/tests/Heimdall.Workers.Tests/Heimdall.Workers.Tests.csproj deleted file mode 100644 index e51bc3c..0000000 --- a/tests/Heimdall.Workers.Tests/Heimdall.Workers.Tests.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - net10.0 - enable - enable - false - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/Heimdall.Workers.Tests/PlaceholderTest.cs b/tests/Heimdall.Workers.Tests/PlaceholderTest.cs deleted file mode 100644 index 8c350cf..0000000 --- a/tests/Heimdall.Workers.Tests/PlaceholderTest.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Hangfire; -using Hangfire.MemoryStorage; -using Microsoft.Extensions.DependencyInjection; - -namespace Heimdall.Workers.Tests; - -public class HangfireConfigurationTests -{ - [Fact] - public void AddHangfire_WithMemoryStorage_RegistersJobStorage() - { - var services = new ServiceCollection(); - services.AddHangfire(config => - { - config.UseMemoryStorage(); - }); - - var provider = services.BuildServiceProvider(); - var storage = provider.GetService(); - - Assert.NotNull(storage); - } - - [Fact] - public void AddHangfire_WithMemoryStorage_StorageIsMemoryStorage() - { - var services = new ServiceCollection(); - services.AddHangfire(config => - { - config.UseMemoryStorage(); - }); - - var provider = services.BuildServiceProvider(); - var storage = provider.GetRequiredService(); - - Assert.IsType(storage); - } -}