From f783bcff566cbf6cc8bca31b2c7146bb91bf4007 Mon Sep 17 00:00:00 2001 From: mdh1418 Date: Thu, 5 Mar 2026 18:26:33 +0000 Subject: [PATCH 1/2] [Tests][UserEvents] Bump tracee timeout and add logs --- .../tracing/userevents/common/UserEventsTestRunner.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tests/tracing/userevents/common/UserEventsTestRunner.cs b/src/tests/tracing/userevents/common/UserEventsTestRunner.cs index 21d3ec8571d2fa..c9720dd38c43cd 100644 --- a/src/tests/tracing/userevents/common/UserEventsTestRunner.cs +++ b/src/tests/tracing/userevents/common/UserEventsTestRunner.cs @@ -17,7 +17,7 @@ namespace Tracing.UserEvents.Tests.Common public class UserEventsTestRunner { private const int SIGINT = 2; - private const int DefaultTraceeExitTimeoutMs = 5000; + private const int DefaultTraceeExitTimeoutMs = 60000; private const int DefaultRecordTraceExitTimeoutMs = 20000; // Delay before starting the tracee to let record-trace finish setup. The @@ -60,7 +60,9 @@ public static int Run( enabledEvent.Set(); } + Console.WriteLine("Tracee waiting for EventSource to be enabled via IPC..."); enabledEvent.Wait(); + Console.WriteLine("Tracee EventSource enabled, emitting events."); traceeAction(); return 0; @@ -131,6 +133,10 @@ private static int RunOrchestrator( recordTraceStartInfo.ArgumentList.Add(scriptFilePath); recordTraceStartInfo.ArgumentList.Add("--out"); recordTraceStartInfo.ArgumentList.Add(traceFilePath); + recordTraceStartInfo.ArgumentList.Add("--log-filter"); + recordTraceStartInfo.ArgumentList.Add("one_collect::helpers::exporting=warn,one_collect::perf_event=warn,one_collect::tracefs=warn,one_collect::scripting=warn,ruwind=warn,engine=warn"); + recordTraceStartInfo.ArgumentList.Add("--log-mode"); + recordTraceStartInfo.ArgumentList.Add("console"); recordTraceStartInfo.WorkingDirectory = userEventsScenarioDir; recordTraceStartInfo.UseShellExecute = false; recordTraceStartInfo.RedirectStandardOutput = true; From 9c5b5067f47cbbcddff19252b6fedb2ff4707ac4 Mon Sep 17 00:00:00 2001 From: mdh1418 Date: Thu, 5 Mar 2026 23:05:01 +0000 Subject: [PATCH 2/2] [Tests][UserEvents] Route record-trace logs to file and upload on failure Route record-trace diagnostic logs to a temporary file via --log-path instead of --log-mode console to keep test console output clean. On test failure, upload the log file alongside the .nettrace to Helix artifacts for post-mortem analysis. Generalize UploadTraceFileFromHelix into UploadArtifactsFromHelixOnFailure to support uploading multiple artifacts, and ensure the record-trace log is uploaded on all failure paths including when the trace file itself is missing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../userevents/common/UserEventsTestRunner.cs | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/tests/tracing/userevents/common/UserEventsTestRunner.cs b/src/tests/tracing/userevents/common/UserEventsTestRunner.cs index c9720dd38c43cd..65d2f02ab26dfb 100644 --- a/src/tests/tracing/userevents/common/UserEventsTestRunner.cs +++ b/src/tests/tracing/userevents/common/UserEventsTestRunner.cs @@ -124,6 +124,7 @@ private static int RunOrchestrator( // As a workaround, deleting the temp file and allowing record-trace to create it works reliably. File.Delete(traceFilePath); traceFilePath = Path.ChangeExtension(traceFilePath, ".nettrace"); + string recordTraceLogPath = Path.ChangeExtension(traceFilePath, ".log"); ProcessStartInfo recordTraceStartInfo = new(); recordTraceStartInfo.FileName = "sudo"; @@ -133,10 +134,8 @@ private static int RunOrchestrator( recordTraceStartInfo.ArgumentList.Add(scriptFilePath); recordTraceStartInfo.ArgumentList.Add("--out"); recordTraceStartInfo.ArgumentList.Add(traceFilePath); - recordTraceStartInfo.ArgumentList.Add("--log-filter"); - recordTraceStartInfo.ArgumentList.Add("one_collect::helpers::exporting=warn,one_collect::perf_event=warn,one_collect::tracefs=warn,one_collect::scripting=warn,ruwind=warn,engine=warn"); - recordTraceStartInfo.ArgumentList.Add("--log-mode"); - recordTraceStartInfo.ArgumentList.Add("console"); + recordTraceStartInfo.ArgumentList.Add("--log-path"); + recordTraceStartInfo.ArgumentList.Add(recordTraceLogPath); recordTraceStartInfo.WorkingDirectory = userEventsScenarioDir; recordTraceStartInfo.UseShellExecute = false; recordTraceStartInfo.RedirectStandardOutput = true; @@ -249,6 +248,7 @@ private static int RunOrchestrator( if (!File.Exists(traceFilePath)) { Console.Error.WriteLine($"Expected trace file not found at `{traceFilePath}`"); + UploadArtifactsFromHelixOnFailure(scenarioName, recordTraceLogPath); return -1; } @@ -256,7 +256,7 @@ private static int RunOrchestrator( if (!traceValidator(traceePid, source)) { Console.Error.WriteLine($"Trace file `{traceFilePath}` does not contain expected events."); - UploadTraceFileFromHelix(traceFilePath, scenarioName); + UploadArtifactsFromHelixOnFailure(scenarioName, traceFilePath, recordTraceLogPath); return -1; } @@ -351,14 +351,24 @@ private static void EnsureCleanDiagnosticPorts(string diagnosticPortDir) } } - private static void UploadTraceFileFromHelix(string traceFilePath, string scenarioName) + private static void UploadArtifactsFromHelixOnFailure(string scenarioName, params string[] filePaths) { var helixWorkItemDirectory = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT"); - if (helixWorkItemDirectory != null && Directory.Exists(helixWorkItemDirectory)) + if (helixWorkItemDirectory is null || !Directory.Exists(helixWorkItemDirectory)) + return; + + foreach (string filePath in filePaths) { - var destPath = Path.Combine(helixWorkItemDirectory, $"{scenarioName}.nettrace"); - Console.WriteLine($"Uploading trace file to Helix work item directory: {destPath}"); - File.Copy(traceFilePath, destPath, overwrite: true); + if (!File.Exists(filePath)) + { + Console.WriteLine($"Artifact not found at `{filePath}`, skipping upload."); + continue; + } + + string extension = Path.GetExtension(filePath); + string destPath = Path.Combine(helixWorkItemDirectory, $"{scenarioName}{extension}"); + Console.WriteLine($"Uploading artifact to Helix work item directory: {destPath}"); + File.Copy(filePath, destPath, overwrite: true); } } }