From 037be06bacb6feea2b73c4caf61619df19d48f3e Mon Sep 17 00:00:00 2001 From: NachoEchevarria Date: Tue, 4 Nov 2025 14:44:42 +0100 Subject: [PATCH 1/3] Fix RedirectInput test flakyness --- .../RunCommandTests.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tracer/test/Datadog.Trace.Tools.dd_dotnet.ArtifactTests/RunCommandTests.cs b/tracer/test/Datadog.Trace.Tools.dd_dotnet.ArtifactTests/RunCommandTests.cs index eebcdf3adaf3..27857a38f57c 100644 --- a/tracer/test/Datadog.Trace.Tools.dd_dotnet.ArtifactTests/RunCommandTests.cs +++ b/tracer/test/Datadog.Trace.Tools.dd_dotnet.ArtifactTests/RunCommandTests.cs @@ -3,6 +3,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // +using System; using System.Text; using System.Threading.Tasks; using Datadog.Trace.TestHelpers; @@ -99,7 +100,20 @@ public void RedirectInput() } finally { - process.Kill(); + // The echo command exits after echoing one line, so the process may have already exited + try + { + if (!process.HasExited) + { + process.Kill(); + } + } + catch (InvalidOperationException) + { + // Process exited between the HasExited check and Kill() call + } + + process.Dispose(); } } From ee2956051627e18c3725141bc4d2ed09970448c4 Mon Sep 17 00:00:00 2001 From: NachoEchevarria Date: Tue, 4 Nov 2025 14:52:26 +0100 Subject: [PATCH 2/3] Add some delay to sample app --- .../test-applications/integrations/Samples.Console/Program.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tracer/test/test-applications/integrations/Samples.Console/Program.cs b/tracer/test/test-applications/integrations/Samples.Console/Program.cs index 7a1dfac62dd5..6a557720b30c 100644 --- a/tracer/test/test-applications/integrations/Samples.Console/Program.cs +++ b/tracer/test/test-applications/integrations/Samples.Console/Program.cs @@ -117,6 +117,8 @@ private static async Task AsyncMain(string[] args) { Console.WriteLine("Ready"); Console.WriteLine($"Echo: {Console.ReadLine()}"); + // Small delay to ensure the test has time to read the output before the process exits + Thread.Sleep(100); return; } From 9236e2beb1ec097aeb3a8dcad6592bf873143992 Mon Sep 17 00:00:00 2001 From: NachoEchevarria Date: Tue, 4 Nov 2025 16:55:01 +0100 Subject: [PATCH 3/3] Remove sleep --- .../test-applications/integrations/Samples.Console/Program.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/tracer/test/test-applications/integrations/Samples.Console/Program.cs b/tracer/test/test-applications/integrations/Samples.Console/Program.cs index 6a557720b30c..7a1dfac62dd5 100644 --- a/tracer/test/test-applications/integrations/Samples.Console/Program.cs +++ b/tracer/test/test-applications/integrations/Samples.Console/Program.cs @@ -117,8 +117,6 @@ private static async Task AsyncMain(string[] args) { Console.WriteLine("Ready"); Console.WriteLine($"Echo: {Console.ReadLine()}"); - // Small delay to ensure the test has time to read the output before the process exits - Thread.Sleep(100); return; }