Browse Source

update sisk cadente tests (#9576)

* update sisk cadente

* add missing dependencies to aot test

* remove aot test

* fix: plaintext strings

* update cadente version

* update cadente version
Gabriel Scatolin 5 months ago
parent
commit
b08578abcc

+ 1 - 1
frameworks/CSharp/sisk/config.toml

@@ -25,4 +25,4 @@ os = "Linux"
 orm = "Raw"
 platform = ".NET"
 webserver = "Cadente"
-versus = "None"
+versus = "None"

+ 7 - 3
frameworks/CSharp/sisk/sisk-cadente.dockerfile

@@ -1,4 +1,4 @@
-FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
+FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
 WORKDIR /source
 
 # copy csproj and restore as distinct layers
@@ -7,10 +7,14 @@ RUN dotnet restore -r linux-musl-x64
 
 # copy and publish app and libraries
 COPY sisk-cadente/ .
-RUN dotnet publish -c release -o /app -r linux-musl-x64
+RUN dotnet publish -c release -o /app
+
+ENV DOTNET_GCDynamicAdaptationMode=0
+ENV DOTNET_ReadyToRun=0
+ENV DOTNET_HillClimbing_Disable=1
 
 # final stage/image
-FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
+FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
 WORKDIR /app
 COPY --from=build /app .
 

+ 22 - 14
frameworks/CSharp/sisk/sisk-cadente/Program.cs

@@ -1,10 +1,19 @@
-using System.Text;
+using System.Net;
+using System.Text;
 using System.Text.Json;
 using Sisk.Cadente;
 
-var host = new HttpHost ( 8080, session => {
-    var request = session.Request;
+HttpHost.QueueSize = 4096;
+
+var host = new HttpHost ( new IPEndPoint ( IPAddress.Any, 8080 ) );
+host.ContextCreated += Host_ContextCreated;
+
+host.Start ();
+Thread.Sleep ( Timeout.Infinite );
 
+void Host_ContextCreated ( HttpHost sender, HttpHostContext session ) {
+    var request = session.Request;
+    
     if (request.Path == "/plaintext") {
         SerializePlainTextResponse ( session.Response );
     }
@@ -14,23 +23,22 @@ var host = new HttpHost ( 8080, session => {
     else {
         session.Response.StatusCode = 404;
     }
-} );
+}
 
-host.Start ();
-Thread.Sleep ( Timeout.Infinite );
+static void SerializePlainTextResponse ( HttpHostContext.HttpResponse response ) {
 
-static void SerializePlainTextResponse ( HttpResponse response ) {
-    var contentBytes = Encoding.UTF8.GetBytes ( "Hello, world!" );
+    var messageBytes = Encoding.UTF8.GetBytes ( "Hello, World!" );
 
-    response.Headers.Add ( new HttpHeader ( "Content-Type", "text/plain" ) );
-    response.ResponseStream = new MemoryStream ( contentBytes );
+    response.Headers.Add ( new HttpHeader ( "Content-Type", "text/plain; charset=UTF-8" ) );
+    response.ResponseStream = new MemoryStream ( messageBytes );
 }
 
-static void SerializeJsonResponse ( HttpResponse response ) {
+static void SerializeJsonResponse ( HttpHostContext.HttpResponse response ) {
+
     var contentBytes = JsonSerializer.SerializeToUtf8Bytes ( new {
-        message = "Hello, world!"
+        message = "Hello, World!"
     } );
-
-    response.Headers.Add ( new HttpHeader ( "Content-Type", "application/json; charset=utf-8" ) );
+    
+    response.Headers.Add ( new HttpHeader ( "Content-Type", "application/json" ) );
     response.ResponseStream = new MemoryStream ( contentBytes );
 }

+ 11 - 11
frameworks/CSharp/sisk/sisk-cadente/sisk.csproj

@@ -1,15 +1,15 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
-	<PropertyGroup>
-		<OutputType>Exe</OutputType>
-		<TargetFramework>net8.0</TargetFramework>
-		<ImplicitUsings>enable</ImplicitUsings>
-		<Nullable>enable</Nullable>
-		<ServerGarbageCollection>true</ServerGarbageCollection>
-	</PropertyGroup>
+    <PropertyGroup>
+        <OutputType>Exe</OutputType>
+        <TargetFramework>net9.0</TargetFramework>
+        <ImplicitUsings>enable</ImplicitUsings>
+        <Nullable>enable</Nullable>
+        <ServerGarbageCollection>true</ServerGarbageCollection>
+    </PropertyGroup>
 
-	<ItemGroup>
-	  <PackageReference Include="Sisk.Cadente" Version="0.1.42-alpha1" />
-	</ItemGroup>
+    <ItemGroup>
+        <PackageReference Include="Sisk.Cadente" Version="0.1.64-alpha4" />
+    </ItemGroup>
 
-</Project>
+</Project>

+ 6 - 2
frameworks/CSharp/sisk/sisk/Program.cs

@@ -1,9 +1,13 @@
 using System.Net.Http.Json;
+using System.Text;
 using Sisk.Core.Http;
 using Sisk.Core.Routing;
 
 var app = HttpServer.CreateBuilder ( host => {
     host.UseListeningPort ( "http://+:8080/" );
+    host.UseConfiguration ( config => {
+        config.AccessLogsStream = null;
+    } );
 } ).Build ();
 
 app.Router.SetRoute ( RouteMethod.Get, "/plaintext", PlainText );
@@ -12,11 +16,11 @@ app.Router.SetRoute ( RouteMethod.Get, "/json", Json );
 app.Start ();
 
 static HttpResponse PlainText ( HttpRequest request ) {
-    return new HttpResponse ( "Hello, world!" );
+    return new HttpResponse ( new StringContent ( "Hello, World!", Encoding.UTF8, "text/plain" ) );
 }
 
 static HttpResponse Json ( HttpRequest request ) {
     return new HttpResponse ( JsonContent.Create ( new {
-        message = "Hello, world!"
+        message = "Hello, World!"
     } ) );
 }