Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory dumps on artifact tests #4906

Merged
merged 10 commits into from
Dec 1, 2023
16 changes: 16 additions & 0 deletions .azure-pipelines/ultimate-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3396,6 +3396,12 @@ stages:
DD_LOGGER_DD_API_KEY: $(ddApiKey)
enable_crash_dumps: true

- publish: tracer/build_data
displayName: Uploading tool_artifacts_tests_windows logs
artifact: _$(System.StageName)_$(Agent.JobName)_logs_$(System.JobAttempt)
condition: succeededOrFailed()
continueOnError: true

- task: PublishTestResults@2
displayName: publish test results
inputs:
Expand Down Expand Up @@ -3500,6 +3506,16 @@ stages:
baseImage: $(baseImage)
command: "BuildAndRunDdDotnetArtifactTests --framework net7.0"

- script: |
sudo chmod -R 644 tracer/build_data/dumps/* || true
displayName: Make dumps uploadable to AzDo
condition: succeededOrFailed()

- publish: tracer/build_data
artifact: _$(System.StageName)_$(Agent.JobName)_logs_$(System.JobAttempt)
condition: succeededOrFailed()
continueOnError: true

- task: PublishTestResults@2
displayName: publish test results
inputs:
Expand Down
16 changes: 16 additions & 0 deletions tracer/test/Datadog.Trace.TestHelpers/CustomTestFramework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ public CustomTestFramework(IMessageSink messageSink)
: base(messageSink)
{
FluentAssertions.Formatting.Formatter.AddFormatter(new DiffPaneModelFormatter());

Task memoryDumpTask = null;
andrewlock marked this conversation as resolved.
Show resolved Hide resolved

if (bool.Parse(Environment.GetEnvironmentVariable("enable_crash_dumps") ?? "false"))
{
var progress = new Progress<string>(message => messageSink.OnMessage(new DiagnosticMessage(message)));

try
{
MemoryDumpHelper.InitializeAsync(progress).GetAwaiter().GetResult();
}
catch (Exception ex)
{
messageSink.OnMessage(new DiagnosticMessage($"MemoryDumpHelper initialization failed: {ex}"));
}
}
}

public CustomTestFramework(IMessageSink messageSink, Type typeTestedAssembly)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Xunit;
using Xunit.Abstractions;

[assembly: TestFramework("Datadog.Trace.Tools.Runner.ArtifactTests.CustomTestFramework", "Datadog.Trace.Tools.Runner.ArtifactTests")]
[assembly: TestFramework("Datadog.Trace.Tools.dd_dotnet.ArtifactTests.CustomTestFramework", "Datadog.Trace.Tools.dd_dotnet.ArtifactTests")]

namespace Datadog.Trace.Tools.dd_dotnet.ArtifactTests;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal static class Program
{
private static async Task Main(string[] args)
{
Thread.Sleep(Timeout.Infinite); // Look Ma I'm frozen!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to remove this afterwards 😅

Suggested change
Thread.Sleep(Timeout.Infinite); // Look Ma I'm frozen!

// Just to make extra sure that the tracer is loaded, if properly configured
_ = WebRequest.CreateHttp("http://localhost");
await Task.Yield();
Expand Down
Loading