From 1f41fdf7183f4a3624235596b4af1a702802339c Mon Sep 17 00:00:00 2001 From: Andrew Lock Date: Mon, 28 Oct 2024 10:27:36 +0000 Subject: [PATCH 1/3] Fix LoaderOptimisation tests Due to a mismatch in `args`, the tracer was never actually installed, which means this test hasn't been running Added check to make sure that we're recording tracer logs to be safe (we could test more, but gets more complex) --- .azure-pipelines/ultimate-pipeline.yml | 11 ++++++----- .dockerignore | 2 +- docker-compose.yml | 6 ++++-- ....dockerfile => iis.loaderoptimization.dockerfile} | 0 .../IIS/LoaderOptimizationStartup.cs | 12 ++++++++++++ 5 files changed, 23 insertions(+), 8 deletions(-) rename tracer/build/_build/docker/{iis.dockerfile => iis.loaderoptimization.dockerfile} (100%) diff --git a/.azure-pipelines/ultimate-pipeline.yml b/.azure-pipelines/ultimate-pipeline.yml index 57774d4b2696..cf016e648eb9 100644 --- a/.azure-pipelines/ultimate-pipeline.yml +++ b/.azure-pipelines/ultimate-pipeline.yml @@ -2012,7 +2012,7 @@ stages: pool: name: azure-windows-scale-set-2 variables: - relativeMsiOutputDirectory: $(relativeArtifacts)/$(targetPlatform)/en-us + relativeMsiOutputDirectory: /artifacts/msi/$(targetPlatform)/en-us steps: - template: steps/clone-repo.yml @@ -2029,14 +2029,15 @@ stages: inputs: artifact: windows-msi-$(targetPlatform) patterns: '**/*-$(targetPlatform).msi' - path: $(System.DefaultWorkingDirectory)/$(relativeMsiOutputDirectory) + path: $(System.DefaultWorkingDirectory)$(relativeMsiOutputDirectory) - script: tracer\build.cmd BuildAspNetIntegrationTests -Framework $(framework) displayName: BuildWindowsIntegrationTests - - script: | - docker compose build --build-arg dotnet_tracer_msi=.$(relativeMsiOutputDirectory)/*.msi --build-arg ENABLE_32_BIT=$(enable32bit) IntegrationTests.IIS - docker compose up -d IntegrationTests.IIS + - powershell: | + mkdir -Force "./artifacts/build_data/logs/LoaderOptimizationStartup" + docker compose build --build-arg DOTNET_TRACER_MSI=.$(relativeMsiOutputDirectory)/*.msi --build-arg ENABLE_32_BIT=$(enable32bit) IntegrationTests.IIS.LoaderOptimizationStartup + docker compose up -d IntegrationTests.IIS.LoaderOptimizationStartup displayName: docker-compose start IntegrationTests.IIS retryCountOnTaskFailure: 5 env: diff --git a/.dockerignore b/.dockerignore index 087076120588..b3cc4e29f439 100644 --- a/.dockerignore +++ b/.dockerignore @@ -11,7 +11,7 @@ packages/ **/obj/ !tracer/test/test-applications/aspnet/Samples.AspNet472.LoaderOptimizationRegKey/bin/ -!tracer/src/WindowsInstaller/bin/ +!artifacts/msi/ !tracer/test/Datadog.Trace.TestHelpers/ !tracer/test/agent/ diff --git a/docker-compose.yml b/docker-compose.yml index be0e1399d555..36dcc41a9a1e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -340,14 +340,16 @@ services: # The IIS images are based on Windows images, so they can only be run on Docker for Windows, # and only after switching to run Windows containers - IntegrationTests.IIS: + IntegrationTests.IIS.LoaderOptimizationStartup: build: context: ./ args: - ENABLE_32_BIT - DOTNET_TRACER_MSI - dockerfile: ./tracer/build/_build/docker/iis.dockerfile + dockerfile: ./tracer/build/_build/docker/iis.loaderoptimization.dockerfile image: datadog-iis-loaderoptimizationregkey + volumes: + - ./artifacts/build_data/logs/LoaderOptimizationStartup:c:/ProgramData/Datadog .NET Tracer/logs ports: - "8080:80" environment: diff --git a/tracer/build/_build/docker/iis.dockerfile b/tracer/build/_build/docker/iis.loaderoptimization.dockerfile similarity index 100% rename from tracer/build/_build/docker/iis.dockerfile rename to tracer/build/_build/docker/iis.loaderoptimization.dockerfile diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/IIS/LoaderOptimizationStartup.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/IIS/LoaderOptimizationStartup.cs index 3a72e8069ba7..00f015887724 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/IIS/LoaderOptimizationStartup.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/IIS/LoaderOptimizationStartup.cs @@ -4,10 +4,14 @@ // #if NETFRAMEWORK +using System.IO; using System.Net; using System.Net.Http; using System.Threading; using System.Threading.Tasks; +using Datadog.Trace.Configuration.Telemetry; +using Datadog.Trace.Logging; +using FluentAssertions; using Xunit; using Xunit.Abstractions; @@ -60,6 +64,14 @@ public async Task ApplicationDoesNotReturnErrors() // Server is ready to receive requests var responseMessage = await client.GetAsync(Url); Assert.Equal(HttpStatusCode.OK, responseMessage.StatusCode); + + // verify we have some logs, so we know instrumentation happened + var logDirectory = Path.Combine( + DatadogLoggingFactory.GetLogDirectory(NullConfigurationTelemetry.Instance), + nameof(LoaderOptimizationStartup)); + + Output.WriteLine($"Reading files from {logDirectory}"); + Directory.GetFiles(logDirectory).Should().NotBeEmpty(); } } } From 29bac402bc1e4018df55850ec5d5328f5c368141 Mon Sep 17 00:00:00 2001 From: Andrew Lock Date: Tue, 29 Oct 2024 07:42:29 +0000 Subject: [PATCH 2/3] Try adding the test agent --- .azure-pipelines/ultimate-pipeline.yml | 13 ++++++++++--- docker-compose.yml | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.azure-pipelines/ultimate-pipeline.yml b/.azure-pipelines/ultimate-pipeline.yml index cf016e648eb9..24ef2784283e 100644 --- a/.azure-pipelines/ultimate-pipeline.yml +++ b/.azure-pipelines/ultimate-pipeline.yml @@ -2035,9 +2035,16 @@ stages: displayName: BuildWindowsIntegrationTests - powershell: | - mkdir -Force "./artifacts/build_data/logs/LoaderOptimizationStartup" - docker compose build --build-arg DOTNET_TRACER_MSI=.$(relativeMsiOutputDirectory)/*.msi --build-arg ENABLE_32_BIT=$(enable32bit) IntegrationTests.IIS.LoaderOptimizationStartup - docker compose up -d IntegrationTests.IIS.LoaderOptimizationStartup + mkdir -Force ./artifacts/build_data/snapshots + mkdir -Force ./artifacts/build_data/logs/LoaderOptimizationStartup + docker compose -f docker-compose.windows.yml run --rm start-test-agent.windows + + docker compose -f docker-compose.yml -f docker-compose.windows.yml build ` + --build-arg DOTNET_TRACER_MSI=.$(relativeMsiOutputDirectory)/*.msi ` + --build-arg ENABLE_32_BIT=$(enable32bit) ` + IntegrationTests.IIS.LoaderOptimizationStartup + + docker compose up -f docker-compose.yml -f docker-compose.windows.yml -d IntegrationTests.IIS.LoaderOptimizationStartup displayName: docker-compose start IntegrationTests.IIS retryCountOnTaskFailure: 5 env: diff --git a/docker-compose.yml b/docker-compose.yml index 36dcc41a9a1e..9307b54b9adb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -352,7 +352,10 @@ services: - ./artifacts/build_data/logs/LoaderOptimizationStartup:c:/ProgramData/Datadog .NET Tracer/logs ports: - "8080:80" + depends_on: + - test-agent.windows environment: + - DD_TRACE_AGENT_URL=http://test-agent.windows:8126 - DD_CLR_ENABLE_NGEN=${DD_CLR_ENABLE_NGEN:-1} - DD_LOGGER_DD_API_KEY - DD_LOGGER_DD_SERVICE From 5f1ebdffa5802abc539750ae613b06e26764cc5c Mon Sep 17 00:00:00 2001 From: Andrew Lock Date: Tue, 29 Oct 2024 09:14:12 +0000 Subject: [PATCH 3/3] Move the LoaderOptimizationStartup step to a separate docker-compose seeing as it depends on services from there --- .azure-pipelines/ultimate-pipeline.yml | 6 ++-- docker-compose.windows.yml | 46 +++++++++++++++++++++++++ docker-compose.yml | 47 -------------------------- 3 files changed, 49 insertions(+), 50 deletions(-) diff --git a/.azure-pipelines/ultimate-pipeline.yml b/.azure-pipelines/ultimate-pipeline.yml index 24ef2784283e..c034d013b0aa 100644 --- a/.azure-pipelines/ultimate-pipeline.yml +++ b/.azure-pipelines/ultimate-pipeline.yml @@ -2039,12 +2039,12 @@ stages: mkdir -Force ./artifacts/build_data/logs/LoaderOptimizationStartup docker compose -f docker-compose.windows.yml run --rm start-test-agent.windows - docker compose -f docker-compose.yml -f docker-compose.windows.yml build ` + docker compose -f docker-compose.windows.yml build ` --build-arg DOTNET_TRACER_MSI=.$(relativeMsiOutputDirectory)/*.msi ` --build-arg ENABLE_32_BIT=$(enable32bit) ` IntegrationTests.IIS.LoaderOptimizationStartup - docker compose up -f docker-compose.yml -f docker-compose.windows.yml -d IntegrationTests.IIS.LoaderOptimizationStartup + docker compose -f docker-compose.windows.yml up -d IntegrationTests.IIS.LoaderOptimizationStartup displayName: docker-compose start IntegrationTests.IIS retryCountOnTaskFailure: 5 env: @@ -2062,7 +2062,7 @@ stages: testResultsFiles: artifacts/build_data/results/**/*.trx condition: succeededOrFailed() - - script: docker compose down + - script: docker compose -f docker-compose.windows.yml down displayName: docker-compose stop services env: DD_LOGGER_DD_API_KEY: $(ddApiKey) diff --git a/docker-compose.windows.yml b/docker-compose.windows.yml index 02c92ea5f21a..be33331dd937 100644 --- a/docker-compose.windows.yml +++ b/docker-compose.windows.yml @@ -25,6 +25,52 @@ services: - SNAPSHOT_CI=1 - SNAPSHOT_IGNORED_ATTRS=span_id,trace_id,parent_id,duration,start,metrics.system.pid,meta.runtime-id,metrics.process_id,meta.http.client_ip,meta.network.client.ip,meta._dd.p.dm,meta._dd.p.tid,meta._dd.parent_id,meta._dd.appsec.s.req.params,meta._dd.appsec.s.res.body,meta._dd.appsec.s.req.headers,meta._dd.appsec.s.res.headers #api-security attrs are unfortunately ignored because gzip compression generates different bytes per platform windows/linux + # The IIS images are based on Windows images, so they can only be run on Docker for Windows, + # and only after switching to run Windows containers + IntegrationTests.IIS.LoaderOptimizationStartup: + build: + context: ./ + args: + - ENABLE_32_BIT + - DOTNET_TRACER_MSI + dockerfile: ./tracer/build/_build/docker/iis.loaderoptimization.dockerfile + image: datadog-iis-loaderoptimizationregkey + volumes: + - ./artifacts/build_data/logs/LoaderOptimizationStartup:c:/ProgramData/Datadog .NET Tracer/logs + ports: + - "8080:80" + depends_on: + - test-agent.windows + environment: + - DD_TRACE_AGENT_URL=http://test-agent.windows:8126 + - DD_CLR_ENABLE_NGEN=${DD_CLR_ENABLE_NGEN:-1} + - DD_LOGGER_DD_API_KEY + - DD_LOGGER_DD_SERVICE + - DD_LOGGER_DD_ENV + - DD_LOGGER_ENABLED + - DD_LOGGER_TF_BUILD=${TF_BUILD:-} + - DD_LOGGER_BUILD_BUILDID + - DD_LOGGER_BUILD_DEFINITIONNAME + - DD_LOGGER_BUILD_SOURCESDIRECTORY + - DD_LOGGER_BUILD_REPOSITORY_URI + - DD_LOGGER_BUILD_SOURCEVERSION + - DD_LOGGER_BUILD_SOURCEBRANCH + - DD_LOGGER_BUILD_SOURCEBRANCHNAME + - DD_LOGGER_BUILD_SOURCEVERSIONMESSAGE + - DD_LOGGER_BUILD_REQUESTEDFORID + - DD_LOGGER_BUILD_REQUESTEDFOREMAIL + - DD_LOGGER_SYSTEM_TEAMFOUNDATIONSERVERURI + - DD_LOGGER_SYSTEM_TEAMPROJECTID + - DD_LOGGER_SYSTEM_STAGEDISPLAYNAME + - DD_LOGGER_SYSTEM_JOBDISPLAYNAME + - DD_LOGGER_SYSTEM_JOBID + - DD_LOGGER_SYSTEM_TASKINSTANCEID=${SYSTEM_TASKINSTANCEID:-} + - DD_LOGGER_SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI + - DD_LOGGER_SYSTEM_PULLREQUEST_SOURCECOMMITID + - DD_LOGGER_SYSTEM_PULLREQUEST_SOURCEBRANCH + - DD_LOGGER_DD_TAGS + - IS_SSI_RUN + smoke-tests.windows: build: context: ./tracer/ # have to use this as the context, as Dockercompose requires dockerfile to be inside context dir diff --git a/docker-compose.yml b/docker-compose.yml index 9307b54b9adb..6a6815471eee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -337,53 +337,6 @@ services: LDAP_ADMIN_PASSWORD: "Passw0rd" LDAP_BASE_DN: "dc=dd-trace-dotnet,dc=com" - - # The IIS images are based on Windows images, so they can only be run on Docker for Windows, - # and only after switching to run Windows containers - IntegrationTests.IIS.LoaderOptimizationStartup: - build: - context: ./ - args: - - ENABLE_32_BIT - - DOTNET_TRACER_MSI - dockerfile: ./tracer/build/_build/docker/iis.loaderoptimization.dockerfile - image: datadog-iis-loaderoptimizationregkey - volumes: - - ./artifacts/build_data/logs/LoaderOptimizationStartup:c:/ProgramData/Datadog .NET Tracer/logs - ports: - - "8080:80" - depends_on: - - test-agent.windows - environment: - - DD_TRACE_AGENT_URL=http://test-agent.windows:8126 - - DD_CLR_ENABLE_NGEN=${DD_CLR_ENABLE_NGEN:-1} - - DD_LOGGER_DD_API_KEY - - DD_LOGGER_DD_SERVICE - - DD_LOGGER_DD_ENV - - DD_LOGGER_ENABLED - - DD_LOGGER_TF_BUILD=${TF_BUILD:-} - - DD_LOGGER_BUILD_BUILDID - - DD_LOGGER_BUILD_DEFINITIONNAME - - DD_LOGGER_BUILD_SOURCESDIRECTORY - - DD_LOGGER_BUILD_REPOSITORY_URI - - DD_LOGGER_BUILD_SOURCEVERSION - - DD_LOGGER_BUILD_SOURCEBRANCH - - DD_LOGGER_BUILD_SOURCEBRANCHNAME - - DD_LOGGER_BUILD_SOURCEVERSIONMESSAGE - - DD_LOGGER_BUILD_REQUESTEDFORID - - DD_LOGGER_BUILD_REQUESTEDFOREMAIL - - DD_LOGGER_SYSTEM_TEAMFOUNDATIONSERVERURI - - DD_LOGGER_SYSTEM_TEAMPROJECTID - - DD_LOGGER_SYSTEM_STAGEDISPLAYNAME - - DD_LOGGER_SYSTEM_JOBDISPLAYNAME - - DD_LOGGER_SYSTEM_JOBID - - DD_LOGGER_SYSTEM_TASKINSTANCEID=${SYSTEM_TASKINSTANCEID:-} - - DD_LOGGER_SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI - - DD_LOGGER_SYSTEM_PULLREQUEST_SOURCECOMMITID - - DD_LOGGER_SYSTEM_PULLREQUEST_SOURCEBRANCH - - DD_LOGGER_DD_TAGS - - IS_SSI_RUN - ProfilerIntegrationTests: build: context: ./tracer/build/_build/