-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add smoke tests for fleet installer (#6645)
## Summary of changes Adds a new smoke test stage, for running inside Windows using the fleet installer ## Reason for change Emulates an end-to-end smoke test for the fleet installer executable. ## Implementation details - Build the fleet installer in the AzDo pipeline, as part of the `package-windows` stage - Adds a new `fleet_installer_smoke_tests` stage for running the smoke tests - Fix issues in ASP.NET Core test app, so that it works when hosted in IIS - Add a dockerfile for running the ASP.NET Core app with the fleet installer, hosted in IIS That latter point proved to be somewhat of a nightmare. The resulting dockerfile feels kind of horrible, but I couldn't find another way to have: - Delay the start of the app pool until the container image is running (i.e. not during build time) - Start the worker process when the app pool starts, _without_ an incoming request - Shut down the app pool when the worker process exits (which is the way the aspnetcore app works) - Exit the container The workaround, using the entrypoint script, makes a 404 request to the app to spin up the worker process, manually shuts down the app pool (to make sure the app definitely shuts down and flushes), and then exits. This causes an additional span in the traces, so needed to create new snapshots. ## Test coverage This gives basic snapshot testing on 2022 which is the only version I could get to work given the hosted images on AzDo and the available python base images for the test agent. I think that is sufficient - we are going to have additional end-to-end testing of Windows images in system tests anyway. ## Other details Part of a stack of PRs: - #6643 - #6644 - #6645 👈
- Loading branch information
1 parent
3008927
commit f74c400
Showing
7 changed files
with
351 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
tracer/build/_build/docker/smoke.windows.fleet-installer.dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
ARG DOTNETSDK_VERSION | ||
ARG RUNTIME_IMAGE | ||
|
||
# Build the ASP.NET Core app using the latest SDK | ||
FROM mcr.microsoft.com/dotnet/sdk:$DOTNETSDK_VERSION-windowsservercore-ltsc2022 as builder | ||
|
||
# Build the smoke test app | ||
WORKDIR /src | ||
COPY ./test/test-applications/regression/AspNetCoreSmokeTest/ . | ||
|
||
ARG PUBLISH_FRAMEWORK | ||
RUN dotnet publish "AspNetCoreSmokeTest.csproj" -c Release --framework %PUBLISH_FRAMEWORK% -o /src/publish | ||
|
||
FROM $RUNTIME_IMAGE AS publish | ||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] | ||
|
||
WORKDIR /app | ||
|
||
ARG CHANNEL | ||
ARG TARGET_PLATFORM | ||
|
||
# Install the hosting bundle | ||
RUN $url='https://builds.dotnet.microsoft.com/dotnet/aspnetcore/Runtime/' + $env:CHANNEL + '.0/dotnet-hosting-' + $env:CHANNEL + '.0-win.exe'; \ | ||
echo "Fetching " + $url; \ | ||
Invoke-WebRequest $url -OutFile c:/hosting.exe; \ | ||
Start-Process -Wait -PassThru -FilePath "c:/hosting.exe" -ArgumentList @('/install', '/q', '/norestart'); \ | ||
rm c:/hosting.exe; | ||
|
||
# Copy the tracer home file from tracer/test/test-applications/regression/AspNetCoreSmokeTest/artifacts | ||
COPY --from=builder /src/artifacts /install | ||
|
||
RUN mkdir /logs; \ | ||
mkdir /monitoring-home; \ | ||
cd /install; \ | ||
Expand-Archive 'c:\install\windows-tracer-home.zip' -DestinationPath 'c:\monitoring-home\'; \ | ||
c:\install\installer\Datadog.FleetInstaller.exe install --home-path c:\monitoring-home; \ | ||
cd /app; | ||
# Set the additional env vars | ||
ENV DD_PROFILING_ENABLED=1 \ | ||
DD_TRACE_DEBUG=1 \ | ||
DD_APPSEC_ENABLED=1 \ | ||
DD_TRACE_LOG_DIRECTORY="C:\logs" | ||
# Set a random env var we should ignore | ||
ENV SUPER_SECRET_CANARY=MySuperSecretCanary | ||
# see https://github.com/DataDog/dd-trace-dotnet/pull/3579 | ||
ENV DD_INTERNAL_WORKAROUND_77973_ENABLED=1 | ||
# Copy the app across | ||
COPY --from=builder /src/publish /app/. | ||
# Create new website we control, but keep auto-start disabled | ||
RUN Remove-WebSite -Name 'Default Web Site'; \ | ||
$ENABLE_32_BIT='false'; \ | ||
if($env:TARGET_PLATFORM -eq 'x86') { $ENABLE_32_BIT='true' }; \ | ||
Write-Host "Creating website with 32 bit enabled: $env:ENABLE_32_BIT"; \ | ||
c:\Windows\System32\inetsrv\appcmd add apppool /startMode:"AlwaysRunning" /autoStart:"false" /name:AspNetCorePool /managedRuntimeVersion:"" /enable32bitapponwin64:$ENABLE_32_BIT; \ | ||
New-Website -Name 'SmokeTest' -Port 5000 -PhysicalPath 'c:\app' -ApplicationPool 'AspNetCorePool'; \ | ||
Set-ItemProperty "IIS:\Sites\SmokeTest" -Name applicationDefaults.preloadEnabled -Value True; | ||
# We override the normal service monitor entrypoint, because we want the container to shut down after the request is sent | ||
# We would really like to get the pid of the worker processes, but we can't do that easily | ||
# This is all way more convoluted than it feels like it should be, but it's the only way I could find to get things to work as required | ||
RUN echo 'Write-Host \"Running servicemonitor to copy variables\"; Start-Process -NoNewWindow -PassThru -FilePath \"c:/ServiceMonitor.exe\" -ArgumentList @(\"w3svc\", \"AspNetCorePool\");' > C:\app\entrypoint.ps1; \ | ||
echo 'Write-Host \"Starting AspNetCorePool app pool\"; Start-WebAppPool -Name \"AspNetCorePool\" -PassThru;' >> C:\app\entrypoint.ps1; \ | ||
echo 'Write-Host \"Making 404 request\"; curl http://localhost:5000;' >> C:\app\entrypoint.ps1; \ | ||
echo 'Write-Host \"Stopping pool\";Stop-WebAppPool \"AspNetCorePool\" -PassThru;' >> C:\app\entrypoint.ps1; \ | ||
echo 'Write-Host \"Shutting down\"' >> C:\app\entrypoint.ps1; | ||
|
||
# Set the script as the entrypoint | ||
ENTRYPOINT ["powershell", "-File", "C:\\app\\entrypoint.ps1"] |
Oops, something went wrong.