From c03f87576779e40547ed38b9bc1cc0d3fa693dcd Mon Sep 17 00:00:00 2001 From: Eden Federman Date: Mon, 23 Dec 2024 12:22:59 +0200 Subject: [PATCH] Add .NET cases to workflow lifecycle --- .../services/dotnet-musl-server/Program.cs | 52 +++++++++++++++++-- .../dotnet-musl-server.csproj | 3 +- 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/tests/e2e/workload-lifecycle/services/dotnet-musl-server/Program.cs b/tests/e2e/workload-lifecycle/services/dotnet-musl-server/Program.cs index c2dc41dbe7..166efb9cc4 100644 --- a/tests/e2e/workload-lifecycle/services/dotnet-musl-server/Program.cs +++ b/tests/e2e/workload-lifecycle/services/dotnet-musl-server/Program.cs @@ -1,6 +1,50 @@ -var builder = WebApplication.CreateBuilder(args); -var app = builder.Build(); +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; +using System; -app.MapGet("/", () => "Hello World!"); -app.Run("http://0.0.0.0:8080"); +namespace LegacyWebHostTest +{ + public class Program + { + public static void Main(string[] args) + { + var host = new WebHostBuilder() + // Configure Kestrel, etc. + .UseKestrel() + + // Logging + .ConfigureLogging(logging => + { + logging.ClearProviders(); + logging.AddConsole(); + // Typically with 2.x hosting, AddConsole() + // sets up the console logger, including logger for WebHost + }) + + // Minimal pipeline + .Configure(app => + { + app.Run(async context => + { + var logger = context + .RequestServices + .GetService(typeof(ILogger)) + as ILogger; + + logger?.LogInformation("Handling request on path {path}", context.Request.Path); + + await context.Response.WriteAsync("Hello from a legacy webhost on .NET 6\n"); + }); + }) + + // Build the host + .Build(); + + // Run + host.Run("http://0.0.0.0:8080"); + } + } +} diff --git a/tests/e2e/workload-lifecycle/services/dotnet-musl-server/dotnet-musl-server.csproj b/tests/e2e/workload-lifecycle/services/dotnet-musl-server/dotnet-musl-server.csproj index 97c4f0efcc..c376351eb4 100644 --- a/tests/e2e/workload-lifecycle/services/dotnet-musl-server/dotnet-musl-server.csproj +++ b/tests/e2e/workload-lifecycle/services/dotnet-musl-server/dotnet-musl-server.csproj @@ -1,7 +1,8 @@  - net8.0 + net6.0 + net8.0 dotnet-musl-server enable enable