From 328158237020ab692ec8b8ad003460359771d5d2 Mon Sep 17 00:00:00 2001 From: Johannes Tax Date: Wed, 24 Jan 2024 16:24:55 +0100 Subject: [PATCH] Add an OATS test configuration running with self-contained executables (#67) * Add test configuration running with self-contained executables * Remove debugging statement * Add docker file for self-contained deployment * Regroup HTTP tests * Use an OATS matrix --- .../docker-compose.self-contained.oats.yml | 28 +++++++++++++++++++ .../http/oats-template.yml | 12 ++++++++ .../http/oats.http-get.yaml | 7 ++--- .../http/oats.http-geterror.yaml | 7 ++--- .../oats-template.yml | 12 ++++++++ .../oats.mssql-query.yaml | 6 ++-- .../oats.mssql-sproc.yaml | 6 ++-- examples/net6.0/aspnetcore/Dockerfile | 7 +++-- 8 files changed, 65 insertions(+), 20 deletions(-) create mode 100644 docker/docker-compose-aspnetcore/docker-compose.self-contained.oats.yml create mode 100644 docker/docker-compose-aspnetcore/http/oats-template.yml create mode 100644 docker/docker-compose-aspnetcore/oats-template.yml diff --git a/docker/docker-compose-aspnetcore/docker-compose.self-contained.oats.yml b/docker/docker-compose-aspnetcore/docker-compose.self-contained.oats.yml new file mode 100644 index 0000000..37dc10c --- /dev/null +++ b/docker/docker-compose-aspnetcore/docker-compose.self-contained.oats.yml @@ -0,0 +1,28 @@ +version: '3.4' + +services: + aspnetcore: + image: ${DOCKER_REGISTRY-}aspnetcore + build: + context: ../.. + dockerfile: examples/net6.0/aspnetcore/Dockerfile + args: + DOTNET_PUBLISH_ARGS: "--self-contained true /p:PublishSingleFile=true" + entrypoint: ./aspnetcore + environment: + - OTEL_EXPORTER_OTLP_ENDPOINT=http://collector:4317 + ports: + - "5000:80" + - "8080:80" # for OATs + depends_on: + - redis + - mssql + redis: + image: redis:7.2 + ports: + - "6379:6379" + mssql: + image: mcr.microsoft.com/mssql/server:2022-latest + environment: + - ACCEPT_EULA=Y + - MSSQL_SA_PASSWORD=Password12345%% diff --git a/docker/docker-compose-aspnetcore/http/oats-template.yml b/docker/docker-compose-aspnetcore/http/oats-template.yml new file mode 100644 index 0000000..4c2b2a7 --- /dev/null +++ b/docker/docker-compose-aspnetcore/http/oats-template.yml @@ -0,0 +1,12 @@ +matrix: + - name: default + docker-compose: + generator: lgtm + files: + - ../docker-compose.oats.yml + - name: self-contained + docker-compose: + generator: lgtm + files: + - ../docker-compose.self-contained.oats.yml +interval: 500ms diff --git a/docker/docker-compose-aspnetcore/http/oats.http-get.yaml b/docker/docker-compose-aspnetcore/http/oats.http-get.yaml index b4fdd57..516cc54 100644 --- a/docker/docker-compose-aspnetcore/http/oats.http-get.yaml +++ b/docker/docker-compose-aspnetcore/http/oats.http-get.yaml @@ -1,10 +1,7 @@ -docker-compose: - generator: lgtm - files: - - ../docker-compose.oats.yml +include: + - ./oats-template.yml input: - path: /api/HttpClient/Get -interval: 500ms expected: traces: - traceql: '{ name =~ "api/HttpClient/Get" }' diff --git a/docker/docker-compose-aspnetcore/http/oats.http-geterror.yaml b/docker/docker-compose-aspnetcore/http/oats.http-geterror.yaml index c2f1689..af7a99a 100644 --- a/docker/docker-compose-aspnetcore/http/oats.http-geterror.yaml +++ b/docker/docker-compose-aspnetcore/http/oats.http-geterror.yaml @@ -1,10 +1,7 @@ -docker-compose: - generator: lgtm - files: - - ../docker-compose.oats.yml +include: + - ./oats-template.yml input: - path: /api/HttpClient/GetError -interval: 500ms expected: traces: - traceql: '{ name =~ "api/HttpClient/GetError" }' diff --git a/docker/docker-compose-aspnetcore/oats-template.yml b/docker/docker-compose-aspnetcore/oats-template.yml new file mode 100644 index 0000000..e0733ac --- /dev/null +++ b/docker/docker-compose-aspnetcore/oats-template.yml @@ -0,0 +1,12 @@ +matrix: + - name: default + docker-compose: + generator: lgtm + files: + - ./docker-compose.oats.yml + - name: self-contained + docker-compose: + generator: lgtm + files: + - ./docker-compose.self-contained.oats.yml +interval: 500ms diff --git a/docker/docker-compose-aspnetcore/oats.mssql-query.yaml b/docker/docker-compose-aspnetcore/oats.mssql-query.yaml index 95c07f6..ef7c986 100644 --- a/docker/docker-compose-aspnetcore/oats.mssql-query.yaml +++ b/docker/docker-compose-aspnetcore/oats.mssql-query.yaml @@ -1,7 +1,5 @@ -docker-compose: - generator: lgtm - files: - - ./docker-compose.oats.yml +include: + - ./oats-template.yml input: - path: /api/MsSql/Tables expected: diff --git a/docker/docker-compose-aspnetcore/oats.mssql-sproc.yaml b/docker/docker-compose-aspnetcore/oats.mssql-sproc.yaml index 9f762d2..0b33994 100644 --- a/docker/docker-compose-aspnetcore/oats.mssql-sproc.yaml +++ b/docker/docker-compose-aspnetcore/oats.mssql-sproc.yaml @@ -1,7 +1,5 @@ -docker-compose: - generator: lgtm - files: - - ./docker-compose.oats.yml +include: + - ./oats-template.yml input: - path: /api/MsSql/ServerInfo expected: diff --git a/examples/net6.0/aspnetcore/Dockerfile b/examples/net6.0/aspnetcore/Dockerfile index 1b45285..c67de40 100644 --- a/examples/net6.0/aspnetcore/Dockerfile +++ b/examples/net6.0/aspnetcore/Dockerfile @@ -5,6 +5,9 @@ WORKDIR /app EXPOSE 80 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build + +ARG DOTNET_PUBLISH_ARGS="" + WORKDIR /src COPY ["examples/net6.0/aspnetcore/aspnetcore.csproj", "examples/net6.0/aspnetcore/"] RUN dotnet restore "examples/net6.0/aspnetcore/aspnetcore.csproj" @@ -13,9 +16,9 @@ WORKDIR "/src/examples/net6.0/aspnetcore" RUN dotnet build "aspnetcore.csproj" -c Release -o /app/build FROM build AS publish -RUN dotnet publish "aspnetcore.csproj" -c Release -o /app/publish /p:UseAppHost=false +RUN dotnet publish "aspnetcore.csproj" -c Release -o /app/publish ${DOTNET_PUBLISH_ARGS} FROM base AS final WORKDIR /app COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "aspnetcore.dll"] \ No newline at end of file +ENTRYPOINT ["dotnet", "aspnetcore.dll"]