Browse Source

[CSharp] add `ServiceStack v6` json/plaintext tests (#7050)

Dĵ ΝιΓΞΗΛψΚ 3 years ago
parent
commit
df657eedab

+ 37 - 0
frameworks/CSharp/servicestack-v6/.gitignore

@@ -0,0 +1,37 @@
+[Oo]bj/
+[Bb]in/
+TestResults/
+.nuget/
+*.sln.ide/
+_ReSharper.*/
+.idea/
+packages/
+artifacts/
+PublishProfiles/
+.vs/
+*.user
+*.suo
+*.cache
+*.docstates
+_ReSharper.*
+nuget.exe
+*net45.csproj
+*net451.csproj
+*k10.csproj
+*.psess
+*.vsp
+*.pidb
+*.userprefs
+*DS_Store
+*.ncrunchsolution
+*.*sdf
+*.ipch
+*.swp
+*~
+.build/
+.testPublish/
+launchSettings.json
+BenchmarkDotNet.Artifacts/
+BDN.Generated/
+binaries/
+global.json

+ 26 - 0
frameworks/CSharp/servicestack-v6/Benchmarks/Configure.AppHost.cs

@@ -0,0 +1,26 @@
+using Funq;
+using ServiceStack;
+using ServicestackV6.ServiceInterface;
+
+[assembly: HostingStartup(typeof(ServicestackV6.AppHost))]
+
+namespace ServicestackV6;
+
+public class AppHost : AppHostBase, IHostingStartup
+{
+    public void Configure(IWebHostBuilder builder) => builder.Configure(app =>
+    {
+        if (!HasInit)
+            app.UseServiceStack(new AppHost());
+    });
+
+    public AppHost() : base("ServicestackV6", typeof(MyServices).Assembly) { }
+
+    public override void Configure(Container container)
+    {
+        SetConfig(new HostConfig
+        {
+            UseSameSiteCookies = true,
+        });
+    }
+}

+ 11 - 0
frameworks/CSharp/servicestack-v6/Benchmarks/Models/Json.cs

@@ -0,0 +1,11 @@
+using ServiceStack;
+
+namespace ServicestackV6.ServiceModel;
+
+[Route("/json")]
+public class JsonRequest : IReturn<JsonResponse> { }
+
+public class JsonResponse
+{
+    public string message => "Hello, World!";
+}

+ 6 - 0
frameworks/CSharp/servicestack-v6/Benchmarks/Models/PlainText.cs

@@ -0,0 +1,6 @@
+using ServiceStack;
+
+namespace ServicestackV6.ServiceModel;
+
+[Route("/plaintext")]
+public class PlainTextRequest : IReturnVoid { }

+ 4 - 0
frameworks/CSharp/servicestack-v6/Benchmarks/Program.cs

@@ -0,0 +1,4 @@
+WebApplication
+    .CreateBuilder(args)
+    .Build()
+    .Run();

+ 22 - 0
frameworks/CSharp/servicestack-v6/Benchmarks/Services/MyServices.cs

@@ -0,0 +1,22 @@
+using ServiceStack;
+using ServicestackV6.ServiceModel;
+
+namespace ServicestackV6.ServiceInterface;
+
+public class MyServices : Service
+{
+    private static readonly byte[] payload = System.Text.Encoding.UTF8.GetBytes("Hello, World!");
+
+    public object Get(JsonRequest _)
+    {
+        Response.SetContentLength(27);
+        return new JsonResponse();
+    }
+
+    public byte[] Get(PlainTextRequest _)
+    {
+        Response.SetContentLength(payload.Length);
+        Response.ContentType = "text/plain";
+        return payload;
+    }
+}

+ 13 - 0
frameworks/CSharp/servicestack-v6/Benchmarks/ServicestackV6.csproj

@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.NET.Sdk.Web">
+
+    <PropertyGroup>
+        <TargetFramework>net6.0</TargetFramework>
+        <Nullable>enable</Nullable>
+        <ImplicitUsings>enable</ImplicitUsings>
+    </PropertyGroup>
+
+    <ItemGroup>
+        <PackageReference Include="ServiceStack" Version="6.*" />
+    </ItemGroup>
+
+</Project>

+ 8 - 0
frameworks/CSharp/servicestack-v6/Benchmarks/appsettings.Development.json

@@ -0,0 +1,8 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft.AspNetCore": "Warning"
+    }
+  }
+}

+ 15 - 0
frameworks/CSharp/servicestack-v6/Benchmarks/appsettings.json

@@ -0,0 +1,15 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Warning"
+    }
+  },
+  "AllowedHosts": "*",
+  "Kestrel": {
+    "Endpoints": {
+      "Http": {
+        "Url": "http://*:8080"
+      }
+    }
+  }
+}

+ 26 - 0
frameworks/CSharp/servicestack-v6/README.md

@@ -0,0 +1,26 @@
+# Servicestack-V6 Tests on Windows and Linux
+This includes tests for plaintext and json serialization.
+
+## Infrastructure Software Versions
+
+**Language**
+
+* C# 10.0
+
+**Platforms**
+
+* .NET 6.0 (Windows and Linux)
+
+**Web Servers**
+
+* [Kestrel](https://github.com/dotnet/aspnetcore/tree/main/src/Servers/Kestrel)
+
+**Web Stack**
+
+* [ServiceStack](https://servicestack.net/)
+* ASP.Net 6
+
+## Paths & Source for Tests
+
+* [Plaintext](Benchmarks/Services/MyServices.cs#L10): "http://localhost:8080/plaintext"
+* [JSON Serialization](Benchmarks/Services/MyServices.cs#16): "http://localhost:8080/json"

+ 26 - 0
frameworks/CSharp/servicestack-v6/benchmark_config.json

@@ -0,0 +1,26 @@
+{
+  "framework": "servicestack-v6",
+  "tests": [
+    {
+      "default": {
+        "plaintext_url": "/plaintext",
+        "json_url": "/json",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Micro",
+        "database": "None",
+        "framework": "ServiceStack-V6",
+        "language": "C#",
+        "orm": "Raw",
+        "platform": ".NET",
+        "flavor": "CoreCLR",
+        "webserver": "Kestrel",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "ServiceStack-V6",
+        "notes": "",
+        "versus": "aspcore-mvc"
+      }
+    }
+  ]
+}

+ 15 - 0
frameworks/CSharp/servicestack-v6/config.toml

@@ -0,0 +1,15 @@
+[framework]
+name = "servicestack-v6"
+
+[main]
+urls.plaintext = "/plaintext"
+urls.json = "/json"
+approach = "Realistic"
+classification = "Micro"
+database = "None"
+database_os = "Linux"
+os = "Linux"
+orm = "Raw"
+platform = ".NET"
+webserver = "Kestrel"
+versus = "aspcore-mvc"

+ 12 - 0
frameworks/CSharp/servicestack-v6/servicestack-v6.dockerfile

@@ -0,0 +1,12 @@
+FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
+WORKDIR /app
+COPY Benchmarks .
+RUN dotnet publish -c Release -o out
+
+FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime
+WORKDIR /app
+COPY --from=build /app/out ./
+
+EXPOSE 8080
+
+ENTRYPOINT ["dotnet", "ServicestackV6.dll"]