Skip to content

Commit

Permalink
Implement #73 integration tests for .NET
Browse files Browse the repository at this point in the history
This adds .NET auto attachment tests
  • Loading branch information
Mpdreamz committed Nov 28, 2023
1 parent 170162e commit 83b4b44
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
- '**.asciidoc'

env:
AGENT_TESTS: java nodejs
AGENT_TESTS: dotnet java nodejs

jobs:
integration-test:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ main

.webhook
.vscode
.idea
bin

html_docs
html_docs
2 changes: 2 additions & 0 deletions test/dotnet/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin
obj
17 changes: 17 additions & 0 deletions test/dotnet/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# https://hub.docker.com/_/microsoft-dotnet
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /source

# copy csproj and restore as distinct layers
COPY *.csproj .
RUN dotnet restore

# copy everything else and build app
COPY . .
RUN dotnet publish -c release -o /app --no-restore

# final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /app ./
ENTRYPOINT ["dotnet", "dotnetapp.dll"]
6 changes: 6 additions & 0 deletions test/dotnet/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/", () => "Hello World!");

app.Run();
10 changes: 10 additions & 0 deletions test/dotnet/agent_has_started.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
#initial 10 second delay for restricted CPUs making agent slow starting
sleep 10
START_MESSAGE=`kubectl logs java-test-app | grep 'Application Started. Press Ctrl+C'`
if [ "x$START_MESSAGE" = "x" ]
then
exit 1
else
exit 0
fi
9 changes: 9 additions & 0 deletions test/dotnet/dotnetapp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

</Project>
13 changes: 13 additions & 0 deletions test/dotnet/test-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Pod
metadata:
name: dotnet-test-app
annotations:
co.elastic.apm/attach: dotnet
labels:
app: dotnet-test-app
spec:
containers:
- image: localhost:5001/registry/dotnet-test-app
imagePullPolicy: Always
name: dotnet-test-app

0 comments on commit 83b4b44

Please sign in to comment.