Skip to content

Commit 913d2fb

Browse files
author
Kevin Gosse
authored
Use dd-dotnet in the nuget smoke tests (#4695)
1 parent 33b40f9 commit 913d2fb

File tree

5 files changed

+181
-0
lines changed

5 files changed

+181
-0
lines changed

.azure-pipelines/ultimate-pipeline.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4674,6 +4674,24 @@ stages:
46744674
target: 'nuget-smoke-tests'
46754675
snapshotPrefix: "smoke_test"
46764676

4677+
- script: |
4678+
docker-compose -p ddtrace_$(Build.BuildNumber) build \
4679+
--build-arg DOTNETSDK_VERSION=$(dotnetCoreSdkLatestVersion) \
4680+
--build-arg RUNTIME_IMAGE=$(runtimeImage) \
4681+
--build-arg PUBLISH_FRAMEWORK=$(publishFramework) \
4682+
--build-arg RELATIVE_PROFILER_PATH="$(relativeProfilerPath)" \
4683+
--build-arg RELATIVE_APIWRAPPER_PATH="$(relativeApiWrapperPath)" \
4684+
nuget-dddotnet-smoke-tests
4685+
env:
4686+
dockerTag: $(dockerTag)
4687+
displayName: docker-compose build nuget-dddotnet-smoke-tests
4688+
retryCountOnTaskFailure: 3
4689+
4690+
- template: steps/run-snapshot-test.yml
4691+
parameters:
4692+
target: 'nuget-dddotnet-smoke-tests'
4693+
snapshotPrefix: "smoke_test"
4694+
46774695
- publish: tracer/build_data
46784696
artifact: _$(System.StageName)_$(Agent.JobName)_logs_$(System.JobAttempt)
46794697
condition: succeededOrFailed()
@@ -5081,6 +5099,23 @@ stages:
50815099
target: 'nuget-smoke-tests'
50825100
snapshotPrefix: "smoke_test"
50835101

5102+
- script: |
5103+
docker-compose -p ddtrace_$(Build.BuildNumber) build \
5104+
--build-arg DOTNETSDK_VERSION=$(dotnetCoreSdkLatestVersion) \
5105+
--build-arg RUNTIME_IMAGE=$(runtimeImage) \
5106+
--build-arg PUBLISH_FRAMEWORK=$(publishFramework) \
5107+
--build-arg RELATIVE_PROFILER_PATH="$(relativeProfilerPath)" \
5108+
nuget-dddotnet-smoke-tests
5109+
env:
5110+
dockerTag: $(dockerTag)
5111+
displayName: docker-compose build smoke-tests dd-dotnet
5112+
retryCountOnTaskFailure: 3
5113+
5114+
- template: steps/run-snapshot-test.yml
5115+
parameters:
5116+
target: 'nuget-dddotnet-smoke-tests'
5117+
snapshotPrefix: "smoke_test"
5118+
50845119
- publish: tracer/build_data
50855120
artifact: _$(System.StageName)_$(Agent.JobName)_logs_$(System.JobAttempt)
50865121
condition: succeededOrFailed()
@@ -5278,6 +5313,25 @@ stages:
52785313
snapshotPrefix: "smoke_test"
52795314
isLinux: false
52805315

5316+
- bash: |
5317+
docker-compose -f docker-compose.windows.yml -p ddtrace_$(Build.BuildNumber) build \
5318+
--build-arg DOTNETSDK_VERSION=$(dotnetCoreSdkLatestVersion) \
5319+
--build-arg RUNTIME_IMAGE=$(runtimeImage) \
5320+
--build-arg PUBLISH_FRAMEWORK=$(publishFramework) \
5321+
--build-arg CHANNEL_32_BIT="$(channel32Bit)" \
5322+
--build-arg RELATIVE_PROFILER_PATH="$(relativeProfilerPath)" \
5323+
nuget-dddotnet-smoke-tests.windows
5324+
env:
5325+
dockerTag: $(dockerTag)
5326+
displayName: docker-compose build smoke-tests dd-dotnet
5327+
retryCountOnTaskFailure: 3
5328+
5329+
- template: steps/run-snapshot-test.yml
5330+
parameters:
5331+
target: 'nuget-dddotnet-smoke-tests.windows'
5332+
snapshotPrefix: "smoke_test"
5333+
isLinux: false
5334+
52815335
- publish: tracer/build_data
52825336
artifact: _$(System.StageName)_$(Agent.JobName)_logs_$(System.JobAttempt)
52835337
condition: succeededOrFailed()

docker-compose.windows.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,24 @@ services:
124124
- dockerTag=${dockerTag:-unset}
125125
- DD_TRACE_AGENT_URL=http://test-agent.windows:8126
126126
depends_on:
127+
- test-agent.windows
128+
129+
nuget-dddotnet-smoke-tests.windows:
130+
build:
131+
context: ./tracer/ # have to use this as the context, as Dockercompose requires dockerfile to be inside context dir
132+
dockerfile: build/_build/docker/smoke.windows.nuget.dd-dotnet.dockerfile
133+
# args:
134+
# Note that the following build arguments must be provided
135+
# - DOTNETSDK_VERSION=
136+
# - RUNTIME_IMAGE=
137+
# - PUBLISH_FRAMEWORK=
138+
# - RELATIVE_PROFILER_PATH=
139+
image: dd-trace-dotnet/${dockerTag:-not-set}-windows-nuget-tester
140+
volumes:
141+
- ./:c:/project
142+
- ./tracer/build_data/logs:c:/logs
143+
environment:
144+
- dockerTag=${dockerTag:-unset}
145+
- DD_TRACE_AGENT_URL=http://test-agent.windows:8126
146+
depends_on:
127147
- test-agent.windows

docker-compose.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,27 @@ services:
906906
depends_on:
907907
- test-agent
908908

909+
nuget-dddotnet-smoke-tests:
910+
build:
911+
context: ./tracer/ # have to use this as the context, as Dockercompose requires dockerfile to be inside context dir
912+
dockerfile: build/_build/docker/smoke.nuget.dd-dotnet.dockerfile
913+
# args:
914+
# Note that the following build arguments must be provided
915+
# - DOTNETSDK_VERSION=
916+
# - RUNTIME_IMAGE=
917+
# - PUBLISH_FRAMEWORK=
918+
# - RELATIVE_PROFILER_PATH=
919+
# - RELATIVE_API_WRAPPER_PATH=
920+
image: dd-trace-dotnet/${dockerTag:-not-set}-nuget-tester
921+
volumes:
922+
- ./:/project
923+
- ./tracer/build_data/logs:/var/log/datadog/dotnet
924+
environment:
925+
- dockerTag=${dockerTag:-unset}
926+
- DD_TRACE_AGENT_URL=http://test-agent:8126
927+
depends_on:
928+
- test-agent
929+
909930
dotnet-tool-smoke-tests:
910931
build:
911932
context: ./tracer/ # have to use this as the context, as Dockercompose requires dockerfile to be inside context dir
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
ARG DOTNETSDK_VERSION
2+
ARG RUNTIME_IMAGE
3+
4+
# Build the ASP.NET Core app using the latest SDK
5+
FROM mcr.microsoft.com/dotnet/sdk:$DOTNETSDK_VERSION-bullseye-slim as builder
6+
7+
# Build the smoke test app
8+
WORKDIR /src
9+
COPY ./test/test-applications/regression/AspNetCoreSmokeTest/ .
10+
11+
# do an initial restore
12+
RUN dotnet restore "AspNetCoreSmokeTest.csproj"
13+
14+
# install the package
15+
RUN dotnet add package "Datadog.Trace.Bundle" --source /src/artifacts
16+
17+
ARG PUBLISH_FRAMEWORK
18+
RUN dotnet publish "AspNetCoreSmokeTest.csproj" -c Release --framework $PUBLISH_FRAMEWORK -o /src/publish
19+
20+
FROM $RUNTIME_IMAGE AS publish
21+
22+
WORKDIR /app
23+
24+
RUN mkdir -p /opt/datadog \
25+
&& mkdir -p /var/log/datadog
26+
27+
# Copy the app across
28+
COPY --from=builder /src/publish /app/.
29+
30+
ENV ASPNETCORE_URLS=http://localhost:5000
31+
32+
# Set a random env var we should ignore
33+
ENV SUPER_SECRET_CANARY=MySuperSecretCanary
34+
35+
# see https://github.com/DataDog/dd-trace-dotnet/pull/3579
36+
ENV DD_INTERNAL_WORKAROUND_77973_ENABLED=1
37+
38+
ENTRYPOINT ["/app/datadog/dd-dotnet.sh", "run", "--set-env", "DD_PROFILING_ENABLED=1","--set-env", "DD_APPSEC_ENABLED=1","--set-env", "DD_TRACE_DEBUG=1", "--", "dotnet", "/app/AspNetCoreSmokeTest.dll"]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
ARG DOTNETSDK_VERSION
2+
ARG RUNTIME_IMAGE
3+
4+
# Build the ASP.NET Core app using the latest SDK
5+
FROM mcr.microsoft.com/dotnet/sdk:$DOTNETSDK_VERSION as builder
6+
7+
# Without this, the container doesn't have permission to add the new package
8+
USER ContainerAdministrator
9+
10+
# Build the smoke test app
11+
WORKDIR /src
12+
COPY ./test/test-applications/regression/AspNetCoreSmokeTest/ .
13+
14+
ARG PUBLISH_FRAMEWORK
15+
RUN dotnet restore "AspNetCoreSmokeTest.csproj" \
16+
&& dotnet nuget add source "c:\src\artifacts" \
17+
&& dotnet add package "Datadog.Trace.Bundle" \
18+
&& dotnet publish "AspNetCoreSmokeTest.csproj" -c Release --framework %PUBLISH_FRAMEWORK% -o "c:\src\publish"
19+
20+
FROM $RUNTIME_IMAGE AS publish-msi
21+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
22+
23+
WORKDIR /app
24+
25+
ARG CHANNEL_32_BIT
26+
RUN if($env:CHANNEL_32_BIT){ \
27+
echo 'Installing x86 dotnet runtime ' + $env:CHANNEL_32_BIT; \
28+
curl 'https://dot.net/v1/dotnet-install.ps1' -o dotnet-install.ps1; \
29+
./dotnet-install.ps1 -Architecture x86 -Runtime aspnetcore -Channel $env:CHANNEL_32_BIT -InstallDir c:\cli; \
30+
[Environment]::SetEnvironmentVariable('Path', 'c:\cli;' + $env:Path, [EnvironmentVariableTarget]::Machine); \
31+
rm ./dotnet-install.ps1; }
32+
33+
RUN mkdir /logs
34+
35+
# Set the required env vars
36+
ENV DD_TRACE_LOG_DIRECTORY="C:\logs" \
37+
ASPNETCORE_URLS=http://localhost:5000
38+
39+
# Set a random env var we should ignore
40+
ENV SUPER_SECRET_CANARY=MySuperSecretCanary
41+
42+
# see https://github.com/DataDog/dd-trace-dotnet/pull/3579
43+
ENV DD_INTERNAL_WORKAROUND_77973_ENABLED=1
44+
45+
# Copy the app across
46+
COPY --from=builder /src/publish /app/.
47+
48+
ENTRYPOINT ["/app/datadog/dd-dotnet.cmd", "run", "--set-env", "DD_PROFILING_ENABLED=1","--set-env", "DD_APPSEC_ENABLED=1","--set-env", "DD_TRACE_DEBUG=1", "--", "dotnet", "/app/AspNetCoreSmokeTest.dll"]

0 commit comments

Comments
 (0)